From 511c6591e66432f183f943a52ec6ebe096d1a56a Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 24 May 2020 15:32:39 -0700 Subject: [PATCH 001/189] Add AST/compiler support for switches and guards --- Include/Python-ast.h | 27 ++++- Parser/Python.asdl | 4 + Parser/pegen/parse.c | 3 + Python/Python-ast.c | 277 +++++++++++++++++++++++++++++++++++++++++++ Python/ast.c | 29 +++++ Python/compile.c | 44 +++++++ Python/symtable.c | 16 +++ 7 files changed, 396 insertions(+), 4 deletions(-) diff --git a/Include/Python-ast.h b/Include/Python-ast.h index e7afa1e6579e8d..f2ebf9244aa512 100644 --- a/Include/Python-ast.h +++ b/Include/Python-ast.h @@ -44,6 +44,8 @@ typedef struct _alias *alias_ty; typedef struct _withitem *withitem_ty; +typedef struct _match_case *match_case_ty; + typedef struct _type_ignore *type_ignore_ty; @@ -77,10 +79,10 @@ enum _stmt_kind {FunctionDef_kind=1, AsyncFunctionDef_kind=2, ClassDef_kind=3, Return_kind=4, Delete_kind=5, Assign_kind=6, AugAssign_kind=7, AnnAssign_kind=8, For_kind=9, AsyncFor_kind=10, While_kind=11, If_kind=12, With_kind=13, - AsyncWith_kind=14, Raise_kind=15, Try_kind=16, - Assert_kind=17, Import_kind=18, ImportFrom_kind=19, - Global_kind=20, Nonlocal_kind=21, Expr_kind=22, Pass_kind=23, - Break_kind=24, Continue_kind=25}; + AsyncWith_kind=14, Match_kind=15, Raise_kind=16, Try_kind=17, + Assert_kind=18, Import_kind=19, ImportFrom_kind=20, + Global_kind=21, Nonlocal_kind=22, Expr_kind=23, Pass_kind=24, + Break_kind=25, Continue_kind=26}; struct _stmt { enum _stmt_kind kind; union { @@ -177,6 +179,11 @@ struct _stmt { string type_comment; } AsyncWith; + struct { + expr_ty target; + asdl_seq *cases; + } Match; + struct { expr_ty exc; expr_ty cause; @@ -443,6 +450,12 @@ struct _withitem { expr_ty optional_vars; }; +struct _match_case { + expr_ty pattern; + expr_ty guard; + asdl_seq *body; +}; + enum _type_ignore_kind {TypeIgnore_kind=1}; struct _type_ignore { enum _type_ignore_kind kind; @@ -523,6 +536,9 @@ stmt_ty _Py_With(asdl_seq * items, asdl_seq * body, string type_comment, int stmt_ty _Py_AsyncWith(asdl_seq * items, asdl_seq * body, string type_comment, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); +#define Match(a0, a1, a2, a3, a4, a5, a6) _Py_Match(a0, a1, a2, a3, a4, a5, a6) +stmt_ty _Py_Match(expr_ty target, asdl_seq * cases, int lineno, int col_offset, + int end_lineno, int end_col_offset, PyArena *arena); #define Raise(a0, a1, a2, a3, a4, a5, a6) _Py_Raise(a0, a1, a2, a3, a4, a5, a6) stmt_ty _Py_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); @@ -683,6 +699,9 @@ alias_ty _Py_alias(identifier name, identifier asname, PyArena *arena); #define withitem(a0, a1, a2) _Py_withitem(a0, a1, a2) withitem_ty _Py_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena); +#define match_case(a0, a1, a2, a3) _Py_match_case(a0, a1, a2, a3) +match_case_ty _Py_match_case(expr_ty pattern, expr_ty guard, asdl_seq * body, + PyArena *arena); #define TypeIgnore(a0, a1, a2) _Py_TypeIgnore(a0, a1, a2) type_ignore_ty _Py_TypeIgnore(int lineno, string tag, PyArena *arena); diff --git a/Parser/Python.asdl b/Parser/Python.asdl index 889712b4b3d36e..517aa256d8d00f 100644 --- a/Parser/Python.asdl +++ b/Parser/Python.asdl @@ -36,6 +36,8 @@ module Python | With(withitem* items, stmt* body, string? type_comment) | AsyncWith(withitem* items, stmt* body, string? type_comment) + | Match(expr target, match_case* cases) + | Raise(expr? exc, expr? cause) | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody) | Assert(expr test, expr? msg) @@ -121,5 +123,7 @@ module Python withitem = (expr context_expr, expr? optional_vars) + match_case = (expr pattern, expr? guard, stmt* body) + type_ignore = TypeIgnore(int lineno, string tag) } diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index fe95d274f37d2b..286f72111e3519 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -12072,6 +12072,9 @@ invalid_star_etc_rule(Parser *p) p->mark = _mark; } { // '*' ',' TYPE_COMMENT + if (p->error_indicator) { + return NULL; + } Token * _literal; Token * _literal_1; Token * type_comment_var; diff --git a/Python/Python-ast.c b/Python/Python-ast.c index f34b1450c66ef1..80ac60edd9cf71 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -87,6 +87,7 @@ typedef struct { PyObject *Lt_type; PyObject *MatMult_singleton; PyObject *MatMult_type; + PyObject *Match_type; PyObject *Mod_singleton; PyObject *Mod_type; PyObject *Module_type; @@ -149,6 +150,7 @@ typedef struct { PyObject *bases; PyObject *body; PyObject *boolop_type; + PyObject *cases; PyObject *cause; PyObject *cmpop_type; PyObject *col_offset; @@ -171,6 +173,7 @@ typedef struct { PyObject *format_spec; PyObject *func; PyObject *generators; + PyObject *guard; PyObject *handlers; PyObject *id; PyObject *ifs; @@ -189,6 +192,7 @@ typedef struct { PyObject *level; PyObject *lineno; PyObject *lower; + PyObject *match_case_type; PyObject *mod_type; PyObject *module; PyObject *msg; @@ -200,6 +204,7 @@ typedef struct { PyObject *ops; PyObject *optional_vars; PyObject *orelse; + PyObject *pattern; PyObject *posonlyargs; PyObject *returns; PyObject *right; @@ -307,6 +312,7 @@ static int astmodule_clear(PyObject *module) Py_CLEAR(astmodulestate(module)->Lt_type); Py_CLEAR(astmodulestate(module)->MatMult_singleton); Py_CLEAR(astmodulestate(module)->MatMult_type); + Py_CLEAR(astmodulestate(module)->Match_type); Py_CLEAR(astmodulestate(module)->Mod_singleton); Py_CLEAR(astmodulestate(module)->Mod_type); Py_CLEAR(astmodulestate(module)->Module_type); @@ -369,6 +375,7 @@ static int astmodule_clear(PyObject *module) Py_CLEAR(astmodulestate(module)->bases); Py_CLEAR(astmodulestate(module)->body); Py_CLEAR(astmodulestate(module)->boolop_type); + Py_CLEAR(astmodulestate(module)->cases); Py_CLEAR(astmodulestate(module)->cause); Py_CLEAR(astmodulestate(module)->cmpop_type); Py_CLEAR(astmodulestate(module)->col_offset); @@ -391,6 +398,7 @@ static int astmodule_clear(PyObject *module) Py_CLEAR(astmodulestate(module)->format_spec); Py_CLEAR(astmodulestate(module)->func); Py_CLEAR(astmodulestate(module)->generators); + Py_CLEAR(astmodulestate(module)->guard); Py_CLEAR(astmodulestate(module)->handlers); Py_CLEAR(astmodulestate(module)->id); Py_CLEAR(astmodulestate(module)->ifs); @@ -409,6 +417,7 @@ static int astmodule_clear(PyObject *module) Py_CLEAR(astmodulestate(module)->level); Py_CLEAR(astmodulestate(module)->lineno); Py_CLEAR(astmodulestate(module)->lower); + Py_CLEAR(astmodulestate(module)->match_case_type); Py_CLEAR(astmodulestate(module)->mod_type); Py_CLEAR(astmodulestate(module)->module); Py_CLEAR(astmodulestate(module)->msg); @@ -420,6 +429,7 @@ static int astmodule_clear(PyObject *module) Py_CLEAR(astmodulestate(module)->ops); Py_CLEAR(astmodulestate(module)->optional_vars); Py_CLEAR(astmodulestate(module)->orelse); + Py_CLEAR(astmodulestate(module)->pattern); Py_CLEAR(astmodulestate(module)->posonlyargs); Py_CLEAR(astmodulestate(module)->returns); Py_CLEAR(astmodulestate(module)->right); @@ -526,6 +536,7 @@ static int astmodule_traverse(PyObject *module, visitproc visit, void* arg) Py_VISIT(astmodulestate(module)->Lt_type); Py_VISIT(astmodulestate(module)->MatMult_singleton); Py_VISIT(astmodulestate(module)->MatMult_type); + Py_VISIT(astmodulestate(module)->Match_type); Py_VISIT(astmodulestate(module)->Mod_singleton); Py_VISIT(astmodulestate(module)->Mod_type); Py_VISIT(astmodulestate(module)->Module_type); @@ -588,6 +599,7 @@ static int astmodule_traverse(PyObject *module, visitproc visit, void* arg) Py_VISIT(astmodulestate(module)->bases); Py_VISIT(astmodulestate(module)->body); Py_VISIT(astmodulestate(module)->boolop_type); + Py_VISIT(astmodulestate(module)->cases); Py_VISIT(astmodulestate(module)->cause); Py_VISIT(astmodulestate(module)->cmpop_type); Py_VISIT(astmodulestate(module)->col_offset); @@ -610,6 +622,7 @@ static int astmodule_traverse(PyObject *module, visitproc visit, void* arg) Py_VISIT(astmodulestate(module)->format_spec); Py_VISIT(astmodulestate(module)->func); Py_VISIT(astmodulestate(module)->generators); + Py_VISIT(astmodulestate(module)->guard); Py_VISIT(astmodulestate(module)->handlers); Py_VISIT(astmodulestate(module)->id); Py_VISIT(astmodulestate(module)->ifs); @@ -628,6 +641,7 @@ static int astmodule_traverse(PyObject *module, visitproc visit, void* arg) Py_VISIT(astmodulestate(module)->level); Py_VISIT(astmodulestate(module)->lineno); Py_VISIT(astmodulestate(module)->lower); + Py_VISIT(astmodulestate(module)->match_case_type); Py_VISIT(astmodulestate(module)->mod_type); Py_VISIT(astmodulestate(module)->module); Py_VISIT(astmodulestate(module)->msg); @@ -639,6 +653,7 @@ static int astmodule_traverse(PyObject *module, visitproc visit, void* arg) Py_VISIT(astmodulestate(module)->ops); Py_VISIT(astmodulestate(module)->optional_vars); Py_VISIT(astmodulestate(module)->orelse); + Py_VISIT(astmodulestate(module)->pattern); Py_VISIT(astmodulestate(module)->posonlyargs); Py_VISIT(astmodulestate(module)->returns); Py_VISIT(astmodulestate(module)->right); @@ -699,6 +714,7 @@ static int init_identifiers(void) if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return 0; if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return 0; if ((state->body = PyUnicode_InternFromString("body")) == NULL) return 0; + if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return 0; if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return 0; if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return 0; if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return 0; @@ -716,6 +732,7 @@ static int init_identifiers(void) if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return 0; if ((state->func = PyUnicode_InternFromString("func")) == NULL) return 0; if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return 0; + if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return 0; if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return 0; if ((state->id = PyUnicode_InternFromString("id")) == NULL) return 0; if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return 0; @@ -742,6 +759,7 @@ static int init_identifiers(void) if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return 0; if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return 0; if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return 0; + if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return 0; if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return 0; if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return 0; if ((state->right = PyUnicode_InternFromString("right")) == NULL) return 0; @@ -863,6 +881,10 @@ static const char * const AsyncWith_fields[]={ "body", "type_comment", }; +static const char * const Match_fields[]={ + "target", + "cases", +}; static const char * const Raise_fields[]={ "exc", "cause", @@ -1080,6 +1102,12 @@ static const char * const withitem_fields[]={ "context_expr", "optional_vars", }; +static PyObject* ast2obj_match_case(void*); +static const char * const match_case_fields[]={ + "pattern", + "guard", + "body", +}; static PyObject* ast2obj_type_ignore(void*); static const char * const TypeIgnore_fields[]={ "lineno", @@ -1430,6 +1458,7 @@ static int init_types(void) " | If(expr test, stmt* body, stmt* orelse)\n" " | With(withitem* items, stmt* body, string? type_comment)\n" " | AsyncWith(withitem* items, stmt* body, string? type_comment)\n" + " | Match(expr target, match_case* cases)\n" " | Raise(expr? exc, expr? cause)\n" " | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n" " | Assert(expr test, expr? msg)\n" @@ -1527,6 +1556,9 @@ static int init_types(void) if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None) == -1) return 0; + state->Match_type = make_type("Match", state->stmt_type, Match_fields, 2, + "Match(expr target, match_case* cases)"); + if (!state->Match_type) return 0; state->Raise_type = make_type("Raise", state->stmt_type, Raise_fields, 2, "Raise(expr? exc, expr? cause)"); if (!state->Raise_type) return 0; @@ -2011,6 +2043,13 @@ static int init_types(void) if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None) == -1) return 0; + state->match_case_type = make_type("match_case", state->AST_type, + match_case_fields, 3, + "match_case(expr pattern, expr? guard, stmt* body)"); + if (!state->match_case_type) return 0; + if (!add_attributes(state->match_case_type, NULL, 0)) return 0; + if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1) + return 0; state->type_ignore_type = make_type("type_ignore", state->AST_type, NULL, 0, "type_ignore = TypeIgnore(int lineno, string tag)"); if (!state->type_ignore_type) return 0; @@ -2041,6 +2080,8 @@ static int obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena); static int obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena); static int obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena); static int obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena); +static int obj2ast_match_case(PyObject* obj, match_case_ty* out, PyArena* + arena); static int obj2ast_type_ignore(PyObject* obj, type_ignore_ty* out, PyArena* arena); @@ -2471,6 +2512,29 @@ AsyncWith(asdl_seq * items, asdl_seq * body, string type_comment, int lineno, return p; } +stmt_ty +Match(expr_ty target, asdl_seq * cases, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena) +{ + stmt_ty p; + if (!target) { + PyErr_SetString(PyExc_ValueError, + "field 'target' is required for Match"); + return NULL; + } + p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); + if (!p) + return NULL; + p->kind = Match_kind; + p->v.Match.target = target; + p->v.Match.cases = cases; + p->lineno = lineno; + p->col_offset = col_offset; + p->end_lineno = end_lineno; + p->end_col_offset = end_col_offset; + return p; +} + stmt_ty Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena) @@ -3486,6 +3550,24 @@ withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena) return p; } +match_case_ty +match_case(expr_ty pattern, expr_ty guard, asdl_seq * body, PyArena *arena) +{ + match_case_ty p; + if (!pattern) { + PyErr_SetString(PyExc_ValueError, + "field 'pattern' is required for match_case"); + return NULL; + } + p = (match_case_ty)PyArena_Malloc(arena, sizeof(*p)); + if (!p) + return NULL; + p->pattern = pattern; + p->guard = guard; + p->body = body; + return p; +} + type_ignore_ty TypeIgnore(int lineno, string tag, PyArena *arena) { @@ -3939,6 +4021,22 @@ ast2obj_stmt(void* _o) goto failed; Py_DECREF(value); break; + case Match_kind: + tp = (PyTypeObject *)astmodulestate_global->Match_type; + result = PyType_GenericNew(tp, NULL, NULL); + if (!result) goto failed; + value = ast2obj_expr(o->v.Match.target); + if (!value) goto failed; + if (PyObject_SetAttr(result, astmodulestate_global->target, value) == + -1) + goto failed; + Py_DECREF(value); + value = ast2obj_list(o->v.Match.cases, ast2obj_match_case); + if (!value) goto failed; + if (PyObject_SetAttr(result, astmodulestate_global->cases, value) == -1) + goto failed; + Py_DECREF(value); + break; case Raise_kind: tp = (PyTypeObject *)astmodulestate_global->Raise_type; result = PyType_GenericNew(tp, NULL, NULL); @@ -5043,6 +5141,41 @@ ast2obj_withitem(void* _o) return NULL; } +PyObject* +ast2obj_match_case(void* _o) +{ + match_case_ty o = (match_case_ty)_o; + PyObject *result = NULL, *value = NULL; + PyTypeObject *tp; + if (!o) { + Py_RETURN_NONE; + } + + tp = (PyTypeObject *)astmodulestate_global->match_case_type; + result = PyType_GenericNew(tp, NULL, NULL); + if (!result) return NULL; + value = ast2obj_expr(o->pattern); + if (!value) goto failed; + if (PyObject_SetAttr(result, astmodulestate_global->pattern, value) == -1) + goto failed; + Py_DECREF(value); + value = ast2obj_expr(o->guard); + if (!value) goto failed; + if (PyObject_SetAttr(result, astmodulestate_global->guard, value) == -1) + goto failed; + Py_DECREF(value); + value = ast2obj_list(o->body, ast2obj_stmt); + if (!value) goto failed; + if (PyObject_SetAttr(result, astmodulestate_global->body, value) == -1) + goto failed; + Py_DECREF(value); + return result; +failed: + Py_XDECREF(value); + Py_XDECREF(result); + return NULL; +} + PyObject* ast2obj_type_ignore(void* _o) { @@ -6729,6 +6862,67 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena) if (*out == NULL) goto failed; return 0; } + tp = astmodulestate_global->Match_type; + isinstance = PyObject_IsInstance(obj, tp); + if (isinstance == -1) { + return 1; + } + if (isinstance) { + expr_ty target; + asdl_seq* cases; + + if (_PyObject_LookupAttr(obj, astmodulestate_global->target, &tmp) < 0) + { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from Match"); + return 1; + } + else { + int res; + res = obj2ast_expr(tmp, &target, arena); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + if (_PyObject_LookupAttr(obj, astmodulestate_global->cases, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"cases\" missing from Match"); + return 1; + } + else { + int res; + Py_ssize_t len; + Py_ssize_t i; + if (!PyList_Check(tmp)) { + PyErr_Format(PyExc_TypeError, "Match field \"cases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp))); + goto failed; + } + len = PyList_GET_SIZE(tmp); + cases = _Py_asdl_seq_new(len, arena); + if (cases == NULL) goto failed; + for (i = 0; i < len; i++) { + match_case_ty val; + PyObject *tmp2 = PyList_GET_ITEM(tmp, i); + Py_INCREF(tmp2); + res = obj2ast_match_case(tmp2, &val, arena); + Py_DECREF(tmp2); + if (res != 0) goto failed; + if (len != PyList_GET_SIZE(tmp)) { + PyErr_SetString(PyExc_RuntimeError, "Match field \"cases\" changed size during iteration"); + goto failed; + } + asdl_seq_SET(cases, i, val); + } + Py_CLEAR(tmp); + } + *out = Match(target, cases, lineno, col_offset, end_lineno, + end_col_offset, arena); + if (*out == NULL) goto failed; + return 0; + } tp = astmodulestate_global->Raise_type; isinstance = PyObject_IsInstance(obj, tp); if (isinstance == -1) { @@ -9824,6 +10018,80 @@ obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena) return 1; } +int +obj2ast_match_case(PyObject* obj, match_case_ty* out, PyArena* arena) +{ + PyObject* tmp = NULL; + expr_ty pattern; + expr_ty guard; + asdl_seq* body; + + if (_PyObject_LookupAttr(obj, astmodulestate_global->pattern, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from match_case"); + return 1; + } + else { + int res; + res = obj2ast_expr(tmp, &pattern, arena); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + if (_PyObject_LookupAttr(obj, astmodulestate_global->guard, &tmp) < 0) { + return 1; + } + if (tmp == NULL || tmp == Py_None) { + Py_CLEAR(tmp); + guard = NULL; + } + else { + int res; + res = obj2ast_expr(tmp, &guard, arena); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + if (_PyObject_LookupAttr(obj, astmodulestate_global->body, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from match_case"); + return 1; + } + else { + int res; + Py_ssize_t len; + Py_ssize_t i; + if (!PyList_Check(tmp)) { + PyErr_Format(PyExc_TypeError, "match_case field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp))); + goto failed; + } + len = PyList_GET_SIZE(tmp); + body = _Py_asdl_seq_new(len, arena); + if (body == NULL) goto failed; + for (i = 0; i < len; i++) { + stmt_ty val; + PyObject *tmp2 = PyList_GET_ITEM(tmp, i); + Py_INCREF(tmp2); + res = obj2ast_stmt(tmp2, &val, arena); + Py_DECREF(tmp2); + if (res != 0) goto failed; + if (len != PyList_GET_SIZE(tmp)) { + PyErr_SetString(PyExc_RuntimeError, "match_case field \"body\" changed size during iteration"); + goto failed; + } + asdl_seq_SET(body, i, val); + } + Py_CLEAR(tmp); + } + *out = match_case(pattern, guard, body, arena); + return 0; +failed: + Py_XDECREF(tmp); + return 1; +} + int obj2ast_type_ignore(PyObject* obj, type_ignore_ty* out, PyArena* arena) { @@ -9998,6 +10266,10 @@ PyInit__ast(void) goto error; } Py_INCREF(astmodulestate(m)->AsyncWith_type); + if (PyModule_AddObject(m, "Match", astmodulestate_global->Match_type) < 0) { + goto error; + } + Py_INCREF(astmodulestate(m)->Match_type); if (PyModule_AddObject(m, "Raise", astmodulestate_global->Raise_type) < 0) { goto error; } @@ -10373,6 +10645,11 @@ PyInit__ast(void) goto error; } Py_INCREF(astmodulestate(m)->withitem_type); + if (PyModule_AddObject(m, "match_case", + astmodulestate_global->match_case_type) < 0) { + goto error; + } + Py_INCREF(astmodulestate(m)->match_case_type); if (PyModule_AddObject(m, "type_ignore", astmodulestate_global->type_ignore_type) < 0) { goto error; diff --git a/Python/ast.c b/Python/ast.c index 2d20ca62aa8378..09300bb4c01228 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -302,6 +302,19 @@ validate_expr(expr_ty exp, expr_context_ty ctx) return 0; } +static int +validate_pattern(expr_ty p) +{ + switch (p->kind) { + case Constant_kind: + return validate_constant(p->v.Constant.value); + default: + break; + } + PyErr_SetString(PyExc_SystemError, "invalid match pattern"); + return 0; +} + static int validate_nonempty_seq(asdl_seq *seq, const char *what, const char *owner) { @@ -399,6 +412,22 @@ validate_stmt(stmt_ty stmt) return 0; } return validate_body(stmt->v.AsyncWith.body, "AsyncWith"); + case Match_kind: + if (!validate_expr(stmt->v.Match.target, Load) + || !validate_nonempty_seq(stmt->v.Match.cases, "cases", "Match")) { + return 0; + } + match_case_ty m; + Py_ssize_t cases = asdl_seq_LEN(stmt->v.Match.cases); + for (i = 0; i < cases; i++) { + m = asdl_seq_GET(stmt->v.Match.cases, i); + if (!validate_pattern(m->pattern) + || (m->guard && !validate_expr(m->guard, Load)) + || !validate_body(m->body, "match_case")) { + return 0; + } + } + return 1; case Raise_kind: if (stmt->v.Raise.exc) { return validate_expr(stmt->v.Raise.exc, Load) && diff --git a/Python/compile.c b/Python/compile.c index 4a587c00fd4021..c90988778ef734 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2746,6 +2746,48 @@ compiler_if(struct compiler *c, stmt_ty s) return 1; } +static int +compiler_pattern(struct compiler *c, expr_ty p, basicblock *next) +{ + switch (p->kind) { + case Constant_kind: + VISIT(c, expr, p); + ADDOP_COMPARE(c, Eq); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, next); + return 1; + default: + break; + } + PyErr_SetString(PyExc_SystemError, "invalid match pattern"); + return 0; +} + +static int +compiler_match(struct compiler *c, stmt_ty s) +{ + basicblock *end = compiler_new_block(c); + VISIT(c, expr, s->v.Match.target); + match_case_ty m; + basicblock *next; + Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); + for (Py_ssize_t i = 0; i < cases; i++) { + m = asdl_seq_GET(s->v.Match.cases, i); + next = compiler_new_block(c); + ADDOP(c, DUP_TOP); + compiler_pattern(c, m->pattern, next); + if (m->guard && !compiler_jump_if(c, m->guard, next, 0)) { + return 0; + } + ADDOP(c, POP_TOP); + VISIT_SEQ(c, stmt, m->body); + ADDOP_JREL(c, JUMP_FORWARD, end); + compiler_use_next_block(c, next); + } + ADDOP(c, POP_TOP); + compiler_use_next_block(c, end); + return 1; +} + static int compiler_for(struct compiler *c, stmt_ty s) { @@ -3409,6 +3451,8 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s) return compiler_while(c, s); case If_kind: return compiler_if(c, s); + case Match_kind: + return compiler_match(c, s); case Raise_kind: n = 0; if (s->v.Raise.exc) { diff --git a/Python/symtable.c b/Python/symtable.c index d192f31deefb77..5cf1f90ed5f942 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -207,6 +207,7 @@ static int symtable_visit_argannotations(struct symtable *st, asdl_seq *args); static int symtable_implicit_arg(struct symtable *st, int pos); static int symtable_visit_annotations(struct symtable *st, arguments_ty, expr_ty); static int symtable_visit_withitem(struct symtable *st, withitem_ty item); +static int symtable_visit_match_case(struct symtable *st, match_case_ty m); static identifier top = NULL, lambda = NULL, genexpr = NULL, @@ -1291,6 +1292,10 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (s->v.If.orelse) VISIT_SEQ(st, stmt, s->v.If.orelse); break; + case Match_kind: + VISIT(st, expr, s->v.Match.target); + VISIT_SEQ(st, match_case, s->v.Match.cases); + break; case Raise_kind: if (s->v.Raise.exc) { VISIT(st, expr, s->v.Raise.exc); @@ -1783,6 +1788,17 @@ symtable_visit_withitem(struct symtable *st, withitem_ty item) } +static int +symtable_visit_match_case(struct symtable *st, match_case_ty m) +{ + VISIT(st, expr, m->pattern); + if (m->guard) { + VISIT(st, expr, m->guard); + } + VISIT_SEQ(st, stmt, m->body); + return 1; +} + static int symtable_visit_alias(struct symtable *st, alias_ty a) { From 1c37cca13fddd5f002a1166699b3a53a95d34b81 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 24 May 2020 15:33:08 -0700 Subject: [PATCH 002/189] Add tests for pattern-matching --- Lib/test/test_patma.py | 143 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 Lib/test/test_patma.py diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py new file mode 100644 index 00000000000000..0cd4e6f03bd918 --- /dev/null +++ b/Lib/test/test_patma.py @@ -0,0 +1,143 @@ +import ast +import typing +import unittest + + +FILENAME = "" + + +class MatchCase(typing.NamedTuple): + pattern: str + body: str + guard: typing.Optional[str] = None + + +class PatMaTests(unittest.TestCase): + @staticmethod + def parse_stmts(stmts: str) -> typing.List[ast.stmt]: + return ast.parse(stmts, FILENAME, "exec").body + + @staticmethod + def parse_expr(expr: str) -> ast.expr: + return ast.parse(expr, FILENAME, "eval").body + + @classmethod + def parse_match_case(cls, match_case: MatchCase) -> ast.expr: + pattern = cls.parse_expr(match_case.pattern) + guard = None if match_case.guard is None else cls.parse_expr(match_case.guard) + body = cls.parse_stmts(match_case.body) + return ast.match_case(pattern=pattern, guard=guard, body=body) + + @classmethod + def execute_match( + cls, pre: str, target: str, match_cases: typing.Iterable[MatchCase], post: str + ) -> typing.Tuple[typing.Dict[str, typing.Any], typing.Dict[str, typing.Any]]: + cases = [cls.parse_match_case(case) for case in match_cases] + match = ast.Match(target=cls.parse_expr(target), cases=cases) + body = [*cls.parse_stmts(pre), match, *cls.parse_stmts(post)] + tree = ast.fix_missing_locations(ast.Module(body=body, type_ignores=[])) + namespace = {} + exec(compile(tree, FILENAME, "exec"), None, namespace) + return namespace + + def test_steroid_switch_0(self) -> None: + match_cases = [MatchCase("0", "y = 0")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertEqual(namespace.get("y"), 0) + + def test_steroid_switch_1(self) -> None: + match_cases = [MatchCase("False", "y = 0")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertEqual(namespace.get("y"), 0) + + def test_steroid_switch_2(self) -> None: + match_cases = [MatchCase("1", "y = 0")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertNotIn("y", namespace) + + def test_steroid_switch_3(self) -> None: + match_cases = [MatchCase("None", "y = 0")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertNotIn("y", namespace) + + def test_steroid_switch_4(self) -> None: + match_cases = [MatchCase("0", "y = 0"), MatchCase("0", "y = 1")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertEqual(namespace.get("y"), 0) + + def test_steroid_switch_5(self) -> None: + match_cases = [MatchCase("1", "y = 0"), MatchCase("1", "y = 1")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertNotIn("y", namespace) + + def test_steroid_switch_6(self) -> None: + match_cases = [MatchCase("'x'", "y = 0"), MatchCase("'y'", "y = 1")] + namespace = self.execute_match("x = 'x'", "x", match_cases, "") + self.assertEqual(namespace.get("x"), "x") + self.assertEqual(namespace.get("y"), 0) + + def test_steroid_switch_7(self) -> None: + match_cases = [MatchCase("'y'", "y = 0"), MatchCase("'x'", "y = 1")] + namespace = self.execute_match("x = 'x'", "x", match_cases, "") + self.assertEqual(namespace.get("x"), "x") + self.assertEqual(namespace.get("y"), 1) + + def test_steroid_switch_8(self) -> None: + match_cases = [MatchCase("'x'", "y = 0"), MatchCase("'y'", "y = 1")] + namespace = self.execute_match("x = 'x'", "x", match_cases, "") + self.assertEqual(namespace.get("x"), "x") + self.assertEqual(namespace.get("y"), 0) + + def test_steroid_switch_9(self) -> None: + match_cases = [MatchCase("b'y'", "y = 0"), MatchCase("b'x'", "y = 1")] + namespace = self.execute_match("x = b'x'", "x", match_cases, "") + self.assertEqual(namespace.get("x"), b"x") + self.assertEqual(namespace.get("y"), 1) + + def test_steroid_switch_guard_0(self) -> None: + match_cases = [MatchCase("0", "y = 0", "False"), MatchCase("0", "y = 1")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertEqual(namespace.get("y"), 1) + + def test_steroid_switch_guard_1(self) -> None: + match_cases = [MatchCase("0", "y = 0", "0"), MatchCase("0", "y = 1", "0")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertNotIn("y", namespace) + + def test_steroid_switch_guard_2(self) -> None: + match_cases = [MatchCase("0", "y = 0", "True"), MatchCase("0", "y = 1", "True")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertEqual(namespace.get("y"), 0) + + def test_steroid_switch_guard_3(self) -> None: + match_cases = [MatchCase("0", "y = 0", "True"), MatchCase("0", "y = 1", "True")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertEqual(namespace.get("y"), 0) + + def test_steroid_switch_guard_4(self) -> None: + match_cases = [MatchCase("0", "y = 0", "True"), MatchCase("0", "y = 1", "True")] + namespace = self.execute_match("x = 0", "x", match_cases, "y = 2") + self.assertEqual(namespace.get("x"), 0) + self.assertEqual(namespace.get("y"), 2) + + def test_steroid_switch_guard_5(self) -> None: + match_cases = [MatchCase("0", "y = 0", "0"), MatchCase("0", "y = 1", "1")] + namespace = self.execute_match("x = 0", "x", match_cases, "y = 2") + self.assertEqual(namespace.get("x"), 0) + self.assertEqual(namespace.get("y"), 2) + + def test_steroid_switch_guard_6(self) -> None: + match_cases = [MatchCase("0", "y = 0", "not (x := 1)"), MatchCase("1", "y = 1")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 1) + self.assertNotIn("y", namespace) From 42cc51b106b7e1672f53db53cbe28a18a4a8fa44 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 25 May 2020 14:11:19 -0700 Subject: [PATCH 003/189] Add soft keywords These are like keywords but they only work in context; they are not reserved except when there is an exact match. This would enable things like match statements. --- Parser/pegen/pegen.c | 24 ++++++++++++++++++++++++ Parser/pegen/pegen.h | 1 + Tools/peg_generator/pegen/c_generator.py | 15 ++++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Parser/pegen/pegen.c b/Parser/pegen/pegen.c index ca4ea824b3f28e..8e8b330fbe489b 100644 --- a/Parser/pegen/pegen.c +++ b/Parser/pegen/pegen.c @@ -753,6 +753,30 @@ _PyPegen_expect_token(Parser *p, int type) return t; } +expr_ty +_PyPegen_expect_soft_keyword(Parser *p, const char *keyword) +{ + if (p->mark == p->fill) { + if (_PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + return NULL; + } + } + Token *t = p->tokens[p->mark]; + if (t->type != NAME) { + return NULL; + } + char* s = PyBytes_AsString(t->bytes); + if (!s) { + return NULL; + } + if (strcmp(s, keyword) != 0) { + return NULL; + } + expr_ty res = _PyPegen_name_token(p); + return res; +} + Token * _PyPegen_get_last_nonnwhitespace_token(Parser *p) { diff --git a/Parser/pegen/pegen.h b/Parser/pegen/pegen.h index 146804a896fd10..3d6c5e49a30df2 100644 --- a/Parser/pegen/pegen.h +++ b/Parser/pegen/pegen.h @@ -121,6 +121,7 @@ int _PyPegen_lookahead_with_int(int, Token *(func)(Parser *, int), Parser *, int int _PyPegen_lookahead(int, void *(func)(Parser *), Parser *); Token *_PyPegen_expect_token(Parser *p, int type); +expr_ty _PyPegen_expect_soft_keyword(Parser *p, const char *keyword); Token *_PyPegen_get_last_nonnwhitespace_token(Parser *); int _PyPegen_fill_token(Parser *p); expr_ty _PyPegen_name_token(Parser *p); diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py index c93b348e2b44c9..09869839480606 100644 --- a/Tools/peg_generator/pegen/c_generator.py +++ b/Tools/peg_generator/pegen/c_generator.py @@ -109,6 +109,16 @@ def keyword_helper(self, keyword: str) -> FunctionCall: comment=f"token='{keyword}'", ) + def soft_keyword_helper(self, value: str) -> FunctionCall: + return FunctionCall( + assigned_variable="_keyword", + function="_PyPegen_expect_soft_keyword", + arguments=["p", value], + return_type="expr_ty", + nodetype=NodeTypes.NAME_TOKEN, + comment=f"soft_keyword='{value}'", + ) + def visit_NameLeaf(self, node: NameLeaf) -> FunctionCall: name = node.value if name in self.non_exact_tokens: @@ -146,7 +156,10 @@ def visit_NameLeaf(self, node: NameLeaf) -> FunctionCall: def visit_StringLeaf(self, node: StringLeaf) -> FunctionCall: val = ast.literal_eval(node.value) if re.match(r"[a-zA-Z_]\w*\Z", val): # This is a keyword - return self.keyword_helper(val) + if node.value.endswith("'"): + return self.keyword_helper(val) + else: + return self.soft_keyword_helper(node.value) else: assert val in self.exact_tokens, f"{node.value} is not a known literal" type = self.exact_tokens[val] From 0fe638f9666e87d9ef2da6609b54ca157227f6ca Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 25 May 2020 14:38:53 -0700 Subject: [PATCH 004/189] Fix bad type hint --- Lib/test/test_patma.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 0cd4e6f03bd918..d2df20851a5c67 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -31,7 +31,7 @@ def parse_match_case(cls, match_case: MatchCase) -> ast.expr: @classmethod def execute_match( cls, pre: str, target: str, match_cases: typing.Iterable[MatchCase], post: str - ) -> typing.Tuple[typing.Dict[str, typing.Any], typing.Dict[str, typing.Any]]: + ) -> typing.Dict[str, typing.Any]: cases = [cls.parse_match_case(case) for case in match_cases] match = ast.Match(target=cls.parse_expr(target), cases=cases) body = [*cls.parse_stmts(pre), match, *cls.parse_stmts(post)] From 40a0c793b75a2a3b7d4e510770f5263a21300f70 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 25 May 2020 14:52:33 -0700 Subject: [PATCH 005/189] Add support for named patterns --- Lib/test/test_patma.py | 14 ++++++++++++++ Python/ast.c | 2 ++ Python/compile.c | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index d2df20851a5c67..4fccaf3026a010 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -141,3 +141,17 @@ def test_steroid_switch_guard_6(self) -> None: namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 1) self.assertNotIn("y", namespace) + + def test_walrus_0(self) -> None: + match_cases = [MatchCase("0", "y = 0", "not (x := 1)"), MatchCase("(z := 0)", "y = 1")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 1) + self.assertEqual(namespace.get("y"), 1) + self.assertEqual(namespace.get("z"), 0) + + def test_walrus_1(self) -> None: + match_cases = [MatchCase("(z := 1)", "y = 0", "not (x := 1)"), MatchCase("0", "y = 1")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertEqual(namespace.get("y"), 1) + self.assertNotIn("z", namespace) diff --git a/Python/ast.c b/Python/ast.c index 09300bb4c01228..207133fee15a01 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -308,6 +308,8 @@ validate_pattern(expr_ty p) switch (p->kind) { case Constant_kind: return validate_constant(p->v.Constant.value); + case NamedExpr_kind: + return validate_pattern(p->v.NamedExpr.value); default: break; } diff --git a/Python/compile.c b/Python/compile.c index c90988778ef734..4e2b9ca14b0d0f 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2755,6 +2755,13 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *next) ADDOP_COMPARE(c, Eq); ADDOP_JABS(c, POP_JUMP_IF_FALSE, next); return 1; + case NamedExpr_kind: + if (!compiler_pattern(c, p->v.NamedExpr.value, next)) { + return 0; + } + ADDOP(c, DUP_TOP); + VISIT(c, expr, p->v.NamedExpr.target); + return 1; default: break; } From 6188176a98a9b710dca1c9a75cc90a254e461b7c Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 25 May 2020 14:56:29 -0700 Subject: [PATCH 006/189] Add more tests for named patterns --- Lib/test/test_patma.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 4fccaf3026a010..5dce64acde47e8 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -143,15 +143,43 @@ def test_steroid_switch_guard_6(self) -> None: self.assertNotIn("y", namespace) def test_walrus_0(self) -> None: - match_cases = [MatchCase("0", "y = 0", "not (x := 1)"), MatchCase("(z := 0)", "y = 1")] + match_cases = [ + MatchCase("0", "y = 0", "not (x := 1)"), + MatchCase("(z := 0)", "y = 1"), + ] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 1) self.assertEqual(namespace.get("y"), 1) self.assertEqual(namespace.get("z"), 0) def test_walrus_1(self) -> None: - match_cases = [MatchCase("(z := 1)", "y = 0", "not (x := 1)"), MatchCase("0", "y = 1")] + match_cases = [ + MatchCase("(z := 1)", "y = 0", "not (x := 1)"), + MatchCase("0", "y = 1"), + ] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 1) self.assertNotIn("z", namespace) + + def test_walrus_2(self) -> None: + match_cases = [MatchCase("(z := 0)", "y = 0")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertEqual(namespace.get("y"), 0) + self.assertEqual(namespace.get("z"), 0) + + def test_walrus_3(self) -> None: + match_cases = [MatchCase("(z := 1)", "y = 0")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertNotIn("y", namespace) + self.assertNotIn("z", namespace) + + def test_walrus_4(self) -> None: + match_cases = [MatchCase("(z := 0)", "y = 0", "(w := 0)")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("w"), 0) + self.assertEqual(namespace.get("x"), 0) + self.assertNotIn("y", namespace) + self.assertEqual(namespace.get("z"), 0) From 3323ae03a8773637ffce52c2a8a50a910825fa40 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 25 May 2020 15:18:32 -0700 Subject: [PATCH 007/189] Add a nested walrus test --- Lib/test/test_patma.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 5dce64acde47e8..20d8ce23ae3028 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -183,3 +183,11 @@ def test_walrus_4(self) -> None: self.assertEqual(namespace.get("x"), 0) self.assertNotIn("y", namespace) self.assertEqual(namespace.get("z"), 0) + + def test_walrus_5(self) -> None: + match_cases = [MatchCase("(z := (w := 0))", "y = 0")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("w"), 0) + self.assertEqual(namespace.get("x"), 0) + self.assertEqual(namespace.get("y"), 0) + self.assertEqual(namespace.get("z"), 0) From 409de6ccc9507f66ae0eb1f5f253e7a7c7a18f82 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 25 May 2020 16:30:12 -0700 Subject: [PATCH 008/189] Fix D() macro usage for soft keywords --- Tools/peg_generator/pegen/c_generator.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py index 0ca0e9443acfef..885ff05858f679 100644 --- a/Tools/peg_generator/pegen/c_generator.py +++ b/Tools/peg_generator/pegen/c_generator.py @@ -669,8 +669,9 @@ def handle_alt_normal(self, node: Alt, is_gather: bool, rulename: Optional[str]) self.print("{") # We have parsed successfully all the conditions for the option. with self.indent(): + node_str = str(node).replace('"', '\\"') self.print( - f'D(fprintf(stderr, "%*c+ {rulename}[%d-%d]: %s succeeded!\\n", p->level, \' \', _mark, p->mark, "{node}"));' + f'D(fprintf(stderr, "%*c+ {rulename}[%d-%d]: %s succeeded!\\n", p->level, \' \', _mark, p->mark, "{node_str}"));' ) # Prepare to emmit the rule action and do so if node.action and "EXTRA" in node.action: @@ -723,8 +724,9 @@ def visit_Alt( self.print(f"{{ // {node}") with self.indent(): self._check_for_errors() + node_str = str(node).replace('"', '\\"') self.print( - f'D(fprintf(stderr, "%*c> {rulename}[%d-%d]: %s\\n", p->level, \' \', _mark, p->mark, "{node}"));' + f'D(fprintf(stderr, "%*c> {rulename}[%d-%d]: %s\\n", p->level, \' \', _mark, p->mark, "{node_str}"));' ) # Prepare variable declarations for the alternative vars = self.collect_vars(node) @@ -746,9 +748,10 @@ def visit_Alt( self.handle_alt_normal(node, is_gather, rulename) self.print("p->mark = _mark;") + node_str = str(node).replace('"', '\\"') self.print( f"D(fprintf(stderr, \"%*c%s {rulename}[%d-%d]: %s failed!\\n\", p->level, ' ',\n" - f' p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "{node}"));' + f' p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "{node_str}"));' ) if "_cut_var" in vars: self.print("if (_cut_var) {") From 1d39be6f9e3351ad9799f9d174edc3e6d142b9d9 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 25 May 2020 16:16:10 -0700 Subject: [PATCH 009/189] Tentative (incomplete) grammar for match statements This currently segfaults but I still like it --- Grammar/python.gram | 51 + Parser/pegen/parse.c | 16923 ++++++++++++++++++++++++----------------- 2 files changed, 9857 insertions(+), 7117 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 19d9bb36fed5f3..dba18e16fc36f6 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -80,6 +80,7 @@ compound_stmt[stmt_ty]: | &('for' | ASYNC) for_stmt | &'try' try_stmt | &'while' while_stmt + | match_stmt # NOTE: annotated_rhs may start with 'yield'; yield_expr must start with 'yield' assignment[stmt_ty]: @@ -191,6 +192,56 @@ except_block[excepthandler_ty]: | 'except' ':' b=block { _Py_ExceptHandler(NULL, NULL, b, EXTRA) } finally_block[asdl_seq*]: 'finally' ':' a=block { a } +match_stmt[stmt_ty]: + | "match" target=expression ':' NEWLINE INDENT cases=case_block+ DEDENT {_Py_Match(target, cases, EXTRA) } +case_block: + | "case" pattern=pattern guard=['if' a=named_expression { a }] ':' body=block { + _Py_match_case(pattern, guard, body, p->arena) } + +pattern: + | a=NAME ':=' b=or_pattern { _Py_NamedExpr(CHECK(_PyPegen_set_expr_context(p, a, Store)), b, EXTRA) } + | or_pattern + +or_pattern: + | '|'.closed_pattern+ + +closed_pattern: + | name_pattern + | literal_pattern + | constant_pattern + | group_pattern + | sequence_pattern + | mapping_pattern + | class_pattern + +name_pattern: + | a=NAME !('.' | '(') { a } +literal_pattern: + | NUMBER + | strings + | 'None' + | 'True' + | 'False' +constant_pattern: + | '.' NAME + | a='.'.NAME+ !'(' { a } +group_pattern: + | '(' a=pattern ')' { a } +sequence_pattern: + | '[' a=[','.pattern+] ']' { _Py_List(a, Load, EXTRA) } + | '(' a=[','.pattern+] ')' { _Py_Tuple(a, Load, EXTRA) } +mapping_pattern: + | '{' ','.(key_pattern ':' closed_pattern)+ '}' { NULL } +key_pattern: + | a=literal_pattern &':' { a } + | a='|'.literal_pattern+ { NULL } +class_pattern: + | '.'.NAME+ '(' pattern_args ')' +pattern_args: + | ','.pattern+ ',' ','.(NAME '=' or_pattern)+ { NULL } + | ','.(NAME '=' or_pattern)+ { NULL } + | a=','.pattern+ { a } + return_stmt[stmt_ty]: | 'return' a=[star_expressions] { _Py_Return(a, EXTRA) } diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index b63924177d400c..f4d59b89f04281 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -14,7 +14,7 @@ static KeywordToken *reserved_keywords[] = { (KeywordToken[]) { {"if", 510}, {"in", 518}, - {"is", 526}, + {"is", 529}, {"as", 531}, {"or", 532}, {NULL, -1}, @@ -23,8 +23,8 @@ static KeywordToken *reserved_keywords[] = { {"del", 503}, {"try", 511}, {"for", 517}, - {"def", 522}, - {"not", 525}, + {"def", 525}, + {"not", 528}, {"and", 533}, {NULL, -1}, }, @@ -34,8 +34,8 @@ static KeywordToken *reserved_keywords[] = { {"elif", 515}, {"else", 516}, {"with", 519}, - {"True", 527}, - {"None", 529}, + {"None", 522}, + {"True", 523}, {NULL, -1}, }, (KeywordToken[]) { @@ -43,8 +43,8 @@ static KeywordToken *reserved_keywords[] = { {"yield", 504}, {"break", 506}, {"while", 512}, - {"class", 523}, - {"False", 528}, + {"False", 524}, + {"class", 526}, {NULL, -1}, }, (KeywordToken[]) { @@ -53,7 +53,7 @@ static KeywordToken *reserved_keywords[] = { {"global", 508}, {"import", 513}, {"except", 520}, - {"lambda", 524}, + {"lambda", 527}, {NULL, -1}, }, (KeywordToken[]) { @@ -113,272 +113,314 @@ static KeywordToken *reserved_keywords[] = { #define try_stmt_type 1035 #define except_block_type 1036 #define finally_block_type 1037 -#define return_stmt_type 1038 -#define raise_stmt_type 1039 -#define function_def_type 1040 -#define function_def_raw_type 1041 -#define func_type_comment_type 1042 -#define params_type 1043 -#define parameters_type 1044 -#define slash_no_default_type 1045 -#define slash_with_default_type 1046 -#define star_etc_type 1047 -#define kwds_type 1048 -#define param_no_default_type 1049 -#define param_with_default_type 1050 -#define param_maybe_default_type 1051 -#define param_type 1052 -#define annotation_type 1053 -#define default_type 1054 -#define decorators_type 1055 -#define class_def_type 1056 -#define class_def_raw_type 1057 -#define block_type 1058 -#define expressions_list_type 1059 -#define star_expressions_type 1060 -#define star_expression_type 1061 -#define star_named_expressions_type 1062 -#define star_named_expression_type 1063 -#define named_expression_type 1064 -#define annotated_rhs_type 1065 -#define expressions_type 1066 -#define expression_type 1067 -#define lambdef_type 1068 -#define lambda_parameters_type 1069 -#define lambda_slash_no_default_type 1070 -#define lambda_slash_with_default_type 1071 -#define lambda_star_etc_type 1072 -#define lambda_kwds_type 1073 -#define lambda_param_no_default_type 1074 -#define lambda_param_with_default_type 1075 -#define lambda_param_maybe_default_type 1076 -#define lambda_param_type 1077 -#define disjunction_type 1078 -#define conjunction_type 1079 -#define inversion_type 1080 -#define comparison_type 1081 -#define compare_op_bitwise_or_pair_type 1082 -#define eq_bitwise_or_type 1083 -#define noteq_bitwise_or_type 1084 -#define lte_bitwise_or_type 1085 -#define lt_bitwise_or_type 1086 -#define gte_bitwise_or_type 1087 -#define gt_bitwise_or_type 1088 -#define notin_bitwise_or_type 1089 -#define in_bitwise_or_type 1090 -#define isnot_bitwise_or_type 1091 -#define is_bitwise_or_type 1092 -#define bitwise_or_type 1093 // Left-recursive -#define bitwise_xor_type 1094 // Left-recursive -#define bitwise_and_type 1095 // Left-recursive -#define shift_expr_type 1096 // Left-recursive -#define sum_type 1097 // Left-recursive -#define term_type 1098 // Left-recursive -#define factor_type 1099 -#define power_type 1100 -#define await_primary_type 1101 -#define primary_type 1102 // Left-recursive -#define slices_type 1103 -#define slice_type 1104 -#define atom_type 1105 -#define strings_type 1106 -#define list_type 1107 -#define listcomp_type 1108 -#define tuple_type 1109 -#define group_type 1110 -#define genexp_type 1111 -#define set_type 1112 -#define setcomp_type 1113 -#define dict_type 1114 -#define dictcomp_type 1115 -#define double_starred_kvpairs_type 1116 -#define double_starred_kvpair_type 1117 -#define kvpair_type 1118 -#define for_if_clauses_type 1119 -#define for_if_clause_type 1120 -#define yield_expr_type 1121 -#define arguments_type 1122 -#define args_type 1123 -#define kwargs_type 1124 -#define starred_expression_type 1125 -#define kwarg_or_starred_type 1126 -#define kwarg_or_double_starred_type 1127 -#define star_targets_type 1128 -#define star_targets_seq_type 1129 -#define star_target_type 1130 -#define star_atom_type 1131 -#define single_target_type 1132 -#define single_subscript_attribute_target_type 1133 -#define del_targets_type 1134 -#define del_target_type 1135 -#define del_t_atom_type 1136 -#define del_target_end_type 1137 -#define targets_type 1138 -#define target_type 1139 -#define t_primary_type 1140 // Left-recursive -#define t_lookahead_type 1141 -#define t_atom_type 1142 -#define incorrect_arguments_type 1143 -#define invalid_kwarg_type 1144 -#define invalid_named_expression_type 1145 -#define invalid_assignment_type 1146 -#define invalid_block_type 1147 -#define invalid_comprehension_type 1148 -#define invalid_dict_comprehension_type 1149 -#define invalid_parameters_type 1150 -#define invalid_star_etc_type 1151 -#define invalid_lambda_star_etc_type 1152 -#define invalid_double_type_comments_type 1153 -#define invalid_del_target_type 1154 -#define invalid_import_from_targets_type 1155 -#define _loop0_1_type 1156 -#define _loop0_2_type 1157 -#define _loop0_4_type 1158 -#define _gather_3_type 1159 -#define _loop0_6_type 1160 -#define _gather_5_type 1161 -#define _loop0_8_type 1162 -#define _gather_7_type 1163 -#define _loop0_10_type 1164 -#define _gather_9_type 1165 -#define _loop1_11_type 1166 -#define _loop0_13_type 1167 -#define _gather_12_type 1168 -#define _tmp_14_type 1169 -#define _tmp_15_type 1170 -#define _tmp_16_type 1171 -#define _tmp_17_type 1172 -#define _tmp_18_type 1173 -#define _tmp_19_type 1174 -#define _tmp_20_type 1175 -#define _tmp_21_type 1176 -#define _loop1_22_type 1177 -#define _tmp_23_type 1178 -#define _tmp_24_type 1179 -#define _loop0_26_type 1180 -#define _gather_25_type 1181 -#define _loop0_28_type 1182 -#define _gather_27_type 1183 -#define _tmp_29_type 1184 -#define _loop0_30_type 1185 -#define _loop1_31_type 1186 -#define _loop0_33_type 1187 -#define _gather_32_type 1188 -#define _tmp_34_type 1189 -#define _loop0_36_type 1190 -#define _gather_35_type 1191 -#define _tmp_37_type 1192 -#define _loop0_39_type 1193 -#define _gather_38_type 1194 -#define _loop0_41_type 1195 -#define _gather_40_type 1196 -#define _loop0_43_type 1197 -#define _gather_42_type 1198 -#define _loop0_45_type 1199 -#define _gather_44_type 1200 -#define _tmp_46_type 1201 -#define _loop1_47_type 1202 -#define _tmp_48_type 1203 -#define _tmp_49_type 1204 -#define _tmp_50_type 1205 -#define _tmp_51_type 1206 -#define _tmp_52_type 1207 -#define _loop0_53_type 1208 -#define _loop0_54_type 1209 -#define _loop0_55_type 1210 -#define _loop1_56_type 1211 -#define _loop0_57_type 1212 -#define _loop1_58_type 1213 -#define _loop1_59_type 1214 -#define _loop1_60_type 1215 -#define _loop0_61_type 1216 -#define _loop1_62_type 1217 -#define _loop0_63_type 1218 -#define _loop1_64_type 1219 -#define _loop0_65_type 1220 -#define _loop1_66_type 1221 -#define _loop1_67_type 1222 -#define _tmp_68_type 1223 -#define _loop0_70_type 1224 -#define _gather_69_type 1225 -#define _loop1_71_type 1226 -#define _loop0_73_type 1227 -#define _gather_72_type 1228 -#define _loop1_74_type 1229 -#define _loop0_75_type 1230 -#define _loop0_76_type 1231 -#define _loop0_77_type 1232 -#define _loop1_78_type 1233 -#define _loop0_79_type 1234 -#define _loop1_80_type 1235 -#define _loop1_81_type 1236 -#define _loop1_82_type 1237 -#define _loop0_83_type 1238 -#define _loop1_84_type 1239 -#define _loop0_85_type 1240 -#define _loop1_86_type 1241 -#define _loop0_87_type 1242 -#define _loop1_88_type 1243 -#define _loop1_89_type 1244 -#define _loop1_90_type 1245 -#define _loop1_91_type 1246 -#define _tmp_92_type 1247 -#define _loop0_94_type 1248 -#define _gather_93_type 1249 -#define _tmp_95_type 1250 -#define _tmp_96_type 1251 -#define _tmp_97_type 1252 -#define _tmp_98_type 1253 -#define _loop1_99_type 1254 -#define _tmp_100_type 1255 -#define _tmp_101_type 1256 -#define _loop0_103_type 1257 -#define _gather_102_type 1258 -#define _loop1_104_type 1259 -#define _loop0_105_type 1260 -#define _loop0_106_type 1261 -#define _tmp_107_type 1262 -#define _tmp_108_type 1263 -#define _loop0_110_type 1264 -#define _gather_109_type 1265 -#define _loop0_112_type 1266 -#define _gather_111_type 1267 -#define _loop0_114_type 1268 -#define _gather_113_type 1269 -#define _loop0_116_type 1270 -#define _gather_115_type 1271 -#define _loop0_117_type 1272 -#define _loop0_119_type 1273 -#define _gather_118_type 1274 -#define _tmp_120_type 1275 -#define _loop0_122_type 1276 -#define _gather_121_type 1277 -#define _loop0_124_type 1278 -#define _gather_123_type 1279 -#define _tmp_125_type 1280 -#define _loop0_126_type 1281 -#define _tmp_127_type 1282 -#define _tmp_128_type 1283 -#define _tmp_129_type 1284 -#define _tmp_130_type 1285 -#define _loop0_131_type 1286 -#define _tmp_132_type 1287 -#define _tmp_133_type 1288 -#define _tmp_134_type 1289 -#define _tmp_135_type 1290 -#define _tmp_136_type 1291 -#define _tmp_137_type 1292 -#define _tmp_138_type 1293 -#define _tmp_139_type 1294 -#define _tmp_140_type 1295 -#define _tmp_141_type 1296 -#define _tmp_142_type 1297 -#define _tmp_143_type 1298 -#define _tmp_144_type 1299 -#define _tmp_145_type 1300 -#define _loop1_146_type 1301 -#define _tmp_147_type 1302 -#define _tmp_148_type 1303 +#define match_stmt_type 1038 +#define case_block_type 1039 +#define pattern_type 1040 +#define or_pattern_type 1041 +#define closed_pattern_type 1042 +#define name_pattern_type 1043 +#define literal_pattern_type 1044 +#define constant_pattern_type 1045 +#define group_pattern_type 1046 +#define sequence_pattern_type 1047 +#define mapping_pattern_type 1048 +#define key_pattern_type 1049 +#define class_pattern_type 1050 +#define pattern_args_type 1051 +#define return_stmt_type 1052 +#define raise_stmt_type 1053 +#define function_def_type 1054 +#define function_def_raw_type 1055 +#define func_type_comment_type 1056 +#define params_type 1057 +#define parameters_type 1058 +#define slash_no_default_type 1059 +#define slash_with_default_type 1060 +#define star_etc_type 1061 +#define kwds_type 1062 +#define param_no_default_type 1063 +#define param_with_default_type 1064 +#define param_maybe_default_type 1065 +#define param_type 1066 +#define annotation_type 1067 +#define default_type 1068 +#define decorators_type 1069 +#define class_def_type 1070 +#define class_def_raw_type 1071 +#define block_type 1072 +#define expressions_list_type 1073 +#define star_expressions_type 1074 +#define star_expression_type 1075 +#define star_named_expressions_type 1076 +#define star_named_expression_type 1077 +#define named_expression_type 1078 +#define annotated_rhs_type 1079 +#define expressions_type 1080 +#define expression_type 1081 +#define lambdef_type 1082 +#define lambda_parameters_type 1083 +#define lambda_slash_no_default_type 1084 +#define lambda_slash_with_default_type 1085 +#define lambda_star_etc_type 1086 +#define lambda_kwds_type 1087 +#define lambda_param_no_default_type 1088 +#define lambda_param_with_default_type 1089 +#define lambda_param_maybe_default_type 1090 +#define lambda_param_type 1091 +#define disjunction_type 1092 +#define conjunction_type 1093 +#define inversion_type 1094 +#define comparison_type 1095 +#define compare_op_bitwise_or_pair_type 1096 +#define eq_bitwise_or_type 1097 +#define noteq_bitwise_or_type 1098 +#define lte_bitwise_or_type 1099 +#define lt_bitwise_or_type 1100 +#define gte_bitwise_or_type 1101 +#define gt_bitwise_or_type 1102 +#define notin_bitwise_or_type 1103 +#define in_bitwise_or_type 1104 +#define isnot_bitwise_or_type 1105 +#define is_bitwise_or_type 1106 +#define bitwise_or_type 1107 // Left-recursive +#define bitwise_xor_type 1108 // Left-recursive +#define bitwise_and_type 1109 // Left-recursive +#define shift_expr_type 1110 // Left-recursive +#define sum_type 1111 // Left-recursive +#define term_type 1112 // Left-recursive +#define factor_type 1113 +#define power_type 1114 +#define await_primary_type 1115 +#define primary_type 1116 // Left-recursive +#define slices_type 1117 +#define slice_type 1118 +#define atom_type 1119 +#define strings_type 1120 +#define list_type 1121 +#define listcomp_type 1122 +#define tuple_type 1123 +#define group_type 1124 +#define genexp_type 1125 +#define set_type 1126 +#define setcomp_type 1127 +#define dict_type 1128 +#define dictcomp_type 1129 +#define double_starred_kvpairs_type 1130 +#define double_starred_kvpair_type 1131 +#define kvpair_type 1132 +#define for_if_clauses_type 1133 +#define for_if_clause_type 1134 +#define yield_expr_type 1135 +#define arguments_type 1136 +#define args_type 1137 +#define kwargs_type 1138 +#define starred_expression_type 1139 +#define kwarg_or_starred_type 1140 +#define kwarg_or_double_starred_type 1141 +#define star_targets_type 1142 +#define star_targets_seq_type 1143 +#define star_target_type 1144 +#define star_atom_type 1145 +#define single_target_type 1146 +#define single_subscript_attribute_target_type 1147 +#define del_targets_type 1148 +#define del_target_type 1149 +#define del_t_atom_type 1150 +#define del_target_end_type 1151 +#define targets_type 1152 +#define target_type 1153 +#define t_primary_type 1154 // Left-recursive +#define t_lookahead_type 1155 +#define t_atom_type 1156 +#define incorrect_arguments_type 1157 +#define invalid_kwarg_type 1158 +#define invalid_named_expression_type 1159 +#define invalid_assignment_type 1160 +#define invalid_block_type 1161 +#define invalid_comprehension_type 1162 +#define invalid_dict_comprehension_type 1163 +#define invalid_parameters_type 1164 +#define invalid_star_etc_type 1165 +#define invalid_lambda_star_etc_type 1166 +#define invalid_double_type_comments_type 1167 +#define invalid_del_target_type 1168 +#define invalid_import_from_targets_type 1169 +#define _loop0_1_type 1170 +#define _loop0_2_type 1171 +#define _loop0_4_type 1172 +#define _gather_3_type 1173 +#define _loop0_6_type 1174 +#define _gather_5_type 1175 +#define _loop0_8_type 1176 +#define _gather_7_type 1177 +#define _loop0_10_type 1178 +#define _gather_9_type 1179 +#define _loop1_11_type 1180 +#define _loop0_13_type 1181 +#define _gather_12_type 1182 +#define _tmp_14_type 1183 +#define _tmp_15_type 1184 +#define _tmp_16_type 1185 +#define _tmp_17_type 1186 +#define _tmp_18_type 1187 +#define _tmp_19_type 1188 +#define _tmp_20_type 1189 +#define _tmp_21_type 1190 +#define _loop1_22_type 1191 +#define _tmp_23_type 1192 +#define _tmp_24_type 1193 +#define _loop0_26_type 1194 +#define _gather_25_type 1195 +#define _loop0_28_type 1196 +#define _gather_27_type 1197 +#define _tmp_29_type 1198 +#define _loop0_30_type 1199 +#define _loop1_31_type 1200 +#define _loop0_33_type 1201 +#define _gather_32_type 1202 +#define _tmp_34_type 1203 +#define _loop0_36_type 1204 +#define _gather_35_type 1205 +#define _tmp_37_type 1206 +#define _loop0_39_type 1207 +#define _gather_38_type 1208 +#define _loop0_41_type 1209 +#define _gather_40_type 1210 +#define _loop0_43_type 1211 +#define _gather_42_type 1212 +#define _loop0_45_type 1213 +#define _gather_44_type 1214 +#define _tmp_46_type 1215 +#define _loop1_47_type 1216 +#define _tmp_48_type 1217 +#define _loop1_49_type 1218 +#define _tmp_50_type 1219 +#define _loop0_52_type 1220 +#define _gather_51_type 1221 +#define _tmp_53_type 1222 +#define _loop0_55_type 1223 +#define _gather_54_type 1224 +#define _loop0_57_type 1225 +#define _gather_56_type 1226 +#define _loop0_59_type 1227 +#define _gather_58_type 1228 +#define _loop0_61_type 1229 +#define _gather_60_type 1230 +#define _loop0_63_type 1231 +#define _gather_62_type 1232 +#define _loop0_65_type 1233 +#define _gather_64_type 1234 +#define _loop0_67_type 1235 +#define _gather_66_type 1236 +#define _loop0_69_type 1237 +#define _gather_68_type 1238 +#define _loop0_71_type 1239 +#define _gather_70_type 1240 +#define _loop0_73_type 1241 +#define _gather_72_type 1242 +#define _tmp_74_type 1243 +#define _tmp_75_type 1244 +#define _tmp_76_type 1245 +#define _tmp_77_type 1246 +#define _loop0_78_type 1247 +#define _loop0_79_type 1248 +#define _loop0_80_type 1249 +#define _loop1_81_type 1250 +#define _loop0_82_type 1251 +#define _loop1_83_type 1252 +#define _loop1_84_type 1253 +#define _loop1_85_type 1254 +#define _loop0_86_type 1255 +#define _loop1_87_type 1256 +#define _loop0_88_type 1257 +#define _loop1_89_type 1258 +#define _loop0_90_type 1259 +#define _loop1_91_type 1260 +#define _loop1_92_type 1261 +#define _tmp_93_type 1262 +#define _loop0_95_type 1263 +#define _gather_94_type 1264 +#define _loop1_96_type 1265 +#define _loop0_98_type 1266 +#define _gather_97_type 1267 +#define _loop1_99_type 1268 +#define _loop0_100_type 1269 +#define _loop0_101_type 1270 +#define _loop0_102_type 1271 +#define _loop1_103_type 1272 +#define _loop0_104_type 1273 +#define _loop1_105_type 1274 +#define _loop1_106_type 1275 +#define _loop1_107_type 1276 +#define _loop0_108_type 1277 +#define _loop1_109_type 1278 +#define _loop0_110_type 1279 +#define _loop1_111_type 1280 +#define _loop0_112_type 1281 +#define _loop1_113_type 1282 +#define _loop1_114_type 1283 +#define _loop1_115_type 1284 +#define _loop1_116_type 1285 +#define _tmp_117_type 1286 +#define _loop0_119_type 1287 +#define _gather_118_type 1288 +#define _tmp_120_type 1289 +#define _tmp_121_type 1290 +#define _tmp_122_type 1291 +#define _tmp_123_type 1292 +#define _loop1_124_type 1293 +#define _tmp_125_type 1294 +#define _tmp_126_type 1295 +#define _loop0_128_type 1296 +#define _gather_127_type 1297 +#define _loop1_129_type 1298 +#define _loop0_130_type 1299 +#define _loop0_131_type 1300 +#define _tmp_132_type 1301 +#define _tmp_133_type 1302 +#define _loop0_135_type 1303 +#define _gather_134_type 1304 +#define _loop0_137_type 1305 +#define _gather_136_type 1306 +#define _loop0_139_type 1307 +#define _gather_138_type 1308 +#define _loop0_141_type 1309 +#define _gather_140_type 1310 +#define _loop0_142_type 1311 +#define _loop0_144_type 1312 +#define _gather_143_type 1313 +#define _tmp_145_type 1314 +#define _loop0_147_type 1315 +#define _gather_146_type 1316 +#define _loop0_149_type 1317 +#define _gather_148_type 1318 +#define _tmp_150_type 1319 +#define _loop0_151_type 1320 +#define _tmp_152_type 1321 +#define _tmp_153_type 1322 +#define _tmp_154_type 1323 +#define _tmp_155_type 1324 +#define _loop0_156_type 1325 +#define _tmp_157_type 1326 +#define _tmp_158_type 1327 +#define _tmp_159_type 1328 +#define _tmp_160_type 1329 +#define _tmp_161_type 1330 +#define _tmp_162_type 1331 +#define _tmp_163_type 1332 +#define _tmp_164_type 1333 +#define _tmp_165_type 1334 +#define _tmp_166_type 1335 +#define _tmp_167_type 1336 +#define _tmp_168_type 1337 +#define _tmp_169_type 1338 +#define _tmp_170_type 1339 +#define _tmp_171_type 1340 +#define _tmp_172_type 1341 +#define _tmp_173_type 1342 +#define _loop1_174_type 1343 +#define _tmp_175_type 1344 +#define _tmp_176_type 1345 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -418,6 +460,20 @@ static withitem_ty with_item_rule(Parser *p); static stmt_ty try_stmt_rule(Parser *p); static excepthandler_ty except_block_rule(Parser *p); static asdl_seq* finally_block_rule(Parser *p); +static stmt_ty match_stmt_rule(Parser *p); +static void *case_block_rule(Parser *p); +static void *pattern_rule(Parser *p); +static void *or_pattern_rule(Parser *p); +static void *closed_pattern_rule(Parser *p); +static void *name_pattern_rule(Parser *p); +static void *literal_pattern_rule(Parser *p); +static void *constant_pattern_rule(Parser *p); +static void *group_pattern_rule(Parser *p); +static void *sequence_pattern_rule(Parser *p); +static void *mapping_pattern_rule(Parser *p); +static void *key_pattern_rule(Parser *p); +static void *class_pattern_rule(Parser *p); +static void *pattern_args_rule(Parser *p); static stmt_ty return_stmt_rule(Parser *p); static stmt_ty raise_stmt_rule(Parser *p); static stmt_ty function_def_rule(Parser *p); @@ -584,106 +640,134 @@ static asdl_seq *_gather_44_rule(Parser *p); static void *_tmp_46_rule(Parser *p); static asdl_seq *_loop1_47_rule(Parser *p); static void *_tmp_48_rule(Parser *p); -static void *_tmp_49_rule(Parser *p); +static asdl_seq *_loop1_49_rule(Parser *p); static void *_tmp_50_rule(Parser *p); -static void *_tmp_51_rule(Parser *p); -static void *_tmp_52_rule(Parser *p); -static asdl_seq *_loop0_53_rule(Parser *p); -static asdl_seq *_loop0_54_rule(Parser *p); +static asdl_seq *_loop0_52_rule(Parser *p); +static asdl_seq *_gather_51_rule(Parser *p); +static void *_tmp_53_rule(Parser *p); static asdl_seq *_loop0_55_rule(Parser *p); -static asdl_seq *_loop1_56_rule(Parser *p); +static asdl_seq *_gather_54_rule(Parser *p); static asdl_seq *_loop0_57_rule(Parser *p); -static asdl_seq *_loop1_58_rule(Parser *p); -static asdl_seq *_loop1_59_rule(Parser *p); -static asdl_seq *_loop1_60_rule(Parser *p); +static asdl_seq *_gather_56_rule(Parser *p); +static asdl_seq *_loop0_59_rule(Parser *p); +static asdl_seq *_gather_58_rule(Parser *p); static asdl_seq *_loop0_61_rule(Parser *p); -static asdl_seq *_loop1_62_rule(Parser *p); +static asdl_seq *_gather_60_rule(Parser *p); static asdl_seq *_loop0_63_rule(Parser *p); -static asdl_seq *_loop1_64_rule(Parser *p); +static asdl_seq *_gather_62_rule(Parser *p); static asdl_seq *_loop0_65_rule(Parser *p); -static asdl_seq *_loop1_66_rule(Parser *p); -static asdl_seq *_loop1_67_rule(Parser *p); -static void *_tmp_68_rule(Parser *p); -static asdl_seq *_loop0_70_rule(Parser *p); -static asdl_seq *_gather_69_rule(Parser *p); -static asdl_seq *_loop1_71_rule(Parser *p); +static asdl_seq *_gather_64_rule(Parser *p); +static asdl_seq *_loop0_67_rule(Parser *p); +static asdl_seq *_gather_66_rule(Parser *p); +static asdl_seq *_loop0_69_rule(Parser *p); +static asdl_seq *_gather_68_rule(Parser *p); +static asdl_seq *_loop0_71_rule(Parser *p); +static asdl_seq *_gather_70_rule(Parser *p); static asdl_seq *_loop0_73_rule(Parser *p); static asdl_seq *_gather_72_rule(Parser *p); -static asdl_seq *_loop1_74_rule(Parser *p); -static asdl_seq *_loop0_75_rule(Parser *p); -static asdl_seq *_loop0_76_rule(Parser *p); -static asdl_seq *_loop0_77_rule(Parser *p); -static asdl_seq *_loop1_78_rule(Parser *p); +static void *_tmp_74_rule(Parser *p); +static void *_tmp_75_rule(Parser *p); +static void *_tmp_76_rule(Parser *p); +static void *_tmp_77_rule(Parser *p); +static asdl_seq *_loop0_78_rule(Parser *p); static asdl_seq *_loop0_79_rule(Parser *p); -static asdl_seq *_loop1_80_rule(Parser *p); +static asdl_seq *_loop0_80_rule(Parser *p); static asdl_seq *_loop1_81_rule(Parser *p); -static asdl_seq *_loop1_82_rule(Parser *p); -static asdl_seq *_loop0_83_rule(Parser *p); +static asdl_seq *_loop0_82_rule(Parser *p); +static asdl_seq *_loop1_83_rule(Parser *p); static asdl_seq *_loop1_84_rule(Parser *p); -static asdl_seq *_loop0_85_rule(Parser *p); -static asdl_seq *_loop1_86_rule(Parser *p); -static asdl_seq *_loop0_87_rule(Parser *p); -static asdl_seq *_loop1_88_rule(Parser *p); +static asdl_seq *_loop1_85_rule(Parser *p); +static asdl_seq *_loop0_86_rule(Parser *p); +static asdl_seq *_loop1_87_rule(Parser *p); +static asdl_seq *_loop0_88_rule(Parser *p); static asdl_seq *_loop1_89_rule(Parser *p); -static asdl_seq *_loop1_90_rule(Parser *p); +static asdl_seq *_loop0_90_rule(Parser *p); static asdl_seq *_loop1_91_rule(Parser *p); -static void *_tmp_92_rule(Parser *p); -static asdl_seq *_loop0_94_rule(Parser *p); -static asdl_seq *_gather_93_rule(Parser *p); -static void *_tmp_95_rule(Parser *p); -static void *_tmp_96_rule(Parser *p); -static void *_tmp_97_rule(Parser *p); -static void *_tmp_98_rule(Parser *p); +static asdl_seq *_loop1_92_rule(Parser *p); +static void *_tmp_93_rule(Parser *p); +static asdl_seq *_loop0_95_rule(Parser *p); +static asdl_seq *_gather_94_rule(Parser *p); +static asdl_seq *_loop1_96_rule(Parser *p); +static asdl_seq *_loop0_98_rule(Parser *p); +static asdl_seq *_gather_97_rule(Parser *p); static asdl_seq *_loop1_99_rule(Parser *p); -static void *_tmp_100_rule(Parser *p); -static void *_tmp_101_rule(Parser *p); -static asdl_seq *_loop0_103_rule(Parser *p); -static asdl_seq *_gather_102_rule(Parser *p); -static asdl_seq *_loop1_104_rule(Parser *p); -static asdl_seq *_loop0_105_rule(Parser *p); -static asdl_seq *_loop0_106_rule(Parser *p); -static void *_tmp_107_rule(Parser *p); -static void *_tmp_108_rule(Parser *p); +static asdl_seq *_loop0_100_rule(Parser *p); +static asdl_seq *_loop0_101_rule(Parser *p); +static asdl_seq *_loop0_102_rule(Parser *p); +static asdl_seq *_loop1_103_rule(Parser *p); +static asdl_seq *_loop0_104_rule(Parser *p); +static asdl_seq *_loop1_105_rule(Parser *p); +static asdl_seq *_loop1_106_rule(Parser *p); +static asdl_seq *_loop1_107_rule(Parser *p); +static asdl_seq *_loop0_108_rule(Parser *p); +static asdl_seq *_loop1_109_rule(Parser *p); static asdl_seq *_loop0_110_rule(Parser *p); -static asdl_seq *_gather_109_rule(Parser *p); +static asdl_seq *_loop1_111_rule(Parser *p); static asdl_seq *_loop0_112_rule(Parser *p); -static asdl_seq *_gather_111_rule(Parser *p); -static asdl_seq *_loop0_114_rule(Parser *p); -static asdl_seq *_gather_113_rule(Parser *p); -static asdl_seq *_loop0_116_rule(Parser *p); -static asdl_seq *_gather_115_rule(Parser *p); -static asdl_seq *_loop0_117_rule(Parser *p); +static asdl_seq *_loop1_113_rule(Parser *p); +static asdl_seq *_loop1_114_rule(Parser *p); +static asdl_seq *_loop1_115_rule(Parser *p); +static asdl_seq *_loop1_116_rule(Parser *p); +static void *_tmp_117_rule(Parser *p); static asdl_seq *_loop0_119_rule(Parser *p); static asdl_seq *_gather_118_rule(Parser *p); static void *_tmp_120_rule(Parser *p); -static asdl_seq *_loop0_122_rule(Parser *p); -static asdl_seq *_gather_121_rule(Parser *p); -static asdl_seq *_loop0_124_rule(Parser *p); -static asdl_seq *_gather_123_rule(Parser *p); +static void *_tmp_121_rule(Parser *p); +static void *_tmp_122_rule(Parser *p); +static void *_tmp_123_rule(Parser *p); +static asdl_seq *_loop1_124_rule(Parser *p); static void *_tmp_125_rule(Parser *p); -static asdl_seq *_loop0_126_rule(Parser *p); -static void *_tmp_127_rule(Parser *p); -static void *_tmp_128_rule(Parser *p); -static void *_tmp_129_rule(Parser *p); -static void *_tmp_130_rule(Parser *p); +static void *_tmp_126_rule(Parser *p); +static asdl_seq *_loop0_128_rule(Parser *p); +static asdl_seq *_gather_127_rule(Parser *p); +static asdl_seq *_loop1_129_rule(Parser *p); +static asdl_seq *_loop0_130_rule(Parser *p); static asdl_seq *_loop0_131_rule(Parser *p); static void *_tmp_132_rule(Parser *p); static void *_tmp_133_rule(Parser *p); -static void *_tmp_134_rule(Parser *p); -static void *_tmp_135_rule(Parser *p); -static void *_tmp_136_rule(Parser *p); -static void *_tmp_137_rule(Parser *p); -static void *_tmp_138_rule(Parser *p); -static void *_tmp_139_rule(Parser *p); -static void *_tmp_140_rule(Parser *p); -static void *_tmp_141_rule(Parser *p); -static void *_tmp_142_rule(Parser *p); -static void *_tmp_143_rule(Parser *p); -static void *_tmp_144_rule(Parser *p); +static asdl_seq *_loop0_135_rule(Parser *p); +static asdl_seq *_gather_134_rule(Parser *p); +static asdl_seq *_loop0_137_rule(Parser *p); +static asdl_seq *_gather_136_rule(Parser *p); +static asdl_seq *_loop0_139_rule(Parser *p); +static asdl_seq *_gather_138_rule(Parser *p); +static asdl_seq *_loop0_141_rule(Parser *p); +static asdl_seq *_gather_140_rule(Parser *p); +static asdl_seq *_loop0_142_rule(Parser *p); +static asdl_seq *_loop0_144_rule(Parser *p); +static asdl_seq *_gather_143_rule(Parser *p); static void *_tmp_145_rule(Parser *p); -static asdl_seq *_loop1_146_rule(Parser *p); -static void *_tmp_147_rule(Parser *p); -static void *_tmp_148_rule(Parser *p); +static asdl_seq *_loop0_147_rule(Parser *p); +static asdl_seq *_gather_146_rule(Parser *p); +static asdl_seq *_loop0_149_rule(Parser *p); +static asdl_seq *_gather_148_rule(Parser *p); +static void *_tmp_150_rule(Parser *p); +static asdl_seq *_loop0_151_rule(Parser *p); +static void *_tmp_152_rule(Parser *p); +static void *_tmp_153_rule(Parser *p); +static void *_tmp_154_rule(Parser *p); +static void *_tmp_155_rule(Parser *p); +static asdl_seq *_loop0_156_rule(Parser *p); +static void *_tmp_157_rule(Parser *p); +static void *_tmp_158_rule(Parser *p); +static void *_tmp_159_rule(Parser *p); +static void *_tmp_160_rule(Parser *p); +static void *_tmp_161_rule(Parser *p); +static void *_tmp_162_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 void *_tmp_167_rule(Parser *p); +static void *_tmp_168_rule(Parser *p); +static void *_tmp_169_rule(Parser *p); +static void *_tmp_170_rule(Parser *p); +static void *_tmp_171_rule(Parser *p); +static void *_tmp_172_rule(Parser *p); +static void *_tmp_173_rule(Parser *p); +static asdl_seq *_loop1_174_rule(Parser *p); +static void *_tmp_175_rule(Parser *p); +static void *_tmp_176_rule(Parser *p); // file: statements? $ @@ -1832,6 +1916,7 @@ small_stmt_rule(Parser *p) // | &('for' | ASYNC) for_stmt // | &'try' try_stmt // | &'while' while_stmt +// | match_stmt static stmt_ty compound_stmt_rule(Parser *p) { @@ -1989,6 +2074,25 @@ compound_stmt_rule(Parser *p) D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'while' while_stmt")); } + { // match_stmt + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "match_stmt")); + stmt_ty match_stmt_var; + if ( + (match_stmt_var = match_stmt_rule(p)) // match_stmt + ) + { + D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "match_stmt")); + _res = match_stmt_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "match_stmt")); + } _res = NULL; done: D(p->level--); @@ -4518,9 +4622,9 @@ finally_block_rule(Parser *p) return _res; } -// return_stmt: 'return' star_expressions? +// match_stmt: "match" expression ':' NEWLINE INDENT case_block+ DEDENT static stmt_ty -return_stmt_rule(Parser *p) +match_stmt_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -4538,21 +4642,36 @@ return_stmt_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // 'return' star_expressions? + { // "match" expression ':' NEWLINE INDENT case_block+ DEDENT if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> return_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?")); - Token * _keyword; - void *a; + D(fprintf(stderr, "%*c> match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"match\" expression ':' NEWLINE INDENT case_block+ DEDENT")); + expr_ty _keyword; + Token * _literal; + asdl_seq * cases; + Token * dedent_var; + Token * indent_var; + Token * newline_var; + expr_ty target; if ( - (_keyword = _PyPegen_expect_token(p, 500)) // token='return' + (_keyword = _PyPegen_expect_soft_keyword(p, "match")) // soft_keyword='"match"' && - (a = star_expressions_rule(p), 1) // star_expressions? + (target = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' + && + (cases = _loop1_49_rule(p)) // case_block+ + && + (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' ) { - D(fprintf(stderr, "%*c+ return_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?")); + D(fprintf(stderr, "%*c+ match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"match\" expression ':' NEWLINE INDENT case_block+ DEDENT")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -4562,7 +4681,7 @@ return_stmt_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Return ( a , EXTRA ); + _res = _Py_Match ( target , cases , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -4571,8 +4690,8 @@ return_stmt_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s return_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'return' star_expressions?")); + D(fprintf(stderr, "%*c%s match_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"match\" expression ':' NEWLINE INDENT case_block+ DEDENT")); } _res = NULL; done: @@ -4580,16 +4699,69 @@ return_stmt_rule(Parser *p) return _res; } -// raise_stmt: 'raise' expression ['from' expression] | 'raise' -static stmt_ty -raise_stmt_rule(Parser *p) +// case_block: "case" pattern ['if' named_expression] ':' block +static void * +case_block_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - stmt_ty _res = NULL; + void * _res = NULL; + int _mark = p->mark; + { // "case" pattern ['if' named_expression] ':' block + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> case_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" pattern ['if' named_expression] ':' block")); + expr_ty _keyword; + Token * _literal; + asdl_seq* body; + void *guard; + void *pattern; + if ( + (_keyword = _PyPegen_expect_soft_keyword(p, "case")) // soft_keyword='"case"' + && + (pattern = pattern_rule(p)) // pattern + && + (guard = _tmp_50_rule(p), 1) // ['if' named_expression] + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (body = block_rule(p)) // block + ) + { + D(fprintf(stderr, "%*c+ case_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" pattern ['if' named_expression] ':' block")); + _res = _Py_match_case ( pattern , guard , body , p -> arena ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s case_block[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" pattern ['if' named_expression] ':' block")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// pattern: NAME ':=' or_pattern | or_pattern +static void * +pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -4600,24 +4772,24 @@ raise_stmt_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // 'raise' expression ['from' expression] + { // NAME ':=' or_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); - Token * _keyword; + D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':=' or_pattern")); + Token * _literal; expr_ty a; void *b; if ( - (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' + (a = _PyPegen_name_token(p)) // NAME && - (a = expression_rule(p)) // expression + (_literal = _PyPegen_expect_token(p, 53)) // token=':=' && - (b = _tmp_49_rule(p), 1) // ['from' expression] + (b = or_pattern_rule(p)) // or_pattern ) { - D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); + D(fprintf(stderr, "%*c+ pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ':=' or_pattern")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -4627,7 +4799,7 @@ raise_stmt_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Raise ( a , b , EXTRA ); + _res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -4636,41 +4808,27 @@ raise_stmt_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise' expression ['from' expression]")); + D(fprintf(stderr, "%*c%s pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':=' or_pattern")); } - { // 'raise' + { // or_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise'")); - Token * _keyword; + D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "or_pattern")); + void *or_pattern_var; if ( - (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' + (or_pattern_var = or_pattern_rule(p)) // or_pattern ) { - D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Raise ( NULL , NULL , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "or_pattern")); + _res = or_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise'")); + D(fprintf(stderr, "%*c%s pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "or_pattern")); } _res = NULL; done: @@ -4678,62 +4836,35 @@ raise_stmt_rule(Parser *p) return _res; } -// function_def: decorators function_def_raw | function_def_raw -static stmt_ty -function_def_rule(Parser *p) +// or_pattern: '|'.closed_pattern+ +static void * +or_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - stmt_ty _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // decorators function_def_raw - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> function_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "decorators function_def_raw")); - asdl_seq* d; - stmt_ty f; - if ( - (d = decorators_rule(p)) // decorators - && - (f = function_def_raw_rule(p)) // function_def_raw - ) - { - D(fprintf(stderr, "%*c+ function_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "decorators function_def_raw")); - _res = _PyPegen_function_def_decorators ( p , d , f ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s function_def[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "decorators function_def_raw")); - } - { // function_def_raw + { // '|'.closed_pattern+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> function_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "function_def_raw")); - stmt_ty function_def_raw_var; + D(fprintf(stderr, "%*c> or_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|'.closed_pattern+")); + asdl_seq * _gather_51_var; if ( - (function_def_raw_var = function_def_raw_rule(p)) // function_def_raw + (_gather_51_var = _gather_51_rule(p)) // '|'.closed_pattern+ ) { - D(fprintf(stderr, "%*c+ function_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "function_def_raw")); - _res = function_def_raw_var; + D(fprintf(stderr, "%*c+ or_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'|'.closed_pattern+")); + _res = _gather_51_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s function_def[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "function_def_raw")); + D(fprintf(stderr, "%*c%s or_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|'.closed_pattern+")); } _res = NULL; done: @@ -4741,231 +4872,156 @@ function_def_rule(Parser *p) return _res; } -// function_def_raw: -// | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block -// | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block -static stmt_ty -function_def_raw_rule(Parser *p) +// closed_pattern: +// | name_pattern +// | literal_pattern +// | constant_pattern +// | group_pattern +// | sequence_pattern +// | mapping_pattern +// | class_pattern +static void * +closed_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - stmt_ty _res = NULL; + void * _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; + { // name_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_pattern")); + void *name_pattern_var; + if ( + (name_pattern_var = name_pattern_rule(p)) // name_pattern + ) + { + D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_pattern")); + _res = name_pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_pattern")); } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block + { // literal_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> function_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block")); - Token * _keyword; - Token * _literal; - Token * _literal_1; - Token * _literal_2; - void *a; - asdl_seq* b; - expr_ty n; - void *params; - void *tc; + D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + void *literal_pattern_var; if ( - (_keyword = _PyPegen_expect_token(p, 522)) // token='def' - && - (n = _PyPegen_name_token(p)) // NAME - && - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (params = params_rule(p), 1) // params? - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' - && - (a = _tmp_50_rule(p), 1) // ['->' expression] - && - (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' - && - (tc = func_type_comment_rule(p), 1) // func_type_comment? - && - (b = block_rule(p)) // block + (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern ) { - D(fprintf(stderr, "%*c+ function_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + _res = literal_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block")); + D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern")); } - { // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block + { // constant_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> function_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block")); - Token * _keyword; - Token * _literal; - Token * _literal_1; - Token * _literal_2; - void *a; - Token * async_var; - asdl_seq* b; - expr_ty n; - void *params; - void *tc; + D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern")); + void *constant_pattern_var; if ( - (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' - && - (_keyword = _PyPegen_expect_token(p, 522)) // token='def' - && - (n = _PyPegen_name_token(p)) // NAME - && - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (params = params_rule(p), 1) // params? - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' - && - (a = _tmp_51_rule(p), 1) // ['->' expression] - && - (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' - && - (tc = func_type_comment_rule(p), 1) // func_type_comment? - && - (b = block_rule(p)) // block + (constant_pattern_var = constant_pattern_rule(p)) // constant_pattern ) { - D(fprintf(stderr, "%*c+ function_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = CHECK_VERSION ( 5 , "Async functions are" , _Py_AsyncFunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "constant_pattern")); + _res = constant_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block")); + D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "constant_pattern")); } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// func_type_comment: -// | NEWLINE TYPE_COMMENT &(NEWLINE INDENT) -// | invalid_double_type_comments -// | TYPE_COMMENT -static Token* -func_type_comment_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + { // group_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group_pattern")); + void *group_pattern_var; + if ( + (group_pattern_var = group_pattern_rule(p)) // group_pattern + ) + { + D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group_pattern")); + _res = group_pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group_pattern")); } - Token* _res = NULL; - int _mark = p->mark; - { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT) + { // sequence_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); - Token * newline_var; - Token * t; + D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sequence_pattern")); + void *sequence_pattern_var; if ( - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' - && - _PyPegen_lookahead(1, _tmp_52_rule, p) + (sequence_pattern_var = sequence_pattern_rule(p)) // sequence_pattern ) { - D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); - _res = t; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sequence_pattern")); + _res = sequence_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); + D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sequence_pattern")); } - { // invalid_double_type_comments + { // mapping_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments")); - void *invalid_double_type_comments_var; + D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "mapping_pattern")); + void *mapping_pattern_var; if ( - (invalid_double_type_comments_var = invalid_double_type_comments_rule(p)) // invalid_double_type_comments + (mapping_pattern_var = mapping_pattern_rule(p)) // mapping_pattern ) { - D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments")); - _res = invalid_double_type_comments_var; + D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "mapping_pattern")); + _res = mapping_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_double_type_comments")); + D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "mapping_pattern")); } - { // TYPE_COMMENT + { // class_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT")); - Token * type_comment_var; + D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "class_pattern")); + void *class_pattern_var; if ( - (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + (class_pattern_var = class_pattern_rule(p)) // class_pattern ) { - D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT")); - _res = type_comment_var; + D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "class_pattern")); + _res = class_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT")); + D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "class_pattern")); } _res = NULL; done: @@ -4973,54 +5029,42 @@ func_type_comment_rule(Parser *p) return _res; } -// params: invalid_parameters | parameters -static arguments_ty -params_rule(Parser *p) +// name_pattern: NAME !('.' | '(') +static void * +name_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - arguments_ty _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // invalid_parameters - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_parameters")); - void *invalid_parameters_var; - if ( - (invalid_parameters_var = invalid_parameters_rule(p)) // invalid_parameters - ) - { - D(fprintf(stderr, "%*c+ params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_parameters")); - _res = invalid_parameters_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s params[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_parameters")); - } - { // parameters + { // NAME !('.' | '(') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "parameters")); - arguments_ty parameters_var; + D(fprintf(stderr, "%*c> name_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME !('.' | '(')")); + expr_ty a; if ( - (parameters_var = parameters_rule(p)) // parameters + (a = _PyPegen_name_token(p)) // NAME + && + _PyPegen_lookahead(0, _tmp_53_rule, p) ) { - D(fprintf(stderr, "%*c+ params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "parameters")); - _res = parameters_var; + D(fprintf(stderr, "%*c+ name_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME !('.' | '(')")); + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s params[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "parameters")); + D(fprintf(stderr, "%*c%s name_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME !('.' | '(')")); } _res = NULL; done: @@ -5028,165 +5072,111 @@ params_rule(Parser *p) return _res; } -// parameters: -// | slash_no_default param_no_default* param_with_default* star_etc? -// | slash_with_default param_with_default* star_etc? -// | param_no_default+ param_with_default* star_etc? -// | param_with_default+ star_etc? -// | star_etc -static arguments_ty -parameters_rule(Parser *p) +// literal_pattern: NUMBER | strings | 'None' | 'True' | 'False' +static void * +literal_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - arguments_ty _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // slash_no_default param_no_default* param_with_default* star_etc? + { // NUMBER if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?")); - asdl_seq* a; - asdl_seq * b; - asdl_seq * c; - void *d; + D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NUMBER")); + expr_ty number_var; if ( - (a = slash_no_default_rule(p)) // slash_no_default - && - (b = _loop0_53_rule(p)) // param_no_default* - && - (c = _loop0_54_rule(p)) // param_with_default* - && - (d = star_etc_rule(p), 1) // star_etc? + (number_var = _PyPegen_number_token(p)) // NUMBER ) { - D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?")); - _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NUMBER")); + _res = number_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?")); + D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER")); } - { // slash_with_default param_with_default* star_etc? + { // strings if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default param_with_default* star_etc?")); - SlashWithDefault* a; - asdl_seq * b; - void *c; + D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "strings")); + expr_ty strings_var; if ( - (a = slash_with_default_rule(p)) // slash_with_default - && - (b = _loop0_55_rule(p)) // param_with_default* - && - (c = star_etc_rule(p), 1) // star_etc? + (strings_var = strings_rule(p)) // strings ) { - D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default param_with_default* star_etc?")); - _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "strings")); + _res = strings_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default param_with_default* star_etc?")); + D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "strings")); } - { // param_no_default+ param_with_default* star_etc? + { // 'None' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ param_with_default* star_etc?")); - asdl_seq * a; - asdl_seq * b; - void *c; + D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); + Token * _keyword; if ( - (a = _loop1_56_rule(p)) // param_no_default+ - && - (b = _loop0_57_rule(p)) // param_with_default* - && - (c = star_etc_rule(p), 1) // star_etc? + (_keyword = _PyPegen_expect_token(p, 522)) // token='None' ) { - D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ param_with_default* star_etc?")); - _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); + _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ param_with_default* star_etc?")); + D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); } - { // param_with_default+ star_etc? + { // 'True' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+ star_etc?")); - asdl_seq * a; - void *b; + D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); + Token * _keyword; if ( - (a = _loop1_58_rule(p)) // param_with_default+ - && - (b = star_etc_rule(p), 1) // star_etc? + (_keyword = _PyPegen_expect_token(p, 523)) // token='True' ) { - D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+ star_etc?")); - _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); + _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+ star_etc?")); + D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); } - { // star_etc + { // 'False' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_etc")); - StarEtc* a; + D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); + Token * _keyword; if ( - (a = star_etc_rule(p)) // star_etc + (_keyword = _PyPegen_expect_token(p, 524)) // token='False' ) { - D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_etc")); - _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); + _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_etc")); + D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); } _res = NULL; done: @@ -5194,64 +5184,100 @@ parameters_rule(Parser *p) return _res; } -// slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')' -static asdl_seq* -slash_no_default_rule(Parser *p) +// constant_pattern: '.' NAME | '.'.NAME+ !'(' +static void * +constant_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - asdl_seq* _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // param_no_default+ '/' ',' + { // '.' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' ','")); + D(fprintf(stderr, "%*c> constant_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.' NAME")); Token * _literal; - Token * _literal_1; - asdl_seq * a; + expr_ty name_var; if ( - (a = _loop1_59_rule(p)) // param_no_default+ - && - (_literal = _PyPegen_expect_token(p, 17)) // token='/' + (_literal = _PyPegen_expect_token(p, 23)) // token='.' && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + (name_var = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' ','")); - _res = a; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); + D(fprintf(stderr, "%*c+ constant_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.' NAME")); + _res = _PyPegen_dummy_name(p, _literal, name_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s constant_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.' NAME")); + } + { // '.'.NAME+ !'(' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> constant_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'.NAME+ !'('")); + asdl_seq * a; + if ( + (a = _gather_54_rule(p)) // '.'.NAME+ + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 7) // token='(' + ) + { + D(fprintf(stderr, "%*c+ constant_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'.NAME+ !'('")); + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); return NULL; } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ '/' ','")); + D(fprintf(stderr, "%*c%s constant_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'.NAME+ !'('")); } - { // param_no_default+ '/' &')' + _res = NULL; + done: + D(p->level--); + return _res; +} + +// group_pattern: '(' pattern ')' +static void * +group_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '(' pattern ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' &')'")); + D(fprintf(stderr, "%*c> group_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' pattern ')'")); Token * _literal; - asdl_seq * a; + Token * _literal_1; + void *a; if ( - (a = _loop1_60_rule(p)) // param_no_default+ + (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_literal = _PyPegen_expect_token(p, 17)) // token='/' + (a = pattern_rule(p)) // pattern && - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' &')'")); + D(fprintf(stderr, "%*c+ group_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' pattern ')'")); _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -5261,8 +5287,8 @@ slash_no_default_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ '/' &')'")); + D(fprintf(stderr, "%*c%s group_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' pattern ')'")); } _res = NULL; done: @@ -5270,41 +5296,54 @@ slash_no_default_rule(Parser *p) return _res; } -// slash_with_default: -// | param_no_default* param_with_default+ '/' ',' -// | param_no_default* param_with_default+ '/' &')' -static SlashWithDefault* -slash_with_default_rule(Parser *p) +// sequence_pattern: '[' ','.pattern+? ']' | '(' ','.pattern+? ')' +static void * +sequence_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - SlashWithDefault* _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // param_no_default* param_with_default+ '/' ',' + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // '[' ','.pattern+? ']' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' ','")); + D(fprintf(stderr, "%*c> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' ','.pattern+? ']'")); Token * _literal; Token * _literal_1; - asdl_seq * a; - asdl_seq * b; + void *a; if ( - (a = _loop0_61_rule(p)) // param_no_default* - && - (b = _loop1_62_rule(p)) // param_with_default+ + (_literal = _PyPegen_expect_token(p, 9)) // token='[' && - (_literal = _PyPegen_expect_token(p, 17)) // token='/' + (a = _gather_56_rule(p), 1) // ','.pattern+? && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' ) { - D(fprintf(stderr, "%*c+ slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' ','")); - _res = _PyPegen_slash_with_default ( p , a , b ); + D(fprintf(stderr, "%*c+ sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' ','.pattern+? ']'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_List ( a , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5313,30 +5352,37 @@ slash_with_default_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* param_with_default+ '/' ','")); + D(fprintf(stderr, "%*c%s sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' ','.pattern+? ']'")); } - { // param_no_default* param_with_default+ '/' &')' + { // '(' ','.pattern+? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' &')'")); + D(fprintf(stderr, "%*c> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' ','.pattern+? ')'")); Token * _literal; - asdl_seq * a; - asdl_seq * b; + Token * _literal_1; + void *a; if ( - (a = _loop0_63_rule(p)) // param_no_default* - && - (b = _loop1_64_rule(p)) // param_with_default+ + (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_literal = _PyPegen_expect_token(p, 17)) // token='/' + (a = _gather_58_rule(p), 1) // ','.pattern+? && - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' &')'")); - _res = _PyPegen_slash_with_default ( p , a , b ); + D(fprintf(stderr, "%*c+ sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' ','.pattern+? ')'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Tuple ( a , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5345,8 +5391,8 @@ slash_with_default_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* param_with_default+ '/' &')'")); + D(fprintf(stderr, "%*c%s sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' ','.pattern+? ')'")); } _res = NULL; done: @@ -5354,43 +5400,36 @@ slash_with_default_rule(Parser *p) return _res; } -// star_etc: -// | '*' param_no_default param_maybe_default* kwds? -// | '*' ',' param_maybe_default+ kwds? -// | kwds -// | invalid_star_etc -static StarEtc* -star_etc_rule(Parser *p) +// mapping_pattern: '{' ','.(key_pattern ':' closed_pattern)+ '}' +static void * +mapping_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - StarEtc* _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // '*' param_no_default param_maybe_default* kwds? + { // '{' ','.(key_pattern ':' closed_pattern)+ '}' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?")); + D(fprintf(stderr, "%*c> mapping_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' ','.(key_pattern ':' closed_pattern)+ '}'")); + asdl_seq * _gather_60_var; Token * _literal; - arg_ty a; - asdl_seq * b; - void *c; + Token * _literal_1; if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (a = param_no_default_rule(p)) // param_no_default + (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (b = _loop0_65_rule(p)) // param_maybe_default* + (_gather_60_var = _gather_60_rule(p)) // ','.(key_pattern ':' closed_pattern)+ && - (c = kwds_rule(p), 1) // kwds? + (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' ) { - D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?")); - _res = _PyPegen_star_etc ( p , a , b , c ); + D(fprintf(stderr, "%*c+ mapping_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' ','.(key_pattern ':' closed_pattern)+ '}'")); + _res = NULL; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5399,31 +5438,41 @@ star_etc_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?")); + D(fprintf(stderr, "%*c%s mapping_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' ','.(key_pattern ':' closed_pattern)+ '}'")); } - { // '*' ',' param_maybe_default+ kwds? + _res = NULL; + done: + D(p->level--); + return _res; +} + +// key_pattern: literal_pattern &':' | '|'.literal_pattern+ +static void * +key_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // literal_pattern &':' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' param_maybe_default+ kwds?")); - Token * _literal; - Token * _literal_1; - asdl_seq * b; - void *c; + D(fprintf(stderr, "%*c> key_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern &':'")); + void *a; if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' - && - (b = _loop1_66_rule(p)) // param_maybe_default+ + (a = literal_pattern_rule(p)) // literal_pattern && - (c = kwds_rule(p), 1) // kwds? + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' ) { - D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' param_maybe_default+ kwds?")); - _res = _PyPegen_star_etc ( p , NULL , b , c ); + D(fprintf(stderr, "%*c+ key_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern &':'")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5432,22 +5481,22 @@ star_etc_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' param_maybe_default+ kwds?")); + D(fprintf(stderr, "%*c%s key_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern &':'")); } - { // kwds + { // '|'.literal_pattern+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwds")); - arg_ty a; + D(fprintf(stderr, "%*c> key_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|'.literal_pattern+")); + asdl_seq * a; if ( - (a = kwds_rule(p)) // kwds + (a = _gather_62_rule(p)) // '|'.literal_pattern+ ) { - D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwds")); - _res = _PyPegen_star_etc ( p , NULL , NULL , a ); + D(fprintf(stderr, "%*c+ key_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'|'.literal_pattern+")); + _res = NULL; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5456,27 +5505,8 @@ star_etc_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwds")); - } - { // invalid_star_etc - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_star_etc")); - void *invalid_star_etc_var; - if ( - (invalid_star_etc_var = invalid_star_etc_rule(p)) // invalid_star_etc - ) - { - D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_star_etc")); - _res = invalid_star_etc_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_star_etc")); + D(fprintf(stderr, "%*c%s key_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|'.literal_pattern+")); } _res = NULL; done: @@ -5484,43 +5514,44 @@ star_etc_rule(Parser *p) return _res; } -// kwds: '**' param_no_default -static arg_ty -kwds_rule(Parser *p) +// class_pattern: '.'.NAME+ '(' pattern_args ')' +static void * +class_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - arg_ty _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // '**' param_no_default + { // '.'.NAME+ '(' pattern_args ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' param_no_default")); + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'.NAME+ '(' pattern_args ')'")); + asdl_seq * _gather_64_var; Token * _literal; - arg_ty a; + Token * _literal_1; + void *pattern_args_var; if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' + (_gather_64_var = _gather_64_rule(p)) // '.'.NAME+ && - (a = param_no_default_rule(p)) // param_no_default + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (pattern_args_var = pattern_args_rule(p)) // pattern_args + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' param_no_default")); - _res = a; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'.NAME+ '(' pattern_args ')'")); + _res = _PyPegen_dummy_name(p, _gather_64_var, _literal, pattern_args_var, _literal_1); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s kwds[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' param_no_default")); + D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'.NAME+ '(' pattern_args ')'")); } _res = NULL; done: @@ -5528,36 +5559,39 @@ kwds_rule(Parser *p) return _res; } -// param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')' -static arg_ty -param_no_default_rule(Parser *p) +// pattern_args: +// | ','.pattern+ ',' ','.(NAME '=' or_pattern)+ +// | ','.(NAME '=' or_pattern)+ +// | ','.pattern+ +static void * +pattern_args_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - arg_ty _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // param ',' TYPE_COMMENT? + { // ','.pattern+ ',' ','.(NAME '=' or_pattern)+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param ',' TYPE_COMMENT?")); + D(fprintf(stderr, "%*c> pattern_args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+ ',' ','.(NAME '=' or_pattern)+")); + asdl_seq * _gather_66_var; + asdl_seq * _gather_68_var; Token * _literal; - arg_ty a; - void *tc; if ( - (a = param_rule(p)) // param + (_gather_66_var = _gather_66_rule(p)) // ','.pattern+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? + (_gather_68_var = _gather_68_rule(p)) // ','.(NAME '=' or_pattern)+ ) { - D(fprintf(stderr, "%*c+ param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param ',' TYPE_COMMENT?")); - _res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); + D(fprintf(stderr, "%*c+ pattern_args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.pattern+ ',' ','.(NAME '=' or_pattern)+")); + _res = NULL; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5566,27 +5600,22 @@ param_no_default_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s param_no_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param ',' TYPE_COMMENT?")); + D(fprintf(stderr, "%*c%s pattern_args[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.pattern+ ',' ','.(NAME '=' or_pattern)+")); } - { // param TYPE_COMMENT? &')' + { // ','.(NAME '=' or_pattern)+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param TYPE_COMMENT? &')'")); - arg_ty a; - void *tc; + D(fprintf(stderr, "%*c> pattern_args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.(NAME '=' or_pattern)+")); + asdl_seq * _gather_70_var; if ( - (a = param_rule(p)) // param - && - (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? - && - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' + (_gather_70_var = _gather_70_rule(p)) // ','.(NAME '=' or_pattern)+ ) { - D(fprintf(stderr, "%*c+ param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param TYPE_COMMENT? &')'")); - _res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); + D(fprintf(stderr, "%*c+ pattern_args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.(NAME '=' or_pattern)+")); + _res = NULL; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5595,80 +5624,22 @@ param_no_default_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s param_no_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param TYPE_COMMENT? &')'")); + D(fprintf(stderr, "%*c%s pattern_args[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.(NAME '=' or_pattern)+")); } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')' -static NameDefaultPair* -param_with_default_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - NameDefaultPair* _res = NULL; - int _mark = p->mark; - { // param default ',' TYPE_COMMENT? - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default ',' TYPE_COMMENT?")); - Token * _literal; - arg_ty a; - expr_ty c; - void *tc; - if ( - (a = param_rule(p)) // param - && - (c = default_rule(p)) // default - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? - ) - { - D(fprintf(stderr, "%*c+ param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default ',' TYPE_COMMENT?")); - _res = _PyPegen_name_default_pair ( p , a , c , tc ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s param_with_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default ',' TYPE_COMMENT?")); - } - { // param default TYPE_COMMENT? &')' + { // ','.pattern+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default TYPE_COMMENT? &')'")); - arg_ty a; - expr_ty c; - void *tc; + D(fprintf(stderr, "%*c> pattern_args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+")); + asdl_seq * a; if ( - (a = param_rule(p)) // param - && - (c = default_rule(p)) // default - && - (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? - && - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' + (a = _gather_72_rule(p)) // ','.pattern+ ) { - D(fprintf(stderr, "%*c+ param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default TYPE_COMMENT? &')'")); - _res = _PyPegen_name_default_pair ( p , a , c , tc ); + D(fprintf(stderr, "%*c+ pattern_args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.pattern+")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5677,8 +5648,8 @@ param_with_default_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s param_with_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default TYPE_COMMENT? &')'")); + D(fprintf(stderr, "%*c%s pattern_args[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.pattern+")); } _res = NULL; done: @@ -5686,73 +5657,51 @@ param_with_default_rule(Parser *p) return _res; } -// param_maybe_default: -// | param default? ',' TYPE_COMMENT? -// | param default? TYPE_COMMENT? &')' -static NameDefaultPair* -param_maybe_default_rule(Parser *p) +// return_stmt: 'return' star_expressions? +static stmt_ty +return_stmt_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - NameDefaultPair* _res = NULL; + stmt_ty _res = NULL; int _mark = p->mark; - { // param default? ',' TYPE_COMMENT? + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // 'return' star_expressions? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default? ',' TYPE_COMMENT?")); - Token * _literal; - arg_ty a; - void *c; - void *tc; + D(fprintf(stderr, "%*c> return_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?")); + Token * _keyword; + void *a; if ( - (a = param_rule(p)) // param - && - (c = default_rule(p), 1) // default? - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (_keyword = _PyPegen_expect_token(p, 500)) // token='return' && - (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? + (a = star_expressions_rule(p), 1) // star_expressions? ) { - D(fprintf(stderr, "%*c+ param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default? ',' TYPE_COMMENT?")); - _res = _PyPegen_name_default_pair ( p , a , c , tc ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; + D(fprintf(stderr, "%*c+ return_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { D(p->level--); return NULL; } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default? ',' TYPE_COMMENT?")); - } - { // param default? TYPE_COMMENT? &')' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default? TYPE_COMMENT? &')'")); - arg_ty a; - void *c; - void *tc; - if ( - (a = param_rule(p)) // param - && - (c = default_rule(p), 1) // default? - && - (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? - && - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' - ) - { - D(fprintf(stderr, "%*c+ param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default? TYPE_COMMENT? &')'")); - _res = _PyPegen_name_default_pair ( p , a , c , tc ); + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Return ( a , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5761,8 +5710,8 @@ param_maybe_default_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default? TYPE_COMMENT? &')'")); + D(fprintf(stderr, "%*c%s return_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'return' star_expressions?")); } _res = NULL; done: @@ -5770,16 +5719,16 @@ param_maybe_default_rule(Parser *p) return _res; } -// param: NAME annotation? -static arg_ty -param_rule(Parser *p) +// raise_stmt: 'raise' expression ['from' expression] | 'raise' +static stmt_ty +raise_stmt_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - arg_ty _res = NULL; + stmt_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -5790,21 +5739,24 @@ param_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME annotation? + { // 'raise' expression ['from' expression] if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME annotation?")); + D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); + Token * _keyword; expr_ty a; void *b; if ( - (a = _PyPegen_name_token(p)) // NAME + (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' && - (b = annotation_rule(p), 1) // annotation? + (a = expression_rule(p)) // expression + && + (b = _tmp_74_rule(p), 1) // ['from' expression] ) { - D(fprintf(stderr, "%*c+ param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME annotation?")); + D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5814,7 +5766,7 @@ param_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA ); + _res = _Py_Raise ( a , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5823,42 +5775,31 @@ param_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s param[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME annotation?")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// annotation: ':' expression -static expr_ty -annotation_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise' expression ['from' expression]")); } - expr_ty _res = NULL; - int _mark = p->mark; - { // ':' expression + { // 'raise' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> annotation[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression")); - Token * _literal; - expr_ty a; + D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise'")); + Token * _keyword; if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (a = expression_rule(p)) // expression + (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' ) { - D(fprintf(stderr, "%*c+ annotation[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression")); - _res = a; + D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Raise ( NULL , NULL , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5867,8 +5808,8 @@ annotation_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s annotation[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression")); + D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise'")); } _res = NULL; done: @@ -5876,33 +5817,33 @@ annotation_rule(Parser *p) return _res; } -// default: '=' expression -static expr_ty -default_rule(Parser *p) +// function_def: decorators function_def_raw | function_def_raw +static stmt_ty +function_def_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + stmt_ty _res = NULL; int _mark = p->mark; - { // '=' expression + { // decorators function_def_raw if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' expression")); - Token * _literal; - expr_ty a; + D(fprintf(stderr, "%*c> function_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "decorators function_def_raw")); + asdl_seq* d; + stmt_ty f; if ( - (_literal = _PyPegen_expect_token(p, 22)) // token='=' + (d = decorators_rule(p)) // decorators && - (a = expression_rule(p)) // expression + (f = function_def_raw_rule(p)) // function_def_raw ) { - D(fprintf(stderr, "%*c+ default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' expression")); - _res = a; + D(fprintf(stderr, "%*c+ function_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "decorators function_def_raw")); + _res = _PyPegen_function_def_decorators ( p , d , f ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5911,49 +5852,27 @@ default_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' expression")); + D(fprintf(stderr, "%*c%s function_def[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "decorators function_def_raw")); } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// decorators: (('@' named_expression NEWLINE))+ -static asdl_seq* -decorators_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - asdl_seq* _res = NULL; - int _mark = p->mark; - { // (('@' named_expression NEWLINE))+ + { // function_def_raw if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> decorators[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); - asdl_seq * a; + D(fprintf(stderr, "%*c> function_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "function_def_raw")); + stmt_ty function_def_raw_var; if ( - (a = _loop1_67_rule(p)) // (('@' named_expression NEWLINE))+ + (function_def_raw_var = function_def_raw_rule(p)) // function_def_raw ) { - D(fprintf(stderr, "%*c+ decorators[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); - _res = a; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ function_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "function_def_raw")); + _res = function_def_raw_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s decorators[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(('@' named_expression NEWLINE))+")); + D(fprintf(stderr, "%*c%s function_def[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "function_def_raw")); } _res = NULL; done: @@ -5961,9 +5880,11 @@ decorators_rule(Parser *p) return _res; } -// class_def: decorators class_def_raw | class_def_raw +// function_def_raw: +// | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block +// | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block static stmt_ty -class_def_rule(Parser *p) +function_def_raw_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -5972,22 +5893,61 @@ class_def_rule(Parser *p) } stmt_ty _res = NULL; int _mark = p->mark; - { // decorators class_def_raw + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "decorators class_def_raw")); - asdl_seq* a; - stmt_ty b; + D(fprintf(stderr, "%*c> function_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block")); + Token * _keyword; + Token * _literal; + Token * _literal_1; + Token * _literal_2; + void *a; + asdl_seq* b; + expr_ty n; + void *params; + void *tc; if ( - (a = decorators_rule(p)) // decorators + (_keyword = _PyPegen_expect_token(p, 525)) // token='def' && - (b = class_def_raw_rule(p)) // class_def_raw + (n = _PyPegen_name_token(p)) // NAME + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (params = params_rule(p), 1) // params? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + && + (a = _tmp_75_rule(p), 1) // ['->' expression] + && + (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' + && + (tc = func_type_comment_rule(p), 1) // func_type_comment? + && + (b = block_rule(p)) // block ) { - D(fprintf(stderr, "%*c+ class_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "decorators class_def_raw")); - _res = _PyPegen_class_def_decorators ( p , a , b ); + D(fprintf(stderr, "%*c+ function_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5996,78 +5956,48 @@ class_def_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s class_def[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "decorators class_def_raw")); - } - { // class_def_raw - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> class_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "class_def_raw")); - stmt_ty class_def_raw_var; - if ( - (class_def_raw_var = class_def_raw_rule(p)) // class_def_raw - ) - { - D(fprintf(stderr, "%*c+ class_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "class_def_raw")); - _res = class_def_raw_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s class_def[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "class_def_raw")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block -static stmt_ty -class_def_raw_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - stmt_ty _res = NULL; - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block")); } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // 'class' NAME ['(' arguments? ')'] ':' block + { // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block")); + D(fprintf(stderr, "%*c> function_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block")); Token * _keyword; Token * _literal; - expr_ty a; - void *b; - asdl_seq* c; + Token * _literal_1; + Token * _literal_2; + void *a; + Token * async_var; + asdl_seq* b; + expr_ty n; + void *params; + void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 523)) // token='class' + (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' && - (a = _PyPegen_name_token(p)) // NAME + (_keyword = _PyPegen_expect_token(p, 525)) // token='def' && - (b = _tmp_68_rule(p), 1) // ['(' arguments? ')'] + (n = _PyPegen_name_token(p)) // NAME && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' + (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (c = block_rule(p)) // block + (params = params_rule(p), 1) // params? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + && + (a = _tmp_76_rule(p), 1) // ['->' expression] + && + (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' + && + (tc = func_type_comment_rule(p), 1) // func_type_comment? + && + (b = block_rule(p)) // block ) { - D(fprintf(stderr, "%*c+ class_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block")); + D(fprintf(stderr, "%*c+ function_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -6077,7 +6007,7 @@ class_def_raw_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_ClassDef ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , c , NULL , EXTRA ); + _res = CHECK_VERSION ( 5 , "Async functions are" , _Py_AsyncFunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6086,8 +6016,8 @@ class_def_raw_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s class_def_raw[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block")); + D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block")); } _res = NULL; done: @@ -6095,43 +6025,38 @@ class_def_raw_rule(Parser *p) return _res; } -// block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block -static asdl_seq* -block_rule(Parser *p) +// func_type_comment: +// | NEWLINE TYPE_COMMENT &(NEWLINE INDENT) +// | invalid_double_type_comments +// | TYPE_COMMENT +static Token* +func_type_comment_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - asdl_seq* _res = NULL; - if (_PyPegen_is_memoized(p, block_type, &_res)) { - D(p->level--); - return _res; - } + Token* _res = NULL; int _mark = p->mark; - { // NEWLINE INDENT statements DEDENT + { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT statements DEDENT")); - asdl_seq* a; - Token * dedent_var; - Token * indent_var; + D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); Token * newline_var; + Token * t; if ( (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' && - (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' - && - (a = statements_rule(p)) // statements + (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' && - (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' + _PyPegen_lookahead(1, _tmp_77_rule, p) ) { - D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT statements DEDENT")); - _res = a; + D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); + _res = t; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6140,92 +6065,101 @@ block_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT statements DEDENT")); + D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); } - { // simple_stmt + { // invalid_double_type_comments if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt")); - asdl_seq* simple_stmt_var; + D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments")); + void *invalid_double_type_comments_var; if ( - (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt + (invalid_double_type_comments_var = invalid_double_type_comments_rule(p)) // invalid_double_type_comments ) { - D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt")); - _res = simple_stmt_var; + D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments")); + _res = invalid_double_type_comments_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt")); + D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_double_type_comments")); } - { // invalid_block + { // TYPE_COMMENT if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_block")); - void *invalid_block_var; + D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT")); + Token * type_comment_var; if ( - (invalid_block_var = invalid_block_rule(p)) // invalid_block + (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' ) { - D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_block")); - _res = invalid_block_var; + D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT")); + _res = type_comment_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_block")); + D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT")); } _res = NULL; done: - _PyPegen_insert_memo(p, _mark, block_type, _res); D(p->level--); return _res; } -// expressions_list: ','.star_expression+ ','? -static asdl_seq* -expressions_list_rule(Parser *p) +// params: invalid_parameters | parameters +static arguments_ty +params_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - asdl_seq* _res = NULL; + arguments_ty _res = NULL; int _mark = p->mark; - { // ','.star_expression+ ','? + { // invalid_parameters if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> expressions_list[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_expression+ ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - asdl_seq * a; - if ( - (a = _gather_69_rule(p)) // ','.star_expression+ - && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + D(fprintf(stderr, "%*c> params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_parameters")); + void *invalid_parameters_var; + if ( + (invalid_parameters_var = invalid_parameters_rule(p)) // invalid_parameters ) { - D(fprintf(stderr, "%*c+ expressions_list[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_expression+ ','?")); - _res = a; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_parameters")); + _res = invalid_parameters_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s expressions_list[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_expression+ ','?")); + D(fprintf(stderr, "%*c%s params[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_parameters")); + } + { // parameters + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "parameters")); + arguments_ty parameters_var; + if ( + (parameters_var = parameters_rule(p)) // parameters + ) + { + D(fprintf(stderr, "%*c+ params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "parameters")); + _res = parameters_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s params[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "parameters")); } _res = NULL; done: @@ -6233,58 +6167,44 @@ expressions_list_rule(Parser *p) return _res; } -// star_expressions: -// | star_expression ((',' star_expression))+ ','? -// | star_expression ',' -// | star_expression -static expr_ty -star_expressions_rule(Parser *p) +// parameters: +// | slash_no_default param_no_default* param_with_default* star_etc? +// | slash_with_default param_with_default* star_etc? +// | param_no_default+ param_with_default* star_etc? +// | param_with_default+ star_etc? +// | star_etc +static arguments_ty +parameters_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + arguments_ty _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // star_expression ((',' star_expression))+ ','? + { // slash_no_default param_no_default* param_with_default* star_etc? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression ((',' star_expression))+ ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty a; + D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?")); + asdl_seq* a; asdl_seq * b; + asdl_seq * c; + void *d; if ( - (a = star_expression_rule(p)) // star_expression + (a = slash_no_default_rule(p)) // slash_no_default && - (b = _loop1_71_rule(p)) // ((',' star_expression))+ + (b = _loop0_78_rule(p)) // param_no_default* && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + (c = _loop0_79_rule(p)) // param_with_default* + && + (d = star_etc_rule(p), 1) // star_etc? ) { - D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression ((',' star_expression))+ ','?")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); + D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?")); + _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6293,34 +6213,28 @@ star_expressions_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression ((',' star_expression))+ ','?")); + D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?")); } - { // star_expression ',' + { // slash_with_default param_with_default* star_etc? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression ','")); - Token * _literal; - expr_ty a; + D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default param_with_default* star_etc?")); + SlashWithDefault* a; + asdl_seq * b; + void *c; if ( - (a = star_expression_rule(p)) // star_expression + (a = slash_with_default_rule(p)) // slash_with_default && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (b = _loop0_80_rule(p)) // param_with_default* + && + (c = star_etc_rule(p), 1) // star_etc? ) { - D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression ','")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); + D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default param_with_default* star_etc?")); + _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6329,83 +6243,55 @@ star_expressions_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression ','")); + D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default param_with_default* star_etc?")); } - { // star_expression + { // param_no_default+ param_with_default* star_etc? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression")); - expr_ty star_expression_var; + D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ param_with_default* star_etc?")); + asdl_seq * a; + asdl_seq * b; + void *c; if ( - (star_expression_var = star_expression_rule(p)) // star_expression + (a = _loop1_81_rule(p)) // param_no_default+ + && + (b = _loop0_82_rule(p)) // param_with_default* + && + (c = star_etc_rule(p), 1) // star_etc? ) { - D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression")); - _res = star_expression_var; + D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ param_with_default* star_etc?")); + _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , 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 star_expressions[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// star_expression: '*' bitwise_or | expression -static expr_ty -star_expression_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, star_expression_type, &_res)) { - D(p->level--); - return _res; - } - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ param_with_default* star_etc?")); } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '*' bitwise_or + { // param_with_default+ star_etc? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); - Token * _literal; - expr_ty a; + D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+ star_etc?")); + asdl_seq * a; + void *b; if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' + (a = _loop1_83_rule(p)) // param_with_default+ && - (a = bitwise_or_rule(p)) // bitwise_or + (b = star_etc_rule(p), 1) // star_etc? ) { - D(fprintf(stderr, "%*c+ star_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Starred ( a , Load , EXTRA ); + D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+ star_etc?")); + _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6414,38 +6300,42 @@ star_expression_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' bitwise_or")); + D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+ star_etc?")); } - { // expression + { // star_etc if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression")); - expr_ty expression_var; + D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_etc")); + StarEtc* a; if ( - (expression_var = expression_rule(p)) // expression + (a = star_etc_rule(p)) // star_etc ) { - D(fprintf(stderr, "%*c+ star_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression")); - _res = expression_var; + D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_etc")); + _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression")); + D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_etc")); } _res = NULL; done: - _PyPegen_insert_memo(p, _mark, star_expression_type, _res); D(p->level--); return _res; } -// star_named_expressions: ','.star_named_expression+ ','? +// slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')' static asdl_seq* -star_named_expressions_rule(Parser *p) +slash_no_default_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -6454,22 +6344,24 @@ star_named_expressions_rule(Parser *p) } asdl_seq* _res = NULL; int _mark = p->mark; - { // ','.star_named_expression+ ','? + { // param_no_default+ '/' ',' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_named_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_named_expression+ ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings + D(fprintf(stderr, "%*c> slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' ','")); + Token * _literal; + Token * _literal_1; asdl_seq * a; if ( - (a = _gather_72_rule(p)) // ','.star_named_expression+ + (a = _loop1_84_rule(p)) // param_no_default+ && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + (_literal = _PyPegen_expect_token(p, 17)) // token='/' + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ star_named_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_named_expression+ ','?")); + D(fprintf(stderr, "%*c+ slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' ','")); _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -6479,60 +6371,79 @@ star_named_expressions_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_named_expressions[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_named_expression+ ','?")); + D(fprintf(stderr, "%*c%s slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ '/' ','")); } - _res = NULL; - done: - D(p->level--); + { // param_no_default+ '/' &')' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' &')'")); + Token * _literal; + asdl_seq * a; + if ( + (a = _loop1_85_rule(p)) // param_no_default+ + && + (_literal = _PyPegen_expect_token(p, 17)) // token='/' + && + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' + ) + { + D(fprintf(stderr, "%*c+ slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' &')'")); + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ '/' &')'")); + } + _res = NULL; + done: + D(p->level--); return _res; } -// star_named_expression: '*' bitwise_or | named_expression -static expr_ty -star_named_expression_rule(Parser *p) +// slash_with_default: +// | param_no_default* param_with_default+ '/' ',' +// | param_no_default* param_with_default+ '/' &')' +static SlashWithDefault* +slash_with_default_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + SlashWithDefault* _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '*' bitwise_or + { // param_no_default* param_with_default+ '/' ',' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); + D(fprintf(stderr, "%*c> slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' ','")); Token * _literal; - expr_ty a; + Token * _literal_1; + asdl_seq * a; + asdl_seq * b; if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' + (a = _loop0_86_rule(p)) // param_no_default* && - (a = bitwise_or_rule(p)) // bitwise_or + (b = _loop1_87_rule(p)) // param_with_default+ + && + (_literal = _PyPegen_expect_token(p, 17)) // token='/' + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ star_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Starred ( a , Load , EXTRA ); + D(fprintf(stderr, "%*c+ slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' ','")); + _res = _PyPegen_slash_with_default ( p , a , b ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6541,27 +6452,40 @@ star_named_expression_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_named_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' bitwise_or")); + D(fprintf(stderr, "%*c%s slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* param_with_default+ '/' ','")); } - { // named_expression + { // param_no_default* param_with_default+ '/' &')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); - expr_ty named_expression_var; + D(fprintf(stderr, "%*c> slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' &')'")); + Token * _literal; + asdl_seq * a; + asdl_seq * b; if ( - (named_expression_var = named_expression_rule(p)) // named_expression + (a = _loop0_88_rule(p)) // param_no_default* + && + (b = _loop1_89_rule(p)) // param_with_default+ + && + (_literal = _PyPegen_expect_token(p, 17)) // token='/' + && + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' ) { - D(fprintf(stderr, "%*c+ star_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); - _res = named_expression_var; + D(fprintf(stderr, "%*c+ slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' &')'")); + _res = _PyPegen_slash_with_default ( p , a , b ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_named_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c%s slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* param_with_default+ '/' &')'")); } _res = NULL; done: @@ -6569,54 +6493,76 @@ star_named_expression_rule(Parser *p) return _res; } -// named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression -static expr_ty -named_expression_rule(Parser *p) +// star_etc: +// | '*' param_no_default param_maybe_default* kwds? +// | '*' ',' param_maybe_default+ kwds? +// | kwds +// | invalid_star_etc +static StarEtc* +star_etc_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + StarEtc* _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME ':=' expression + { // '*' param_no_default param_maybe_default* kwds? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':=' expression")); + D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?")); Token * _literal; - expr_ty a; - expr_ty b; + arg_ty a; + asdl_seq * b; + void *c; if ( - (a = _PyPegen_name_token(p)) // NAME + (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_literal = _PyPegen_expect_token(p, 53)) // token=':=' + (a = param_no_default_rule(p)) // param_no_default && - (b = expression_rule(p)) // expression + (b = _loop0_90_rule(p)) // param_maybe_default* + && + (c = kwds_rule(p), 1) // kwds? ) { - D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ':=' expression")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { + D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?")); + _res = _PyPegen_star_etc ( p , a , b , c ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; D(p->level--); return NULL; } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA ); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?")); + } + { // '*' ',' param_maybe_default+ kwds? + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' param_maybe_default+ kwds?")); + Token * _literal; + Token * _literal_1; + asdl_seq * b; + void *c; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + && + (b = _loop1_91_rule(p)) // param_maybe_default+ + && + (c = kwds_rule(p), 1) // kwds? + ) + { + D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' param_maybe_default+ kwds?")); + _res = _PyPegen_star_etc ( p , NULL , b , c ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6625,48 +6571,51 @@ named_expression_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':=' expression")); + D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' param_maybe_default+ kwds?")); } - { // expression !':=' + { // kwds if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); - expr_ty expression_var; + D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwds")); + arg_ty a; if ( - (expression_var = expression_rule(p)) // expression - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' + (a = kwds_rule(p)) // kwds ) { - D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); - _res = expression_var; + D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwds")); + _res = _PyPegen_star_etc ( p , NULL , NULL , a ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); + D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwds")); } - { // invalid_named_expression + { // invalid_star_etc if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_named_expression")); - void *invalid_named_expression_var; + D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_star_etc")); + void *invalid_star_etc_var; if ( - (invalid_named_expression_var = invalid_named_expression_rule(p)) // invalid_named_expression + (invalid_star_etc_var = invalid_star_etc_rule(p)) // invalid_star_etc ) { - D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_named_expression")); - _res = invalid_named_expression_var; + D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_star_etc")); + _res = invalid_star_etc_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_named_expression")); + D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_star_etc")); } _res = NULL; done: @@ -6674,54 +6623,43 @@ named_expression_rule(Parser *p) return _res; } -// annotated_rhs: yield_expr | star_expressions -static expr_ty -annotated_rhs_rule(Parser *p) +// kwds: '**' param_no_default +static arg_ty +kwds_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + arg_ty _res = NULL; int _mark = p->mark; - { // yield_expr + { // '**' param_no_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> annotated_rhs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); - expr_ty yield_expr_var; + D(fprintf(stderr, "%*c> kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' param_no_default")); + Token * _literal; + arg_ty a; if ( - (yield_expr_var = yield_expr_rule(p)) // yield_expr + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + && + (a = param_no_default_rule(p)) // param_no_default ) { - D(fprintf(stderr, "%*c+ annotated_rhs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); - _res = yield_expr_var; + D(fprintf(stderr, "%*c+ kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' param_no_default")); + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s annotated_rhs[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); - } - { // star_expressions - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> annotated_rhs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); - expr_ty star_expressions_var; - if ( - (star_expressions_var = star_expressions_rule(p)) // star_expressions - ) - { - D(fprintf(stderr, "%*c+ annotated_rhs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); - _res = star_expressions_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s annotated_rhs[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c%s kwds[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' param_no_default")); } _res = NULL; done: @@ -6729,55 +6667,36 @@ annotated_rhs_rule(Parser *p) return _res; } -// expressions: expression ((',' expression))+ ','? | expression ',' | expression -static expr_ty -expressions_rule(Parser *p) +// param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')' +static arg_ty +param_no_default_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + arg_ty _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // expression ((',' expression))+ ','? + { // param ',' TYPE_COMMENT? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ((',' expression))+ ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty a; - asdl_seq * b; + D(fprintf(stderr, "%*c> param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param ',' TYPE_COMMENT?")); + Token * _literal; + arg_ty a; + void *tc; if ( - (a = expression_rule(p)) // expression + (a = param_rule(p)) // param && - (b = _loop1_74_rule(p)) // ((',' expression))+ + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? ) { - D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ((',' expression))+ ','?")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); + D(fprintf(stderr, "%*c+ param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param ',' TYPE_COMMENT?")); + _res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6786,34 +6705,27 @@ expressions_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ((',' expression))+ ','?")); + D(fprintf(stderr, "%*c%s param_no_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param ',' TYPE_COMMENT?")); } - { // expression ',' + { // param TYPE_COMMENT? &')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ','")); - Token * _literal; - expr_ty a; + D(fprintf(stderr, "%*c> param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param TYPE_COMMENT? &')'")); + arg_ty a; + void *tc; if ( - (a = expression_rule(p)) // expression + (a = param_rule(p)) // param && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? + && + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' ) { - D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ','")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); + D(fprintf(stderr, "%*c+ param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param TYPE_COMMENT? &')'")); + _res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6822,27 +6734,8 @@ expressions_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ','")); - } - { // expression - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression")); - expr_ty expression_var; - if ( - (expression_var = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression")); - _res = expression_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression")); + D(fprintf(stderr, "%*c%s param_no_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param TYPE_COMMENT? &')'")); } _res = NULL; done: @@ -6850,64 +6743,39 @@ expressions_rule(Parser *p) return _res; } -// expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef -static expr_ty -expression_rule(Parser *p) +// param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')' +static NameDefaultPair* +param_with_default_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, expression_type, &_res)) { - D(p->level--); - return _res; - } + NameDefaultPair* _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // disjunction 'if' disjunction 'else' expression + { // param default ',' TYPE_COMMENT? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); - Token * _keyword; - Token * _keyword_1; - expr_ty a; - expr_ty b; + D(fprintf(stderr, "%*c> param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default ',' TYPE_COMMENT?")); + Token * _literal; + arg_ty a; expr_ty c; + void *tc; if ( - (a = disjunction_rule(p)) // disjunction - && - (_keyword = _PyPegen_expect_token(p, 510)) // token='if' + (a = param_rule(p)) // param && - (b = disjunction_rule(p)) // disjunction + (c = default_rule(p)) // default && - (_keyword_1 = _PyPegen_expect_token(p, 516)) // token='else' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (c = expression_rule(p)) // expression + (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? ) { - D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_IfExp ( b , a , c , EXTRA ); + D(fprintf(stderr, "%*c+ param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default ',' TYPE_COMMENT?")); + _res = _PyPegen_name_default_pair ( p , a , c , tc ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6916,105 +6784,82 @@ expression_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); - } - { // disjunction - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction")); - expr_ty disjunction_var; - if ( - (disjunction_var = disjunction_rule(p)) // disjunction - ) - { - D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction")); - _res = disjunction_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction")); + D(fprintf(stderr, "%*c%s param_with_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default ',' TYPE_COMMENT?")); } - { // lambdef + { // param default TYPE_COMMENT? &')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambdef")); - expr_ty lambdef_var; + D(fprintf(stderr, "%*c> param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default TYPE_COMMENT? &')'")); + arg_ty a; + expr_ty c; + void *tc; if ( - (lambdef_var = lambdef_rule(p)) // lambdef + (a = param_rule(p)) // param + && + (c = default_rule(p)) // default + && + (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? + && + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' ) { - D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambdef")); - _res = lambdef_var; + D(fprintf(stderr, "%*c+ param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default TYPE_COMMENT? &')'")); + _res = _PyPegen_name_default_pair ( p , a , c , tc ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambdef")); + D(fprintf(stderr, "%*c%s param_with_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default TYPE_COMMENT? &')'")); } _res = NULL; done: - _PyPegen_insert_memo(p, _mark, expression_type, _res); D(p->level--); return _res; } -// lambdef: 'lambda' lambda_parameters? ':' expression -static expr_ty -lambdef_rule(Parser *p) +// param_maybe_default: +// | param default? ',' TYPE_COMMENT? +// | param default? TYPE_COMMENT? &')' +static NameDefaultPair* +param_maybe_default_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + NameDefaultPair* _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // 'lambda' lambda_parameters? ':' expression + { // param default? ',' TYPE_COMMENT? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambdef[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_parameters? ':' expression")); - Token * _keyword; + D(fprintf(stderr, "%*c> param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default? ',' TYPE_COMMENT?")); Token * _literal; - void *a; - expr_ty b; + arg_ty a; + void *c; + void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 524)) // token='lambda' + (a = param_rule(p)) // param && - (a = lambda_parameters_rule(p), 1) // lambda_parameters? + (c = default_rule(p), 1) // default? && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (b = expression_rule(p)) // expression + (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? ) { - D(fprintf(stderr, "%*c+ lambdef[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_parameters? ':' expression")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA ); + D(fprintf(stderr, "%*c+ param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default? ',' TYPE_COMMENT?")); + _res = _PyPegen_name_default_pair ( p , a , c , tc ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -7023,53 +6868,30 @@ lambdef_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambdef[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'lambda' lambda_parameters? ':' expression")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// lambda_parameters: -// | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? -// | lambda_slash_with_default lambda_param_with_default* lambda_star_etc? -// | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? -// | lambda_param_with_default+ lambda_star_etc? -// | lambda_star_etc -static arguments_ty -lambda_parameters_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default? ',' TYPE_COMMENT?")); } - arguments_ty _res = NULL; - int _mark = p->mark; - { // lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? + { // param default? TYPE_COMMENT? &')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?")); - asdl_seq* a; - asdl_seq * b; - asdl_seq * c; - void *d; + D(fprintf(stderr, "%*c> param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default? TYPE_COMMENT? &')'")); + arg_ty a; + void *c; + void *tc; if ( - (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default + (a = param_rule(p)) // param && - (b = _loop0_75_rule(p)) // lambda_param_no_default* + (c = default_rule(p), 1) // default? && - (c = _loop0_76_rule(p)) // lambda_param_with_default* + (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? && - (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' ) { - D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?")); - _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); + D(fprintf(stderr, "%*c+ param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default? TYPE_COMMENT? &')'")); + _res = _PyPegen_name_default_pair ( p , a , c , tc ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -7078,58 +6900,60 @@ lambda_parameters_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?")); + D(fprintf(stderr, "%*c%s param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default? TYPE_COMMENT? &')'")); } - { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc? + _res = NULL; + done: + D(p->level--); + return _res; +} + +// param: NAME annotation? +static arg_ty +param_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + arg_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // NAME annotation? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?")); - SlashWithDefault* a; - asdl_seq * b; - void *c; + D(fprintf(stderr, "%*c> param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME annotation?")); + expr_ty a; + void *b; if ( - (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default - && - (b = _loop0_77_rule(p)) // lambda_param_with_default* + (a = _PyPegen_name_token(p)) // NAME && - (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? + (b = annotation_rule(p), 1) // annotation? ) { - D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?")); - _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; + D(fprintf(stderr, "%*c+ param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME annotation?")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { D(p->level--); return NULL; } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?")); - } - { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?")); - asdl_seq * a; - asdl_seq * b; - void *c; - if ( - (a = _loop1_78_rule(p)) // lambda_param_no_default+ - && - (b = _loop0_79_rule(p)) // lambda_param_with_default* - && - (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? - ) - { - D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?")); - _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -7138,25 +6962,42 @@ lambda_parameters_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?")); + D(fprintf(stderr, "%*c%s param[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME annotation?")); } - { // lambda_param_with_default+ lambda_star_etc? + _res = NULL; + done: + D(p->level--); + return _res; +} + +// annotation: ':' expression +static expr_ty +annotation_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + { // ':' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?")); - asdl_seq * a; - void *b; + D(fprintf(stderr, "%*c> annotation[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression")); + Token * _literal; + expr_ty a; if ( - (a = _loop1_80_rule(p)) // lambda_param_with_default+ + (_literal = _PyPegen_expect_token(p, 11)) // token=':' && - (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? + (a = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?")); - _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); + D(fprintf(stderr, "%*c+ annotation[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -7165,22 +7006,42 @@ lambda_parameters_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?")); + D(fprintf(stderr, "%*c%s annotation[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression")); } - { // lambda_star_etc + _res = NULL; + done: + D(p->level--); + return _res; +} + +// default: '=' expression +static expr_ty +default_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + { // '=' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_star_etc")); - StarEtc* a; + D(fprintf(stderr, "%*c> default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' expression")); + Token * _literal; + expr_ty a; if ( - (a = lambda_star_etc_rule(p)) // lambda_star_etc + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + && + (a = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_star_etc")); - _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); + D(fprintf(stderr, "%*c+ default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' expression")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -7189,8 +7050,8 @@ lambda_parameters_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_star_etc")); + D(fprintf(stderr, "%*c%s default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' expression")); } _res = NULL; done: @@ -7198,11 +7059,9 @@ lambda_parameters_rule(Parser *p) return _res; } -// lambda_slash_no_default: -// | lambda_param_no_default+ '/' ',' -// | lambda_param_no_default+ '/' &':' +// decorators: (('@' named_expression NEWLINE))+ static asdl_seq* -lambda_slash_no_default_rule(Parser *p) +decorators_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -7211,24 +7070,18 @@ lambda_slash_no_default_rule(Parser *p) } asdl_seq* _res = NULL; int _mark = p->mark; - { // lambda_param_no_default+ '/' ',' + { // (('@' named_expression NEWLINE))+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' ','")); - Token * _literal; - Token * _literal_1; + D(fprintf(stderr, "%*c> decorators[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); asdl_seq * a; if ( - (a = _loop1_81_rule(p)) // lambda_param_no_default+ - && - (_literal = _PyPegen_expect_token(p, 17)) // token='/' - && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + (a = _loop1_92_rule(p)) // (('@' named_expression NEWLINE))+ ) { - D(fprintf(stderr, "%*c+ lambda_slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' ','")); + D(fprintf(stderr, "%*c+ decorators[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -7238,37 +7091,8 @@ lambda_slash_no_default_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ '/' ','")); - } - { // lambda_param_no_default+ '/' &':' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> lambda_slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' &':'")); - Token * _literal; - asdl_seq * a; - if ( - (a = _loop1_82_rule(p)) // lambda_param_no_default+ - && - (_literal = _PyPegen_expect_token(p, 17)) // token='/' - && - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' - ) - { - D(fprintf(stderr, "%*c+ lambda_slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' &':'")); - _res = a; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ '/' &':'")); + D(fprintf(stderr, "%*c%s decorators[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(('@' named_expression NEWLINE))+")); } _res = NULL; done: @@ -7276,41 +7100,33 @@ lambda_slash_no_default_rule(Parser *p) return _res; } -// lambda_slash_with_default: -// | lambda_param_no_default* lambda_param_with_default+ '/' ',' -// | lambda_param_no_default* lambda_param_with_default+ '/' &':' -static SlashWithDefault* -lambda_slash_with_default_rule(Parser *p) +// class_def: decorators class_def_raw | class_def_raw +static stmt_ty +class_def_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - SlashWithDefault* _res = NULL; + stmt_ty _res = NULL; int _mark = p->mark; - { // lambda_param_no_default* lambda_param_with_default+ '/' ',' + { // decorators class_def_raw if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','")); - Token * _literal; - Token * _literal_1; - asdl_seq * a; - asdl_seq * b; + D(fprintf(stderr, "%*c> class_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "decorators class_def_raw")); + asdl_seq* a; + stmt_ty b; if ( - (a = _loop0_83_rule(p)) // lambda_param_no_default* - && - (b = _loop1_84_rule(p)) // lambda_param_with_default+ - && - (_literal = _PyPegen_expect_token(p, 17)) // token='/' + (a = decorators_rule(p)) // decorators && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + (b = class_def_raw_rule(p)) // class_def_raw ) { - D(fprintf(stderr, "%*c+ lambda_slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','")); - _res = _PyPegen_slash_with_default ( p , a , b ); + D(fprintf(stderr, "%*c+ class_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "decorators class_def_raw")); + _res = _PyPegen_class_def_decorators ( p , a , b ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -7319,40 +7135,27 @@ lambda_slash_with_default_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','")); + D(fprintf(stderr, "%*c%s class_def[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "decorators class_def_raw")); } - { // lambda_param_no_default* lambda_param_with_default+ '/' &':' + { // class_def_raw if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'")); - Token * _literal; - asdl_seq * a; - asdl_seq * b; + D(fprintf(stderr, "%*c> class_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "class_def_raw")); + stmt_ty class_def_raw_var; if ( - (a = _loop0_85_rule(p)) // lambda_param_no_default* - && - (b = _loop1_86_rule(p)) // lambda_param_with_default+ - && - (_literal = _PyPegen_expect_token(p, 17)) // token='/' - && - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' + (class_def_raw_var = class_def_raw_rule(p)) // class_def_raw ) { - D(fprintf(stderr, "%*c+ lambda_slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'")); - _res = _PyPegen_slash_with_default ( p , a , b ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ class_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "class_def_raw")); + _res = class_def_raw_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'")); + D(fprintf(stderr, "%*c%s class_def[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "class_def_raw")); } _res = NULL; done: @@ -7360,43 +7163,60 @@ lambda_slash_with_default_rule(Parser *p) return _res; } -// lambda_star_etc: -// | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? -// | '*' ',' lambda_param_maybe_default+ lambda_kwds? -// | lambda_kwds -// | invalid_lambda_star_etc -static StarEtc* -lambda_star_etc_rule(Parser *p) +// class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block +static stmt_ty +class_def_raw_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - StarEtc* _res = NULL; + stmt_ty _res = NULL; int _mark = p->mark; - { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // 'class' NAME ['(' arguments? ')'] ':' block if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?")); + D(fprintf(stderr, "%*c> class_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block")); + Token * _keyword; Token * _literal; - arg_ty a; - asdl_seq * b; - void *c; + expr_ty a; + void *b; + asdl_seq* c; if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' + (_keyword = _PyPegen_expect_token(p, 526)) // token='class' && - (a = lambda_param_no_default_rule(p)) // lambda_param_no_default + (a = _PyPegen_name_token(p)) // NAME && - (b = _loop0_87_rule(p)) // lambda_param_maybe_default* + (b = _tmp_93_rule(p), 1) // ['(' arguments? ')'] && - (c = lambda_kwds_rule(p), 1) // lambda_kwds? + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (c = block_rule(p)) // block ) { - D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?")); - _res = _PyPegen_star_etc ( p , a , b , c ); + D(fprintf(stderr, "%*c+ class_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_ClassDef ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , c , NULL , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -7405,31 +7225,52 @@ lambda_star_etc_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?")); + D(fprintf(stderr, "%*c%s class_def_raw[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block")); } - { // '*' ',' lambda_param_maybe_default+ lambda_kwds? + _res = NULL; + done: + D(p->level--); + return _res; +} + +// block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block +static asdl_seq* +block_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq* _res = NULL; + if (_PyPegen_is_memoized(p, block_type, &_res)) { + D(p->level--); + return _res; + } + int _mark = p->mark; + { // NEWLINE INDENT statements DEDENT if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?")); - Token * _literal; - Token * _literal_1; - asdl_seq * b; - void *c; + D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT statements DEDENT")); + asdl_seq* a; + Token * dedent_var; + Token * indent_var; + Token * newline_var; if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' && - (b = _loop1_88_rule(p)) // lambda_param_maybe_default+ + (a = statements_rule(p)) // statements && - (c = lambda_kwds_rule(p), 1) // lambda_kwds? + (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' ) { - D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?")); - _res = _PyPegen_star_etc ( p , NULL , b , c ); + D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT statements DEDENT")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -7438,84 +7279,81 @@ lambda_star_etc_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?")); + D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT statements DEDENT")); } - { // lambda_kwds + { // simple_stmt if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_kwds")); - arg_ty a; + D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt")); + asdl_seq* simple_stmt_var; if ( - (a = lambda_kwds_rule(p)) // lambda_kwds + (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt ) { - D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_kwds")); - _res = _PyPegen_star_etc ( p , NULL , NULL , a ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt")); + _res = simple_stmt_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_kwds")); + D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt")); } - { // invalid_lambda_star_etc + { // invalid_block if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_lambda_star_etc")); - void *invalid_lambda_star_etc_var; + D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_block")); + void *invalid_block_var; if ( - (invalid_lambda_star_etc_var = invalid_lambda_star_etc_rule(p)) // invalid_lambda_star_etc + (invalid_block_var = invalid_block_rule(p)) // invalid_block ) { - D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_lambda_star_etc")); - _res = invalid_lambda_star_etc_var; + D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_block")); + _res = invalid_block_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_lambda_star_etc")); + D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_block")); } _res = NULL; done: + _PyPegen_insert_memo(p, _mark, block_type, _res); D(p->level--); return _res; } -// lambda_kwds: '**' lambda_param_no_default -static arg_ty -lambda_kwds_rule(Parser *p) +// expressions_list: ','.star_expression+ ','? +static asdl_seq* +expressions_list_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - arg_ty _res = NULL; + asdl_seq* _res = NULL; int _mark = p->mark; - { // '**' lambda_param_no_default + { // ','.star_expression+ ','? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' lambda_param_no_default")); - Token * _literal; - arg_ty a; + D(fprintf(stderr, "%*c> expressions_list[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_expression+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_seq * a; if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' + (a = _gather_94_rule(p)) // ','.star_expression+ && - (a = lambda_param_no_default_rule(p)) // lambda_param_no_default + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) { - D(fprintf(stderr, "%*c+ lambda_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' lambda_param_no_default")); + D(fprintf(stderr, "%*c+ expressions_list[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_expression+ ','?")); _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -7525,8 +7363,8 @@ lambda_kwds_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_kwds[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' lambda_param_no_default")); + D(fprintf(stderr, "%*c%s expressions_list[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_expression+ ','?")); } _res = NULL; done: @@ -7534,33 +7372,58 @@ lambda_kwds_rule(Parser *p) return _res; } -// lambda_param_no_default: lambda_param ',' | lambda_param &':' -static arg_ty -lambda_param_no_default_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; +// star_expressions: +// | star_expression ((',' star_expression))+ ','? +// | star_expression ',' +// | star_expression +static expr_ty +star_expressions_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; } - arg_ty _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; - { // lambda_param ',' + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // star_expression ((',' star_expression))+ ','? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param ','")); - Token * _literal; - arg_ty a; + D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression ((',' star_expression))+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty a; + asdl_seq * b; if ( - (a = lambda_param_rule(p)) // lambda_param + (a = star_expression_rule(p)) // star_expression && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (b = _loop1_96_rule(p)) // ((',' star_expression))+ + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) { - D(fprintf(stderr, "%*c+ lambda_param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param ','")); - _res = a; + D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression ((',' star_expression))+ ','?")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -7569,24 +7432,34 @@ lambda_param_no_default_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_param_no_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param ','")); + D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression ((',' star_expression))+ ','?")); } - { // lambda_param &':' + { // star_expression ',' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param &':'")); - arg_ty a; + D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression ','")); + Token * _literal; + expr_ty a; if ( - (a = lambda_param_rule(p)) // lambda_param + (a = star_expression_rule(p)) // star_expression && - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ lambda_param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param &':'")); - _res = a; + D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression ','")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -7595,8 +7468,27 @@ lambda_param_no_default_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_param_no_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param &':'")); + D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression ','")); + } + { // star_expression + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression")); + expr_ty star_expression_var; + if ( + (star_expression_var = star_expression_rule(p)) // star_expression + ) + { + D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression")); + _res = star_expression_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression")); } _res = NULL; done: @@ -7604,36 +7496,55 @@ lambda_param_no_default_rule(Parser *p) return _res; } -// lambda_param_with_default: lambda_param default ',' | lambda_param default &':' -static NameDefaultPair* -lambda_param_with_default_rule(Parser *p) +// star_expression: '*' bitwise_or | expression +static expr_ty +star_expression_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - NameDefaultPair* _res = NULL; + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, star_expression_type, &_res)) { + D(p->level--); + return _res; + } int _mark = p->mark; - { // lambda_param default ',' + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // '*' bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default ','")); + D(fprintf(stderr, "%*c> star_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); Token * _literal; - arg_ty a; - expr_ty c; + expr_ty a; if ( - (a = lambda_param_rule(p)) // lambda_param - && - (c = default_rule(p)) // default + (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ lambda_param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default ','")); - _res = _PyPegen_name_default_pair ( p , a , c , NULL ); + D(fprintf(stderr, "%*c+ star_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Starred ( a , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -7642,103 +7553,63 @@ lambda_param_with_default_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_param_with_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default ','")); + D(fprintf(stderr, "%*c%s star_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' bitwise_or")); } - { // lambda_param default &':' + { // expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default &':'")); - arg_ty a; - expr_ty c; + D(fprintf(stderr, "%*c> star_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression")); + expr_ty expression_var; if ( - (a = lambda_param_rule(p)) // lambda_param - && - (c = default_rule(p)) // default - && - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' + (expression_var = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ lambda_param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default &':'")); - _res = _PyPegen_name_default_pair ( p , a , c , NULL ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ star_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression")); + _res = expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_param_with_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default &':'")); + D(fprintf(stderr, "%*c%s star_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression")); } _res = NULL; done: + _PyPegen_insert_memo(p, _mark, star_expression_type, _res); D(p->level--); return _res; } -// lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':' -static NameDefaultPair* -lambda_param_maybe_default_rule(Parser *p) +// star_named_expressions: ','.star_named_expression+ ','? +static asdl_seq* +star_named_expressions_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - NameDefaultPair* _res = NULL; + asdl_seq* _res = NULL; int _mark = p->mark; - { // lambda_param default? ',' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> lambda_param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default? ','")); - Token * _literal; - arg_ty a; - void *c; - if ( - (a = lambda_param_rule(p)) // lambda_param - && - (c = default_rule(p), 1) // default? - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ lambda_param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default? ','")); - _res = _PyPegen_name_default_pair ( p , a , c , NULL ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default? ','")); - } - { // lambda_param default? &':' + { // ','.star_named_expression+ ','? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default? &':'")); - arg_ty a; - void *c; + D(fprintf(stderr, "%*c> star_named_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_named_expression+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_seq * a; if ( - (a = lambda_param_rule(p)) // lambda_param - && - (c = default_rule(p), 1) // default? + (a = _gather_97_rule(p)) // ','.star_named_expression+ && - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) { - D(fprintf(stderr, "%*c+ lambda_param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default? &':'")); - _res = _PyPegen_name_default_pair ( p , a , c , NULL ); + D(fprintf(stderr, "%*c+ star_named_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_named_expression+ ','?")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -7747,8 +7618,8 @@ lambda_param_maybe_default_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default? &':'")); + D(fprintf(stderr, "%*c%s star_named_expressions[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_named_expression+ ','?")); } _res = NULL; done: @@ -7756,16 +7627,16 @@ lambda_param_maybe_default_rule(Parser *p) return _res; } -// lambda_param: NAME -static arg_ty -lambda_param_rule(Parser *p) +// star_named_expression: '*' bitwise_or | named_expression +static expr_ty +star_named_expression_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - arg_ty _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -7776,18 +7647,21 @@ lambda_param_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME + { // '*' bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lambda_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); + D(fprintf(stderr, "%*c> star_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); + Token * _literal; expr_ty a; if ( - (a = _PyPegen_name_token(p)) // NAME + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ lambda_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); + D(fprintf(stderr, "%*c+ star_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -7797,7 +7671,7 @@ lambda_param_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_arg ( a -> v . Name . id , NULL , NULL , EXTRA ); + _res = _Py_Starred ( a , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -7806,8 +7680,27 @@ lambda_param_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lambda_param[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); + D(fprintf(stderr, "%*c%s star_named_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' bitwise_or")); + } + { // named_expression + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> star_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); + expr_ty named_expression_var; + if ( + (named_expression_var = named_expression_rule(p)) // named_expression + ) + { + D(fprintf(stderr, "%*c+ star_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + _res = named_expression_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s star_named_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); } _res = NULL; done: @@ -7815,9 +7708,9 @@ lambda_param_rule(Parser *p) return _res; } -// disjunction: conjunction (('or' conjunction))+ | conjunction +// named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression static expr_ty -disjunction_rule(Parser *p) +named_expression_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -7825,10 +7718,6 @@ disjunction_rule(Parser *p) return NULL; } expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, disjunction_type, &_res)) { - D(p->level--); - return _res; - } int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -7839,21 +7728,24 @@ disjunction_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // conjunction (('or' conjunction))+ + { // NAME ':=' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> disjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); + D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':=' expression")); + Token * _literal; expr_ty a; - asdl_seq * b; + expr_ty b; if ( - (a = conjunction_rule(p)) // conjunction + (a = _PyPegen_name_token(p)) // NAME && - (b = _loop1_89_rule(p)) // (('or' conjunction))+ + (_literal = _PyPegen_expect_token(p, 53)) // token=':=' + && + (b = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); + D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ':=' expression")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -7863,7 +7755,7 @@ disjunction_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); + _res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -7872,38 +7764,58 @@ disjunction_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s disjunction[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "conjunction (('or' conjunction))+")); + D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':=' expression")); } - { // conjunction + { // expression !':=' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> disjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "conjunction")); - expr_ty conjunction_var; + D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); + expr_ty expression_var; if ( - (conjunction_var = conjunction_rule(p)) // conjunction + (expression_var = expression_rule(p)) // expression + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' ) { - D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction")); - _res = conjunction_var; + D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); + _res = expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s disjunction[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "conjunction")); + D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); + } + { // invalid_named_expression + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_named_expression")); + void *invalid_named_expression_var; + if ( + (invalid_named_expression_var = invalid_named_expression_rule(p)) // invalid_named_expression + ) + { + D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_named_expression")); + _res = invalid_named_expression_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_named_expression")); } _res = NULL; done: - _PyPegen_insert_memo(p, _mark, disjunction_type, _res); D(p->level--); return _res; } -// conjunction: inversion (('and' inversion))+ | inversion +// annotated_rhs: yield_expr | star_expressions static expr_ty -conjunction_rule(Parser *p) +annotated_rhs_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -7911,85 +7823,54 @@ conjunction_rule(Parser *p) return NULL; } expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, conjunction_type, &_res)) { - D(p->level--); - return _res; - } int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // inversion (('and' inversion))+ + { // yield_expr if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> conjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); - expr_ty a; - asdl_seq * b; + D(fprintf(stderr, "%*c> annotated_rhs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + expr_ty yield_expr_var; if ( - (a = inversion_rule(p)) // inversion - && - (b = _loop1_90_rule(p)) // (('and' inversion))+ + (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ annotated_rhs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s conjunction[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "inversion (('and' inversion))+")); + D(fprintf(stderr, "%*c%s annotated_rhs[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } - { // inversion + { // star_expressions if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> conjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "inversion")); - expr_ty inversion_var; + D(fprintf(stderr, "%*c> annotated_rhs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + expr_ty star_expressions_var; if ( - (inversion_var = inversion_rule(p)) // inversion + (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion")); - _res = inversion_var; + D(fprintf(stderr, "%*c+ annotated_rhs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s conjunction[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "inversion")); + D(fprintf(stderr, "%*c%s annotated_rhs[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; done: - _PyPegen_insert_memo(p, _mark, conjunction_type, _res); D(p->level--); return _res; } -// inversion: 'not' inversion | comparison +// expressions: expression ((',' expression))+ ','? | expression ',' | expression static expr_ty -inversion_rule(Parser *p) +expressions_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -7997,10 +7878,6 @@ inversion_rule(Parser *p) return NULL; } expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, inversion_type, &_res)) { - D(p->level--); - return _res; - } int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -8011,21 +7888,25 @@ inversion_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // 'not' inversion + { // expression ((',' expression))+ ','? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> inversion[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'not' inversion")); - Token * _keyword; + D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ((',' expression))+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings expr_ty a; + asdl_seq * b; if ( - (_keyword = _PyPegen_expect_token(p, 525)) // token='not' + (a = expression_rule(p)) // expression && - (a = inversion_rule(p)) // inversion + (b = _loop1_99_rule(p)) // ((',' expression))+ + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) { - D(fprintf(stderr, "%*c+ inversion[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'not' inversion")); + D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ((',' expression))+ ','?")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -8035,7 +7916,7 @@ inversion_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_UnaryOp ( Not , a , EXTRA ); + _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -8044,38 +7925,73 @@ inversion_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s inversion[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'not' inversion")); + D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ((',' expression))+ ','?")); } - { // comparison + { // expression ',' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> inversion[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "comparison")); - expr_ty comparison_var; + D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ','")); + Token * _literal; + expr_ty a; if ( - (comparison_var = comparison_rule(p)) // comparison + (a = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ inversion[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "comparison")); - _res = comparison_var; + D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ','")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s inversion[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "comparison")); + D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ','")); + } + { // expression + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression")); + expr_ty expression_var; + if ( + (expression_var = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression")); + _res = expression_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression")); } _res = NULL; done: - _PyPegen_insert_memo(p, _mark, inversion_type, _res); D(p->level--); return _res; } -// comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or +// expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef static expr_ty -comparison_rule(Parser *p) +expression_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -8083,6 +7999,10 @@ comparison_rule(Parser *p) return NULL; } expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, expression_type, &_res)) { + D(p->level--); + return _res; + } int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -8093,21 +8013,30 @@ comparison_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // bitwise_or compare_op_bitwise_or_pair+ + { // disjunction 'if' disjunction 'else' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> comparison[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); + D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); + Token * _keyword; + Token * _keyword_1; expr_ty a; - asdl_seq * b; - if ( - (a = bitwise_or_rule(p)) // bitwise_or + expr_ty b; + expr_ty c; + if ( + (a = disjunction_rule(p)) // disjunction + && + (_keyword = _PyPegen_expect_token(p, 510)) // token='if' + && + (b = disjunction_rule(p)) // disjunction + && + (_keyword_1 = _PyPegen_expect_token(p, 516)) // token='else' && - (b = _loop1_91_rule(p)) // compare_op_bitwise_or_pair+ + (c = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); + D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -8117,7 +8046,7 @@ comparison_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA ); + _res = _Py_IfExp ( b , a , c , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -8126,244 +8055,281 @@ comparison_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s comparison[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); + D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); } - { // bitwise_or + { // disjunction if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> comparison[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or")); - expr_ty bitwise_or_var; + D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction")); + expr_ty disjunction_var; if ( - (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + (disjunction_var = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or")); - _res = bitwise_or_var; + D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction")); + _res = disjunction_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s comparison[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or")); + D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction")); + } + { // lambdef + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambdef")); + expr_ty lambdef_var; + if ( + (lambdef_var = lambdef_rule(p)) // lambdef + ) + { + D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambdef")); + _res = lambdef_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambdef")); } _res = NULL; done: + _PyPegen_insert_memo(p, _mark, expression_type, _res); D(p->level--); return _res; } -// compare_op_bitwise_or_pair: -// | eq_bitwise_or -// | noteq_bitwise_or -// | lte_bitwise_or -// | lt_bitwise_or -// | gte_bitwise_or -// | gt_bitwise_or -// | notin_bitwise_or -// | in_bitwise_or -// | isnot_bitwise_or -// | is_bitwise_or -static CmpopExprPair* -compare_op_bitwise_or_pair_rule(Parser *p) +// lambdef: 'lambda' lambda_parameters? ':' expression +static expr_ty +lambdef_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - CmpopExprPair* _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; - { // eq_bitwise_or + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // 'lambda' lambda_parameters? ':' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "eq_bitwise_or")); - CmpopExprPair* eq_bitwise_or_var; + D(fprintf(stderr, "%*c> lambdef[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_parameters? ':' expression")); + Token * _keyword; + Token * _literal; + void *a; + expr_ty b; if ( - (eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or + (_keyword = _PyPegen_expect_token(p, 527)) // token='lambda' + && + (a = lambda_parameters_rule(p), 1) // lambda_parameters? + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (b = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "eq_bitwise_or")); - _res = eq_bitwise_or_var; + D(fprintf(stderr, "%*c+ lambdef[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_parameters? ':' expression")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "eq_bitwise_or")); + D(fprintf(stderr, "%*c%s lambdef[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'lambda' lambda_parameters? ':' expression")); } - { // noteq_bitwise_or + _res = NULL; + done: + D(p->level--); + return _res; +} + +// lambda_parameters: +// | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? +// | lambda_slash_with_default lambda_param_with_default* lambda_star_etc? +// | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? +// | lambda_param_with_default+ lambda_star_etc? +// | lambda_star_etc +static arguments_ty +lambda_parameters_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + arguments_ty _res = NULL; + int _mark = p->mark; + { // lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "noteq_bitwise_or")); - CmpopExprPair* noteq_bitwise_or_var; + D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?")); + asdl_seq* a; + asdl_seq * b; + asdl_seq * c; + void *d; if ( - (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or + (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default + && + (b = _loop0_100_rule(p)) // lambda_param_no_default* + && + (c = _loop0_101_rule(p)) // lambda_param_with_default* + && + (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "noteq_bitwise_or")); - _res = noteq_bitwise_or_var; + D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?")); + _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "noteq_bitwise_or")); + D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?")); } - { // lte_bitwise_or + { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lte_bitwise_or")); - CmpopExprPair* lte_bitwise_or_var; + D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?")); + SlashWithDefault* a; + asdl_seq * b; + void *c; if ( - (lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or + (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default + && + (b = _loop0_102_rule(p)) // lambda_param_with_default* + && + (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lte_bitwise_or")); - _res = lte_bitwise_or_var; + D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?")); + _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , 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 compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lte_bitwise_or")); + D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?")); } - { // lt_bitwise_or + { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lt_bitwise_or")); - CmpopExprPair* lt_bitwise_or_var; + D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?")); + asdl_seq * a; + asdl_seq * b; + void *c; if ( - (lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or + (a = _loop1_103_rule(p)) // lambda_param_no_default+ + && + (b = _loop0_104_rule(p)) // lambda_param_with_default* + && + (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lt_bitwise_or")); - _res = lt_bitwise_or_var; + D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?")); + _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , 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 compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lt_bitwise_or")); + D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?")); } - { // gte_bitwise_or + { // lambda_param_with_default+ lambda_star_etc? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "gte_bitwise_or")); - CmpopExprPair* gte_bitwise_or_var; + D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?")); + asdl_seq * a; + void *b; if ( - (gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or + (a = _loop1_105_rule(p)) // lambda_param_with_default+ + && + (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "gte_bitwise_or")); - _res = gte_bitwise_or_var; + D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?")); + _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "gte_bitwise_or")); + D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?")); } - { // gt_bitwise_or + { // lambda_star_etc if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "gt_bitwise_or")); - CmpopExprPair* gt_bitwise_or_var; + D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_star_etc")); + StarEtc* a; if ( - (gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or + (a = lambda_star_etc_rule(p)) // lambda_star_etc ) { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "gt_bitwise_or")); - _res = gt_bitwise_or_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "gt_bitwise_or")); - } - { // notin_bitwise_or - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "notin_bitwise_or")); - CmpopExprPair* notin_bitwise_or_var; - if ( - (notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or - ) - { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "notin_bitwise_or")); - _res = notin_bitwise_or_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "notin_bitwise_or")); - } - { // in_bitwise_or - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "in_bitwise_or")); - CmpopExprPair* in_bitwise_or_var; - if ( - (in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or - ) - { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "in_bitwise_or")); - _res = in_bitwise_or_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "in_bitwise_or")); - } - { // isnot_bitwise_or - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "isnot_bitwise_or")); - CmpopExprPair* isnot_bitwise_or_var; - if ( - (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or - ) - { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "isnot_bitwise_or")); - _res = isnot_bitwise_or_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "isnot_bitwise_or")); - } - { // is_bitwise_or - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "is_bitwise_or")); - CmpopExprPair* is_bitwise_or_var; - if ( - (is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or - ) - { - D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "is_bitwise_or")); - _res = is_bitwise_or_var; + D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_star_etc")); + _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "is_bitwise_or")); + D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_star_etc")); } _res = NULL; done: @@ -8371,33 +8337,38 @@ compare_op_bitwise_or_pair_rule(Parser *p) return _res; } -// eq_bitwise_or: '==' bitwise_or -static CmpopExprPair* -eq_bitwise_or_rule(Parser *p) +// lambda_slash_no_default: +// | lambda_param_no_default+ '/' ',' +// | lambda_param_no_default+ '/' &':' +static asdl_seq* +lambda_slash_no_default_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - CmpopExprPair* _res = NULL; + asdl_seq* _res = NULL; int _mark = p->mark; - { // '==' bitwise_or + { // lambda_param_no_default+ '/' ',' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> eq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or")); + D(fprintf(stderr, "%*c> lambda_slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' ','")); Token * _literal; - expr_ty a; + Token * _literal_1; + asdl_seq * a; if ( - (_literal = _PyPegen_expect_token(p, 27)) // token='==' + (a = _loop1_106_rule(p)) // lambda_param_no_default+ && - (a = bitwise_or_rule(p)) // bitwise_or + (_literal = _PyPegen_expect_token(p, 17)) // token='/' + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ eq_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , Eq , a ); + D(fprintf(stderr, "%*c+ lambda_slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' ','")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -8406,42 +8377,27 @@ eq_bitwise_or_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s eq_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'==' bitwise_or")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// noteq_bitwise_or: ('!=') bitwise_or -static CmpopExprPair* -noteq_bitwise_or_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s lambda_slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ '/' ','")); } - CmpopExprPair* _res = NULL; - int _mark = p->mark; - { // ('!=') bitwise_or + { // lambda_param_no_default+ '/' &':' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); - void *_tmp_92_var; - expr_ty a; + D(fprintf(stderr, "%*c> lambda_slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' &':'")); + Token * _literal; + asdl_seq * a; if ( - (_tmp_92_var = _tmp_92_rule(p)) // '!=' + (a = _loop1_107_rule(p)) // lambda_param_no_default+ && - (a = bitwise_or_rule(p)) // bitwise_or + (_literal = _PyPegen_expect_token(p, 17)) // token='/' + && + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' ) { - D(fprintf(stderr, "%*c+ noteq_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , NotEq , a ); + D(fprintf(stderr, "%*c+ lambda_slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' &':'")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -8450,8 +8406,8 @@ noteq_bitwise_or_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s noteq_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('!=') bitwise_or")); + D(fprintf(stderr, "%*c%s lambda_slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ '/' &':'")); } _res = NULL; done: @@ -8459,33 +8415,41 @@ noteq_bitwise_or_rule(Parser *p) return _res; } -// lte_bitwise_or: '<=' bitwise_or -static CmpopExprPair* -lte_bitwise_or_rule(Parser *p) +// lambda_slash_with_default: +// | lambda_param_no_default* lambda_param_with_default+ '/' ',' +// | lambda_param_no_default* lambda_param_with_default+ '/' &':' +static SlashWithDefault* +lambda_slash_with_default_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - CmpopExprPair* _res = NULL; + SlashWithDefault* _res = NULL; int _mark = p->mark; - { // '<=' bitwise_or + { // lambda_param_no_default* lambda_param_with_default+ '/' ',' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lte_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or")); + D(fprintf(stderr, "%*c> lambda_slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','")); Token * _literal; - expr_ty a; + Token * _literal_1; + asdl_seq * a; + asdl_seq * b; if ( - (_literal = _PyPegen_expect_token(p, 29)) // token='<=' + (a = _loop0_108_rule(p)) // lambda_param_no_default* && - (a = bitwise_or_rule(p)) // bitwise_or + (b = _loop1_109_rule(p)) // lambda_param_with_default+ + && + (_literal = _PyPegen_expect_token(p, 17)) // token='/' + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ lte_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , LtE , a ); + D(fprintf(stderr, "%*c+ lambda_slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','")); + _res = _PyPegen_slash_with_default ( p , a , b ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -8494,42 +8458,30 @@ lte_bitwise_or_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lte_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<=' bitwise_or")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// lt_bitwise_or: '<' bitwise_or -static CmpopExprPair* -lt_bitwise_or_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s lambda_slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','")); } - CmpopExprPair* _res = NULL; - int _mark = p->mark; - { // '<' bitwise_or + { // lambda_param_no_default* lambda_param_with_default+ '/' &':' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> lt_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or")); + D(fprintf(stderr, "%*c> lambda_slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'")); Token * _literal; - expr_ty a; + asdl_seq * a; + asdl_seq * b; if ( - (_literal = _PyPegen_expect_token(p, 20)) // token='<' + (a = _loop0_110_rule(p)) // lambda_param_no_default* && - (a = bitwise_or_rule(p)) // bitwise_or + (b = _loop1_111_rule(p)) // lambda_param_with_default+ + && + (_literal = _PyPegen_expect_token(p, 17)) // token='/' + && + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' ) { - D(fprintf(stderr, "%*c+ lt_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , Lt , a ); + D(fprintf(stderr, "%*c+ lambda_slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'")); + _res = _PyPegen_slash_with_default ( p , a , b ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -8538,8 +8490,8 @@ lt_bitwise_or_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s lt_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<' bitwise_or")); + D(fprintf(stderr, "%*c%s lambda_slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'")); } _res = NULL; done: @@ -8547,33 +8499,43 @@ lt_bitwise_or_rule(Parser *p) return _res; } -// gte_bitwise_or: '>=' bitwise_or -static CmpopExprPair* -gte_bitwise_or_rule(Parser *p) +// lambda_star_etc: +// | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? +// | '*' ',' lambda_param_maybe_default+ lambda_kwds? +// | lambda_kwds +// | invalid_lambda_star_etc +static StarEtc* +lambda_star_etc_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - CmpopExprPair* _res = NULL; + StarEtc* _res = NULL; int _mark = p->mark; - { // '>=' bitwise_or + { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> gte_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or")); + D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?")); Token * _literal; - expr_ty a; + arg_ty a; + asdl_seq * b; + void *c; if ( - (_literal = _PyPegen_expect_token(p, 30)) // token='>=' + (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (a = bitwise_or_rule(p)) // bitwise_or + (a = lambda_param_no_default_rule(p)) // lambda_param_no_default + && + (b = _loop0_112_rule(p)) // lambda_param_maybe_default* + && + (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) { - D(fprintf(stderr, "%*c+ gte_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , GtE , a ); + D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?")); + _res = _PyPegen_star_etc ( p , a , b , c ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -8582,42 +8544,31 @@ gte_bitwise_or_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s gte_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>=' bitwise_or")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// gt_bitwise_or: '>' bitwise_or -static CmpopExprPair* -gt_bitwise_or_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?")); } - CmpopExprPair* _res = NULL; - int _mark = p->mark; - { // '>' bitwise_or + { // '*' ',' lambda_param_maybe_default+ lambda_kwds? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> gt_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or")); + D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?")); Token * _literal; - expr_ty a; + Token * _literal_1; + asdl_seq * b; + void *c; if ( - (_literal = _PyPegen_expect_token(p, 21)) // token='>' + (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (a = bitwise_or_rule(p)) // bitwise_or + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + && + (b = _loop1_113_rule(p)) // lambda_param_maybe_default+ + && + (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) { - D(fprintf(stderr, "%*c+ gt_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , Gt , a ); + D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?")); + _res = _PyPegen_star_etc ( p , NULL , b , c ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -8626,8 +8577,51 @@ gt_bitwise_or_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s gt_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>' bitwise_or")); + D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?")); + } + { // lambda_kwds + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_kwds")); + arg_ty a; + if ( + (a = lambda_kwds_rule(p)) // lambda_kwds + ) + { + D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_kwds")); + _res = _PyPegen_star_etc ( p , NULL , NULL , a ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_kwds")); + } + { // invalid_lambda_star_etc + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_lambda_star_etc")); + void *invalid_lambda_star_etc_var; + if ( + (invalid_lambda_star_etc_var = invalid_lambda_star_etc_rule(p)) // invalid_lambda_star_etc + ) + { + D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_lambda_star_etc")); + _res = invalid_lambda_star_etc_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_lambda_star_etc")); } _res = NULL; done: @@ -8635,36 +8629,33 @@ gt_bitwise_or_rule(Parser *p) return _res; } -// notin_bitwise_or: 'not' 'in' bitwise_or -static CmpopExprPair* -notin_bitwise_or_rule(Parser *p) +// lambda_kwds: '**' lambda_param_no_default +static arg_ty +lambda_kwds_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - CmpopExprPair* _res = NULL; + arg_ty _res = NULL; int _mark = p->mark; - { // 'not' 'in' bitwise_or + { // '**' lambda_param_no_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> notin_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or")); - Token * _keyword; - Token * _keyword_1; - expr_ty a; + D(fprintf(stderr, "%*c> lambda_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' lambda_param_no_default")); + Token * _literal; + arg_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 525)) // token='not' - && - (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' + (_literal = _PyPegen_expect_token(p, 35)) // token='**' && - (a = bitwise_or_rule(p)) // bitwise_or + (a = lambda_param_no_default_rule(p)) // lambda_param_no_default ) { - D(fprintf(stderr, "%*c+ notin_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , NotIn , a ); + D(fprintf(stderr, "%*c+ lambda_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' lambda_param_no_default")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -8673,8 +8664,8 @@ notin_bitwise_or_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s notin_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'not' 'in' bitwise_or")); + D(fprintf(stderr, "%*c%s lambda_kwds[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' lambda_param_no_default")); } _res = NULL; done: @@ -8682,33 +8673,33 @@ notin_bitwise_or_rule(Parser *p) return _res; } -// in_bitwise_or: 'in' bitwise_or -static CmpopExprPair* -in_bitwise_or_rule(Parser *p) +// lambda_param_no_default: lambda_param ',' | lambda_param &':' +static arg_ty +lambda_param_no_default_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - CmpopExprPair* _res = NULL; + arg_ty _res = NULL; int _mark = p->mark; - { // 'in' bitwise_or + { // lambda_param ',' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> in_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or")); - Token * _keyword; - expr_ty a; + D(fprintf(stderr, "%*c> lambda_param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param ','")); + Token * _literal; + arg_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 518)) // token='in' + (a = lambda_param_rule(p)) // lambda_param && - (a = bitwise_or_rule(p)) // bitwise_or + (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ in_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , In , a ); + D(fprintf(stderr, "%*c+ lambda_param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param ','")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -8717,8 +8708,34 @@ in_bitwise_or_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s in_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'in' bitwise_or")); + D(fprintf(stderr, "%*c%s lambda_param_no_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param ','")); + } + { // lambda_param &':' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> lambda_param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param &':'")); + arg_ty a; + if ( + (a = lambda_param_rule(p)) // lambda_param + && + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' + ) + { + D(fprintf(stderr, "%*c+ lambda_param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param &':'")); + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s lambda_param_no_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param &':'")); } _res = NULL; done: @@ -8726,36 +8743,36 @@ in_bitwise_or_rule(Parser *p) return _res; } -// isnot_bitwise_or: 'is' 'not' bitwise_or -static CmpopExprPair* -isnot_bitwise_or_rule(Parser *p) +// lambda_param_with_default: lambda_param default ',' | lambda_param default &':' +static NameDefaultPair* +lambda_param_with_default_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - CmpopExprPair* _res = NULL; + NameDefaultPair* _res = NULL; int _mark = p->mark; - { // 'is' 'not' bitwise_or + { // lambda_param default ',' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> isnot_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or")); - Token * _keyword; - Token * _keyword_1; - expr_ty a; + D(fprintf(stderr, "%*c> lambda_param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default ','")); + Token * _literal; + arg_ty a; + expr_ty c; if ( - (_keyword = _PyPegen_expect_token(p, 526)) // token='is' + (a = lambda_param_rule(p)) // lambda_param && - (_keyword_1 = _PyPegen_expect_token(p, 525)) // token='not' + (c = default_rule(p)) // default && - (a = bitwise_or_rule(p)) // bitwise_or + (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ isnot_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , IsNot , a ); + D(fprintf(stderr, "%*c+ lambda_param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default ','")); + _res = _PyPegen_name_default_pair ( p , a , c , NULL ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -8764,42 +8781,27 @@ isnot_bitwise_or_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s isnot_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' 'not' bitwise_or")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// is_bitwise_or: 'is' bitwise_or -static CmpopExprPair* -is_bitwise_or_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s lambda_param_with_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default ','")); } - CmpopExprPair* _res = NULL; - int _mark = p->mark; - { // 'is' bitwise_or + { // lambda_param default &':' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> is_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or")); - Token * _keyword; - expr_ty a; + D(fprintf(stderr, "%*c> lambda_param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default &':'")); + arg_ty a; + expr_ty c; if ( - (_keyword = _PyPegen_expect_token(p, 526)) // token='is' + (a = lambda_param_rule(p)) // lambda_param && - (a = bitwise_or_rule(p)) // bitwise_or + (c = default_rule(p)) // default + && + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' ) { - D(fprintf(stderr, "%*c+ is_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or")); - _res = _PyPegen_cmpop_expr_pair ( p , Is , a ); + D(fprintf(stderr, "%*c+ lambda_param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default &':'")); + _res = _PyPegen_name_default_pair ( p , a , c , NULL ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -8808,8 +8810,8 @@ is_bitwise_or_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s is_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' bitwise_or")); + D(fprintf(stderr, "%*c%s lambda_param_with_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default &':'")); } _res = NULL; done: @@ -8817,46 +8819,92 @@ is_bitwise_or_rule(Parser *p) return _res; } -// Left-recursive -// bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor -static expr_ty bitwise_or_raw(Parser *); -static expr_ty -bitwise_or_rule(Parser *p) +// lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':' +static NameDefaultPair* +lambda_param_maybe_default_rule(Parser *p) { D(p->level++); - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, bitwise_or_type, &_res)) { + if (p->error_indicator) { D(p->level--); - return _res; + return NULL; } + NameDefaultPair* _res = NULL; int _mark = p->mark; - int _resmark = p->mark; - while (1) { - int tmpvar_1 = _PyPegen_update_memo(p, _mark, bitwise_or_type, _res); - if (tmpvar_1) { + { // lambda_param default? ',' + if (p->error_indicator) { D(p->level--); - return _res; + return NULL; + } + D(fprintf(stderr, "%*c> lambda_param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default? ','")); + Token * _literal; + arg_ty a; + void *c; + if ( + (a = lambda_param_rule(p)) // lambda_param + && + (c = default_rule(p), 1) // default? + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ lambda_param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default? ','")); + _res = _PyPegen_name_default_pair ( p , a , c , NULL ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; } p->mark = _mark; - void *_raw = bitwise_or_raw(p); - if (_raw == NULL || p->mark <= _resmark) - break; - _resmark = p->mark; - _res = _raw; + D(fprintf(stderr, "%*c%s lambda_param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default? ','")); } - p->mark = _resmark; + { // lambda_param default? &':' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> lambda_param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default? &':'")); + arg_ty a; + void *c; + if ( + (a = lambda_param_rule(p)) // lambda_param + && + (c = default_rule(p), 1) // default? + && + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' + ) + { + D(fprintf(stderr, "%*c+ lambda_param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default? &':'")); + _res = _PyPegen_name_default_pair ( p , a , c , NULL ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s lambda_param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default? &':'")); + } + _res = NULL; + done: D(p->level--); return _res; } -static expr_ty -bitwise_or_raw(Parser *p) + +// lambda_param: NAME +static arg_ty +lambda_param_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + arg_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -8867,24 +8915,18 @@ bitwise_or_raw(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // bitwise_or '|' bitwise_xor + { // NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor")); - Token * _literal; + D(fprintf(stderr, "%*c> lambda_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); expr_ty a; - expr_ty b; if ( - (a = bitwise_or_rule(p)) // bitwise_or - && - (_literal = _PyPegen_expect_token(p, 18)) // token='|' - && - (b = bitwise_xor_rule(p)) // bitwise_xor + (a = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor")); + D(fprintf(stderr, "%*c+ lambda_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -8894,7 +8936,7 @@ bitwise_or_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BinOp ( a , BitOr , b , EXTRA ); + _res = _Py_arg ( a -> v . Name . id , NULL , NULL , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -8903,27 +8945,8 @@ bitwise_or_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or '|' bitwise_xor")); - } - { // bitwise_xor - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor")); - expr_ty bitwise_xor_var; - if ( - (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor - ) - { - D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor")); - _res = bitwise_xor_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor")); + D(fprintf(stderr, "%*c%s lambda_param[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); } _res = NULL; done: @@ -8931,39 +8954,9 @@ bitwise_or_raw(Parser *p) return _res; } -// Left-recursive -// bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and -static expr_ty bitwise_xor_raw(Parser *); -static expr_ty -bitwise_xor_rule(Parser *p) -{ - D(p->level++); - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, bitwise_xor_type, &_res)) { - D(p->level--); - return _res; - } - int _mark = p->mark; - int _resmark = p->mark; - while (1) { - int tmpvar_2 = _PyPegen_update_memo(p, _mark, bitwise_xor_type, _res); - if (tmpvar_2) { - D(p->level--); - return _res; - } - p->mark = _mark; - void *_raw = bitwise_xor_raw(p); - if (_raw == NULL || p->mark <= _resmark) - break; - _resmark = p->mark; - _res = _raw; - } - p->mark = _resmark; - D(p->level--); - return _res; -} +// disjunction: conjunction (('or' conjunction))+ | conjunction static expr_ty -bitwise_xor_raw(Parser *p) +disjunction_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -8971,6 +8964,10 @@ bitwise_xor_raw(Parser *p) return NULL; } expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, disjunction_type, &_res)) { + D(p->level--); + return _res; + } int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -8981,24 +8978,21 @@ bitwise_xor_raw(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // bitwise_xor '^' bitwise_and + { // conjunction (('or' conjunction))+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and")); - Token * _literal; + D(fprintf(stderr, "%*c> disjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); expr_ty a; - expr_ty b; + asdl_seq * b; if ( - (a = bitwise_xor_rule(p)) // bitwise_xor - && - (_literal = _PyPegen_expect_token(p, 32)) // token='^' + (a = conjunction_rule(p)) // conjunction && - (b = bitwise_and_rule(p)) // bitwise_and + (b = _loop1_114_rule(p)) // (('or' conjunction))+ ) { - D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and")); + D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -9008,7 +9002,7 @@ bitwise_xor_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BinOp ( a , BitXor , b , EXTRA ); + _res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -9017,67 +9011,38 @@ bitwise_xor_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor '^' bitwise_and")); + D(fprintf(stderr, "%*c%s disjunction[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "conjunction (('or' conjunction))+")); } - { // bitwise_and + { // conjunction if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and")); - expr_ty bitwise_and_var; + D(fprintf(stderr, "%*c> disjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "conjunction")); + expr_ty conjunction_var; if ( - (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and + (conjunction_var = conjunction_rule(p)) // conjunction ) { - D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and")); - _res = bitwise_and_var; + D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction")); + _res = conjunction_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and")); + D(fprintf(stderr, "%*c%s disjunction[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "conjunction")); } _res = NULL; done: + _PyPegen_insert_memo(p, _mark, disjunction_type, _res); D(p->level--); return _res; } -// Left-recursive -// bitwise_and: bitwise_and '&' shift_expr | shift_expr -static expr_ty bitwise_and_raw(Parser *); -static expr_ty -bitwise_and_rule(Parser *p) -{ - D(p->level++); - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, bitwise_and_type, &_res)) { - D(p->level--); - return _res; - } - int _mark = p->mark; - int _resmark = p->mark; - while (1) { - int tmpvar_3 = _PyPegen_update_memo(p, _mark, bitwise_and_type, _res); - if (tmpvar_3) { - D(p->level--); - return _res; - } - p->mark = _mark; - void *_raw = bitwise_and_raw(p); - if (_raw == NULL || p->mark <= _resmark) - break; - _resmark = p->mark; - _res = _raw; - } - p->mark = _resmark; - D(p->level--); - return _res; -} +// conjunction: inversion (('and' inversion))+ | inversion static expr_ty -bitwise_and_raw(Parser *p) +conjunction_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -9085,6 +9050,10 @@ bitwise_and_raw(Parser *p) return NULL; } expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, conjunction_type, &_res)) { + D(p->level--); + return _res; + } int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -9095,24 +9064,21 @@ bitwise_and_raw(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // bitwise_and '&' shift_expr + { // inversion (('and' inversion))+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr")); - Token * _literal; + D(fprintf(stderr, "%*c> conjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); expr_ty a; - expr_ty b; + asdl_seq * b; if ( - (a = bitwise_and_rule(p)) // bitwise_and - && - (_literal = _PyPegen_expect_token(p, 19)) // token='&' + (a = inversion_rule(p)) // inversion && - (b = shift_expr_rule(p)) // shift_expr + (b = _loop1_115_rule(p)) // (('and' inversion))+ ) { - D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr")); + D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -9122,7 +9088,7 @@ bitwise_and_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BinOp ( a , BitAnd , b , EXTRA ); + _res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -9131,67 +9097,38 @@ bitwise_and_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and '&' shift_expr")); + D(fprintf(stderr, "%*c%s conjunction[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "inversion (('and' inversion))+")); } - { // shift_expr + { // inversion if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr")); - expr_ty shift_expr_var; + D(fprintf(stderr, "%*c> conjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "inversion")); + expr_ty inversion_var; if ( - (shift_expr_var = shift_expr_rule(p)) // shift_expr + (inversion_var = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr")); - _res = shift_expr_var; + D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion")); + _res = inversion_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr")); + D(fprintf(stderr, "%*c%s conjunction[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "inversion")); } _res = NULL; done: + _PyPegen_insert_memo(p, _mark, conjunction_type, _res); D(p->level--); return _res; } -// Left-recursive -// shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum -static expr_ty shift_expr_raw(Parser *); -static expr_ty -shift_expr_rule(Parser *p) -{ - D(p->level++); - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, shift_expr_type, &_res)) { - D(p->level--); - return _res; - } - int _mark = p->mark; - int _resmark = p->mark; - while (1) { - int tmpvar_4 = _PyPegen_update_memo(p, _mark, shift_expr_type, _res); - if (tmpvar_4) { - D(p->level--); - return _res; - } - p->mark = _mark; - void *_raw = shift_expr_raw(p); - if (_raw == NULL || p->mark <= _resmark) - break; - _resmark = p->mark; - _res = _raw; - } - p->mark = _resmark; - D(p->level--); - return _res; -} +// inversion: 'not' inversion | comparison static expr_ty -shift_expr_raw(Parser *p) +inversion_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -9199,6 +9136,10 @@ shift_expr_raw(Parser *p) return NULL; } expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, inversion_type, &_res)) { + D(p->level--); + return _res; + } int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -9209,63 +9150,21 @@ shift_expr_raw(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // shift_expr '<<' sum - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum")); - Token * _literal; - expr_ty a; - expr_ty b; - if ( - (a = shift_expr_rule(p)) // shift_expr - && - (_literal = _PyPegen_expect_token(p, 33)) // token='<<' - && - (b = sum_rule(p)) // sum - ) - { - D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BinOp ( a , LShift , b , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '<<' sum")); - } - { // shift_expr '>>' sum + { // 'not' inversion if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum")); - Token * _literal; + D(fprintf(stderr, "%*c> inversion[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'not' inversion")); + Token * _keyword; expr_ty a; - expr_ty b; if ( - (a = shift_expr_rule(p)) // shift_expr + (_keyword = _PyPegen_expect_token(p, 528)) // token='not' && - (_literal = _PyPegen_expect_token(p, 34)) // token='>>' - && - (b = sum_rule(p)) // sum + (a = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum")); + D(fprintf(stderr, "%*c+ inversion[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'not' inversion")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -9275,7 +9174,7 @@ shift_expr_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BinOp ( a , RShift , b , EXTRA ); + _res = _Py_UnaryOp ( Not , a , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -9284,67 +9183,38 @@ shift_expr_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '>>' sum")); + D(fprintf(stderr, "%*c%s inversion[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'not' inversion")); } - { // sum + { // comparison if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum")); - expr_ty sum_var; + D(fprintf(stderr, "%*c> inversion[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "comparison")); + expr_ty comparison_var; if ( - (sum_var = sum_rule(p)) // sum + (comparison_var = comparison_rule(p)) // comparison ) { - D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum")); - _res = sum_var; + D(fprintf(stderr, "%*c+ inversion[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "comparison")); + _res = comparison_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum")); + D(fprintf(stderr, "%*c%s inversion[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "comparison")); } _res = NULL; done: + _PyPegen_insert_memo(p, _mark, inversion_type, _res); D(p->level--); return _res; } -// Left-recursive -// sum: sum '+' term | sum '-' term | term -static expr_ty sum_raw(Parser *); -static expr_ty -sum_rule(Parser *p) -{ - D(p->level++); - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, sum_type, &_res)) { - D(p->level--); - return _res; - } - int _mark = p->mark; - int _resmark = p->mark; - while (1) { - int tmpvar_5 = _PyPegen_update_memo(p, _mark, sum_type, _res); - if (tmpvar_5) { - D(p->level--); - return _res; - } - p->mark = _mark; - void *_raw = sum_raw(p); - if (_raw == NULL || p->mark <= _resmark) - break; - _resmark = p->mark; - _res = _raw; - } - p->mark = _resmark; - D(p->level--); - return _res; -} +// comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or static expr_ty -sum_raw(Parser *p) +comparison_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -9362,63 +9232,21 @@ sum_raw(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // sum '+' term - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '+' term")); - Token * _literal; - expr_ty a; - expr_ty b; - if ( - (a = sum_rule(p)) // sum - && - (_literal = _PyPegen_expect_token(p, 14)) // token='+' - && - (b = term_rule(p)) // term - ) - { - D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '+' term")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BinOp ( a , Add , b , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '+' term")); - } - { // sum '-' term + { // bitwise_or compare_op_bitwise_or_pair+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '-' term")); - Token * _literal; + D(fprintf(stderr, "%*c> comparison[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); expr_ty a; - expr_ty b; + asdl_seq * b; if ( - (a = sum_rule(p)) // sum - && - (_literal = _PyPegen_expect_token(p, 15)) // token='-' + (a = bitwise_or_rule(p)) // bitwise_or && - (b = term_rule(p)) // term + (b = _loop1_116_rule(p)) // compare_op_bitwise_or_pair+ ) { - D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '-' term")); + D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -9428,7 +9256,7 @@ sum_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BinOp ( a , Sub , b , EXTRA ); + _res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -9437,27 +9265,27 @@ sum_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '-' term")); + D(fprintf(stderr, "%*c%s comparison[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); } - { // term + { // bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term")); - expr_ty term_var; + D(fprintf(stderr, "%*c> comparison[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or")); + expr_ty bitwise_or_var; if ( - (term_var = term_rule(p)) // term + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term")); - _res = term_var; + D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or")); + _res = bitwise_or_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term")); + D(fprintf(stderr, "%*c%s comparison[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or")); } _res = NULL; done: @@ -9465,488 +9293,250 @@ sum_raw(Parser *p) return _res; } -// Left-recursive -// term: -// | term '*' factor -// | term '/' factor -// | term '//' factor -// | term '%' factor -// | term '@' factor -// | factor -static expr_ty term_raw(Parser *); -static expr_ty -term_rule(Parser *p) +// compare_op_bitwise_or_pair: +// | eq_bitwise_or +// | noteq_bitwise_or +// | lte_bitwise_or +// | lt_bitwise_or +// | gte_bitwise_or +// | gt_bitwise_or +// | notin_bitwise_or +// | in_bitwise_or +// | isnot_bitwise_or +// | is_bitwise_or +static CmpopExprPair* +compare_op_bitwise_or_pair_rule(Parser *p) { D(p->level++); - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, term_type, &_res)) { + if (p->error_indicator) { D(p->level--); - return _res; + return NULL; } + CmpopExprPair* _res = NULL; int _mark = p->mark; - int _resmark = p->mark; - while (1) { - int tmpvar_6 = _PyPegen_update_memo(p, _mark, term_type, _res); - if (tmpvar_6) { + { // eq_bitwise_or + if (p->error_indicator) { D(p->level--); - return _res; + return NULL; + } + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "eq_bitwise_or")); + CmpopExprPair* eq_bitwise_or_var; + if ( + (eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or + ) + { + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "eq_bitwise_or")); + _res = eq_bitwise_or_var; + goto done; } p->mark = _mark; - void *_raw = term_raw(p); - if (_raw == NULL || p->mark <= _resmark) - break; - _resmark = p->mark; - _res = _raw; - } - p->mark = _resmark; - D(p->level--); - return _res; -} -static expr_ty -term_raw(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - expr_ty _res = NULL; - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "eq_bitwise_or")); } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // term '*' factor + { // noteq_bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '*' factor")); - Token * _literal; - expr_ty a; - expr_ty b; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "noteq_bitwise_or")); + CmpopExprPair* noteq_bitwise_or_var; if ( - (a = term_rule(p)) // term - && - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (b = factor_rule(p)) // factor + (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or ) { - D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '*' factor")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BinOp ( a , Mult , b , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "noteq_bitwise_or")); + _res = noteq_bitwise_or_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '*' factor")); + D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "noteq_bitwise_or")); } - { // term '/' factor + { // lte_bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '/' factor")); - Token * _literal; - expr_ty a; - expr_ty b; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lte_bitwise_or")); + CmpopExprPair* lte_bitwise_or_var; if ( - (a = term_rule(p)) // term - && - (_literal = _PyPegen_expect_token(p, 17)) // token='/' - && - (b = factor_rule(p)) // factor + (lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or ) { - D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '/' factor")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BinOp ( a , Div , b , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lte_bitwise_or")); + _res = lte_bitwise_or_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '/' factor")); + D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lte_bitwise_or")); } - { // term '//' factor + { // lt_bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '//' factor")); - Token * _literal; - expr_ty a; - expr_ty b; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lt_bitwise_or")); + CmpopExprPair* lt_bitwise_or_var; if ( - (a = term_rule(p)) // term - && - (_literal = _PyPegen_expect_token(p, 47)) // token='//' - && - (b = factor_rule(p)) // factor + (lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or ) { - D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '//' factor")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BinOp ( a , FloorDiv , b , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lt_bitwise_or")); + _res = lt_bitwise_or_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '//' factor")); + D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lt_bitwise_or")); } - { // term '%' factor + { // gte_bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '%' factor")); - Token * _literal; - expr_ty a; - expr_ty b; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "gte_bitwise_or")); + CmpopExprPair* gte_bitwise_or_var; if ( - (a = term_rule(p)) // term - && - (_literal = _PyPegen_expect_token(p, 24)) // token='%' - && - (b = factor_rule(p)) // factor + (gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or ) { - D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '%' factor")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BinOp ( a , Mod , b , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "gte_bitwise_or")); + _res = gte_bitwise_or_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '%' factor")); + D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "gte_bitwise_or")); } - { // term '@' factor + { // gt_bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '@' factor")); - Token * _literal; - expr_ty a; - expr_ty b; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "gt_bitwise_or")); + CmpopExprPair* gt_bitwise_or_var; if ( - (a = term_rule(p)) // term - && - (_literal = _PyPegen_expect_token(p, 49)) // token='@' - && - (b = factor_rule(p)) // factor + (gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or ) { - D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '@' factor")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = CHECK_VERSION ( 5 , "The '@' operator is" , _Py_BinOp ( a , MatMult , b , EXTRA ) ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "gt_bitwise_or")); + _res = gt_bitwise_or_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '@' factor")); + D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "gt_bitwise_or")); } - { // factor + { // notin_bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "factor")); - expr_ty factor_var; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "notin_bitwise_or")); + CmpopExprPair* notin_bitwise_or_var; if ( - (factor_var = factor_rule(p)) // factor + (notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or ) { - D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "factor")); - _res = factor_var; + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "notin_bitwise_or")); + _res = notin_bitwise_or_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "factor")); + D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "notin_bitwise_or")); } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// factor: '+' factor | '-' factor | '~' factor | power -static expr_ty -factor_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, factor_type, &_res)) { - D(p->level--); - return _res; - } - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '+' factor - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+' factor")); - Token * _literal; - expr_ty a; - if ( - (_literal = _PyPegen_expect_token(p, 14)) // token='+' - && - (a = factor_rule(p)) // factor - ) - { - D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+' factor")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_UnaryOp ( UAdd , a , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+' factor")); - } - { // '-' factor + { // in_bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-' factor")); - Token * _literal; - expr_ty a; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "in_bitwise_or")); + CmpopExprPair* in_bitwise_or_var; if ( - (_literal = _PyPegen_expect_token(p, 15)) // token='-' - && - (a = factor_rule(p)) // factor + (in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or ) { - D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-' factor")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_UnaryOp ( USub , a , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "in_bitwise_or")); + _res = in_bitwise_or_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-' factor")); + D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "in_bitwise_or")); } - { // '~' factor + { // isnot_bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'~' factor")); - Token * _literal; - expr_ty a; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "isnot_bitwise_or")); + CmpopExprPair* isnot_bitwise_or_var; if ( - (_literal = _PyPegen_expect_token(p, 31)) // token='~' - && - (a = factor_rule(p)) // factor + (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or ) { - D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'~' factor")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_UnaryOp ( Invert , a , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "isnot_bitwise_or")); + _res = isnot_bitwise_or_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'~' factor")); + D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "isnot_bitwise_or")); } - { // power + { // is_bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "power")); - expr_ty power_var; + D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "is_bitwise_or")); + CmpopExprPair* is_bitwise_or_var; if ( - (power_var = power_rule(p)) // power + (is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or ) { - D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "power")); - _res = power_var; + D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "is_bitwise_or")); + _res = is_bitwise_or_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "power")); + D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "is_bitwise_or")); } _res = NULL; done: - _PyPegen_insert_memo(p, _mark, factor_type, _res); D(p->level--); return _res; } -// power: await_primary '**' factor | await_primary -static expr_ty -power_rule(Parser *p) +// eq_bitwise_or: '==' bitwise_or +static CmpopExprPair* +eq_bitwise_or_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + CmpopExprPair* _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // await_primary '**' factor + { // '==' bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> power[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "await_primary '**' factor")); + D(fprintf(stderr, "%*c> eq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or")); Token * _literal; expr_ty a; - expr_ty b; if ( - (a = await_primary_rule(p)) // await_primary - && - (_literal = _PyPegen_expect_token(p, 35)) // token='**' + (_literal = _PyPegen_expect_token(p, 27)) // token='==' && - (b = factor_rule(p)) // factor + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ power[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "await_primary '**' factor")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BinOp ( a , Pow , b , EXTRA ); + D(fprintf(stderr, "%*c+ eq_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , Eq , a ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -9955,27 +9545,52 @@ power_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s power[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "await_primary '**' factor")); + D(fprintf(stderr, "%*c%s eq_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'==' bitwise_or")); } - { // await_primary + _res = NULL; + done: + D(p->level--); + return _res; +} + +// noteq_bitwise_or: ('!=') bitwise_or +static CmpopExprPair* +noteq_bitwise_or_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + CmpopExprPair* _res = NULL; + int _mark = p->mark; + { // ('!=') bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> power[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "await_primary")); - expr_ty await_primary_var; + D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); + void *_tmp_117_var; + expr_ty a; if ( - (await_primary_var = await_primary_rule(p)) // await_primary + (_tmp_117_var = _tmp_117_rule(p)) // '!=' + && + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ power[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "await_primary")); - _res = await_primary_var; + D(fprintf(stderr, "%*c+ noteq_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , NotEq , a ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s power[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "await_primary")); + D(fprintf(stderr, "%*c%s noteq_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('!=') bitwise_or")); } _res = NULL; done: @@ -9983,55 +9598,33 @@ power_rule(Parser *p) return _res; } -// await_primary: AWAIT primary | primary -static expr_ty -await_primary_rule(Parser *p) +// lte_bitwise_or: '<=' bitwise_or +static CmpopExprPair* +lte_bitwise_or_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, await_primary_type, &_res)) { - D(p->level--); - return _res; - } + CmpopExprPair* _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // AWAIT primary + { // '<=' bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> await_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "AWAIT primary")); + D(fprintf(stderr, "%*c> lte_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or")); + Token * _literal; expr_ty a; - Token * await_var; if ( - (await_var = _PyPegen_expect_token(p, AWAIT)) // token='AWAIT' + (_literal = _PyPegen_expect_token(p, 29)) // token='<=' && - (a = primary_rule(p)) // primary + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ await_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "AWAIT primary")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) ); + D(fprintf(stderr, "%*c+ lte_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , LtE , a ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -10040,118 +9633,130 @@ await_primary_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s await_primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "AWAIT primary")); + D(fprintf(stderr, "%*c%s lte_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<=' bitwise_or")); } - { // primary + _res = NULL; + done: + D(p->level--); + return _res; +} + +// lt_bitwise_or: '<' bitwise_or +static CmpopExprPair* +lt_bitwise_or_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + CmpopExprPair* _res = NULL; + int _mark = p->mark; + { // '<' bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> await_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary")); - expr_ty primary_var; + D(fprintf(stderr, "%*c> lt_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or")); + Token * _literal; + expr_ty a; if ( - (primary_var = primary_rule(p)) // primary + (_literal = _PyPegen_expect_token(p, 20)) // token='<' + && + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ await_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary")); - _res = primary_var; + D(fprintf(stderr, "%*c+ lt_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , Lt , a ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s await_primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary")); + D(fprintf(stderr, "%*c%s lt_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<' bitwise_or")); } _res = NULL; done: - _PyPegen_insert_memo(p, _mark, await_primary_type, _res); D(p->level--); return _res; } -// Left-recursive -// primary: -// | primary '.' NAME -// | primary genexp -// | primary '(' arguments? ')' -// | primary '[' slices ']' -// | atom -static expr_ty primary_raw(Parser *); -static expr_ty -primary_rule(Parser *p) +// gte_bitwise_or: '>=' bitwise_or +static CmpopExprPair* +gte_bitwise_or_rule(Parser *p) { D(p->level++); - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, primary_type, &_res)) { + if (p->error_indicator) { D(p->level--); - return _res; + return NULL; } + CmpopExprPair* _res = NULL; int _mark = p->mark; - int _resmark = p->mark; - while (1) { - int tmpvar_7 = _PyPegen_update_memo(p, _mark, primary_type, _res); - if (tmpvar_7) { + { // '>=' bitwise_or + if (p->error_indicator) { D(p->level--); - return _res; + return NULL; + } + D(fprintf(stderr, "%*c> gte_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or")); + Token * _literal; + expr_ty a; + if ( + (_literal = _PyPegen_expect_token(p, 30)) // token='>=' + && + (a = bitwise_or_rule(p)) // bitwise_or + ) + { + D(fprintf(stderr, "%*c+ gte_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , GtE , a ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; } p->mark = _mark; - void *_raw = primary_raw(p); - if (_raw == NULL || p->mark <= _resmark) - break; - _resmark = p->mark; - _res = _raw; + D(fprintf(stderr, "%*c%s gte_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>=' bitwise_or")); } - p->mark = _resmark; + _res = NULL; + done: D(p->level--); return _res; } -static expr_ty -primary_raw(Parser *p) + +// gt_bitwise_or: '>' bitwise_or +static CmpopExprPair* +gt_bitwise_or_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + CmpopExprPair* _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // primary '.' NAME + { // '>' bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '.' NAME")); + D(fprintf(stderr, "%*c> gt_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or")); Token * _literal; expr_ty a; - expr_ty b; if ( - (a = primary_rule(p)) // primary - && - (_literal = _PyPegen_expect_token(p, 23)) // token='.' + (_literal = _PyPegen_expect_token(p, 21)) // token='>' && - (b = _PyPegen_name_token(p)) // NAME + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '.' NAME")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); + D(fprintf(stderr, "%*c+ gt_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , Gt , a ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -10160,34 +9765,45 @@ primary_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '.' NAME")); + D(fprintf(stderr, "%*c%s gt_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>' bitwise_or")); } - { // primary genexp + _res = NULL; + done: + D(p->level--); + return _res; +} + +// notin_bitwise_or: 'not' 'in' bitwise_or +static CmpopExprPair* +notin_bitwise_or_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + CmpopExprPair* _res = NULL; + int _mark = p->mark; + { // 'not' 'in' bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary genexp")); + D(fprintf(stderr, "%*c> notin_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or")); + Token * _keyword; + Token * _keyword_1; expr_ty a; - expr_ty b; if ( - (a = primary_rule(p)) // primary + (_keyword = _PyPegen_expect_token(p, 528)) // token='not' && - (b = genexp_rule(p)) // genexp + (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' + && + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary genexp")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); + D(fprintf(stderr, "%*c+ notin_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , NotIn , a ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -10196,40 +9812,42 @@ primary_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary genexp")); + D(fprintf(stderr, "%*c%s notin_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'not' 'in' bitwise_or")); } - { // primary '(' arguments? ')' + _res = NULL; + done: + D(p->level--); + return _res; +} + +// in_bitwise_or: 'in' bitwise_or +static CmpopExprPair* +in_bitwise_or_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + CmpopExprPair* _res = NULL; + int _mark = p->mark; + { // 'in' bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '(' arguments? ')'")); - Token * _literal; - Token * _literal_1; + D(fprintf(stderr, "%*c> in_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or")); + Token * _keyword; expr_ty a; - void *b; if ( - (a = primary_rule(p)) // primary - && - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (b = arguments_rule(p), 1) // arguments? + (_keyword = _PyPegen_expect_token(p, 518)) // token='in' && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '(' arguments? ')'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); + D(fprintf(stderr, "%*c+ in_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , In , a ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -10238,40 +9856,45 @@ primary_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '(' arguments? ')'")); + D(fprintf(stderr, "%*c%s in_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'in' bitwise_or")); } - { // primary '[' slices ']' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '[' slices ']'")); - Token * _literal; - Token * _literal_1; + _res = NULL; + done: + D(p->level--); + return _res; +} + +// isnot_bitwise_or: 'is' 'not' bitwise_or +static CmpopExprPair* +isnot_bitwise_or_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + CmpopExprPair* _res = NULL; + int _mark = p->mark; + { // 'is' 'not' bitwise_or + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> isnot_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or")); + Token * _keyword; + Token * _keyword_1; expr_ty a; - expr_ty b; if ( - (a = primary_rule(p)) // primary - && - (_literal = _PyPegen_expect_token(p, 9)) // token='[' + (_keyword = _PyPegen_expect_token(p, 529)) // token='is' && - (b = slices_rule(p)) // slices + (_keyword_1 = _PyPegen_expect_token(p, 528)) // token='not' && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '[' slices ']'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Subscript ( a , b , Load , EXTRA ); + D(fprintf(stderr, "%*c+ isnot_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , IsNot , a ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -10280,27 +9903,52 @@ primary_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '[' slices ']'")); + D(fprintf(stderr, "%*c%s isnot_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' 'not' bitwise_or")); } - { // atom + _res = NULL; + done: + D(p->level--); + return _res; +} + +// is_bitwise_or: 'is' bitwise_or +static CmpopExprPair* +is_bitwise_or_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + CmpopExprPair* _res = NULL; + int _mark = p->mark; + { // 'is' bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "atom")); - expr_ty atom_var; + D(fprintf(stderr, "%*c> is_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or")); + Token * _keyword; + expr_ty a; if ( - (atom_var = atom_rule(p)) // atom + (_keyword = _PyPegen_expect_token(p, 529)) // token='is' + && + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "atom")); - _res = atom_var; + D(fprintf(stderr, "%*c+ is_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or")); + _res = _PyPegen_cmpop_expr_pair ( p , Is , a ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "atom")); + D(fprintf(stderr, "%*c%s is_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' bitwise_or")); } _res = NULL; done: @@ -10308,9 +9956,39 @@ primary_raw(Parser *p) return _res; } -// slices: slice !',' | ','.slice+ ','? +// Left-recursive +// bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor +static expr_ty bitwise_or_raw(Parser *); static expr_ty -slices_rule(Parser *p) +bitwise_or_rule(Parser *p) +{ + D(p->level++); + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, bitwise_or_type, &_res)) { + D(p->level--); + return _res; + } + int _mark = p->mark; + int _resmark = p->mark; + while (1) { + int tmpvar_1 = _PyPegen_update_memo(p, _mark, bitwise_or_type, _res); + if (tmpvar_1) { + D(p->level--); + return _res; + } + p->mark = _mark; + void *_raw = bitwise_or_raw(p); + if (_raw == NULL || p->mark <= _resmark) + break; + _resmark = p->mark; + _res = _raw; + } + p->mark = _resmark; + D(p->level--); + return _res; +} +static expr_ty +bitwise_or_raw(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -10328,21 +10006,34 @@ slices_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // slice !',' + { // bitwise_or '|' bitwise_xor if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> slices[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice !','")); + D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor")); + Token * _literal; expr_ty a; + expr_ty b; if ( - (a = slice_rule(p)) // slice + (a = bitwise_or_rule(p)) // bitwise_or && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' + (_literal = _PyPegen_expect_token(p, 18)) // token='|' + && + (b = bitwise_xor_rule(p)) // bitwise_xor ) { - D(fprintf(stderr, "%*c+ slices[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice !','")); - _res = a; + D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_BinOp ( a , BitOr , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -10351,45 +10042,27 @@ slices_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s slices[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice !','")); + D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or '|' bitwise_xor")); } - { // ','.slice+ ','? + { // bitwise_xor if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> slices[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.slice+ ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - asdl_seq * a; + D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor")); + expr_ty bitwise_xor_var; if ( - (a = _gather_93_rule(p)) // ','.slice+ - && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor ) { - D(fprintf(stderr, "%*c+ slices[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.slice+ ','?")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( a , Load , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor")); + _res = bitwise_xor_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s slices[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.slice+ ','?")); + D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor")); } _res = NULL; done: @@ -10397,9 +10070,39 @@ slices_rule(Parser *p) return _res; } -// slice: expression? ':' expression? [':' expression?] | expression +// Left-recursive +// bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and +static expr_ty bitwise_xor_raw(Parser *); static expr_ty -slice_rule(Parser *p) +bitwise_xor_rule(Parser *p) +{ + D(p->level++); + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, bitwise_xor_type, &_res)) { + D(p->level--); + return _res; + } + int _mark = p->mark; + int _resmark = p->mark; + while (1) { + int tmpvar_2 = _PyPegen_update_memo(p, _mark, bitwise_xor_type, _res); + if (tmpvar_2) { + D(p->level--); + return _res; + } + p->mark = _mark; + void *_raw = bitwise_xor_raw(p); + if (_raw == NULL || p->mark <= _resmark) + break; + _resmark = p->mark; + _res = _raw; + } + p->mark = _resmark; + D(p->level--); + return _res; +} +static expr_ty +bitwise_xor_raw(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -10417,27 +10120,24 @@ slice_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // expression? ':' expression? [':' expression?] + { // bitwise_xor '^' bitwise_and if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> slice[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); + D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and")); Token * _literal; - void *a; - void *b; - void *c; + expr_ty a; + expr_ty b; if ( - (a = expression_rule(p), 1) // expression? - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' + (a = bitwise_xor_rule(p)) // bitwise_xor && - (b = expression_rule(p), 1) // expression? + (_literal = _PyPegen_expect_token(p, 32)) // token='^' && - (c = _tmp_95_rule(p), 1) // [':' expression?] + (b = bitwise_and_rule(p)) // bitwise_and ) { - D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); + D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -10447,7 +10147,7 @@ slice_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Slice ( a , b , c , EXTRA ); + _res = _Py_BinOp ( a , BitXor , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -10456,32 +10156,27 @@ slice_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s slice[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression? ':' expression? [':' expression?]")); + D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor '^' bitwise_and")); } - { // expression + { // bitwise_and if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> slice[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression")); - expr_ty a; + D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and")); + expr_ty bitwise_and_var; if ( - (a = expression_rule(p)) // expression + (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and ) { - D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression")); - _res = a; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and")); + _res = bitwise_and_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s slice[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression")); + D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and")); } _res = NULL; done: @@ -10489,20 +10184,39 @@ slice_rule(Parser *p) return _res; } -// atom: -// | NAME -// | 'True' -// | 'False' -// | 'None' -// | '__new_parser__' -// | &STRING strings -// | NUMBER -// | &'(' (tuple | group | genexp) -// | &'[' (list | listcomp) -// | &'{' (dict | set | dictcomp | setcomp) -// | '...' +// Left-recursive +// bitwise_and: bitwise_and '&' shift_expr | shift_expr +static expr_ty bitwise_and_raw(Parser *); static expr_ty -atom_rule(Parser *p) +bitwise_and_rule(Parser *p) +{ + D(p->level++); + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, bitwise_and_type, &_res)) { + D(p->level--); + return _res; + } + int _mark = p->mark; + int _resmark = p->mark; + while (1) { + int tmpvar_3 = _PyPegen_update_memo(p, _mark, bitwise_and_type, _res); + if (tmpvar_3) { + D(p->level--); + return _res; + } + p->mark = _mark; + void *_raw = bitwise_and_raw(p); + if (_raw == NULL || p->mark <= _resmark) + break; + _resmark = p->mark; + _res = _raw; + } + p->mark = _resmark; + D(p->level--); + return _res; +} +static expr_ty +bitwise_and_raw(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -10520,37 +10234,24 @@ atom_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); - expr_ty name_var; - if ( - (name_var = _PyPegen_name_token(p)) // NAME - ) - { - D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); - _res = name_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); - } - { // 'True' + { // bitwise_and '&' shift_expr if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); - Token * _keyword; + D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr")); + Token * _literal; + expr_ty a; + expr_ty b; if ( - (_keyword = _PyPegen_expect_token(p, 527)) // token='True' + (a = bitwise_and_rule(p)) // bitwise_and + && + (_literal = _PyPegen_expect_token(p, 19)) // token='&' + && + (b = shift_expr_rule(p)) // shift_expr ) { - D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); + D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -10560,7 +10261,7 @@ atom_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Constant ( Py_True , NULL , EXTRA ); + _res = _Py_BinOp ( a , BitAnd , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -10569,54 +10270,102 @@ atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); + D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and '&' shift_expr")); } - { // 'False' + { // shift_expr if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); - Token * _keyword; + D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr")); + expr_ty shift_expr_var; if ( - (_keyword = _PyPegen_expect_token(p, 528)) // token='False' + (shift_expr_var = shift_expr_rule(p)) // shift_expr ) { - D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Constant ( Py_False , NULL , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr")); + _res = shift_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); + D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr")); } - { // 'None' + _res = NULL; + done: + D(p->level--); + return _res; +} + +// Left-recursive +// shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum +static expr_ty shift_expr_raw(Parser *); +static expr_ty +shift_expr_rule(Parser *p) +{ + D(p->level++); + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, shift_expr_type, &_res)) { + D(p->level--); + return _res; + } + int _mark = p->mark; + int _resmark = p->mark; + while (1) { + int tmpvar_4 = _PyPegen_update_memo(p, _mark, shift_expr_type, _res); + if (tmpvar_4) { + D(p->level--); + return _res; + } + p->mark = _mark; + void *_raw = shift_expr_raw(p); + if (_raw == NULL || p->mark <= _resmark) + break; + _resmark = p->mark; + _res = _raw; + } + p->mark = _resmark; + D(p->level--); + return _res; +} +static expr_ty +shift_expr_raw(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // shift_expr '<<' sum if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); - Token * _keyword; + D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum")); + Token * _literal; + expr_ty a; + expr_ty b; if ( - (_keyword = _PyPegen_expect_token(p, 529)) // token='None' + (a = shift_expr_rule(p)) // shift_expr + && + (_literal = _PyPegen_expect_token(p, 33)) // token='<<' + && + (b = sum_rule(p)) // sum ) { - D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); + D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -10626,7 +10375,7 @@ atom_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Constant ( Py_None , NULL , EXTRA ); + _res = _Py_BinOp ( a , LShift , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -10635,22 +10384,37 @@ atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); + D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '<<' sum")); } - { // '__new_parser__' + { // shift_expr '>>' sum if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'__new_parser__'")); - Token * _keyword; + D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum")); + Token * _literal; + expr_ty a; + expr_ty b; if ( - (_keyword = _PyPegen_expect_token(p, 530)) // token='__new_parser__' + (a = shift_expr_rule(p)) // shift_expr + && + (_literal = _PyPegen_expect_token(p, 34)) // token='>>' + && + (b = sum_rule(p)) // sum ) { - D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'__new_parser__'")); - _res = RAISE_SYNTAX_ERROR ( "You found it!" ); + D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_BinOp ( a , RShift , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -10659,144 +10423,27 @@ atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'__new_parser__'")); + D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '>>' sum")); } - { // &STRING strings + { // sum if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&STRING strings")); - expr_ty strings_var; + D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum")); + expr_ty sum_var; if ( - _PyPegen_lookahead(1, _PyPegen_string_token, p) - && - (strings_var = strings_rule(p)) // strings + (sum_var = sum_rule(p)) // sum ) { - D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&STRING strings")); - _res = strings_var; + D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum")); + _res = sum_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&STRING strings")); - } - { // NUMBER - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NUMBER")); - expr_ty number_var; - if ( - (number_var = _PyPegen_number_token(p)) // NUMBER - ) - { - D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NUMBER")); - _res = number_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER")); - } - { // &'(' (tuple | group | genexp) - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - void *_tmp_96_var; - if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' - && - (_tmp_96_var = _tmp_96_rule(p)) // tuple | group | genexp - ) - { - D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - _res = _tmp_96_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'(' (tuple | group | genexp)")); - } - { // &'[' (list | listcomp) - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - void *_tmp_97_var; - if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' - && - (_tmp_97_var = _tmp_97_rule(p)) // list | listcomp - ) - { - D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - _res = _tmp_97_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'[' (list | listcomp)")); - } - { // &'{' (dict | set | dictcomp | setcomp) - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - void *_tmp_98_var; - if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' - && - (_tmp_98_var = _tmp_98_rule(p)) // dict | set | dictcomp | setcomp - ) - { - D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - _res = _tmp_98_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - } - { // '...' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 52)) // token='...' - ) - { - D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum")); } _res = NULL; done: @@ -10804,55 +10451,39 @@ atom_rule(Parser *p) return _res; } -// strings: STRING+ +// Left-recursive +// sum: sum '+' term | sum '-' term | term +static expr_ty sum_raw(Parser *); static expr_ty -strings_rule(Parser *p) +sum_rule(Parser *p) { D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, strings_type, &_res)) { + if (_PyPegen_is_memoized(p, sum_type, &_res)) { D(p->level--); return _res; } int _mark = p->mark; - { // STRING+ - if (p->error_indicator) { + int _resmark = p->mark; + while (1) { + int tmpvar_5 = _PyPegen_update_memo(p, _mark, sum_type, _res); + if (tmpvar_5) { D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+")); - asdl_seq * a; - if ( - (a = _loop1_99_rule(p)) // STRING+ - ) - { - D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+")); - _res = _PyPegen_concatenate_strings ( p , a ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; + return _res; } p->mark = _mark; - D(fprintf(stderr, "%*c%s strings[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING+")); + void *_raw = sum_raw(p); + if (_raw == NULL || p->mark <= _resmark) + break; + _resmark = p->mark; + _res = _raw; } - _res = NULL; - done: - _PyPegen_insert_memo(p, _mark, strings_type, _res); + p->mark = _resmark; D(p->level--); return _res; } - -// list: '[' star_named_expressions? ']' static expr_ty -list_rule(Parser *p) +sum_raw(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -10870,24 +10501,24 @@ list_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '[' star_named_expressions? ']' + { // sum '+' term if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> list[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' star_named_expressions? ']'")); + D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '+' term")); Token * _literal; - Token * _literal_1; - void *a; + expr_ty a; + expr_ty b; if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' + (a = sum_rule(p)) // sum && - (a = star_named_expressions_rule(p), 1) // star_named_expressions? + (_literal = _PyPegen_expect_token(p, 14)) // token='+' && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + (b = term_rule(p)) // term ) { - D(fprintf(stderr, "%*c+ list[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' star_named_expressions? ']'")); + D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '+' term")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -10897,7 +10528,7 @@ list_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_List ( a , Load , EXTRA ); + _res = _Py_BinOp ( a , Add , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -10906,56 +10537,27 @@ list_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s list[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' star_named_expressions? ']'")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension -static expr_ty -listcomp_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - expr_ty _res = NULL; - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '+' term")); } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '[' named_expression for_if_clauses ']' + { // sum '-' term if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> listcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' named_expression for_if_clauses ']'")); + D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '-' term")); Token * _literal; - Token * _literal_1; expr_ty a; - asdl_seq* b; + expr_ty b; if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - && - (a = named_expression_rule(p)) // named_expression + (a = sum_rule(p)) // sum && - (b = for_if_clauses_rule(p)) // for_if_clauses + (_literal = _PyPegen_expect_token(p, 15)) // token='-' && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + (b = term_rule(p)) // term ) { - D(fprintf(stderr, "%*c+ listcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' named_expression for_if_clauses ']'")); + D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '-' term")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -10965,7 +10567,7 @@ listcomp_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_ListComp ( a , b , EXTRA ); + _res = _Py_BinOp ( a , Sub , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -10974,27 +10576,27 @@ listcomp_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s listcomp[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' named_expression for_if_clauses ']'")); + D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '-' term")); } - { // invalid_comprehension + { // term if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> listcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); - void *invalid_comprehension_var; + D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term")); + expr_ty term_var; if ( - (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension + (term_var = term_rule(p)) // term ) { - D(fprintf(stderr, "%*c+ listcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); - _res = invalid_comprehension_var; + D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term")); + _res = term_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s listcomp[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension")); + D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term")); } _res = NULL; done: @@ -11002,18 +10604,54 @@ listcomp_rule(Parser *p) return _res; } -// tuple: '(' [star_named_expression ',' star_named_expressions?] ')' +// Left-recursive +// term: +// | term '*' factor +// | term '/' factor +// | term '//' factor +// | term '%' factor +// | term '@' factor +// | factor +static expr_ty term_raw(Parser *); static expr_ty -tuple_rule(Parser *p) +term_rule(Parser *p) { D(p->level++); - if (p->error_indicator) { + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, term_type, &_res)) { D(p->level--); - return NULL; + return _res; } - expr_ty _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + int _resmark = p->mark; + while (1) { + int tmpvar_6 = _PyPegen_update_memo(p, _mark, term_type, _res); + if (tmpvar_6) { + D(p->level--); + return _res; + } + p->mark = _mark; + void *_raw = term_raw(p); + if (_raw == NULL || p->mark <= _resmark) + break; + _resmark = p->mark; + _res = _raw; + } + p->mark = _resmark; + D(p->level--); + return _res; +} +static expr_ty +term_raw(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; D(p->level--); return NULL; @@ -11022,24 +10660,24 @@ tuple_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '(' [star_named_expression ',' star_named_expressions?] ')' + { // term '*' factor if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> tuple[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'")); + D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '*' factor")); Token * _literal; - Token * _literal_1; - void *a; + expr_ty a; + expr_ty b; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' + (a = term_rule(p)) // term && - (a = _tmp_100_rule(p), 1) // [star_named_expression ',' star_named_expressions?] + (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (b = factor_rule(p)) // factor ) { - D(fprintf(stderr, "%*c+ tuple[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'")); + D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '*' factor")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -11049,7 +10687,7 @@ tuple_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( a , Load , EXTRA ); + _res = _Py_BinOp ( a , Mult , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -11058,45 +10696,37 @@ tuple_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s tuple[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// group: '(' (yield_expr | named_expression) ')' -static expr_ty -group_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '*' factor")); } - expr_ty _res = NULL; - int _mark = p->mark; - { // '(' (yield_expr | named_expression) ')' + { // term '/' factor if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> group[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' (yield_expr | named_expression) ')'")); + D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '/' factor")); Token * _literal; - Token * _literal_1; - void *a; + expr_ty a; + expr_ty b; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' + (a = term_rule(p)) // term && - (a = _tmp_101_rule(p)) // yield_expr | named_expression + (_literal = _PyPegen_expect_token(p, 17)) // token='/' && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (b = factor_rule(p)) // factor ) { - D(fprintf(stderr, "%*c+ group[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' (yield_expr | named_expression) ')'")); - _res = a; + D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '/' factor")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_BinOp ( a , Div , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -11105,56 +10735,27 @@ group_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s group[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' (yield_expr | named_expression) ')'")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// genexp: '(' expression for_if_clauses ')' | invalid_comprehension -static expr_ty -genexp_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - expr_ty _res = NULL; - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '/' factor")); } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '(' expression for_if_clauses ')' + { // term '//' factor if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' expression for_if_clauses ')'")); + D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '//' factor")); Token * _literal; - Token * _literal_1; expr_ty a; - asdl_seq* b; + expr_ty b; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (a = expression_rule(p)) // expression + (a = term_rule(p)) // term && - (b = for_if_clauses_rule(p)) // for_if_clauses + (_literal = _PyPegen_expect_token(p, 47)) // token='//' && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (b = factor_rule(p)) // factor ) { - D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' expression for_if_clauses ')'")); + D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '//' factor")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -11164,7 +10765,7 @@ genexp_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_GeneratorExp ( a , b , EXTRA ); + _res = _Py_BinOp ( a , FloorDiv , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -11173,72 +10774,66 @@ genexp_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s genexp[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' expression for_if_clauses ')'")); + D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '//' factor")); } - { // invalid_comprehension + { // term '%' factor if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); - void *invalid_comprehension_var; + D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '%' factor")); + Token * _literal; + expr_ty a; + expr_ty b; if ( - (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension + (a = term_rule(p)) // term + && + (_literal = _PyPegen_expect_token(p, 24)) // token='%' + && + (b = factor_rule(p)) // factor ) { - D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); - _res = invalid_comprehension_var; + D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '%' factor")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_BinOp ( a , Mod , b , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s genexp[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// set: '{' expressions_list '}' -static expr_ty -set_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - expr_ty _res = NULL; - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '%' factor")); } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '{' expressions_list '}' + { // term '@' factor if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> set[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' expressions_list '}'")); + D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '@' factor")); Token * _literal; - Token * _literal_1; - asdl_seq* a; + expr_ty a; + expr_ty b; if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' + (a = term_rule(p)) // term && - (a = expressions_list_rule(p)) // expressions_list + (_literal = _PyPegen_expect_token(p, 49)) // token='@' && - (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' + (b = factor_rule(p)) // factor ) { - D(fprintf(stderr, "%*c+ set[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' expressions_list '}'")); + D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '@' factor")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -11248,7 +10843,7 @@ set_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Set ( a , EXTRA ); + _res = CHECK_VERSION ( 5 , "The '@' operator is" , _Py_BinOp ( a , MatMult , b , EXTRA ) ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -11257,8 +10852,27 @@ set_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s set[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' expressions_list '}'")); + D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '@' factor")); + } + { // factor + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "factor")); + expr_ty factor_var; + if ( + (factor_var = factor_rule(p)) // factor + ) + { + D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "factor")); + _res = factor_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "factor")); } _res = NULL; done: @@ -11266,9 +10880,9 @@ set_rule(Parser *p) return _res; } -// setcomp: '{' expression for_if_clauses '}' | invalid_comprehension +// factor: '+' factor | '-' factor | '~' factor | power static expr_ty -setcomp_rule(Parser *p) +factor_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -11276,9 +10890,13 @@ setcomp_rule(Parser *p) return NULL; } expr_ty _res = NULL; - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; + if (_PyPegen_is_memoized(p, factor_type, &_res)) { + D(p->level--); + return _res; + } + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; D(p->level--); return NULL; } @@ -11286,27 +10904,93 @@ setcomp_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '{' expression for_if_clauses '}' + { // '+' factor if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> setcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' expression for_if_clauses '}'")); + D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+' factor")); Token * _literal; - Token * _literal_1; expr_ty a; - asdl_seq* b; if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' + (_literal = _PyPegen_expect_token(p, 14)) // token='+' && - (a = expression_rule(p)) // expression + (a = factor_rule(p)) // factor + ) + { + D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+' factor")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_UnaryOp ( UAdd , a , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+' factor")); + } + { // '-' factor + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-' factor")); + Token * _literal; + expr_ty a; + if ( + (_literal = _PyPegen_expect_token(p, 15)) // token='-' && - (b = for_if_clauses_rule(p)) // for_if_clauses + (a = factor_rule(p)) // factor + ) + { + D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-' factor")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_UnaryOp ( USub , a , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-' factor")); + } + { // '~' factor + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'~' factor")); + Token * _literal; + expr_ty a; + if ( + (_literal = _PyPegen_expect_token(p, 31)) // token='~' && - (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' + (a = factor_rule(p)) // factor ) { - D(fprintf(stderr, "%*c+ setcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' expression for_if_clauses '}'")); + D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'~' factor")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -11316,7 +11000,7 @@ setcomp_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_SetComp ( a , b , EXTRA ); + _res = _Py_UnaryOp ( Invert , a , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -11325,37 +11009,38 @@ setcomp_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s setcomp[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' expression for_if_clauses '}'")); + D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'~' factor")); } - { // invalid_comprehension + { // power if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> setcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); - void *invalid_comprehension_var; + D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "power")); + expr_ty power_var; if ( - (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension + (power_var = power_rule(p)) // power ) { - D(fprintf(stderr, "%*c+ setcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); - _res = invalid_comprehension_var; + D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "power")); + _res = power_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s setcomp[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension")); + D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "power")); } _res = NULL; done: + _PyPegen_insert_memo(p, _mark, factor_type, _res); D(p->level--); return _res; } -// dict: '{' double_starred_kvpairs? '}' +// power: await_primary '**' factor | await_primary static expr_ty -dict_rule(Parser *p) +power_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -11373,24 +11058,24 @@ dict_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '{' double_starred_kvpairs? '}' + { // await_primary '**' factor if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> dict[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' double_starred_kvpairs? '}'")); + D(fprintf(stderr, "%*c> power[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "await_primary '**' factor")); Token * _literal; - Token * _literal_1; - void *a; + expr_ty a; + expr_ty b; if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' + (a = await_primary_rule(p)) // await_primary && - (a = double_starred_kvpairs_rule(p), 1) // double_starred_kvpairs? + (_literal = _PyPegen_expect_token(p, 35)) // token='**' && - (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' + (b = factor_rule(p)) // factor ) { - D(fprintf(stderr, "%*c+ dict[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' double_starred_kvpairs? '}'")); + D(fprintf(stderr, "%*c+ power[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "await_primary '**' factor")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -11400,7 +11085,7 @@ dict_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA ); + _res = _Py_BinOp ( a , Pow , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -11409,8 +11094,27 @@ dict_rule(Parser *p) 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, "'{' double_starred_kvpairs? '}'")); + D(fprintf(stderr, "%*c%s power[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "await_primary '**' factor")); + } + { // await_primary + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> power[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "await_primary")); + expr_ty await_primary_var; + if ( + (await_primary_var = await_primary_rule(p)) // await_primary + ) + { + D(fprintf(stderr, "%*c+ power[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "await_primary")); + _res = await_primary_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s power[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "await_primary")); } _res = NULL; done: @@ -11418,9 +11122,9 @@ dict_rule(Parser *p) return _res; } -// dictcomp: '{' kvpair for_if_clauses '}' | invalid_dict_comprehension +// await_primary: AWAIT primary | primary static expr_ty -dictcomp_rule(Parser *p) +await_primary_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -11428,6 +11132,10 @@ dictcomp_rule(Parser *p) return NULL; } expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, await_primary_type, &_res)) { + D(p->level--); + return _res; + } int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -11438,27 +11146,21 @@ dictcomp_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '{' kvpair for_if_clauses '}' + { // AWAIT primary if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> dictcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' kvpair for_if_clauses '}'")); - Token * _literal; - Token * _literal_1; - KeyValuePair* a; - asdl_seq* b; + D(fprintf(stderr, "%*c> await_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "AWAIT primary")); + expr_ty a; + Token * await_var; if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (a = kvpair_rule(p)) // kvpair - && - (b = for_if_clauses_rule(p)) // for_if_clauses + (await_var = _PyPegen_expect_token(p, AWAIT)) // token='AWAIT' && - (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' + (a = primary_rule(p)) // primary ) { - D(fprintf(stderr, "%*c+ dictcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' kvpair for_if_clauses '}'")); + D(fprintf(stderr, "%*c+ await_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "AWAIT primary")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -11468,7 +11170,7 @@ dictcomp_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_DictComp ( a -> key , a -> value , b , EXTRA ); + _res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -11477,106 +11179,118 @@ dictcomp_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s dictcomp[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' kvpair for_if_clauses '}'")); + D(fprintf(stderr, "%*c%s await_primary[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "AWAIT primary")); } - { // invalid_dict_comprehension + { // primary if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> dictcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_dict_comprehension")); - void *invalid_dict_comprehension_var; + D(fprintf(stderr, "%*c> await_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary")); + expr_ty primary_var; if ( - (invalid_dict_comprehension_var = invalid_dict_comprehension_rule(p)) // invalid_dict_comprehension + (primary_var = primary_rule(p)) // primary ) { - D(fprintf(stderr, "%*c+ dictcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_dict_comprehension")); - _res = invalid_dict_comprehension_var; + D(fprintf(stderr, "%*c+ await_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary")); + _res = primary_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s dictcomp[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_dict_comprehension")); + D(fprintf(stderr, "%*c%s await_primary[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary")); } _res = NULL; done: + _PyPegen_insert_memo(p, _mark, await_primary_type, _res); D(p->level--); return _res; } -// double_starred_kvpairs: ','.double_starred_kvpair+ ','? -static asdl_seq* -double_starred_kvpairs_rule(Parser *p) +// Left-recursive +// primary: +// | primary '.' NAME +// | primary genexp +// | primary '(' arguments? ')' +// | primary '[' slices ']' +// | atom +static expr_ty primary_raw(Parser *); +static expr_ty +primary_rule(Parser *p) { D(p->level++); - if (p->error_indicator) { + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, primary_type, &_res)) { D(p->level--); - return NULL; + return _res; } - asdl_seq* _res = NULL; int _mark = p->mark; - { // ','.double_starred_kvpair+ ','? - if (p->error_indicator) { + int _resmark = p->mark; + while (1) { + int tmpvar_7 = _PyPegen_update_memo(p, _mark, primary_type, _res); + if (tmpvar_7) { D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - asdl_seq * a; - if ( - (a = _gather_102_rule(p)) // ','.double_starred_kvpair+ - && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? - ) - { - D(fprintf(stderr, "%*c+ double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ','?")); - _res = a; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; + return _res; } p->mark = _mark; - D(fprintf(stderr, "%*c%s double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.double_starred_kvpair+ ','?")); + void *_raw = primary_raw(p); + if (_raw == NULL || p->mark <= _resmark) + break; + _resmark = p->mark; + _res = _raw; } - _res = NULL; - done: + p->mark = _resmark; D(p->level--); return _res; } - -// double_starred_kvpair: '**' bitwise_or | kvpair -static KeyValuePair* -double_starred_kvpair_rule(Parser *p) +static expr_ty +primary_raw(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - KeyValuePair* _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; - { // '**' bitwise_or + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // primary '.' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> double_starred_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or")); + D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '.' NAME")); Token * _literal; expr_ty a; + expr_ty b; if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' + (a = primary_rule(p)) // primary && - (a = bitwise_or_rule(p)) // bitwise_or + (_literal = _PyPegen_expect_token(p, 23)) // token='.' + && + (b = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ double_starred_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or")); - _res = _PyPegen_key_value_pair ( p , NULL , a ); + D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '.' NAME")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -11585,64 +11299,118 @@ double_starred_kvpair_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s double_starred_kvpair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' bitwise_or")); + D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '.' NAME")); } - { // kvpair + { // primary genexp if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> double_starred_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kvpair")); - KeyValuePair* kvpair_var; + D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary genexp")); + expr_ty a; + expr_ty b; if ( - (kvpair_var = kvpair_rule(p)) // kvpair + (a = primary_rule(p)) // primary + && + (b = genexp_rule(p)) // genexp ) { - D(fprintf(stderr, "%*c+ double_starred_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kvpair")); - _res = kvpair_var; + D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary genexp")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s double_starred_kvpair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kvpair")); + D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary genexp")); } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// kvpair: expression ':' expression -static KeyValuePair* -kvpair_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + { // primary '(' arguments? ')' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '(' arguments? ')'")); + Token * _literal; + Token * _literal_1; + expr_ty a; + void *b; + if ( + (a = primary_rule(p)) // primary + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (b = arguments_rule(p), 1) // arguments? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '(' arguments? ')'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '(' arguments? ')'")); } - KeyValuePair* _res = NULL; - int _mark = p->mark; - { // expression ':' expression + { // primary '[' slices ']' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' expression")); + D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '[' slices ']'")); Token * _literal; + Token * _literal_1; expr_ty a; expr_ty b; if ( - (a = expression_rule(p)) // expression + (a = primary_rule(p)) // primary && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' + (_literal = _PyPegen_expect_token(p, 9)) // token='[' && - (b = expression_rule(p)) // expression + (b = slices_rule(p)) // slices + && + (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' ) { - D(fprintf(stderr, "%*c+ kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression")); - _res = _PyPegen_key_value_pair ( p , a , b ); + D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '[' slices ']'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Subscript ( a , b , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -11651,44 +11419,27 @@ kvpair_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s kvpair[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' expression")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// for_if_clauses: for_if_clause+ -static asdl_seq* -for_if_clauses_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '[' slices ']'")); } - asdl_seq* _res = NULL; - int _mark = p->mark; - { // for_if_clause+ + { // atom if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); - asdl_seq * _loop1_104_var; + D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "atom")); + expr_ty atom_var; if ( - (_loop1_104_var = _loop1_104_rule(p)) // for_if_clause+ + (atom_var = atom_rule(p)) // atom ) { - D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); - _res = _loop1_104_var; + D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "atom")); + _res = atom_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s for_if_clauses[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause+")); + D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "atom")); } _res = NULL; done: @@ -11696,47 +11447,41 @@ for_if_clauses_rule(Parser *p) return _res; } -// for_if_clause: -// | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* -// | 'for' star_targets 'in' disjunction (('if' disjunction))* -static comprehension_ty -for_if_clause_rule(Parser *p) +// slices: slice !',' | ','.slice+ ','? +static expr_ty +slices_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - comprehension_ty _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; - { // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // slice !',' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*")); - Token * _keyword; - Token * _keyword_1; + D(fprintf(stderr, "%*c> slices[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice !','")); expr_ty a; - Token * async_var; - expr_ty b; - asdl_seq * c; if ( - (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' - && - (_keyword = _PyPegen_expect_token(p, 517)) // token='for' - && - (a = star_targets_rule(p)) // star_targets - && - (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' - && - (b = disjunction_rule(p)) // disjunction + (a = slice_rule(p)) // slice && - (c = _loop0_105_rule(p)) // (('if' disjunction))* + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' ) { - D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*")); - _res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) ); + D(fprintf(stderr, "%*c+ slices[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice !','")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -11745,34 +11490,35 @@ for_if_clause_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s for_if_clause[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*")); + D(fprintf(stderr, "%*c%s slices[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice !','")); } - { // 'for' star_targets 'in' disjunction (('if' disjunction))* + { // ','.slice+ ','? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*")); - Token * _keyword; - Token * _keyword_1; - expr_ty a; - expr_ty b; - asdl_seq * c; + D(fprintf(stderr, "%*c> slices[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.slice+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_seq * a; if ( - (_keyword = _PyPegen_expect_token(p, 517)) // token='for' + (a = _gather_118_rule(p)) // ','.slice+ && - (a = star_targets_rule(p)) // star_targets - && - (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' - && - (b = disjunction_rule(p)) // disjunction - && - (c = _loop0_106_rule(p)) // (('if' disjunction))* + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) { - D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*")); - _res = _Py_comprehension ( a , b , c , 0 , p -> arena ); + D(fprintf(stderr, "%*c+ slices[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.slice+ ','?")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Tuple ( a , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -11781,8 +11527,8 @@ for_if_clause_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s for_if_clause[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*")); + D(fprintf(stderr, "%*c%s slices[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.slice+ ','?")); } _res = NULL; done: @@ -11790,9 +11536,9 @@ for_if_clause_rule(Parser *p) return _res; } -// yield_expr: 'yield' 'from' expression | 'yield' star_expressions? +// slice: expression? ':' expression? [':' expression?] | expression static expr_ty -yield_expr_rule(Parser *p) +slice_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -11810,24 +11556,27 @@ yield_expr_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // 'yield' 'from' expression + { // expression? ':' expression? [':' expression?] if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> yield_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'yield' 'from' expression")); - Token * _keyword; - Token * _keyword_1; - expr_ty a; + D(fprintf(stderr, "%*c> slice[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); + Token * _literal; + void *a; + void *b; + void *c; if ( - (_keyword = _PyPegen_expect_token(p, 504)) // token='yield' + (a = expression_rule(p), 1) // expression? && - (_keyword_1 = _PyPegen_expect_token(p, 514)) // token='from' + (_literal = _PyPegen_expect_token(p, 11)) // token=':' && - (a = expression_rule(p)) // expression + (b = expression_rule(p), 1) // expression? + && + (c = _tmp_120_rule(p), 1) // [':' expression?] ) { - D(fprintf(stderr, "%*c+ yield_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'yield' 'from' expression")); + D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -11837,7 +11586,7 @@ yield_expr_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_YieldFrom ( a , EXTRA ); + _res = _Py_Slice ( a , b , c , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -11846,34 +11595,22 @@ yield_expr_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s yield_expr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'yield' 'from' expression")); + D(fprintf(stderr, "%*c%s slice[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression? ':' expression? [':' expression?]")); } - { // 'yield' star_expressions? + { // expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> yield_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'yield' star_expressions?")); - Token * _keyword; - void *a; + D(fprintf(stderr, "%*c> slice[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression")); + expr_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 504)) // token='yield' - && - (a = star_expressions_rule(p), 1) // star_expressions? + (a = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ yield_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'yield' star_expressions?")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Yield ( a , EXTRA ); + D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -11882,8 +11619,8 @@ yield_expr_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s yield_expr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'yield' star_expressions?")); + D(fprintf(stderr, "%*c%s slice[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression")); } _res = NULL; done: @@ -11891,9 +11628,20 @@ yield_expr_rule(Parser *p) return _res; } -// arguments: args ','? &')' | incorrect_arguments +// atom: +// | NAME +// | 'True' +// | 'False' +// | 'None' +// | '__new_parser__' +// | &STRING strings +// | NUMBER +// | &'(' (tuple | group | genexp) +// | &'[' (list | listcomp) +// | &'{' (dict | set | dictcomp | setcomp) +// | '...' static expr_ty -arguments_rule(Parser *p) +atom_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -11901,102 +11649,80 @@ arguments_rule(Parser *p) return NULL; } expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, arguments_type, &_res)) { + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; D(p->level--); - return _res; + return NULL; } - int _mark = p->mark; - { // args ','? &')' + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ','? &')'")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty a; + D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); + expr_ty name_var; if ( - (a = args_rule(p)) // args - && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? - && - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' + (name_var = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ','? &')'")); - _res = a; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); + _res = name_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s arguments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ','? &')'")); + D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); } - { // incorrect_arguments + { // 'True' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "incorrect_arguments")); - void *incorrect_arguments_var; + D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); + Token * _keyword; if ( - (incorrect_arguments_var = incorrect_arguments_rule(p)) // incorrect_arguments + (_keyword = _PyPegen_expect_token(p, 523)) // token='True' ) { - D(fprintf(stderr, "%*c+ arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "incorrect_arguments")); - _res = incorrect_arguments_var; + D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Constant ( Py_True , NULL , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s arguments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "incorrect_arguments")); - } - _res = NULL; - done: - _PyPegen_insert_memo(p, _mark, arguments_type, _res); - D(p->level--); - return _res; -} - -// args: starred_expression [',' args] | kwargs | named_expression [',' args] -static expr_ty -args_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - expr_ty _res = NULL; - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // starred_expression [',' args] + { // 'False' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]")); - expr_ty a; - void *b; + D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); + Token * _keyword; if ( - (a = starred_expression_rule(p)) // starred_expression - && - (b = _tmp_107_rule(p), 1) // [',' args] + (_keyword = _PyPegen_expect_token(p, 524)) // token='False' ) { - D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]")); + D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -12006,7 +11732,7 @@ args_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Call ( _PyPegen_dummy_name ( p ) , ( b ) ? CHECK ( _PyPegen_seq_insert_in_front ( p , a , ( ( expr_ty ) b ) -> v . Call . args ) ) : CHECK ( _PyPegen_singleton_seq ( p , a ) ) , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); + _res = _Py_Constant ( Py_False , NULL , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -12015,21 +11741,21 @@ args_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression [',' args]")); + D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); } - { // kwargs + { // 'None' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwargs")); - asdl_seq* a; + D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); + Token * _keyword; if ( - (a = kwargs_rule(p)) // kwargs + (_keyword = _PyPegen_expect_token(p, 522)) // token='None' ) { - D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwargs")); + D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -12039,7 +11765,7 @@ args_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Call ( _PyPegen_dummy_name ( p ) , CHECK_NULL_ALLOWED ( _PyPegen_seq_extract_starred_exprs ( p , a ) ) , CHECK_NULL_ALLOWED ( _PyPegen_seq_delete_starred_exprs ( p , a ) ) , EXTRA ); + _res = _Py_Constant ( Py_None , NULL , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -12048,34 +11774,22 @@ args_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwargs")); + D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); } - { // named_expression [',' args] + { // '__new_parser__' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]")); - expr_ty a; - void *b; + D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'__new_parser__'")); + Token * _keyword; if ( - (a = named_expression_rule(p)) // named_expression - && - (b = _tmp_108_rule(p), 1) // [',' args] + (_keyword = _PyPegen_expect_token(p, 530)) // token='__new_parser__' ) { - D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Call ( _PyPegen_dummy_name ( p ) , ( b ) ? CHECK ( _PyPegen_seq_insert_in_front ( p , a , ( ( expr_ty ) b ) -> v . Call . args ) ) : CHECK ( _PyPegen_singleton_seq ( p , a ) ) , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); + D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'__new_parser__'")); + _res = RAISE_SYNTAX_ERROR ( "You found it!" ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -12084,96 +11798,144 @@ args_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression [',' args]")); + D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'__new_parser__'")); } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// kwargs: -// | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ -// | ','.kwarg_or_starred+ -// | ','.kwarg_or_double_starred+ -static asdl_seq* -kwargs_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + { // &STRING strings + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&STRING strings")); + expr_ty strings_var; + if ( + _PyPegen_lookahead(1, _PyPegen_string_token, p) + && + (strings_var = strings_rule(p)) // strings + ) + { + D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&STRING strings")); + _res = strings_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&STRING strings")); } - asdl_seq* _res = NULL; - int _mark = p->mark; - { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ + { // NUMBER if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); - Token * _literal; - asdl_seq * a; - asdl_seq * b; + D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NUMBER")); + expr_ty number_var; + if ( + (number_var = _PyPegen_number_token(p)) // NUMBER + ) + { + D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NUMBER")); + _res = number_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER")); + } + { // &'(' (tuple | group | genexp) + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); + void *_tmp_121_var; if ( - (a = _gather_109_rule(p)) // ','.kwarg_or_starred+ + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (_tmp_121_var = _tmp_121_rule(p)) // tuple | group | genexp + ) + { + D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); + _res = _tmp_121_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'(' (tuple | group | genexp)")); + } + { // &'[' (list | listcomp) + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); + void *_tmp_122_var; + if ( + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' && - (b = _gather_111_rule(p)) // ','.kwarg_or_double_starred+ + (_tmp_122_var = _tmp_122_rule(p)) // list | listcomp ) { - D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); - _res = _PyPegen_join_sequences ( p , a , b ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); + _res = _tmp_122_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); + D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'[' (list | listcomp)")); } - { // ','.kwarg_or_starred+ + { // &'{' (dict | set | dictcomp | setcomp) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - asdl_seq * _gather_113_var; + D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); + void *_tmp_123_var; if ( - (_gather_113_var = _gather_113_rule(p)) // ','.kwarg_or_starred+ + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' + && + (_tmp_123_var = _tmp_123_rule(p)) // dict | set | dictcomp | setcomp ) { - D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - _res = _gather_113_var; + D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); + _res = _tmp_123_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+")); + D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); } - { // ','.kwarg_or_double_starred+ + { // '...' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - asdl_seq * _gather_115_var; + D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + Token * _literal; if ( - (_gather_115_var = _gather_115_rule(p)) // ','.kwarg_or_double_starred+ + (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - _res = _gather_115_var; + D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_double_starred+")); + D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; done: @@ -12181,9 +11943,55 @@ kwargs_rule(Parser *p) return _res; } -// starred_expression: '*' expression +// strings: STRING+ static expr_ty -starred_expression_rule(Parser *p) +strings_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, strings_type, &_res)) { + D(p->level--); + return _res; + } + int _mark = p->mark; + { // STRING+ + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+")); + asdl_seq * a; + if ( + (a = _loop1_124_rule(p)) // STRING+ + ) + { + D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+")); + _res = _PyPegen_concatenate_strings ( p , a ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s strings[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING+")); + } + _res = NULL; + done: + _PyPegen_insert_memo(p, _mark, strings_type, _res); + D(p->level--); + return _res; +} + +// list: '[' star_named_expressions? ']' +static expr_ty +list_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -12201,21 +12009,24 @@ starred_expression_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '*' expression + { // '[' star_named_expressions? ']' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> starred_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression")); + D(fprintf(stderr, "%*c> list[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' star_named_expressions? ']'")); Token * _literal; - expr_ty a; + Token * _literal_1; + void *a; if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' + (_literal = _PyPegen_expect_token(p, 9)) // token='[' && - (a = expression_rule(p)) // expression + (a = star_named_expressions_rule(p), 1) // star_named_expressions? + && + (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' ) { - D(fprintf(stderr, "%*c+ starred_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression")); + D(fprintf(stderr, "%*c+ list[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' star_named_expressions? ']'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -12225,7 +12036,7 @@ starred_expression_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Starred ( a , Load , EXTRA ); + _res = _Py_List ( a , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -12234,8 +12045,8 @@ starred_expression_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s starred_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression")); + D(fprintf(stderr, "%*c%s list[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' star_named_expressions? ']'")); } _res = NULL; done: @@ -12243,16 +12054,16 @@ starred_expression_rule(Parser *p) return _res; } -// kwarg_or_starred: NAME '=' expression | starred_expression | invalid_kwarg -static KeywordOrStarred* -kwarg_or_starred_rule(Parser *p) +// listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension +static expr_ty +listcomp_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - KeywordOrStarred* _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -12263,24 +12074,27 @@ kwarg_or_starred_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME '=' expression + { // '[' named_expression for_if_clauses ']' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); + D(fprintf(stderr, "%*c> listcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' named_expression for_if_clauses ']'")); Token * _literal; + Token * _literal_1; expr_ty a; - expr_ty b; + asdl_seq* b; if ( - (a = _PyPegen_name_token(p)) // NAME + (_literal = _PyPegen_expect_token(p, 9)) // token='[' && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' + (a = named_expression_rule(p)) // named_expression && - (b = expression_rule(p)) // expression + (b = for_if_clauses_rule(p)) // for_if_clauses + && + (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' ) { - D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); + D(fprintf(stderr, "%*c+ listcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' named_expression for_if_clauses ']'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -12290,7 +12104,7 @@ kwarg_or_starred_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); + _res = _Py_ListComp ( a , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -12299,51 +12113,27 @@ kwarg_or_starred_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression")); + D(fprintf(stderr, "%*c%s listcomp[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' named_expression for_if_clauses ']'")); } - { // starred_expression + { // invalid_comprehension if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); - expr_ty a; + D(fprintf(stderr, "%*c> listcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); + void *invalid_comprehension_var; if ( - (a = starred_expression_rule(p)) // starred_expression + (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension ) { - D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); - _res = _PyPegen_keyword_or_starred ( p , a , 0 ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ listcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); + _res = invalid_comprehension_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); - } - { // invalid_kwarg - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); - void *invalid_kwarg_var; - if ( - (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg - ) - { - D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); - _res = invalid_kwarg_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kwarg")); + D(fprintf(stderr, "%*c%s listcomp[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension")); } _res = NULL; done: @@ -12351,16 +12141,16 @@ kwarg_or_starred_rule(Parser *p) return _res; } -// kwarg_or_double_starred: NAME '=' expression | '**' expression | invalid_kwarg -static KeywordOrStarred* -kwarg_or_double_starred_rule(Parser *p) +// tuple: '(' [star_named_expression ',' star_named_expressions?] ')' +static expr_ty +tuple_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - KeywordOrStarred* _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -12371,24 +12161,24 @@ kwarg_or_double_starred_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME '=' expression + { // '(' [star_named_expression ',' star_named_expressions?] ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); + D(fprintf(stderr, "%*c> tuple[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'")); Token * _literal; - expr_ty a; - expr_ty b; + Token * _literal_1; + void *a; if ( - (a = _PyPegen_name_token(p)) // NAME + (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' + (a = _tmp_125_rule(p), 1) // [star_named_expression ',' star_named_expressions?] && - (b = expression_rule(p)) // expression + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); + D(fprintf(stderr, "%*c+ tuple[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -12398,7 +12188,7 @@ kwarg_or_double_starred_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); + _res = _Py_Tuple ( a , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -12407,34 +12197,45 @@ kwarg_or_double_starred_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression")); + D(fprintf(stderr, "%*c%s tuple[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'")); } - { // '**' expression + _res = NULL; + done: + D(p->level--); + return _res; +} + +// group: '(' (yield_expr | named_expression) ')' +static expr_ty +group_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + { // '(' (yield_expr | named_expression) ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' expression")); + D(fprintf(stderr, "%*c> group[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' (yield_expr | named_expression) ')'")); Token * _literal; - expr_ty a; + Token * _literal_1; + void *a; if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' + (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = expression_rule(p)) // expression + (a = _tmp_126_rule(p)) // yield_expr | named_expression + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' expression")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 ); + D(fprintf(stderr, "%*c+ group[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' (yield_expr | named_expression) ')'")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -12443,27 +12244,8 @@ kwarg_or_double_starred_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' expression")); - } - { // invalid_kwarg - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); - void *invalid_kwarg_var; - if ( - (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg - ) - { - D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); - _res = invalid_kwarg_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kwarg")); + D(fprintf(stderr, "%*c%s group[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' (yield_expr | named_expression) ')'")); } _res = NULL; done: @@ -12471,9 +12253,9 @@ kwarg_or_double_starred_rule(Parser *p) return _res; } -// star_targets: star_target !',' | star_target ((',' star_target))* ','? +// genexp: '(' expression for_if_clauses ')' | invalid_comprehension static expr_ty -star_targets_rule(Parser *p) +genexp_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -12491,51 +12273,27 @@ star_targets_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // star_target !',' + { // '(' expression for_if_clauses ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target !','")); + D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' expression for_if_clauses ')'")); + Token * _literal; + Token * _literal_1; expr_ty a; + asdl_seq* b; if ( - (a = star_target_rule(p)) // star_target + (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' - ) - { - D(fprintf(stderr, "%*c+ star_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target !','")); - _res = a; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s star_targets[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target !','")); - } - { // star_target ((',' star_target))* ','? - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> star_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))* ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty a; - asdl_seq * b; - if ( - (a = star_target_rule(p)) // star_target + (a = expression_rule(p)) // expression && - (b = _loop0_117_rule(p)) // ((',' star_target))* + (b = for_if_clauses_rule(p)) // for_if_clauses && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ star_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))* ','?")); + D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' expression for_if_clauses ')'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -12545,7 +12303,7 @@ star_targets_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA ); + _res = _Py_GeneratorExp ( a , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -12554,53 +12312,27 @@ star_targets_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_targets[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target ((',' star_target))* ','?")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// star_targets_seq: ','.star_target+ ','? -static asdl_seq* -star_targets_seq_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s genexp[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' expression for_if_clauses ')'")); } - asdl_seq* _res = NULL; - int _mark = p->mark; - { // ','.star_target+ ','? + { // invalid_comprehension if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_targets_seq[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_target+ ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - asdl_seq * a; + D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); + void *invalid_comprehension_var; if ( - (a = _gather_118_rule(p)) // ','.star_target+ - && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension ) { - D(fprintf(stderr, "%*c+ star_targets_seq[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_target+ ','?")); - _res = a; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); + _res = invalid_comprehension_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_targets_seq[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_target+ ','?")); + D(fprintf(stderr, "%*c%s genexp[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension")); } _res = NULL; done: @@ -12608,13 +12340,9 @@ star_targets_seq_rule(Parser *p) return _res; } -// star_target: -// | '*' (!'*' star_target) -// | t_primary '.' NAME !t_lookahead -// | t_primary '[' slices ']' !t_lookahead -// | star_atom +// set: '{' expressions_list '}' static expr_ty -star_target_rule(Parser *p) +set_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -12622,10 +12350,6 @@ star_target_rule(Parser *p) return NULL; } expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, star_target_type, &_res)) { - D(p->level--); - return _res; - } int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -12636,21 +12360,24 @@ star_target_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '*' (!'*' star_target) + { // '{' expressions_list '}' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); + D(fprintf(stderr, "%*c> set[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' expressions_list '}'")); Token * _literal; - void *a; + Token * _literal_1; + asdl_seq* a; if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (a = expressions_list_rule(p)) // expressions_list && - (a = _tmp_120_rule(p)) // !'*' star_target + (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' ) { - D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); + D(fprintf(stderr, "%*c+ set[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' expressions_list '}'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -12660,7 +12387,7 @@ star_target_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA ); + _res = _Py_Set ( a , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -12669,73 +12396,56 @@ star_target_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (!'*' star_target)")); + D(fprintf(stderr, "%*c%s set[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' expressions_list '}'")); } - { // t_primary '.' NAME !t_lookahead - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); - Token * _literal; - expr_ty a; - expr_ty b; - if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 23)) // token='.' - && - (b = _PyPegen_name_token(p)) // NAME - && - _PyPegen_lookahead(0, t_lookahead_rule, p) - ) - { - D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); + _res = NULL; + done: + D(p->level--); + return _res; +} + +// setcomp: '{' expression for_if_clauses '}' | invalid_comprehension +static expr_ty +setcomp_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; } - { // t_primary '[' slices ']' !t_lookahead + expr_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // '{' expression for_if_clauses '}' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + D(fprintf(stderr, "%*c> setcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' expression for_if_clauses '}'")); Token * _literal; Token * _literal_1; expr_ty a; - expr_ty b; + asdl_seq* b; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 9)) // token='[' + (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (b = slices_rule(p)) // slices + (a = expression_rule(p)) // expression && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + (b = for_if_clauses_rule(p)) // for_if_clauses && - _PyPegen_lookahead(0, t_lookahead_rule, p) + (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' ) { - D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + D(fprintf(stderr, "%*c+ setcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' expression for_if_clauses '}'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -12745,7 +12455,7 @@ star_target_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Subscript ( a , b , Store , EXTRA ); + _res = _Py_SetComp ( a , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -12754,42 +12464,37 @@ star_target_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + D(fprintf(stderr, "%*c%s setcomp[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' expression for_if_clauses '}'")); } - { // star_atom + { // invalid_comprehension if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_atom")); - expr_ty star_atom_var; + D(fprintf(stderr, "%*c> setcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); + void *invalid_comprehension_var; if ( - (star_atom_var = star_atom_rule(p)) // star_atom + (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension ) { - D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_atom")); - _res = star_atom_var; + D(fprintf(stderr, "%*c+ setcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); + _res = invalid_comprehension_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_atom")); + D(fprintf(stderr, "%*c%s setcomp[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension")); } _res = NULL; done: - _PyPegen_insert_memo(p, _mark, star_target_type, _res); D(p->level--); return _res; } -// star_atom: -// | NAME -// | '(' star_target ')' -// | '(' star_targets_seq? ')' -// | '[' star_targets_seq? ']' +// dict: '{' double_starred_kvpairs? '}' static expr_ty -star_atom_rule(Parser *p) +dict_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -12807,49 +12512,34 @@ star_atom_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); - expr_ty a; - if ( - (a = _PyPegen_name_token(p)) // NAME - ) - { - D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); - _res = _PyPegen_set_expr_context ( p , a , Store ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); - } - { // '(' star_target ')' + { // '{' double_starred_kvpairs? '}' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' star_target ')'")); + D(fprintf(stderr, "%*c> dict[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' double_starred_kvpairs? '}'")); Token * _literal; Token * _literal_1; - expr_ty a; + void *a; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' + (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (a = star_target_rule(p)) // star_target + (a = double_starred_kvpairs_rule(p), 1) // double_starred_kvpairs? && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' ) { - D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' star_target ')'")); - _res = _PyPegen_set_expr_context ( p , a , Store ); + D(fprintf(stderr, "%*c+ dict[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' double_starred_kvpairs? '}'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -12858,27 +12548,56 @@ star_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' star_target ')'")); + D(fprintf(stderr, "%*c%s dict[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' double_starred_kvpairs? '}'")); } - { // '(' star_targets_seq? ')' + _res = NULL; + done: + D(p->level--); + return _res; +} + +// dictcomp: '{' kvpair for_if_clauses '}' | invalid_dict_comprehension +static expr_ty +dictcomp_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // '{' kvpair for_if_clauses '}' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' star_targets_seq? ')'")); + D(fprintf(stderr, "%*c> dictcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' kvpair for_if_clauses '}'")); Token * _literal; Token * _literal_1; - void *a; + KeyValuePair* a; + asdl_seq* b; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' + (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (a = star_targets_seq_rule(p), 1) // star_targets_seq? + (a = kvpair_rule(p)) // kvpair && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (b = for_if_clauses_rule(p)) // for_if_clauses + && + (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' ) { - D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' star_targets_seq? ')'")); + D(fprintf(stderr, "%*c+ dictcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' kvpair for_if_clauses '}'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -12888,7 +12607,7 @@ star_atom_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( a , Store , EXTRA ); + _res = _Py_DictComp ( a -> key , a -> value , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -12897,47 +12616,27 @@ star_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' star_targets_seq? ')'")); + D(fprintf(stderr, "%*c%s dictcomp[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' kvpair for_if_clauses '}'")); } - { // '[' star_targets_seq? ']' + { // invalid_dict_comprehension if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' star_targets_seq? ']'")); - Token * _literal; - Token * _literal_1; - void *a; + D(fprintf(stderr, "%*c> dictcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_dict_comprehension")); + void *invalid_dict_comprehension_var; if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - && - (a = star_targets_seq_rule(p), 1) // star_targets_seq? - && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + (invalid_dict_comprehension_var = invalid_dict_comprehension_rule(p)) // invalid_dict_comprehension ) { - D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' star_targets_seq? ']'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_List ( a , Store , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ dictcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_dict_comprehension")); + _res = invalid_dict_comprehension_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' star_targets_seq? ']'")); + D(fprintf(stderr, "%*c%s dictcomp[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_dict_comprehension")); } _res = NULL; done: @@ -12945,49 +12644,78 @@ star_atom_rule(Parser *p) return _res; } -// single_target: single_subscript_attribute_target | NAME | '(' single_target ')' -static expr_ty -single_target_rule(Parser *p) +// double_starred_kvpairs: ','.double_starred_kvpair+ ','? +static asdl_seq* +double_starred_kvpairs_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + asdl_seq* _res = NULL; int _mark = p->mark; - { // single_subscript_attribute_target + { // ','.double_starred_kvpair+ ','? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); - expr_ty single_subscript_attribute_target_var; + D(fprintf(stderr, "%*c> double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_seq * a; if ( - (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target - ) + (a = _gather_127_rule(p)) // ','.double_starred_kvpair+ + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + ) { - D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); - _res = single_subscript_attribute_target_var; + D(fprintf(stderr, "%*c+ double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ','?")); + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_subscript_attribute_target")); + D(fprintf(stderr, "%*c%s double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.double_starred_kvpair+ ','?")); } - { // NAME + _res = NULL; + done: + D(p->level--); + return _res; +} + +// double_starred_kvpair: '**' bitwise_or | kvpair +static KeyValuePair* +double_starred_kvpair_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + KeyValuePair* _res = NULL; + int _mark = p->mark; + { // '**' bitwise_or if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); + D(fprintf(stderr, "%*c> double_starred_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or")); + Token * _literal; expr_ty a; if ( - (a = _PyPegen_name_token(p)) // NAME + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + && + (a = bitwise_or_rule(p)) // bitwise_or ) { - D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); - _res = _PyPegen_set_expr_context ( p , a , Store ); + D(fprintf(stderr, "%*c+ double_starred_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or")); + _res = _PyPegen_key_value_pair ( p , NULL , a ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -12996,38 +12724,27 @@ single_target_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); + D(fprintf(stderr, "%*c%s double_starred_kvpair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' bitwise_or")); } - { // '(' single_target ')' + { // kvpair if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); - Token * _literal; - Token * _literal_1; - expr_ty a; + D(fprintf(stderr, "%*c> double_starred_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kvpair")); + KeyValuePair* kvpair_var; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (a = single_target_rule(p)) // single_target - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (kvpair_var = kvpair_rule(p)) // kvpair ) { - D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); - _res = a; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ double_starred_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kvpair")); + _res = kvpair_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'")); + D(fprintf(stderr, "%*c%s double_starred_kvpair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kvpair")); } _res = NULL; done: @@ -13035,102 +12752,36 @@ single_target_rule(Parser *p) return _res; } -// single_subscript_attribute_target: -// | t_primary '.' NAME !t_lookahead -// | t_primary '[' slices ']' !t_lookahead -static expr_ty -single_subscript_attribute_target_rule(Parser *p) +// kvpair: expression ':' expression +static KeyValuePair* +kvpair_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + KeyValuePair* _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // t_primary '.' NAME !t_lookahead - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> single_subscript_attribute_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); - Token * _literal; - expr_ty a; - expr_ty b; - if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 23)) // token='.' - && - (b = _PyPegen_name_token(p)) // NAME - && - _PyPegen_lookahead(0, t_lookahead_rule, p) - ) - { - D(fprintf(stderr, "%*c+ single_subscript_attribute_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s single_subscript_attribute_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); - } - { // t_primary '[' slices ']' !t_lookahead + { // expression ':' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> single_subscript_attribute_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + D(fprintf(stderr, "%*c> kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' expression")); Token * _literal; - Token * _literal_1; expr_ty a; expr_ty b; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - && - (b = slices_rule(p)) // slices + (a = expression_rule(p)) // expression && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + (_literal = _PyPegen_expect_token(p, 11)) // token=':' && - _PyPegen_lookahead(0, t_lookahead_rule, p) + (b = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ single_subscript_attribute_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Subscript ( a , b , Store , EXTRA ); + D(fprintf(stderr, "%*c+ kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression")); + _res = _PyPegen_key_value_pair ( p , a , b ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -13139,8 +12790,8 @@ single_subscript_attribute_target_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s single_subscript_attribute_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + D(fprintf(stderr, "%*c%s kvpair[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' expression")); } _res = NULL; done: @@ -13148,9 +12799,9 @@ single_subscript_attribute_target_rule(Parser *p) return _res; } -// del_targets: ','.del_target+ ','? +// for_if_clauses: for_if_clause+ static asdl_seq* -del_targets_rule(Parser *p) +for_if_clauses_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -13159,33 +12810,24 @@ del_targets_rule(Parser *p) } asdl_seq* _res = NULL; int _mark = p->mark; - { // ','.del_target+ ','? + { // for_if_clause+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> del_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - asdl_seq * a; + D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); + asdl_seq * _loop1_129_var; if ( - (a = _gather_121_rule(p)) // ','.del_target+ - && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + (_loop1_129_var = _loop1_129_rule(p)) // for_if_clause+ ) { - D(fprintf(stderr, "%*c+ del_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?")); - _res = a; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); + _res = _loop1_129_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_targets[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.del_target+ ','?")); + D(fprintf(stderr, "%*c%s for_if_clauses[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause+")); } _res = NULL; done: @@ -13193,63 +12835,47 @@ del_targets_rule(Parser *p) return _res; } -// del_target: -// | t_primary '.' NAME &del_target_end -// | t_primary '[' slices ']' &del_target_end -// | del_t_atom -static expr_ty -del_target_rule(Parser *p) +// for_if_clause: +// | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* +// | 'for' star_targets 'in' disjunction (('if' disjunction))* +static comprehension_ty +for_if_clause_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, del_target_type, &_res)) { - D(p->level--); - return _res; - } + comprehension_ty _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // t_primary '.' NAME &del_target_end + { // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &del_target_end")); - Token * _literal; + D(fprintf(stderr, "%*c> for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*")); + Token * _keyword; + Token * _keyword_1; expr_ty a; + Token * async_var; expr_ty b; + asdl_seq * c; if ( - (a = t_primary_rule(p)) // t_primary + (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' && - (_literal = _PyPegen_expect_token(p, 23)) // token='.' + (_keyword = _PyPegen_expect_token(p, 517)) // token='for' && - (b = _PyPegen_name_token(p)) // NAME + (a = star_targets_rule(p)) // star_targets && - _PyPegen_lookahead(1, del_target_end_rule, p) + (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' + && + (b = disjunction_rule(p)) // disjunction + && + (c = _loop0_130_rule(p)) // (('if' disjunction))* ) { - D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &del_target_end")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA ); + D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*")); + _res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -13258,42 +12884,34 @@ del_target_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME &del_target_end")); - } - { // t_primary '[' slices ']' &del_target_end + D(fprintf(stderr, "%*c%s for_if_clause[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*")); + } + { // 'for' star_targets 'in' disjunction (('if' disjunction))* if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &del_target_end")); - Token * _literal; - Token * _literal_1; + D(fprintf(stderr, "%*c> for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*")); + Token * _keyword; + Token * _keyword_1; expr_ty a; expr_ty b; + asdl_seq * c; if ( - (a = t_primary_rule(p)) // t_primary + (_keyword = _PyPegen_expect_token(p, 517)) // token='for' && - (_literal = _PyPegen_expect_token(p, 9)) // token='[' + (a = star_targets_rule(p)) // star_targets && - (b = slices_rule(p)) // slices + (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + (b = disjunction_rule(p)) // disjunction && - _PyPegen_lookahead(1, del_target_end_rule, p) + (c = _loop0_131_rule(p)) // (('if' disjunction))* ) { - D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &del_target_end")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Subscript ( a , b , Del , EXTRA ); + D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*")); + _res = _Py_comprehension ( a , b , c , 0 , p -> arena ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -13302,43 +12920,18 @@ del_target_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' &del_target_end")); - } - { // del_t_atom - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_t_atom")); - expr_ty del_t_atom_var; - if ( - (del_t_atom_var = del_t_atom_rule(p)) // del_t_atom - ) - { - D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_t_atom")); - _res = del_t_atom_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_t_atom")); + D(fprintf(stderr, "%*c%s for_if_clause[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*")); } _res = NULL; done: - _PyPegen_insert_memo(p, _mark, del_target_type, _res); D(p->level--); return _res; } -// del_t_atom: -// | NAME &del_target_end -// | '(' del_target ')' -// | '(' del_targets? ')' -// | '[' del_targets? ']' -// | invalid_del_target +// yield_expr: 'yield' 'from' expression | 'yield' star_expressions? static expr_ty -del_t_atom_rule(Parser *p) +yield_expr_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -13356,51 +12949,34 @@ del_t_atom_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME &del_target_end + { // 'yield' 'from' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME &del_target_end")); + D(fprintf(stderr, "%*c> yield_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'yield' 'from' expression")); + Token * _keyword; + Token * _keyword_1; expr_ty a; if ( - (a = _PyPegen_name_token(p)) // NAME + (_keyword = _PyPegen_expect_token(p, 504)) // token='yield' && - _PyPegen_lookahead(1, del_target_end_rule, p) + (_keyword_1 = _PyPegen_expect_token(p, 514)) // token='from' + && + (a = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME &del_target_end")); - _res = _PyPegen_set_expr_context ( p , a , Del ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; + D(fprintf(stderr, "%*c+ yield_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'yield' 'from' expression")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { D(p->level--); return NULL; } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME &del_target_end")); - } - { // '(' del_target ')' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' del_target ')'")); - Token * _literal; - Token * _literal_1; - expr_ty a; - if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (a = del_target_rule(p)) // del_target - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' del_target ')'")); - _res = _PyPegen_set_expr_context ( p , a , Del ); + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_YieldFrom ( a , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -13409,27 +12985,24 @@ del_t_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' del_target ')'")); + D(fprintf(stderr, "%*c%s yield_expr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'yield' 'from' expression")); } - { // '(' del_targets? ')' + { // 'yield' star_expressions? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' del_targets? ')'")); - Token * _literal; - Token * _literal_1; + D(fprintf(stderr, "%*c> yield_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'yield' star_expressions?")); + Token * _keyword; void *a; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (a = del_targets_rule(p), 1) // del_targets? + (_keyword = _PyPegen_expect_token(p, 504)) // token='yield' && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (a = star_expressions_rule(p), 1) // star_expressions? ) { - D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' del_targets? ')'")); + D(fprintf(stderr, "%*c+ yield_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'yield' star_expressions?")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -13439,7 +13012,7 @@ del_t_atom_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( a , Del , EXTRA ); + _res = _Py_Yield ( a , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -13448,37 +13021,49 @@ del_t_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' del_targets? ')'")); + D(fprintf(stderr, "%*c%s yield_expr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'yield' star_expressions?")); } - { // '[' del_targets? ']' + _res = NULL; + done: + D(p->level--); + return _res; +} + +// arguments: args ','? &')' | incorrect_arguments +static expr_ty +arguments_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, arguments_type, &_res)) { + D(p->level--); + return _res; + } + int _mark = p->mark; + { // args ','? &')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' del_targets? ']'")); - Token * _literal; - Token * _literal_1; - void *a; + D(fprintf(stderr, "%*c> arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ','? &')'")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty a; if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' + (a = args_rule(p)) // args && - (a = del_targets_rule(p), 1) // del_targets? + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' ) { - D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' del_targets? ']'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_List ( a , Del , EXTRA ); + D(fprintf(stderr, "%*c+ arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ','? &')'")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -13487,139 +13072,159 @@ del_t_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' del_targets? ']'")); + D(fprintf(stderr, "%*c%s arguments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ','? &')'")); } - { // invalid_del_target + { // incorrect_arguments if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_del_target")); - void *invalid_del_target_var; + D(fprintf(stderr, "%*c> arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "incorrect_arguments")); + void *incorrect_arguments_var; if ( - (invalid_del_target_var = invalid_del_target_rule(p)) // invalid_del_target + (incorrect_arguments_var = incorrect_arguments_rule(p)) // incorrect_arguments ) { - D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_del_target")); - _res = invalid_del_target_var; + D(fprintf(stderr, "%*c+ arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "incorrect_arguments")); + _res = incorrect_arguments_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_del_target")); + D(fprintf(stderr, "%*c%s arguments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "incorrect_arguments")); } _res = NULL; done: + _PyPegen_insert_memo(p, _mark, arguments_type, _res); D(p->level--); return _res; } -// del_target_end: ')' | ']' | ',' | ';' | NEWLINE -static void * -del_target_end_rule(Parser *p) +// args: starred_expression [',' args] | kwargs | named_expression [',' args] +static expr_ty +args_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; - { // ')' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; } - { // ']' + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // starred_expression [',' args] if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "']'")); - Token * _literal; + D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]")); + expr_ty a; + void *b; if ( - (_literal = _PyPegen_expect_token(p, 10)) // token=']' + (a = starred_expression_rule(p)) // starred_expression + && + (b = _tmp_132_rule(p), 1) // [',' args] ) { - D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "']'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s del_target_end[%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> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; + D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Call ( _PyPegen_dummy_name ( p ) , ( b ) ? CHECK ( _PyPegen_seq_insert_in_front ( p , a , ( ( expr_ty ) b ) -> v . Call . args ) ) : CHECK ( _PyPegen_singleton_seq ( p , a ) ) , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); + D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression [',' args]")); } - { // ';' + { // kwargs if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'")); - Token * _literal; + D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwargs")); + asdl_seq* a; if ( - (_literal = _PyPegen_expect_token(p, 13)) // token=';' + (a = kwargs_rule(p)) // kwargs ) { - D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'")); - _res = _literal; + D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwargs")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Call ( _PyPegen_dummy_name ( p ) , CHECK_NULL_ALLOWED ( _PyPegen_seq_extract_starred_exprs ( p , a ) ) , CHECK_NULL_ALLOWED ( _PyPegen_seq_delete_starred_exprs ( p , a ) ) , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'")); + D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwargs")); } - { // NEWLINE + { // named_expression [',' args] if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - Token * newline_var; + D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]")); + expr_ty a; + void *b; if ( - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + (a = named_expression_rule(p)) // named_expression + && + (b = _tmp_133_rule(p), 1) // [',' args] ) { - D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - _res = newline_var; + D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Call ( _PyPegen_dummy_name ( p ) , ( b ) ? CHECK ( _PyPegen_seq_insert_in_front ( p , a , ( ( expr_ty ) b ) -> v . Call . args ) ) : CHECK ( _PyPegen_singleton_seq ( p , a ) ) , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); + D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression [',' args]")); } _res = NULL; done: @@ -13627,9 +13232,12 @@ del_target_end_rule(Parser *p) return _res; } -// targets: ','.target+ ','? +// kwargs: +// | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ +// | ','.kwarg_or_starred+ +// | ','.kwarg_or_double_starred+ static asdl_seq* -targets_rule(Parser *p) +kwargs_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -13638,23 +13246,25 @@ targets_rule(Parser *p) } asdl_seq* _res = NULL; int _mark = p->mark; - { // ','.target+ ','? + { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.target+ ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings + D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); + Token * _literal; asdl_seq * a; + asdl_seq * b; if ( - (a = _gather_123_rule(p)) // ','.target+ + (a = _gather_134_rule(p)) // ','.kwarg_or_starred+ && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (b = _gather_136_rule(p)) // ','.kwarg_or_double_starred+ ) { - D(fprintf(stderr, "%*c+ targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.target+ ','?")); - _res = a; + D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); + _res = _PyPegen_join_sequences ( p , a , b ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -13663,8 +13273,46 @@ targets_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s targets[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.target+ ','?")); + D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); + } + { // ','.kwarg_or_starred+ + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); + asdl_seq * _gather_138_var; + if ( + (_gather_138_var = _gather_138_rule(p)) // ','.kwarg_or_starred+ + ) + { + D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); + _res = _gather_138_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+")); + } + { // ','.kwarg_or_double_starred+ + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); + asdl_seq * _gather_140_var; + if ( + (_gather_140_var = _gather_140_rule(p)) // ','.kwarg_or_double_starred+ + ) + { + D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); + _res = _gather_140_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_double_starred+")); } _res = NULL; done: @@ -13672,12 +13320,9 @@ targets_rule(Parser *p) return _res; } -// target: -// | t_primary '.' NAME !t_lookahead -// | t_primary '[' slices ']' !t_lookahead -// | t_atom +// starred_expression: '*' expression static expr_ty -target_rule(Parser *p) +starred_expression_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -13685,10 +13330,6 @@ target_rule(Parser *p) return NULL; } expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, target_type, &_res)) { - D(p->level--); - return _res; - } int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -13699,26 +13340,21 @@ target_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // t_primary '.' NAME !t_lookahead + { // '*' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); + D(fprintf(stderr, "%*c> starred_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression")); Token * _literal; expr_ty a; - expr_ty b; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 23)) // token='.' - && - (b = _PyPegen_name_token(p)) // NAME + (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - _PyPegen_lookahead(0, t_lookahead_rule, p) + (a = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); + D(fprintf(stderr, "%*c+ starred_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -13728,7 +13364,7 @@ target_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); + _res = _Py_Starred ( a , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -13737,32 +13373,53 @@ target_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); + D(fprintf(stderr, "%*c%s starred_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression")); } - { // t_primary '[' slices ']' !t_lookahead + _res = NULL; + done: + D(p->level--); + return _res; +} + +// kwarg_or_starred: NAME '=' expression | starred_expression | invalid_kwarg +static KeywordOrStarred* +kwarg_or_starred_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + KeywordOrStarred* _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // NAME '=' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); Token * _literal; - Token * _literal_1; expr_ty a; expr_ty b; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - && - (b = slices_rule(p)) // slices + (a = _PyPegen_name_token(p)) // NAME && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + (_literal = _PyPegen_expect_token(p, 22)) // token='=' && - _PyPegen_lookahead(0, t_lookahead_rule, p) + (b = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -13772,7 +13429,7 @@ target_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Subscript ( a , b , Store , EXTRA ); + _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -13781,80 +13438,68 @@ target_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression")); } - { // t_atom + { // starred_expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_atom")); - expr_ty t_atom_var; + D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); + expr_ty a; if ( - (t_atom_var = t_atom_rule(p)) // t_atom + (a = starred_expression_rule(p)) // starred_expression ) { - D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_atom")); - _res = t_atom_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_atom")); - } - _res = NULL; - done: - _PyPegen_insert_memo(p, _mark, target_type, _res); - D(p->level--); - return _res; -} - -// Left-recursive -// t_primary: -// | t_primary '.' NAME &t_lookahead -// | t_primary '[' slices ']' &t_lookahead -// | t_primary genexp &t_lookahead -// | t_primary '(' arguments? ')' &t_lookahead -// | atom &t_lookahead -static expr_ty t_primary_raw(Parser *); -static expr_ty -t_primary_rule(Parser *p) -{ - D(p->level++); - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, t_primary_type, &_res)) { - D(p->level--); - return _res; + D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); + _res = _PyPegen_keyword_or_starred ( p , a , 0 ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); } - int _mark = p->mark; - int _resmark = p->mark; - while (1) { - int tmpvar_8 = _PyPegen_update_memo(p, _mark, t_primary_type, _res); - if (tmpvar_8) { + { // invalid_kwarg + if (p->error_indicator) { D(p->level--); - return _res; + return NULL; + } + D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); + void *invalid_kwarg_var; + if ( + (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg + ) + { + D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); + _res = invalid_kwarg_var; + goto done; } p->mark = _mark; - void *_raw = t_primary_raw(p); - if (_raw == NULL || p->mark <= _resmark) - break; - _resmark = p->mark; - _res = _raw; + D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kwarg")); } - p->mark = _resmark; + _res = NULL; + done: D(p->level--); return _res; } -static expr_ty -t_primary_raw(Parser *p) + +// kwarg_or_double_starred: NAME '=' expression | '**' expression | invalid_kwarg +static KeywordOrStarred* +kwarg_or_double_starred_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + KeywordOrStarred* _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -13865,26 +13510,24 @@ t_primary_raw(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // t_primary '.' NAME &t_lookahead + { // NAME '=' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &t_lookahead")); + D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); Token * _literal; expr_ty a; expr_ty b; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 23)) // token='.' + (a = _PyPegen_name_token(p)) // NAME && - (b = _PyPegen_name_token(p)) // NAME + (_literal = _PyPegen_expect_token(p, 22)) // token='=' && - _PyPegen_lookahead(1, t_lookahead_rule, p) + (b = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &t_lookahead")); + D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -13894,7 +13537,7 @@ t_primary_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); + _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -13903,32 +13546,24 @@ t_primary_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME &t_lookahead")); + D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression")); } - { // t_primary '[' slices ']' &t_lookahead + { // '**' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); + D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' expression")); Token * _literal; - Token * _literal_1; expr_ty a; - expr_ty b; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - && - (b = slices_rule(p)) // slices - && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + (_literal = _PyPegen_expect_token(p, 35)) // token='**' && - _PyPegen_lookahead(1, t_lookahead_rule, p) + (a = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); + D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' expression")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -13938,7 +13573,7 @@ t_primary_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Subscript ( a , b , Load , EXTRA ); + _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -13947,36 +13582,69 @@ t_primary_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); + D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' expression")); } - { // t_primary genexp &t_lookahead + { // invalid_kwarg if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary genexp &t_lookahead")); + D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); + void *invalid_kwarg_var; + if ( + (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg + ) + { + D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); + _res = invalid_kwarg_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kwarg")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// star_targets: star_target !',' | star_target ((',' star_target))* ','? +static expr_ty +star_targets_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // star_target !',' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> star_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target !','")); expr_ty a; - expr_ty b; if ( - (a = t_primary_rule(p)) // t_primary - && - (b = genexp_rule(p)) // genexp + (a = star_target_rule(p)) // star_target && - _PyPegen_lookahead(1, t_lookahead_rule, p) + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' ) { - D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary genexp &t_lookahead")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); + D(fprintf(stderr, "%*c+ star_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target !','")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -13985,32 +13653,28 @@ t_primary_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary genexp &t_lookahead")); + D(fprintf(stderr, "%*c%s star_targets[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target !','")); } - { // t_primary '(' arguments? ')' &t_lookahead + { // star_target ((',' star_target))* ','? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); - Token * _literal; - Token * _literal_1; + D(fprintf(stderr, "%*c> star_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))* ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings expr_ty a; - void *b; + asdl_seq * b; if ( - (a = t_primary_rule(p)) // t_primary - && - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (b = arguments_rule(p), 1) // arguments? + (a = star_target_rule(p)) // star_target && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (b = _loop0_142_rule(p)) // ((',' star_target))* && - _PyPegen_lookahead(1, t_lookahead_rule, p) + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) { - D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); + D(fprintf(stderr, "%*c+ star_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))* ','?")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -14020,7 +13684,7 @@ t_primary_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); + _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -14029,23 +13693,42 @@ t_primary_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); + D(fprintf(stderr, "%*c%s star_targets[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target ((',' star_target))* ','?")); } - { // atom &t_lookahead + _res = NULL; + done: + D(p->level--); + return _res; +} + +// star_targets_seq: ','.star_target+ ','? +static asdl_seq* +star_targets_seq_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq* _res = NULL; + int _mark = p->mark; + { // ','.star_target+ ','? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "atom &t_lookahead")); - expr_ty a; + D(fprintf(stderr, "%*c> star_targets_seq[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_target+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_seq * a; if ( - (a = atom_rule(p)) // atom + (a = _gather_143_rule(p)) // ','.star_target+ && - _PyPegen_lookahead(1, t_lookahead_rule, p) + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) { - D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "atom &t_lookahead")); + D(fprintf(stderr, "%*c+ star_targets_seq[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_target+ ','?")); _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -14055,8 +13738,8 @@ t_primary_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "atom &t_lookahead")); + D(fprintf(stderr, "%*c%s star_targets_seq[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_target+ ','?")); } _res = NULL; done: @@ -14064,83 +13747,188 @@ t_primary_raw(Parser *p) return _res; } -// t_lookahead: '(' | '[' | '.' -static void * -t_lookahead_rule(Parser *p) -{ +// star_target: +// | '*' (!'*' star_target) +// | t_primary '.' NAME !t_lookahead +// | t_primary '[' slices ']' !t_lookahead +// | star_atom +static expr_ty +star_target_rule(Parser *p) +{ D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, star_target_type, &_res)) { + D(p->level--); + return _res; + } int _mark = p->mark; - { // '(' + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // '*' (!'*' star_target) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); Token * _literal; + void *a; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (a = _tmp_145_rule(p)) // !'*' star_target ) { - D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); - _res = _literal; + D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (!'*' star_target)")); } - { // '[' + { // t_primary '.' NAME !t_lookahead if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); Token * _literal; + expr_ty a; + expr_ty b; if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' + (a = t_primary_rule(p)) // t_primary + && + (_literal = _PyPegen_expect_token(p, 23)) // token='.' + && + (b = _PyPegen_name_token(p)) // NAME + && + _PyPegen_lookahead(0, t_lookahead_rule, p) ) { - D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); - _res = _literal; + D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); } - { // '.' + { // t_primary '[' slices ']' !t_lookahead if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); Token * _literal; + Token * _literal_1; + expr_ty a; + expr_ty b; if ( - (_literal = _PyPegen_expect_token(p, 23)) // token='.' + (a = t_primary_rule(p)) // t_primary + && + (_literal = _PyPegen_expect_token(p, 9)) // token='[' + && + (b = slices_rule(p)) // slices + && + (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + && + _PyPegen_lookahead(0, t_lookahead_rule, p) ) { - D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); - _res = _literal; + D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Subscript ( a , b , Store , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + } + { // star_atom + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_atom")); + expr_ty star_atom_var; + if ( + (star_atom_var = star_atom_rule(p)) // star_atom + ) + { + D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_atom")); + _res = star_atom_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_atom")); } _res = NULL; done: + _PyPegen_insert_memo(p, _mark, star_target_type, _res); D(p->level--); return _res; } -// t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']' +// star_atom: +// | NAME +// | '(' star_target ')' +// | '(' star_targets_seq? ')' +// | '[' star_targets_seq? ']' static expr_ty -t_atom_rule(Parser *p) +star_atom_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -14163,13 +13951,13 @@ t_atom_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); + D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); expr_ty a; if ( (a = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); + D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); _res = _PyPegen_set_expr_context ( p , a , Store ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -14179,27 +13967,27 @@ t_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); } - { // '(' target ')' + { // '(' star_target ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' target ')'")); + D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' star_target ')'")); Token * _literal; Token * _literal_1; expr_ty a; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = target_rule(p)) // target + (a = star_target_rule(p)) // star_target && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' target ')'")); + D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' star_target ')'")); _res = _PyPegen_set_expr_context ( p , a , Store ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -14209,27 +13997,27 @@ t_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' target ')'")); + D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' star_target ')'")); } - { // '(' targets? ')' + { // '(' star_targets_seq? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' targets? ')'")); + D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' star_targets_seq? ')'")); Token * _literal; Token * _literal_1; - void *b; + void *a; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (b = targets_rule(p), 1) // targets? + (a = star_targets_seq_rule(p), 1) // star_targets_seq? && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' targets? ')'")); + D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' star_targets_seq? ')'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -14239,7 +14027,7 @@ t_atom_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( b , Store , EXTRA ); + _res = _Py_Tuple ( a , Store , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -14248,27 +14036,27 @@ t_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' targets? ')'")); + D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' star_targets_seq? ')'")); } - { // '[' targets? ']' + { // '[' star_targets_seq? ']' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' targets? ']'")); + D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' star_targets_seq? ']'")); Token * _literal; Token * _literal_1; - void *b; + void *a; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' && - (b = targets_rule(p), 1) // targets? + (a = star_targets_seq_rule(p), 1) // star_targets_seq? && (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' ) { - D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' targets? ']'")); + D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' star_targets_seq? ']'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -14278,7 +14066,7 @@ t_atom_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_List ( b , Store , EXTRA ); + _res = _Py_List ( a , Store , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -14287,8 +14075,8 @@ t_atom_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' targets? ']'")); + D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' star_targets_seq? ']'")); } _res = NULL; done: @@ -14296,75 +14084,49 @@ t_atom_rule(Parser *p) return _res; } -// incorrect_arguments: -// | args ',' '*' -// | expression for_if_clauses ',' [args | expression for_if_clauses] -// | args for_if_clauses -// | args ',' expression for_if_clauses -// | args ',' args -static void * -incorrect_arguments_rule(Parser *p) +// single_target: single_subscript_attribute_target | NAME | '(' single_target ')' +static expr_ty +single_target_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; - { // args ',' '*' + { // single_subscript_attribute_target if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' '*'")); - Token * _literal; - Token * _literal_1; - expr_ty args_var; + D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); + expr_ty single_subscript_attribute_target_var; if ( - (args_var = args_rule(p)) // args - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' + (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target ) { - D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' '*'")); - _res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); + _res = single_subscript_attribute_target_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' '*'")); + D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_subscript_attribute_target")); } - { // expression for_if_clauses ',' [args | expression for_if_clauses] + { // NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings + D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); expr_ty a; - asdl_seq* for_if_clauses_var; if ( - (a = expression_rule(p)) // expression - && - (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (_opt_var = _tmp_125_rule(p), 1) // [args | expression for_if_clauses] + (a = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "Generator expression must be parenthesized" ); + D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); + _res = _PyPegen_set_expr_context ( p , a , Store ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -14373,25 +14135,28 @@ incorrect_arguments_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); + D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); } - { // args for_if_clauses + { // '(' single_target ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args for_if_clauses")); + D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); + Token * _literal; + Token * _literal_1; expr_ty a; - asdl_seq* for_if_clauses_var; if ( - (a = args_rule(p)) // args + (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + (a = single_target_rule(p)) // single_target + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args for_if_clauses")); - _res = _PyPegen_nonparen_genexp_in_call ( p , a ); + D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); + _res = a; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -14400,31 +14165,67 @@ incorrect_arguments_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args for_if_clauses")); + D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'")); } - { // args ',' expression for_if_clauses + _res = NULL; + done: + D(p->level--); + return _res; +} + +// single_subscript_attribute_target: +// | t_primary '.' NAME !t_lookahead +// | t_primary '[' slices ']' !t_lookahead +static expr_ty +single_subscript_attribute_target_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // t_primary '.' NAME !t_lookahead if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses")); + D(fprintf(stderr, "%*c> single_subscript_attribute_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); Token * _literal; expr_ty a; - expr_ty args_var; - asdl_seq* for_if_clauses_var; + expr_ty b; if ( - (args_var = args_rule(p)) // args + (a = t_primary_rule(p)) // t_primary && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (_literal = _PyPegen_expect_token(p, 23)) // token='.' && - (a = expression_rule(p)) // expression + (b = _PyPegen_name_token(p)) // NAME && - (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + _PyPegen_lookahead(0, t_lookahead_rule, p) ) { - D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "Generator expression must be parenthesized" ); + D(fprintf(stderr, "%*c+ single_subscript_attribute_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -14433,28 +14234,42 @@ incorrect_arguments_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' expression for_if_clauses")); + D(fprintf(stderr, "%*c%s single_subscript_attribute_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); } - { // args ',' args + { // t_primary '[' slices ']' !t_lookahead if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' args")); + D(fprintf(stderr, "%*c> single_subscript_attribute_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); Token * _literal; + Token * _literal_1; expr_ty a; - expr_ty args_var; + expr_ty b; if ( - (a = args_rule(p)) // args + (a = t_primary_rule(p)) // t_primary && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (_literal = _PyPegen_expect_token(p, 9)) // token='[' && - (args_var = args_rule(p)) // args + (b = slices_rule(p)) // slices + && + (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + && + _PyPegen_lookahead(0, t_lookahead_rule, p) ) { - D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' args")); - _res = _PyPegen_arguments_parsing_error ( p , a ); + D(fprintf(stderr, "%*c+ single_subscript_attribute_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Subscript ( a , b , Store , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -14463,52 +14278,2436 @@ incorrect_arguments_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' args")); + D(fprintf(stderr, "%*c%s single_subscript_attribute_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); } _res = NULL; done: D(p->level--); - return _res; + return _res; +} + +// del_targets: ','.del_target+ ','? +static asdl_seq* +del_targets_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq* _res = NULL; + int _mark = p->mark; + { // ','.del_target+ ','? + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> del_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_seq * a; + if ( + (a = _gather_146_rule(p)) // ','.del_target+ + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + ) + { + D(fprintf(stderr, "%*c+ del_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?")); + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s del_targets[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.del_target+ ','?")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// del_target: +// | t_primary '.' NAME &del_target_end +// | t_primary '[' slices ']' &del_target_end +// | del_t_atom +static expr_ty +del_target_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, del_target_type, &_res)) { + D(p->level--); + return _res; + } + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // t_primary '.' NAME &del_target_end + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &del_target_end")); + Token * _literal; + expr_ty a; + expr_ty b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = _PyPegen_expect_token(p, 23)) // token='.' + && + (b = _PyPegen_name_token(p)) // NAME + && + _PyPegen_lookahead(1, del_target_end_rule, p) + ) + { + D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &del_target_end")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME &del_target_end")); + } + { // t_primary '[' slices ']' &del_target_end + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &del_target_end")); + Token * _literal; + Token * _literal_1; + expr_ty a; + expr_ty b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = _PyPegen_expect_token(p, 9)) // token='[' + && + (b = slices_rule(p)) // slices + && + (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + && + _PyPegen_lookahead(1, del_target_end_rule, p) + ) + { + D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &del_target_end")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Subscript ( a , b , Del , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' &del_target_end")); + } + { // del_t_atom + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_t_atom")); + expr_ty del_t_atom_var; + if ( + (del_t_atom_var = del_t_atom_rule(p)) // del_t_atom + ) + { + D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_t_atom")); + _res = del_t_atom_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_t_atom")); + } + _res = NULL; + done: + _PyPegen_insert_memo(p, _mark, del_target_type, _res); + D(p->level--); + return _res; +} + +// del_t_atom: +// | NAME &del_target_end +// | '(' del_target ')' +// | '(' del_targets? ')' +// | '[' del_targets? ']' +// | invalid_del_target +static expr_ty +del_t_atom_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // NAME &del_target_end + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME &del_target_end")); + expr_ty a; + if ( + (a = _PyPegen_name_token(p)) // NAME + && + _PyPegen_lookahead(1, del_target_end_rule, p) + ) + { + D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME &del_target_end")); + _res = _PyPegen_set_expr_context ( p , a , Del ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME &del_target_end")); + } + { // '(' del_target ')' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' del_target ')'")); + Token * _literal; + Token * _literal_1; + expr_ty a; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (a = del_target_rule(p)) // del_target + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' del_target ')'")); + _res = _PyPegen_set_expr_context ( p , a , Del ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' del_target ')'")); + } + { // '(' del_targets? ')' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' del_targets? ')'")); + Token * _literal; + Token * _literal_1; + void *a; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (a = del_targets_rule(p), 1) // del_targets? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' del_targets? ')'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Tuple ( a , Del , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' del_targets? ')'")); + } + { // '[' del_targets? ']' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' del_targets? ']'")); + Token * _literal; + Token * _literal_1; + void *a; + if ( + (_literal = _PyPegen_expect_token(p, 9)) // token='[' + && + (a = del_targets_rule(p), 1) // del_targets? + && + (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + ) + { + D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' del_targets? ']'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_List ( a , Del , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' del_targets? ']'")); + } + { // invalid_del_target + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_del_target")); + void *invalid_del_target_var; + if ( + (invalid_del_target_var = invalid_del_target_rule(p)) // invalid_del_target + ) + { + D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_del_target")); + _res = invalid_del_target_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_del_target")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// del_target_end: ')' | ']' | ',' | ';' | NEWLINE +static void * +del_target_end_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> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s del_target_end[%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> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "']'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 10)) // token=']' + ) + { + D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "']'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s del_target_end[%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> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s del_target_end[%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> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 13)) // token=';' + ) + { + D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'")); + } + { // NEWLINE + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + Token * newline_var; + if ( + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + _res = newline_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// targets: ','.target+ ','? +static asdl_seq* +targets_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq* _res = NULL; + int _mark = p->mark; + { // ','.target+ ','? + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.target+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_seq * a; + if ( + (a = _gather_148_rule(p)) // ','.target+ + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + ) + { + D(fprintf(stderr, "%*c+ targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.target+ ','?")); + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s targets[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.target+ ','?")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// target: +// | t_primary '.' NAME !t_lookahead +// | t_primary '[' slices ']' !t_lookahead +// | t_atom +static expr_ty +target_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, target_type, &_res)) { + D(p->level--); + return _res; + } + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // t_primary '.' NAME !t_lookahead + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); + Token * _literal; + expr_ty a; + expr_ty b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = _PyPegen_expect_token(p, 23)) // token='.' + && + (b = _PyPegen_name_token(p)) // NAME + && + _PyPegen_lookahead(0, t_lookahead_rule, p) + ) + { + D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); + } + { // t_primary '[' slices ']' !t_lookahead + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + Token * _literal; + Token * _literal_1; + expr_ty a; + expr_ty b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = _PyPegen_expect_token(p, 9)) // token='[' + && + (b = slices_rule(p)) // slices + && + (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + && + _PyPegen_lookahead(0, t_lookahead_rule, p) + ) + { + D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Subscript ( a , b , Store , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); + } + { // t_atom + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_atom")); + expr_ty t_atom_var; + if ( + (t_atom_var = t_atom_rule(p)) // t_atom + ) + { + D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_atom")); + _res = t_atom_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_atom")); + } + _res = NULL; + done: + _PyPegen_insert_memo(p, _mark, target_type, _res); + D(p->level--); + return _res; +} + +// Left-recursive +// t_primary: +// | t_primary '.' NAME &t_lookahead +// | t_primary '[' slices ']' &t_lookahead +// | t_primary genexp &t_lookahead +// | t_primary '(' arguments? ')' &t_lookahead +// | atom &t_lookahead +static expr_ty t_primary_raw(Parser *); +static expr_ty +t_primary_rule(Parser *p) +{ + D(p->level++); + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, t_primary_type, &_res)) { + D(p->level--); + return _res; + } + int _mark = p->mark; + int _resmark = p->mark; + while (1) { + int tmpvar_8 = _PyPegen_update_memo(p, _mark, t_primary_type, _res); + if (tmpvar_8) { + D(p->level--); + return _res; + } + p->mark = _mark; + void *_raw = t_primary_raw(p); + if (_raw == NULL || p->mark <= _resmark) + break; + _resmark = p->mark; + _res = _raw; + } + p->mark = _resmark; + D(p->level--); + return _res; +} +static expr_ty +t_primary_raw(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // t_primary '.' NAME &t_lookahead + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &t_lookahead")); + Token * _literal; + expr_ty a; + expr_ty b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = _PyPegen_expect_token(p, 23)) // token='.' + && + (b = _PyPegen_name_token(p)) // NAME + && + _PyPegen_lookahead(1, t_lookahead_rule, p) + ) + { + D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &t_lookahead")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME &t_lookahead")); + } + { // t_primary '[' slices ']' &t_lookahead + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); + Token * _literal; + Token * _literal_1; + expr_ty a; + expr_ty b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = _PyPegen_expect_token(p, 9)) // token='[' + && + (b = slices_rule(p)) // slices + && + (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + && + _PyPegen_lookahead(1, t_lookahead_rule, p) + ) + { + D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Subscript ( a , b , Load , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); + } + { // t_primary genexp &t_lookahead + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary genexp &t_lookahead")); + expr_ty a; + expr_ty b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (b = genexp_rule(p)) // genexp + && + _PyPegen_lookahead(1, t_lookahead_rule, p) + ) + { + D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary genexp &t_lookahead")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary genexp &t_lookahead")); + } + { // t_primary '(' arguments? ')' &t_lookahead + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); + Token * _literal; + Token * _literal_1; + expr_ty a; + void *b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (b = arguments_rule(p), 1) // arguments? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + && + _PyPegen_lookahead(1, t_lookahead_rule, p) + ) + { + D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); + } + { // atom &t_lookahead + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "atom &t_lookahead")); + expr_ty a; + if ( + (a = atom_rule(p)) // atom + && + _PyPegen_lookahead(1, t_lookahead_rule, p) + ) + { + D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "atom &t_lookahead")); + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "atom &t_lookahead")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// t_lookahead: '(' | '[' | '.' +static void * +t_lookahead_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> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + ) + { + D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s t_lookahead[%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> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 9)) // token='[' + ) + { + D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s t_lookahead[%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> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 23)) // token='.' + ) + { + D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']' +static expr_ty +t_atom_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // NAME + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); + expr_ty a; + if ( + (a = _PyPegen_name_token(p)) // NAME + ) + { + D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); + _res = _PyPegen_set_expr_context ( p , a , Store ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); + } + { // '(' target ')' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' target ')'")); + Token * _literal; + Token * _literal_1; + expr_ty a; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (a = target_rule(p)) // target + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' target ')'")); + _res = _PyPegen_set_expr_context ( p , a , Store ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' target ')'")); + } + { // '(' targets? ')' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' targets? ')'")); + Token * _literal; + Token * _literal_1; + void *b; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (b = targets_rule(p), 1) // targets? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' targets? ')'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Tuple ( b , Store , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' targets? ')'")); + } + { // '[' targets? ']' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' targets? ']'")); + Token * _literal; + Token * _literal_1; + void *b; + if ( + (_literal = _PyPegen_expect_token(p, 9)) // token='[' + && + (b = targets_rule(p), 1) // targets? + && + (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + ) + { + D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' targets? ']'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_List ( b , Store , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' targets? ']'")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// incorrect_arguments: +// | args ',' '*' +// | expression for_if_clauses ',' [args | expression for_if_clauses] +// | args for_if_clauses +// | args ',' expression for_if_clauses +// | args ',' args +static void * +incorrect_arguments_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // args ',' '*' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' '*'")); + Token * _literal; + Token * _literal_1; + expr_ty args_var; + if ( + (args_var = args_rule(p)) // args + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' + ) + { + D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' '*'")); + _res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' '*'")); + } + { // expression for_if_clauses ',' [args | expression for_if_clauses] + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty a; + asdl_seq* for_if_clauses_var; + if ( + (a = expression_rule(p)) // expression + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (_opt_var = _tmp_150_rule(p), 1) // [args | expression for_if_clauses] + ) + { + D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "Generator expression must be parenthesized" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); + } + { // args for_if_clauses + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args for_if_clauses")); + expr_ty a; + asdl_seq* for_if_clauses_var; + if ( + (a = args_rule(p)) // args + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args for_if_clauses")); + _res = _PyPegen_nonparen_genexp_in_call ( p , a ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args for_if_clauses")); + } + { // args ',' expression for_if_clauses + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses")); + Token * _literal; + expr_ty a; + expr_ty args_var; + asdl_seq* for_if_clauses_var; + if ( + (args_var = args_rule(p)) // args + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (a = expression_rule(p)) // expression + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "Generator expression must be parenthesized" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' expression for_if_clauses")); + } + { // args ',' args + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' args")); + Token * _literal; + expr_ty a; + expr_ty args_var; + if ( + (a = args_rule(p)) // args + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (args_var = args_rule(p)) // args + ) + { + D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' args")); + _res = _PyPegen_arguments_parsing_error ( p , a ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' args")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// invalid_kwarg: expression '=' +static void * +invalid_kwarg_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_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression '='")); + Token * _literal; + expr_ty a; + if ( + (a = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression '='")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expression cannot contain assignment, perhaps you meant \"==\"?" ); + 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_kwarg[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression '='")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// invalid_named_expression: expression ':=' expression +static void * +invalid_named_expression_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // expression ':=' expression + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':=' expression")); + Token * _literal; + expr_ty a; + expr_ty expression_var; + if ( + (a = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 53)) // token=':=' + && + (expression_var = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':=' expression")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) ); + 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_named_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':=' expression")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// invalid_assignment: +// | list ':' +// | tuple ':' +// | star_named_expression ',' star_named_expressions* ':' +// | expression ':' expression ['=' annotated_rhs] +// | star_expressions '=' (yield_expr | star_expressions) +// | star_expressions augassign (yield_expr | star_expressions) +static void * +invalid_assignment_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // list ':' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list ':'")); + Token * _literal; + expr_ty a; + if ( + (a = list_rule(p)) // list + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list ':'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not list) can be annotated" ); + 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_assignment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list ':'")); + } + { // tuple ':' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple ':'")); + Token * _literal; + expr_ty a; + if ( + (a = tuple_rule(p)) // tuple + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple ':'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" ); + 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_assignment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple ':'")); + } + { // star_named_expression ',' star_named_expressions* ':' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'")); + Token * _literal; + Token * _literal_1; + asdl_seq * _loop0_151_var; + expr_ty a; + if ( + (a = star_named_expression_rule(p)) // star_named_expression + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (_loop0_151_var = _loop0_151_rule(p)) // star_named_expressions* + && + (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" ); + 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_assignment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'")); + } + { // expression ':' expression ['=' annotated_rhs] + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]")); + Token * _literal; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty a; + expr_ty expression_var; + if ( + (a = expression_rule(p)) // expression + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (expression_var = expression_rule(p)) // expression + && + (_opt_var = _tmp_152_rule(p), 1) // ['=' annotated_rhs] + ) + { + D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "illegal target for annotation" ); + 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_assignment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' expression ['=' annotated_rhs]")); + } + { // star_expressions '=' (yield_expr | star_expressions) + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); + Token * _literal; + void *_tmp_153_var; + expr_ty a; + if ( + (a = star_expressions_rule(p)) // star_expressions + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + && + (_tmp_153_var = _tmp_153_rule(p)) // yield_expr | star_expressions + ) + { + D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( _PyPegen_get_invalid_target ( a ) , "cannot assign to %s" , _PyPegen_get_expr_name ( _PyPegen_get_invalid_target ( a ) ) ); + 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_assignment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); + } + { // star_expressions augassign (yield_expr | star_expressions) + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); + void *_tmp_154_var; + expr_ty a; + AugOperator* augassign_var; + if ( + (a = star_expressions_rule(p)) // star_expressions + && + (augassign_var = augassign_rule(p)) // augassign + && + (_tmp_154_var = _tmp_154_rule(p)) // yield_expr | star_expressions + ) + { + D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "'%s' is an illegal expression for augmented assignment" , _PyPegen_get_expr_name ( a ) ); + 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_assignment[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// invalid_block: NEWLINE !INDENT +static void * +invalid_block_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // NEWLINE !INDENT + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT")); + Token * newline_var; + if ( + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + ) + { + D(fprintf(stderr, "%*c+ invalid_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT")); + _res = RAISE_INDENTATION_ERROR ( "expected an indented block" ); + 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_block[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE !INDENT")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// invalid_comprehension: ('[' | '(' | '{') starred_expression for_if_clauses +static void * +invalid_comprehension_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ('[' | '(' | '{') starred_expression for_if_clauses + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); + void *_tmp_155_var; + expr_ty a; + asdl_seq* for_if_clauses_var; + if ( + (_tmp_155_var = _tmp_155_rule(p)) // '[' | '(' | '{' + && + (a = starred_expression_rule(p)) // starred_expression + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "iterable unpacking cannot be used in comprehension" ); + 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_comprehension[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// invalid_dict_comprehension: '{' '**' bitwise_or for_if_clauses '}' +static void * +invalid_dict_comprehension_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // '{' '**' bitwise_or for_if_clauses '}' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_dict_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'")); + Token * _literal; + Token * _literal_1; + Token * a; + expr_ty bitwise_or_var; + asdl_seq* for_if_clauses_var; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (a = _PyPegen_expect_token(p, 35)) // token='**' + && + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + && + (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' + ) + { + D(fprintf(stderr, "%*c+ invalid_dict_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "dict unpacking cannot be used in dict comprehension" ); + 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_dict_comprehension[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// invalid_parameters: +// | param_no_default* (slash_with_default | param_with_default+) param_no_default +static void * +invalid_parameters_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // param_no_default* (slash_with_default | param_with_default+) param_no_default + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); + asdl_seq * _loop0_156_var; + void *_tmp_157_var; + arg_ty param_no_default_var; + if ( + (_loop0_156_var = _loop0_156_rule(p)) // param_no_default* + && + (_tmp_157_var = _tmp_157_rule(p)) // slash_with_default | param_with_default+ + && + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); + _res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" ); + 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_parameters[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// invalid_star_etc: '*' (')' | ',' (')' | '**')) | '*' ',' TYPE_COMMENT +static void * +invalid_star_etc_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> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); + Token * _literal; + void *_tmp_158_var; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (_tmp_158_var = _tmp_158_rule(p)) // ')' | ',' (')' | '**') + ) + { + D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); + _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); + 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_star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); + } + { // '*' ',' TYPE_COMMENT + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT")); + Token * _literal; + Token * _literal_1; + Token * type_comment_var; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + && + (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + ) + { + D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT")); + _res = RAISE_SYNTAX_ERROR ( "bare * has associated type comment" ); + 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_star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' TYPE_COMMENT")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// invalid_lambda_star_etc: '*' (':' | ',' (':' | '**')) +static void * +invalid_lambda_star_etc_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> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); + Token * _literal; + void *_tmp_159_var; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (_tmp_159_var = _tmp_159_rule(p)) // ':' | ',' (':' | '**') + ) + { + D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); + _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); + 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_lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT +static void * +invalid_double_type_comments_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_double_type_comments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); + Token * indent_var; + Token * newline_var; + Token * newline_var_1; + Token * type_comment_var; + Token * type_comment_var_1; + if ( + (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + (type_comment_var_1 = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + && + (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' + ) + { + D(fprintf(stderr, "%*c+ invalid_double_type_comments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); + _res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" ); + 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_type_comments[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// invalid_del_target: star_expression &del_target_end +static void * +invalid_del_target_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // star_expression &del_target_end + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression &del_target_end")); + expr_ty a; + if ( + (a = star_expression_rule(p)) // star_expression + && + _PyPegen_lookahead(1, del_target_end_rule, p) + ) + { + D(fprintf(stderr, "%*c+ invalid_del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression &del_target_end")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot delete %s" , _PyPegen_get_expr_name ( a ) ); + 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_del_target[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression &del_target_end")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// invalid_import_from_targets: import_from_as_names ',' +static void * +invalid_import_from_targets_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // import_from_as_names ',' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> invalid_import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_names ','")); + Token * _literal; + asdl_seq* import_from_as_names_var; + if ( + (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ invalid_import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_names ','")); + _res = RAISE_SYNTAX_ERROR ( "trailing comma not allowed without surrounding parentheses" ); + 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_import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_names ','")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_1: NEWLINE +static asdl_seq * +_loop0_1_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // NEWLINE + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_1[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + Token * newline_var; + while ( + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = newline_var; + 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_1[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); + } + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_1_type, _seq); + D(p->level--); + return _seq; +} + +// _loop0_2: NEWLINE +static asdl_seq * +_loop0_2_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // NEWLINE + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_2[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + Token * newline_var; + while ( + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = newline_var; + 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_2[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); + } + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_2_type, _seq); + D(p->level--); + return _seq; +} + +// _loop0_4: ',' expression +static asdl_seq * +_loop0_4_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' expression + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_4[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + Token * _literal; + expr_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = expression_rule(p)) // expression + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + 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_4[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); + } + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_4_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_3: expression _loop0_4 +static asdl_seq * +_gather_3_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // expression _loop0_4 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _gather_3[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_4")); + expr_ty elem; + asdl_seq * seq; + if ( + (elem = expression_rule(p)) // expression + && + (seq = _loop0_4_rule(p)) // _loop0_4 + ) + { + D(fprintf(stderr, "%*c+ _gather_3[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_4")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_3[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_4")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_6: ',' expression +static asdl_seq * +_loop0_6_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' expression + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_6[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + Token * _literal; + expr_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = expression_rule(p)) // expression + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + 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_6[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); + } + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_6_type, _seq); + D(p->level--); + return _seq; } -// invalid_kwarg: expression '=' -static void * -invalid_kwarg_rule(Parser *p) +// _gather_5: expression _loop0_6 +static asdl_seq * +_gather_5_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // expression '=' + { // expression _loop0_6 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression '='")); - Token * _literal; - expr_ty a; + D(fprintf(stderr, "%*c> _gather_5[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_6")); + expr_ty elem; + asdl_seq * seq; if ( - (a = expression_rule(p)) // expression + (elem = expression_rule(p)) // expression && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' + (seq = _loop0_6_rule(p)) // _loop0_6 ) { - D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression '='")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expression cannot contain assignment, perhaps you meant \"==\"?" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _gather_5[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_6")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression '='")); + D(fprintf(stderr, "%*c%s _gather_5[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_6")); } _res = NULL; done: @@ -14516,293 +16715,412 @@ invalid_kwarg_rule(Parser *p) return _res; } -// invalid_named_expression: expression ':=' expression -static void * -invalid_named_expression_rule(Parser *p) +// _loop0_8: ',' expression +static asdl_seq * +_loop0_8_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // expression ':=' expression + int _start_mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':=' expression")); + D(fprintf(stderr, "%*c> _loop0_8[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; - expr_ty a; - expr_ty expression_var; - if ( - (a = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 53)) // token=':=' + expr_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (expression_var = expression_rule(p)) // expression + (elem = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':=' expression")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) ); + _res = elem; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; + PyMem_Free(_children); D(p->level--); return NULL; } - goto done; + 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 invalid_named_expression[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':=' expression")); + D(fprintf(stderr, "%*c%s _loop0_8[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } - _res = NULL; - done: + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_8_type, _seq); D(p->level--); - return _res; + return _seq; } -// invalid_assignment: -// | list ':' -// | tuple ':' -// | star_named_expression ',' star_named_expressions* ':' -// | expression ':' expression ['=' annotated_rhs] -// | star_expressions '=' (yield_expr | star_expressions) -// | star_expressions augassign (yield_expr | star_expressions) -static void * -invalid_assignment_rule(Parser *p) +// _gather_7: expression _loop0_8 +static asdl_seq * +_gather_7_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // list ':' + { // expression _loop0_8 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list ':'")); - Token * _literal; - expr_ty a; + D(fprintf(stderr, "%*c> _gather_7[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_8")); + expr_ty elem; + asdl_seq * seq; if ( - (a = list_rule(p)) // list + (elem = expression_rule(p)) // expression && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' + (seq = _loop0_8_rule(p)) // _loop0_8 ) { - D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list ':'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not list) can be annotated" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _gather_7[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_8")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list ':'")); + D(fprintf(stderr, "%*c%s _gather_7[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_8")); } - { // tuple ':' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple ':'")); - Token * _literal; - expr_ty a; - if ( - (a = tuple_rule(p)) // tuple - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple ':'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" ); - 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_assignment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple ':'")); + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_10: ',' expression +static asdl_seq * +_loop0_10_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; } - { // star_named_expression ',' star_named_expressions* ':' + 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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'")); + D(fprintf(stderr, "%*c> _loop0_10[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; - Token * _literal_1; - asdl_seq * _loop0_126_var; - expr_ty a; - if ( - (a = star_named_expression_rule(p)) // star_named_expression - && + expr_ty elem; + while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_loop0_126_var = _loop0_126_rule(p)) // star_named_expressions* - && - (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' + (elem = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" ); + _res = elem; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; + PyMem_Free(_children); D(p->level--); return NULL; } - goto done; + 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 invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'")); + D(fprintf(stderr, "%*c%s _loop0_10[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); + } + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_10_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_9: expression _loop0_10 +static asdl_seq * +_gather_9_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; } - { // expression ':' expression ['=' annotated_rhs] + asdl_seq * _res = NULL; + int _mark = p->mark; + { // expression _loop0_10 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]")); - Token * _literal; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty a; - expr_ty expression_var; + D(fprintf(stderr, "%*c> _gather_9[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_10")); + expr_ty elem; + asdl_seq * seq; if ( - (a = expression_rule(p)) // expression - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (expression_var = expression_rule(p)) // expression + (elem = expression_rule(p)) // expression && - (_opt_var = _tmp_127_rule(p), 1) // ['=' annotated_rhs] + (seq = _loop0_10_rule(p)) // _loop0_10 ) { - D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "illegal target for annotation" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _gather_9[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_10")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' expression ['=' annotated_rhs]")); + D(fprintf(stderr, "%*c%s _gather_9[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_10")); } - { // star_expressions '=' (yield_expr | star_expressions) + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop1_11: statement +static asdl_seq * +_loop1_11_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // statement if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); - Token * _literal; - void *_tmp_128_var; - expr_ty a; - if ( - (a = star_expressions_rule(p)) // star_expressions - && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - && - (_tmp_128_var = _tmp_128_rule(p)) // yield_expr | star_expressions + D(fprintf(stderr, "%*c> _loop1_11[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement")); + asdl_seq* statement_var; + while ( + (statement_var = statement_rule(p)) // statement ) { - D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( _PyPegen_get_invalid_target ( a ) , "cannot assign to %s" , _PyPegen_get_expr_name ( _PyPegen_get_invalid_target ( a ) ) ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; + _res = statement_var; + 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; } - goto done; + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); + D(fprintf(stderr, "%*c%s _loop1_11[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement")); } - { // star_expressions augassign (yield_expr | star_expressions) + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; + } + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop1_11_type, _seq); + D(p->level--); + return _seq; +} + +// _loop0_13: ';' small_stmt +static asdl_seq * +_loop0_13_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ';' small_stmt if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); - void *_tmp_129_var; - expr_ty a; - AugOperator* augassign_var; - if ( - (a = star_expressions_rule(p)) // star_expressions - && - (augassign_var = augassign_rule(p)) // augassign + D(fprintf(stderr, "%*c> _loop0_13[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';' small_stmt")); + Token * _literal; + stmt_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 13)) // token=';' && - (_tmp_129_var = _tmp_129_rule(p)) // yield_expr | star_expressions + (elem = small_stmt_rule(p)) // small_stmt ) { - D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "'%s' is an illegal expression for augmented assignment" , _PyPegen_get_expr_name ( a ) ); + _res = elem; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; + PyMem_Free(_children); D(p->level--); return NULL; } - goto done; + 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 invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); + D(fprintf(stderr, "%*c%s _loop0_13[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';' small_stmt")); } - _res = NULL; - done: + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_13_type, _seq); D(p->level--); - return _res; + return _seq; } -// invalid_block: NEWLINE !INDENT -static void * -invalid_block_rule(Parser *p) +// _gather_12: small_stmt _loop0_13 +static asdl_seq * +_gather_12_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // NEWLINE !INDENT + { // small_stmt _loop0_13 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT")); - Token * newline_var; + D(fprintf(stderr, "%*c> _gather_12[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13")); + stmt_ty elem; + asdl_seq * seq; if ( - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + (elem = small_stmt_rule(p)) // small_stmt && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT + (seq = _loop0_13_rule(p)) // _loop0_13 ) { - D(fprintf(stderr, "%*c+ invalid_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT")); - _res = RAISE_INDENTATION_ERROR ( "expected an indented block" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _gather_12[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_block[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE !INDENT")); + D(fprintf(stderr, "%*c%s _gather_12[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "small_stmt _loop0_13")); } _res = NULL; done: @@ -14810,9 +17128,9 @@ invalid_block_rule(Parser *p) return _res; } -// invalid_comprehension: ('[' | '(' | '{') starred_expression for_if_clauses +// _tmp_14: 'import' | 'from' static void * -invalid_comprehension_rule(Parser *p) +_tmp_14_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -14821,35 +17139,43 @@ invalid_comprehension_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ('[' | '(' | '{') starred_expression for_if_clauses + { // 'import' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); - void *_tmp_130_var; - expr_ty a; - asdl_seq* for_if_clauses_var; + D(fprintf(stderr, "%*c> _tmp_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import'")); + Token * _keyword; + if ( + (_keyword = _PyPegen_expect_token(p, 513)) // token='import' + ) + { + D(fprintf(stderr, "%*c+ _tmp_14[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import'")); + _res = _keyword; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_14[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import'")); + } + { // 'from' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from'")); + Token * _keyword; if ( - (_tmp_130_var = _tmp_130_rule(p)) // '[' | '(' | '{' - && - (a = starred_expression_rule(p)) // starred_expression - && - (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + (_keyword = _PyPegen_expect_token(p, 514)) // token='from' ) { - D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "iterable unpacking cannot be used in comprehension" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_14[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from'")); + _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_comprehension[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); + D(fprintf(stderr, "%*c%s _tmp_14[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from'")); } _res = NULL; done: @@ -14857,9 +17183,9 @@ invalid_comprehension_rule(Parser *p) return _res; } -// invalid_dict_comprehension: '{' '**' bitwise_or for_if_clauses '}' +// _tmp_15: 'def' | '@' | ASYNC static void * -invalid_dict_comprehension_rule(Parser *p) +_tmp_15_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -14868,41 +17194,62 @@ invalid_dict_comprehension_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '{' '**' bitwise_or for_if_clauses '}' + { // 'def' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_dict_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'")); + D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def'")); + Token * _keyword; + if ( + (_keyword = _PyPegen_expect_token(p, 525)) // token='def' + ) + { + D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def'")); + _res = _keyword; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def'")); + } + { // '@' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'")); Token * _literal; - Token * _literal_1; - Token * a; - expr_ty bitwise_or_var; - asdl_seq* for_if_clauses_var; if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - && - (a = _PyPegen_expect_token(p, 35)) // token='**' - && - (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or - && - (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses - && - (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' + (_literal = _PyPegen_expect_token(p, 49)) // token='@' ) { - D(fprintf(stderr, "%*c+ invalid_dict_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "dict unpacking cannot be used in dict comprehension" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_dict_comprehension[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'")); + D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'")); + } + { // ASYNC + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC")); + Token * async_var; + if ( + (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' + ) + { + D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC")); + _res = async_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC")); } _res = NULL; done: @@ -14910,10 +17257,9 @@ invalid_dict_comprehension_rule(Parser *p) return _res; } -// invalid_parameters: -// | param_no_default* (slash_with_default | param_with_default+) param_no_default +// _tmp_16: 'class' | '@' static void * -invalid_parameters_rule(Parser *p) +_tmp_16_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -14922,35 +17268,43 @@ invalid_parameters_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // param_no_default* (slash_with_default | param_with_default+) param_no_default + { // 'class' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); - asdl_seq * _loop0_131_var; - void *_tmp_132_var; - arg_ty param_no_default_var; + D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class'")); + Token * _keyword; if ( - (_loop0_131_var = _loop0_131_rule(p)) // param_no_default* - && - (_tmp_132_var = _tmp_132_rule(p)) // slash_with_default | param_with_default+ - && - (param_no_default_var = param_no_default_rule(p)) // param_no_default + (_keyword = _PyPegen_expect_token(p, 526)) // token='class' ) { - D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); - _res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class'")); + _res = _keyword; goto done; } 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* (slash_with_default | param_with_default+) param_no_default")); + D(fprintf(stderr, "%*c%s _tmp_16[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class'")); + } + { // '@' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 49)) // token='@' + ) + { + D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_16[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'")); } _res = NULL; done: @@ -14958,9 +17312,9 @@ invalid_parameters_rule(Parser *p) return _res; } -// invalid_star_etc: '*' (')' | ',' (')' | '**')) | '*' ',' TYPE_COMMENT +// _tmp_17: 'with' | ASYNC static void * -invalid_star_etc_rule(Parser *p) +_tmp_17_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -14969,62 +17323,43 @@ invalid_star_etc_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '*' (')' | ',' (')' | '**')) + { // 'with' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); - Token * _literal; - void *_tmp_133_var; + D(fprintf(stderr, "%*c> _tmp_17[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with'")); + Token * _keyword; if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_133_var = _tmp_133_rule(p)) // ')' | ',' (')' | '**') + (_keyword = _PyPegen_expect_token(p, 519)) // token='with' ) { - D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); - _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_17[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with'")); + _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); + D(fprintf(stderr, "%*c%s _tmp_17[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with'")); } - { // '*' ',' TYPE_COMMENT + { // ASYNC if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT")); - Token * _literal; - Token * _literal_1; - Token * type_comment_var; + D(fprintf(stderr, "%*c> _tmp_17[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC")); + Token * async_var; if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' - && - (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' ) { - D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT")); - _res = RAISE_SYNTAX_ERROR ( "bare * has associated type comment" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_17[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC")); + _res = async_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' TYPE_COMMENT")); + D(fprintf(stderr, "%*c%s _tmp_17[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC")); } _res = NULL; done: @@ -15032,9 +17367,9 @@ invalid_star_etc_rule(Parser *p) return _res; } -// invalid_lambda_star_etc: '*' (':' | ',' (':' | '**')) +// _tmp_18: 'for' | ASYNC static void * -invalid_lambda_star_etc_rule(Parser *p) +_tmp_18_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -15043,32 +17378,43 @@ invalid_lambda_star_etc_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '*' (':' | ',' (':' | '**')) + { // 'for' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); - Token * _literal; - void *_tmp_134_var; + D(fprintf(stderr, "%*c> _tmp_18[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for'")); + Token * _keyword; if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_134_var = _tmp_134_rule(p)) // ':' | ',' (':' | '**') + (_keyword = _PyPegen_expect_token(p, 517)) // token='for' ) { - D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); - _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_18[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for'")); + _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); + D(fprintf(stderr, "%*c%s _tmp_18[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for'")); + } + { // ASYNC + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_18[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC")); + Token * async_var; + if ( + (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' + ) + { + D(fprintf(stderr, "%*c+ _tmp_18[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC")); + _res = async_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_18[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC")); } _res = NULL; done: @@ -15076,9 +17422,9 @@ invalid_lambda_star_etc_rule(Parser *p) return _res; } -// invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT +// _tmp_19: '=' annotated_rhs static void * -invalid_double_type_comments_rule(Parser *p) +_tmp_19_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -15087,31 +17433,22 @@ invalid_double_type_comments_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT + { // '=' annotated_rhs if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_double_type_comments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); - Token * indent_var; - Token * newline_var; - Token * newline_var_1; - Token * type_comment_var; - Token * type_comment_var_1; + D(fprintf(stderr, "%*c> _tmp_19[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + Token * _literal; + expr_ty d; if ( - (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - (type_comment_var_1 = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' - && - (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + (_literal = _PyPegen_expect_token(p, 22)) // token='=' && - (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' + (d = annotated_rhs_rule(p)) // annotated_rhs ) { - D(fprintf(stderr, "%*c+ invalid_double_type_comments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); - _res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" ); + D(fprintf(stderr, "%*c+ _tmp_19[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + _res = d; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -15120,8 +17457,8 @@ invalid_double_type_comments_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_double_type_comments[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); + D(fprintf(stderr, "%*c%s _tmp_19[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); } _res = NULL; done: @@ -15129,9 +17466,9 @@ invalid_double_type_comments_rule(Parser *p) return _res; } -// invalid_del_target: star_expression &del_target_end +// _tmp_20: '(' single_target ')' | single_subscript_attribute_target static void * -invalid_del_target_rule(Parser *p) +_tmp_20_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -15140,21 +17477,25 @@ invalid_del_target_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // star_expression &del_target_end + { // '(' single_target ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression &del_target_end")); - expr_ty a; + D(fprintf(stderr, "%*c> _tmp_20[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); + Token * _literal; + Token * _literal_1; + expr_ty b; if ( - (a = star_expression_rule(p)) // star_expression + (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - _PyPegen_lookahead(1, del_target_end_rule, p) + (b = single_target_rule(p)) // single_target + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ invalid_del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression &del_target_end")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot delete %s" , _PyPegen_get_expr_name ( a ) ); + D(fprintf(stderr, "%*c+ _tmp_20[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); + _res = b; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -15163,8 +17504,27 @@ invalid_del_target_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_del_target[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression &del_target_end")); + D(fprintf(stderr, "%*c%s _tmp_20[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'")); + } + { // single_subscript_attribute_target + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_20[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); + expr_ty single_subscript_attribute_target_var; + if ( + (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target + ) + { + D(fprintf(stderr, "%*c+ _tmp_20[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); + _res = single_subscript_attribute_target_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_20[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_subscript_attribute_target")); } _res = NULL; done: @@ -15172,9 +17532,9 @@ invalid_del_target_rule(Parser *p) return _res; } -// invalid_import_from_targets: import_from_as_names ',' +// _tmp_21: '=' annotated_rhs static void * -invalid_import_from_targets_rule(Parser *p) +_tmp_21_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -15183,22 +17543,22 @@ invalid_import_from_targets_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // import_from_as_names ',' + { // '=' annotated_rhs if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> invalid_import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_names ','")); + D(fprintf(stderr, "%*c> _tmp_21[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); Token * _literal; - asdl_seq* import_from_as_names_var; + expr_ty d; if ( - (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names + (_literal = _PyPegen_expect_token(p, 22)) // token='=' && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (d = annotated_rhs_rule(p)) // annotated_rhs ) { - D(fprintf(stderr, "%*c+ invalid_import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_names ','")); - _res = RAISE_SYNTAX_ERROR ( "trailing comma not allowed without surrounding parentheses" ); + D(fprintf(stderr, "%*c+ _tmp_21[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + _res = d; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -15207,8 +17567,8 @@ invalid_import_from_targets_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s invalid_import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_names ','")); + D(fprintf(stderr, "%*c%s _tmp_21[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); } _res = NULL; done: @@ -15216,9 +17576,9 @@ invalid_import_from_targets_rule(Parser *p) return _res; } -// _loop0_1: NEWLINE +// _loop1_22: (star_targets '=') static asdl_seq * -_loop0_1_rule(Parser *p) +_loop1_22_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -15237,18 +17597,18 @@ _loop0_1_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // NEWLINE + { // (star_targets '=') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_1[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - Token * newline_var; + D(fprintf(stderr, "%*c> _loop1_22[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); + void *_tmp_160_var; while ( - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + (_tmp_160_var = _tmp_160_rule(p)) // star_targets '=' ) { - _res = newline_var; + _res = _tmp_160_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -15264,8 +17624,13 @@ _loop0_1_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_1[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); + D(fprintf(stderr, "%*c%s _loop1_22[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -15277,80 +17642,124 @@ _loop0_1_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_1_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_22_type, _seq); D(p->level--); return _seq; } -// _loop0_2: NEWLINE -static asdl_seq * -_loop0_2_rule(Parser *p) +// _tmp_23: yield_expr | star_expressions +static void * +_tmp_23_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void *_res = 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; + { // yield_expr + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_23[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + expr_ty yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + D(fprintf(stderr, "%*c+ _tmp_23[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + _res = yield_expr_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_23[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // NEWLINE + { // star_expressions if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_2[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - Token * newline_var; - while ( - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + D(fprintf(stderr, "%*c> _tmp_23[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + expr_ty star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - _res = newline_var; - 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; + D(fprintf(stderr, "%*c+ _tmp_23[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + _res = star_expressions_var; + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_2[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); + D(fprintf(stderr, "%*c%s _tmp_23[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } - asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_24: yield_expr | star_expressions +static void * +_tmp_24_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { D(p->level--); return NULL; } - for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); - PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_2_type, _seq); + void * _res = NULL; + int _mark = p->mark; + { // yield_expr + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + expr_ty yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + D(fprintf(stderr, "%*c+ _tmp_24[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + _res = yield_expr_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_24[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); + } + { // star_expressions + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + expr_ty star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions + ) + { + D(fprintf(stderr, "%*c+ _tmp_24[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + _res = star_expressions_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_24[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); + } + _res = NULL; + done: D(p->level--); - return _seq; + return _res; } -// _loop0_4: ',' expression +// _loop0_26: ',' NAME static asdl_seq * -_loop0_4_rule(Parser *p) +_loop0_26_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -15369,18 +17778,18 @@ _loop0_4_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' expression + { // ',' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_4[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _loop0_26[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME")); Token * _literal; expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = expression_rule(p)) // expression + (elem = _PyPegen_name_token(p)) // NAME ) { _res = elem; @@ -15405,8 +17814,8 @@ _loop0_4_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_4[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c%s _loop0_26[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -15418,14 +17827,14 @@ _loop0_4_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_4_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_26_type, _seq); D(p->level--); return _seq; } -// _gather_3: expression _loop0_4 +// _gather_25: NAME _loop0_26 static asdl_seq * -_gather_3_rule(Parser *p) +_gather_25_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -15434,27 +17843,27 @@ _gather_3_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // expression _loop0_4 + { // NAME _loop0_26 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_3[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_4")); + D(fprintf(stderr, "%*c> _gather_25[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26")); expr_ty elem; asdl_seq * seq; if ( - (elem = expression_rule(p)) // expression + (elem = _PyPegen_name_token(p)) // NAME && - (seq = _loop0_4_rule(p)) // _loop0_4 + (seq = _loop0_26_rule(p)) // _loop0_26 ) { - D(fprintf(stderr, "%*c+ _gather_3[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_4")); + D(fprintf(stderr, "%*c+ _gather_25[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_3[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_4")); + D(fprintf(stderr, "%*c%s _gather_25[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_26")); } _res = NULL; done: @@ -15462,9 +17871,9 @@ _gather_3_rule(Parser *p) return _res; } -// _loop0_6: ',' expression +// _loop0_28: ',' NAME static asdl_seq * -_loop0_6_rule(Parser *p) +_loop0_28_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -15483,18 +17892,18 @@ _loop0_6_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' expression + { // ',' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_6[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _loop0_28[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME")); Token * _literal; expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = expression_rule(p)) // expression + (elem = _PyPegen_name_token(p)) // NAME ) { _res = elem; @@ -15519,8 +17928,8 @@ _loop0_6_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_6[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c%s _loop0_28[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -15532,14 +17941,14 @@ _loop0_6_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_6_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_28_type, _seq); D(p->level--); return _seq; } -// _gather_5: expression _loop0_6 +// _gather_27: NAME _loop0_28 static asdl_seq * -_gather_5_rule(Parser *p) +_gather_27_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -15548,27 +17957,27 @@ _gather_5_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // expression _loop0_6 + { // NAME _loop0_28 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_5[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_6")); + D(fprintf(stderr, "%*c> _gather_27[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28")); expr_ty elem; asdl_seq * seq; if ( - (elem = expression_rule(p)) // expression + (elem = _PyPegen_name_token(p)) // NAME && - (seq = _loop0_6_rule(p)) // _loop0_6 + (seq = _loop0_28_rule(p)) // _loop0_28 ) { - D(fprintf(stderr, "%*c+ _gather_5[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_6")); + D(fprintf(stderr, "%*c+ _gather_27[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_5[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_6")); + D(fprintf(stderr, "%*c%s _gather_27[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_28")); } _res = NULL; done: @@ -15576,9 +17985,53 @@ _gather_5_rule(Parser *p) return _res; } -// _loop0_8: ',' expression +// _tmp_29: ',' expression +static void * +_tmp_29_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> _tmp_29[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + Token * _literal; + expr_ty z; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (z = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ _tmp_29[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); + _res = z; + 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_29[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_30: ('.' | '...') static asdl_seq * -_loop0_8_rule(Parser *p) +_loop0_30_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -15597,27 +18050,18 @@ _loop0_8_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' expression + { // ('.' | '...') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_8[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); - Token * _literal; - expr_ty elem; + D(fprintf(stderr, "%*c> _loop0_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); + void *_tmp_161_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = expression_rule(p)) // expression + (_tmp_161_var = _tmp_161_rule(p)) // '.' | '...' ) { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - D(p->level--); - return NULL; - } + _res = _tmp_161_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -15633,8 +18077,8 @@ _loop0_8_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_8[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c%s _loop0_30[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -15646,53 +18090,85 @@ _loop0_8_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_8_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_30_type, _seq); D(p->level--); return _seq; } -// _gather_7: expression _loop0_8 +// _loop1_31: ('.' | '...') static asdl_seq * -_gather_7_rule(Parser *p) +_loop1_31_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - asdl_seq * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // expression _loop0_8 + int _start_mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ('.' | '...') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_7[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_8")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = expression_rule(p)) // expression - && - (seq = _loop0_8_rule(p)) // _loop0_8 + D(fprintf(stderr, "%*c> _loop1_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); + void *_tmp_162_var; + while ( + (_tmp_162_var = _tmp_162_rule(p)) // '.' | '...' ) { - D(fprintf(stderr, "%*c+ _gather_7[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_8")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; + _res = _tmp_162_var; + 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 _gather_7[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_8")); + D(fprintf(stderr, "%*c%s _loop1_31[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); } - _res = NULL; - done: + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; + } + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop1_31_type, _seq); D(p->level--); - return _res; + return _seq; } -// _loop0_10: ',' expression +// _loop0_33: ',' import_from_as_name static asdl_seq * -_loop0_10_rule(Parser *p) +_loop0_33_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -15711,18 +18187,18 @@ _loop0_10_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' expression + { // ',' import_from_as_name if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_10[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _loop0_33[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' import_from_as_name")); Token * _literal; - expr_ty elem; + alias_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = expression_rule(p)) // expression + (elem = import_from_as_name_rule(p)) // import_from_as_name ) { _res = elem; @@ -15747,8 +18223,8 @@ _loop0_10_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_10[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c%s _loop0_33[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' import_from_as_name")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -15760,14 +18236,14 @@ _loop0_10_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_10_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_33_type, _seq); D(p->level--); return _seq; } -// _gather_9: expression _loop0_10 +// _gather_32: import_from_as_name _loop0_33 static asdl_seq * -_gather_9_rule(Parser *p) +_gather_32_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -15776,27 +18252,27 @@ _gather_9_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // expression _loop0_10 + { // import_from_as_name _loop0_33 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_9[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_10")); - expr_ty elem; + D(fprintf(stderr, "%*c> _gather_32[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_33")); + alias_ty elem; asdl_seq * seq; if ( - (elem = expression_rule(p)) // expression + (elem = import_from_as_name_rule(p)) // import_from_as_name && - (seq = _loop0_10_rule(p)) // _loop0_10 + (seq = _loop0_33_rule(p)) // _loop0_33 ) { - D(fprintf(stderr, "%*c+ _gather_9[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_10")); + D(fprintf(stderr, "%*c+ _gather_32[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_33")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_9[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_10")); + D(fprintf(stderr, "%*c%s _gather_32[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_name _loop0_33")); } _res = NULL; done: @@ -15804,80 +18280,53 @@ _gather_9_rule(Parser *p) return _res; } -// _loop1_11: statement -static asdl_seq * -_loop1_11_rule(Parser *p) +// _tmp_34: 'as' NAME +static void * +_tmp_34_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void *_res = 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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // statement + { // 'as' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_11[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement")); - asdl_seq* statement_var; - while ( - (statement_var = statement_rule(p)) // statement - ) - { - _res = statement_var; - 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; + D(fprintf(stderr, "%*c> _tmp_34[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + Token * _keyword; + expr_ty z; + if ( + (_keyword = _PyPegen_expect_token(p, 531)) // token='as' + && + (z = _PyPegen_name_token(p)) // NAME + ) + { + D(fprintf(stderr, "%*c+ _tmp_34[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; } - _children[_n++] = _res; - _mark = p->mark; + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_11[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - D(p->level--); - return NULL; - } - asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s _tmp_34[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } - for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); - PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_11_type, _seq); + _res = NULL; + done: D(p->level--); - return _seq; + return _res; } -// _loop0_13: ';' small_stmt +// _loop0_36: ',' dotted_as_name static asdl_seq * -_loop0_13_rule(Parser *p) +_loop0_36_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -15896,18 +18345,18 @@ _loop0_13_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ';' small_stmt + { // ',' dotted_as_name if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_13[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';' small_stmt")); + D(fprintf(stderr, "%*c> _loop0_36[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' dotted_as_name")); Token * _literal; - stmt_ty elem; + alias_ty elem; while ( - (_literal = _PyPegen_expect_token(p, 13)) // token=';' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = small_stmt_rule(p)) // small_stmt + (elem = dotted_as_name_rule(p)) // dotted_as_name ) { _res = elem; @@ -15932,8 +18381,8 @@ _loop0_13_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_13[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';' small_stmt")); + D(fprintf(stderr, "%*c%s _loop0_36[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' dotted_as_name")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -15945,14 +18394,14 @@ _loop0_13_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_13_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_36_type, _seq); D(p->level--); return _seq; } -// _gather_12: small_stmt _loop0_13 +// _gather_35: dotted_as_name _loop0_36 static asdl_seq * -_gather_12_rule(Parser *p) +_gather_35_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -15961,27 +18410,27 @@ _gather_12_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // small_stmt _loop0_13 + { // dotted_as_name _loop0_36 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_12[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13")); - stmt_ty elem; + D(fprintf(stderr, "%*c> _gather_35[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_36")); + alias_ty elem; asdl_seq * seq; if ( - (elem = small_stmt_rule(p)) // small_stmt + (elem = dotted_as_name_rule(p)) // dotted_as_name && - (seq = _loop0_13_rule(p)) // _loop0_13 + (seq = _loop0_36_rule(p)) // _loop0_36 ) { - D(fprintf(stderr, "%*c+ _gather_12[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13")); + D(fprintf(stderr, "%*c+ _gather_35[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_36")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_12[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "small_stmt _loop0_13")); + D(fprintf(stderr, "%*c%s _gather_35[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_as_name _loop0_36")); } _res = NULL; done: @@ -15989,9 +18438,9 @@ _gather_12_rule(Parser *p) return _res; } -// _tmp_14: 'import' | 'from' +// _tmp_37: 'as' NAME static void * -_tmp_14_rule(Parser *p) +_tmp_37_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -16000,43 +18449,32 @@ _tmp_14_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // 'import' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 513)) // token='import' - ) - { - D(fprintf(stderr, "%*c+ _tmp_14[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_14[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import'")); - } - { // 'from' + { // 'as' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from'")); + D(fprintf(stderr, "%*c> _tmp_37[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; + expr_ty z; if ( - (_keyword = _PyPegen_expect_token(p, 514)) // token='from' + (_keyword = _PyPegen_expect_token(p, 531)) // token='as' + && + (z = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_14[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from'")); - _res = _keyword; + D(fprintf(stderr, "%*c+ _tmp_37[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + _res = z; + 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_14[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from'")); + D(fprintf(stderr, "%*c%s _tmp_37[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; done: @@ -16044,128 +18482,113 @@ _tmp_14_rule(Parser *p) return _res; } -// _tmp_15: 'def' | '@' | ASYNC -static void * -_tmp_15_rule(Parser *p) +// _loop0_39: ',' with_item +static asdl_seq * +_loop0_39_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // 'def' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 522)) // token='def' - ) - { - D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def'")); + int _start_mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; } - { // '@' + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' with_item if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'")); + D(fprintf(stderr, "%*c> _loop0_39[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 49)) // token='@' + withitem_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = with_item_rule(p)) // with_item ) { - D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'")); - _res = _literal; - goto done; + _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 _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'")); + D(fprintf(stderr, "%*c%s _loop0_39[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); } - { // ASYNC - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC")); - Token * async_var; - if ( - (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' - ) - { - D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC")); - _res = async_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC")); + asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); + if (!_seq) { + PyMem_Free(_children); + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; } - _res = NULL; - done: + for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_39_type, _seq); D(p->level--); - return _res; + return _seq; } -// _tmp_16: 'class' | '@' -static void * -_tmp_16_rule(Parser *p) +// _gather_38: with_item _loop0_39 +static asdl_seq * +_gather_38_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; - int _mark = p->mark; - { // 'class' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 523)) // token='class' - ) - { - D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_16[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class'")); - } - { // '@' + asdl_seq * _res = NULL; + int _mark = p->mark; + { // with_item _loop0_39 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'")); - Token * _literal; + D(fprintf(stderr, "%*c> _gather_38[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_39")); + withitem_ty elem; + asdl_seq * seq; if ( - (_literal = _PyPegen_expect_token(p, 49)) // token='@' + (elem = with_item_rule(p)) // with_item + && + (seq = _loop0_39_rule(p)) // _loop0_39 ) { - D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _gather_38[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_39")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_16[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'")); + D(fprintf(stderr, "%*c%s _gather_38[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_39")); } _res = NULL; done: @@ -16173,54 +18596,113 @@ _tmp_16_rule(Parser *p) return _res; } -// _tmp_17: 'with' | ASYNC -static void * -_tmp_17_rule(Parser *p) +// _loop0_41: ',' with_item +static asdl_seq * +_loop0_41_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // 'with' + int _start_mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' with_item if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_17[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 519)) // token='with' + D(fprintf(stderr, "%*c> _loop0_41[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); + Token * _literal; + withitem_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = with_item_rule(p)) // with_item ) { - D(fprintf(stderr, "%*c+ _tmp_17[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with'")); - _res = _keyword; - goto done; + _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 _tmp_17[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with'")); + D(fprintf(stderr, "%*c%s _loop0_41[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); } - { // ASYNC + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_41_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_40: with_item _loop0_41 +static asdl_seq * +_gather_40_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // with_item _loop0_41 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_17[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC")); - Token * async_var; + D(fprintf(stderr, "%*c> _gather_40[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_41")); + withitem_ty elem; + asdl_seq * seq; if ( - (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' + (elem = with_item_rule(p)) // with_item + && + (seq = _loop0_41_rule(p)) // _loop0_41 ) { - D(fprintf(stderr, "%*c+ _tmp_17[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC")); - _res = async_var; + D(fprintf(stderr, "%*c+ _gather_40[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_41")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_17[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC")); + D(fprintf(stderr, "%*c%s _gather_40[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_41")); } _res = NULL; done: @@ -16228,54 +18710,113 @@ _tmp_17_rule(Parser *p) return _res; } -// _tmp_18: 'for' | ASYNC -static void * -_tmp_18_rule(Parser *p) +// _loop0_43: ',' with_item +static asdl_seq * +_loop0_43_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // 'for' + int _start_mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' with_item if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_18[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 517)) // token='for' + D(fprintf(stderr, "%*c> _loop0_43[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); + Token * _literal; + withitem_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = with_item_rule(p)) // with_item ) { - D(fprintf(stderr, "%*c+ _tmp_18[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for'")); - _res = _keyword; - goto done; + _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 _tmp_18[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for'")); + D(fprintf(stderr, "%*c%s _loop0_43[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); } - { // ASYNC + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_43_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_42: with_item _loop0_43 +static asdl_seq * +_gather_42_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // with_item _loop0_43 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_18[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC")); - Token * async_var; + D(fprintf(stderr, "%*c> _gather_42[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_43")); + withitem_ty elem; + asdl_seq * seq; if ( - (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' + (elem = with_item_rule(p)) // with_item + && + (seq = _loop0_43_rule(p)) // _loop0_43 ) { - D(fprintf(stderr, "%*c+ _tmp_18[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC")); - _res = async_var; + D(fprintf(stderr, "%*c+ _gather_42[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_43")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_18[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC")); + D(fprintf(stderr, "%*c%s _gather_42[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_43")); } _res = NULL; done: @@ -16283,109 +18824,113 @@ _tmp_18_rule(Parser *p) return _res; } -// _tmp_19: '=' annotated_rhs -static void * -_tmp_19_rule(Parser *p) +// _loop0_45: ',' with_item +static asdl_seq * +_loop0_45_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // '=' annotated_rhs + int _start_mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' with_item if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_19[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c> _loop0_45[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); Token * _literal; - expr_ty d; - if ( - (_literal = _PyPegen_expect_token(p, 22)) // token='=' + withitem_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (d = annotated_rhs_rule(p)) // annotated_rhs + (elem = with_item_rule(p)) // with_item ) { - D(fprintf(stderr, "%*c+ _tmp_19[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); - _res = d; + _res = elem; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; + PyMem_Free(_children); D(p->level--); return NULL; } - goto done; + 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 _tmp_19[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c%s _loop0_45[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); } - _res = NULL; - done: + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_45_type, _seq); D(p->level--); - return _res; + return _seq; } -// _tmp_20: '(' single_target ')' | single_subscript_attribute_target -static void * -_tmp_20_rule(Parser *p) +// _gather_44: with_item _loop0_45 +static asdl_seq * +_gather_44_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // '(' single_target ')' + { // with_item _loop0_45 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_20[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); - Token * _literal; - Token * _literal_1; - expr_ty b; + D(fprintf(stderr, "%*c> _gather_44[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_45")); + withitem_ty elem; + asdl_seq * seq; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (b = single_target_rule(p)) // single_target + (elem = with_item_rule(p)) // with_item && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ _tmp_20[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); - _res = b; - 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_20[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'")); - } - { // single_subscript_attribute_target - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_20[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); - expr_ty single_subscript_attribute_target_var; - if ( - (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target + (seq = _loop0_45_rule(p)) // _loop0_45 ) { - D(fprintf(stderr, "%*c+ _tmp_20[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); - _res = single_subscript_attribute_target_var; + D(fprintf(stderr, "%*c+ _gather_44[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_45")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_20[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_subscript_attribute_target")); + D(fprintf(stderr, "%*c%s _gather_44[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_45")); } _res = NULL; done: @@ -16393,9 +18938,9 @@ _tmp_20_rule(Parser *p) return _res; } -// _tmp_21: '=' annotated_rhs +// _tmp_46: 'as' target static void * -_tmp_21_rule(Parser *p) +_tmp_46_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -16404,22 +18949,22 @@ _tmp_21_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '=' annotated_rhs + { // 'as' target if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_21[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); - Token * _literal; - expr_ty d; + D(fprintf(stderr, "%*c> _tmp_46[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' target")); + Token * _keyword; + expr_ty t; if ( - (_literal = _PyPegen_expect_token(p, 22)) // token='=' + (_keyword = _PyPegen_expect_token(p, 531)) // token='as' && - (d = annotated_rhs_rule(p)) // annotated_rhs + (t = target_rule(p)) // target ) { - D(fprintf(stderr, "%*c+ _tmp_21[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); - _res = d; + D(fprintf(stderr, "%*c+ _tmp_46[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' target")); + _res = t; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -16428,8 +18973,8 @@ _tmp_21_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_21[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c%s _tmp_46[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' target")); } _res = NULL; done: @@ -16437,9 +18982,9 @@ _tmp_21_rule(Parser *p) return _res; } -// _loop1_22: (star_targets '=') +// _loop1_47: except_block static asdl_seq * -_loop1_22_rule(Parser *p) +_loop1_47_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -16458,18 +19003,18 @@ _loop1_22_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // (star_targets '=') + { // except_block if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_22[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_135_var; + D(fprintf(stderr, "%*c> _loop1_47[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block")); + excepthandler_ty except_block_var; while ( - (_tmp_135_var = _tmp_135_rule(p)) // star_targets '=' + (except_block_var = except_block_rule(p)) // except_block ) { - _res = _tmp_135_var; + _res = except_block_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -16485,8 +19030,8 @@ _loop1_22_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_22[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); + D(fprintf(stderr, "%*c%s _loop1_47[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_block")); } if (_n == 0 || p->error_indicator) { PyMem_Free(_children); @@ -16503,69 +19048,14 @@ _loop1_22_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_22_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_47_type, _seq); D(p->level--); return _seq; } -// _tmp_23: yield_expr | star_expressions -static void * -_tmp_23_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // yield_expr - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_23[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); - expr_ty yield_expr_var; - if ( - (yield_expr_var = yield_expr_rule(p)) // yield_expr - ) - { - D(fprintf(stderr, "%*c+ _tmp_23[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); - _res = yield_expr_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_23[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); - } - { // star_expressions - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_23[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); - expr_ty star_expressions_var; - if ( - (star_expressions_var = star_expressions_rule(p)) // star_expressions - ) - { - D(fprintf(stderr, "%*c+ _tmp_23[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); - _res = star_expressions_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_23[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_24: yield_expr | star_expressions +// _tmp_48: 'as' NAME static void * -_tmp_24_rule(Parser *p) +_tmp_48_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -16574,43 +19064,32 @@ _tmp_24_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // yield_expr - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); - expr_ty yield_expr_var; - if ( - (yield_expr_var = yield_expr_rule(p)) // yield_expr - ) - { - D(fprintf(stderr, "%*c+ _tmp_24[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); - _res = yield_expr_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_24[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); - } - { // star_expressions + { // 'as' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); - expr_ty star_expressions_var; + D(fprintf(stderr, "%*c> _tmp_48[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + Token * _keyword; + expr_ty z; if ( - (star_expressions_var = star_expressions_rule(p)) // star_expressions + (_keyword = _PyPegen_expect_token(p, 531)) // token='as' + && + (z = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_24[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); - _res = star_expressions_var; + D(fprintf(stderr, "%*c+ _tmp_48[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + _res = z; + 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_24[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c%s _tmp_48[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; done: @@ -16618,9 +19097,9 @@ _tmp_24_rule(Parser *p) return _res; } -// _loop0_26: ',' NAME +// _loop1_49: case_block static asdl_seq * -_loop0_26_rule(Parser *p) +_loop1_49_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -16639,27 +19118,18 @@ _loop0_26_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' NAME + { // case_block if (p->error_indicator) { D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_26[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME")); - Token * _literal; - expr_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = _PyPegen_name_token(p)) // NAME - ) - { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - D(p->level--); - return NULL; - } + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_49[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "case_block")); + void *case_block_var; + while ( + (case_block_var = case_block_rule(p)) // case_block + ) + { + _res = case_block_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -16675,8 +19145,13 @@ _loop0_26_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_26[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME")); + D(fprintf(stderr, "%*c%s _loop1_49[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "case_block")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -16688,43 +19163,48 @@ _loop0_26_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_26_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_49_type, _seq); D(p->level--); return _seq; } -// _gather_25: NAME _loop0_26 -static asdl_seq * -_gather_25_rule(Parser *p) +// _tmp_50: 'if' named_expression +static void * +_tmp_50_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - asdl_seq * _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // NAME _loop0_26 + { // 'if' named_expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_25[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26")); - expr_ty elem; - asdl_seq * seq; + D(fprintf(stderr, "%*c> _tmp_50[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression")); + Token * _keyword; + expr_ty a; if ( - (elem = _PyPegen_name_token(p)) // NAME + (_keyword = _PyPegen_expect_token(p, 510)) // token='if' && - (seq = _loop0_26_rule(p)) // _loop0_26 + (a = named_expression_rule(p)) // named_expression ) { - D(fprintf(stderr, "%*c+ _gather_25[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); + D(fprintf(stderr, "%*c+ _tmp_50[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression")); + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_25[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_26")); + D(fprintf(stderr, "%*c%s _tmp_50[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression")); } _res = NULL; done: @@ -16732,9 +19212,9 @@ _gather_25_rule(Parser *p) return _res; } -// _loop0_28: ',' NAME +// _loop0_52: '|' closed_pattern static asdl_seq * -_loop0_28_rule(Parser *p) +_loop0_52_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -16753,18 +19233,18 @@ _loop0_28_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' NAME + { // '|' closed_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_28[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME")); + D(fprintf(stderr, "%*c> _loop0_52[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|' closed_pattern")); Token * _literal; - expr_ty elem; + void *elem; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (_literal = _PyPegen_expect_token(p, 18)) // token='|' && - (elem = _PyPegen_name_token(p)) // NAME + (elem = closed_pattern_rule(p)) // closed_pattern ) { _res = elem; @@ -16789,8 +19269,8 @@ _loop0_28_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_28[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME")); + D(fprintf(stderr, "%*c%s _loop0_52[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|' closed_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -16802,14 +19282,14 @@ _loop0_28_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_28_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_52_type, _seq); D(p->level--); return _seq; } -// _gather_27: NAME _loop0_28 +// _gather_51: closed_pattern _loop0_52 static asdl_seq * -_gather_27_rule(Parser *p) +_gather_51_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -16818,27 +19298,27 @@ _gather_27_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // NAME _loop0_28 + { // closed_pattern _loop0_52 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_27[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28")); - expr_ty elem; + D(fprintf(stderr, "%*c> _gather_51[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "closed_pattern _loop0_52")); + void *elem; asdl_seq * seq; if ( - (elem = _PyPegen_name_token(p)) // NAME + (elem = closed_pattern_rule(p)) // closed_pattern && - (seq = _loop0_28_rule(p)) // _loop0_28 + (seq = _loop0_52_rule(p)) // _loop0_52 ) { - D(fprintf(stderr, "%*c+ _gather_27[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28")); + D(fprintf(stderr, "%*c+ _gather_51[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "closed_pattern _loop0_52")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_27[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_28")); + D(fprintf(stderr, "%*c%s _gather_51[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "closed_pattern _loop0_52")); } _res = NULL; done: @@ -16846,9 +19326,9 @@ _gather_27_rule(Parser *p) return _res; } -// _tmp_29: ',' expression +// _tmp_53: '.' | '(' static void * -_tmp_29_rule(Parser *p) +_tmp_53_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -16857,32 +19337,43 @@ _tmp_29_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ',' expression + { // '.' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_29[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _tmp_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; - expr_ty z; if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (z = expression_rule(p)) // expression + (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_29[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); - _res = z; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_29[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c%s _tmp_53[%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_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + ) + { + D(fprintf(stderr, "%*c+ _tmp_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_53[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } _res = NULL; done: @@ -16890,9 +19381,9 @@ _tmp_29_rule(Parser *p) return _res; } -// _loop0_30: ('.' | '...') +// _loop0_55: '.' NAME static asdl_seq * -_loop0_30_rule(Parser *p) +_loop0_55_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -16911,18 +19402,27 @@ _loop0_30_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ('.' | '...') + { // '.' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_136_var; + D(fprintf(stderr, "%*c> _loop0_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.' NAME")); + Token * _literal; + expr_ty elem; while ( - (_tmp_136_var = _tmp_136_rule(p)) // '.' | '...' + (_literal = _PyPegen_expect_token(p, 23)) // token='.' + && + (elem = _PyPegen_name_token(p)) // NAME ) { - _res = _tmp_136_var; + _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 *)); @@ -16938,8 +19438,8 @@ _loop0_30_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_30[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); + D(fprintf(stderr, "%*c%s _loop0_55[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.' NAME")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -16951,14 +19451,53 @@ _loop0_30_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_30_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_55_type, _seq); D(p->level--); return _seq; } -// _loop1_31: ('.' | '...') +// _gather_54: NAME _loop0_55 static asdl_seq * -_loop1_31_rule(Parser *p) +_gather_54_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // NAME _loop0_55 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _gather_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_55")); + expr_ty elem; + asdl_seq * seq; + if ( + (elem = _PyPegen_name_token(p)) // NAME + && + (seq = _loop0_55_rule(p)) // _loop0_55 + ) + { + D(fprintf(stderr, "%*c+ _gather_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_55")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_54[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_55")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_57: ',' pattern +static asdl_seq * +_loop0_57_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -16977,18 +19516,27 @@ _loop1_31_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ('.' | '...') + { // ',' pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_137_var; + D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + Token * _literal; + void *elem; while ( - (_tmp_137_var = _tmp_137_rule(p)) // '.' | '...' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = pattern_rule(p)) // pattern ) { - _res = _tmp_137_var; + _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 *)); @@ -17004,13 +19552,8 @@ _loop1_31_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_31[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s _loop0_57[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -17022,14 +19565,53 @@ _loop1_31_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_31_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_57_type, _seq); D(p->level--); return _seq; } -// _loop0_33: ',' import_from_as_name +// _gather_56: pattern _loop0_57 static asdl_seq * -_loop0_33_rule(Parser *p) +_gather_56_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // pattern _loop0_57 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _gather_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_57")); + void *elem; + asdl_seq * seq; + if ( + (elem = pattern_rule(p)) // pattern + && + (seq = _loop0_57_rule(p)) // _loop0_57 + ) + { + D(fprintf(stderr, "%*c+ _gather_56[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_57")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_56[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_57")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_59: ',' pattern +static asdl_seq * +_loop0_59_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -17048,18 +19630,18 @@ _loop0_33_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' import_from_as_name + { // ',' pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_33[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' import_from_as_name")); + D(fprintf(stderr, "%*c> _loop0_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; - alias_ty elem; + void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = import_from_as_name_rule(p)) // import_from_as_name + (elem = pattern_rule(p)) // pattern ) { _res = elem; @@ -17084,8 +19666,8 @@ _loop0_33_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_33[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' import_from_as_name")); + D(fprintf(stderr, "%*c%s _loop0_59[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -17097,14 +19679,14 @@ _loop0_33_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_33_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_59_type, _seq); D(p->level--); return _seq; } -// _gather_32: import_from_as_name _loop0_33 +// _gather_58: pattern _loop0_59 static asdl_seq * -_gather_32_rule(Parser *p) +_gather_58_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -17113,71 +19695,27 @@ _gather_32_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // import_from_as_name _loop0_33 - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _gather_32[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_33")); - alias_ty elem; - asdl_seq * seq; - if ( - (elem = import_from_as_name_rule(p)) // import_from_as_name - && - (seq = _loop0_33_rule(p)) // _loop0_33 - ) - { - D(fprintf(stderr, "%*c+ _gather_32[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_33")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_32[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_name _loop0_33")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_34: 'as' NAME -static void * -_tmp_34_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'as' NAME + { // pattern _loop0_59 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_34[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - Token * _keyword; - expr_ty z; + D(fprintf(stderr, "%*c> _gather_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_59")); + void *elem; + asdl_seq * seq; if ( - (_keyword = _PyPegen_expect_token(p, 531)) // token='as' + (elem = pattern_rule(p)) // pattern && - (z = _PyPegen_name_token(p)) // NAME + (seq = _loop0_59_rule(p)) // _loop0_59 ) { - D(fprintf(stderr, "%*c+ _tmp_34[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - _res = z; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _gather_58[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_59")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_34[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c%s _gather_58[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_59")); } _res = NULL; done: @@ -17185,9 +19723,9 @@ _tmp_34_rule(Parser *p) return _res; } -// _loop0_36: ',' dotted_as_name +// _loop0_61: ',' (key_pattern ':' closed_pattern) static asdl_seq * -_loop0_36_rule(Parser *p) +_loop0_61_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -17206,18 +19744,18 @@ _loop0_36_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' dotted_as_name + { // ',' (key_pattern ':' closed_pattern) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_36[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' dotted_as_name")); + D(fprintf(stderr, "%*c> _loop0_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (key_pattern ':' closed_pattern)")); Token * _literal; - alias_ty elem; + void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = dotted_as_name_rule(p)) // dotted_as_name + (elem = _tmp_163_rule(p)) // key_pattern ':' closed_pattern ) { _res = elem; @@ -17242,8 +19780,8 @@ _loop0_36_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_36[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' dotted_as_name")); + D(fprintf(stderr, "%*c%s _loop0_61[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (key_pattern ':' closed_pattern)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -17255,14 +19793,14 @@ _loop0_36_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_36_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_61_type, _seq); D(p->level--); return _seq; } -// _gather_35: dotted_as_name _loop0_36 +// _gather_60: (key_pattern ':' closed_pattern) _loop0_61 static asdl_seq * -_gather_35_rule(Parser *p) +_gather_60_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -17271,27 +19809,27 @@ _gather_35_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // dotted_as_name _loop0_36 + { // (key_pattern ':' closed_pattern) _loop0_61 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_35[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_36")); - alias_ty elem; + D(fprintf(stderr, "%*c> _gather_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(key_pattern ':' closed_pattern) _loop0_61")); + void *elem; asdl_seq * seq; if ( - (elem = dotted_as_name_rule(p)) // dotted_as_name + (elem = _tmp_163_rule(p)) // key_pattern ':' closed_pattern && - (seq = _loop0_36_rule(p)) // _loop0_36 + (seq = _loop0_61_rule(p)) // _loop0_61 ) { - D(fprintf(stderr, "%*c+ _gather_35[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_36")); + D(fprintf(stderr, "%*c+ _gather_60[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(key_pattern ':' closed_pattern) _loop0_61")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_35[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_as_name _loop0_36")); + D(fprintf(stderr, "%*c%s _gather_60[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(key_pattern ':' closed_pattern) _loop0_61")); } _res = NULL; done: @@ -17299,43 +19837,113 @@ _gather_35_rule(Parser *p) return _res; } -// _tmp_37: 'as' NAME -static void * -_tmp_37_rule(Parser *p) +// _loop0_63: '|' literal_pattern +static asdl_seq * +_loop0_63_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // 'as' NAME + int _start_mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // '|' literal_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_37[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - Token * _keyword; - expr_ty z; - if ( - (_keyword = _PyPegen_expect_token(p, 531)) // token='as' + D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|' literal_pattern")); + Token * _literal; + void *elem; + while ( + (_literal = _PyPegen_expect_token(p, 18)) // token='|' && - (z = _PyPegen_name_token(p)) // NAME + (elem = literal_pattern_rule(p)) // literal_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_37[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - _res = z; + _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_63[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|' literal_pattern")); + } + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_63_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_62: literal_pattern _loop0_63 +static asdl_seq * +_gather_62_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // literal_pattern _loop0_63 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _gather_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern _loop0_63")); + void *elem; + asdl_seq * seq; + if ( + (elem = literal_pattern_rule(p)) // literal_pattern + && + (seq = _loop0_63_rule(p)) // _loop0_63 + ) + { + D(fprintf(stderr, "%*c+ _gather_62[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern _loop0_63")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_37[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c%s _gather_62[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern _loop0_63")); } _res = NULL; done: @@ -17343,9 +19951,9 @@ _tmp_37_rule(Parser *p) return _res; } -// _loop0_39: ',' with_item +// _loop0_65: '.' NAME static asdl_seq * -_loop0_39_rule(Parser *p) +_loop0_65_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -17364,18 +19972,18 @@ _loop0_39_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' with_item + { // '.' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_39[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); + D(fprintf(stderr, "%*c> _loop0_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.' NAME")); Token * _literal; - withitem_ty elem; + expr_ty elem; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (_literal = _PyPegen_expect_token(p, 23)) // token='.' && - (elem = with_item_rule(p)) // with_item + (elem = _PyPegen_name_token(p)) // NAME ) { _res = elem; @@ -17400,8 +20008,8 @@ _loop0_39_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_39[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); + D(fprintf(stderr, "%*c%s _loop0_65[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.' NAME")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -17413,14 +20021,14 @@ _loop0_39_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_39_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_65_type, _seq); D(p->level--); return _seq; } -// _gather_38: with_item _loop0_39 +// _gather_64: NAME _loop0_65 static asdl_seq * -_gather_38_rule(Parser *p) +_gather_64_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -17429,27 +20037,27 @@ _gather_38_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // with_item _loop0_39 + { // NAME _loop0_65 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_38[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_39")); - withitem_ty elem; + D(fprintf(stderr, "%*c> _gather_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_65")); + expr_ty elem; asdl_seq * seq; if ( - (elem = with_item_rule(p)) // with_item + (elem = _PyPegen_name_token(p)) // NAME && - (seq = _loop0_39_rule(p)) // _loop0_39 + (seq = _loop0_65_rule(p)) // _loop0_65 ) { - D(fprintf(stderr, "%*c+ _gather_38[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_39")); + D(fprintf(stderr, "%*c+ _gather_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_65")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_38[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_39")); + D(fprintf(stderr, "%*c%s _gather_64[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_65")); } _res = NULL; done: @@ -17457,9 +20065,9 @@ _gather_38_rule(Parser *p) return _res; } -// _loop0_41: ',' with_item +// _loop0_67: ',' pattern static asdl_seq * -_loop0_41_rule(Parser *p) +_loop0_67_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -17478,18 +20086,18 @@ _loop0_41_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' with_item + { // ',' pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_41[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); + D(fprintf(stderr, "%*c> _loop0_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; - withitem_ty elem; + void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = with_item_rule(p)) // with_item + (elem = pattern_rule(p)) // pattern ) { _res = elem; @@ -17514,8 +20122,8 @@ _loop0_41_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_41[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); + D(fprintf(stderr, "%*c%s _loop0_67[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -17527,14 +20135,14 @@ _loop0_41_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_41_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_67_type, _seq); D(p->level--); return _seq; } -// _gather_40: with_item _loop0_41 +// _gather_66: pattern _loop0_67 static asdl_seq * -_gather_40_rule(Parser *p) +_gather_66_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -17543,27 +20151,27 @@ _gather_40_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // with_item _loop0_41 + { // pattern _loop0_67 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_40[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_41")); - withitem_ty elem; + D(fprintf(stderr, "%*c> _gather_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_67")); + void *elem; asdl_seq * seq; if ( - (elem = with_item_rule(p)) // with_item + (elem = pattern_rule(p)) // pattern && - (seq = _loop0_41_rule(p)) // _loop0_41 + (seq = _loop0_67_rule(p)) // _loop0_67 ) { - D(fprintf(stderr, "%*c+ _gather_40[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_41")); + D(fprintf(stderr, "%*c+ _gather_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_67")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_40[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_41")); + D(fprintf(stderr, "%*c%s _gather_66[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_67")); } _res = NULL; done: @@ -17571,9 +20179,9 @@ _gather_40_rule(Parser *p) return _res; } -// _loop0_43: ',' with_item +// _loop0_69: ',' (NAME '=' or_pattern) static asdl_seq * -_loop0_43_rule(Parser *p) +_loop0_69_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -17592,18 +20200,18 @@ _loop0_43_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' with_item + { // ',' (NAME '=' or_pattern) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_43[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); + D(fprintf(stderr, "%*c> _loop0_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (NAME '=' or_pattern)")); Token * _literal; - withitem_ty elem; + void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = with_item_rule(p)) // with_item + (elem = _tmp_164_rule(p)) // NAME '=' or_pattern ) { _res = elem; @@ -17628,8 +20236,8 @@ _loop0_43_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_43[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); + D(fprintf(stderr, "%*c%s _loop0_69[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (NAME '=' or_pattern)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -17641,14 +20249,14 @@ _loop0_43_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_43_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_69_type, _seq); D(p->level--); return _seq; } -// _gather_42: with_item _loop0_43 +// _gather_68: (NAME '=' or_pattern) _loop0_69 static asdl_seq * -_gather_42_rule(Parser *p) +_gather_68_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -17657,27 +20265,27 @@ _gather_42_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // with_item _loop0_43 + { // (NAME '=' or_pattern) _loop0_69 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_42[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_43")); - withitem_ty elem; + D(fprintf(stderr, "%*c> _gather_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(NAME '=' or_pattern) _loop0_69")); + void *elem; asdl_seq * seq; if ( - (elem = with_item_rule(p)) // with_item + (elem = _tmp_164_rule(p)) // NAME '=' or_pattern && - (seq = _loop0_43_rule(p)) // _loop0_43 + (seq = _loop0_69_rule(p)) // _loop0_69 ) { - D(fprintf(stderr, "%*c+ _gather_42[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_43")); + D(fprintf(stderr, "%*c+ _gather_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(NAME '=' or_pattern) _loop0_69")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_42[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_43")); + D(fprintf(stderr, "%*c%s _gather_68[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(NAME '=' or_pattern) _loop0_69")); } _res = NULL; done: @@ -17685,9 +20293,9 @@ _gather_42_rule(Parser *p) return _res; } -// _loop0_45: ',' with_item +// _loop0_71: ',' (NAME '=' or_pattern) static asdl_seq * -_loop0_45_rule(Parser *p) +_loop0_71_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -17706,18 +20314,18 @@ _loop0_45_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' with_item + { // ',' (NAME '=' or_pattern) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_45[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); + D(fprintf(stderr, "%*c> _loop0_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (NAME '=' or_pattern)")); Token * _literal; - withitem_ty elem; + void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = with_item_rule(p)) // with_item + (elem = _tmp_165_rule(p)) // NAME '=' or_pattern ) { _res = elem; @@ -17742,8 +20350,8 @@ _loop0_45_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_45[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); + D(fprintf(stderr, "%*c%s _loop0_71[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (NAME '=' or_pattern)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -17755,14 +20363,14 @@ _loop0_45_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_45_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_71_type, _seq); D(p->level--); return _seq; } -// _gather_44: with_item _loop0_45 +// _gather_70: (NAME '=' or_pattern) _loop0_71 static asdl_seq * -_gather_44_rule(Parser *p) +_gather_70_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -17771,71 +20379,27 @@ _gather_44_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // with_item _loop0_45 + { // (NAME '=' or_pattern) _loop0_71 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_44[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_45")); - withitem_ty elem; + D(fprintf(stderr, "%*c> _gather_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(NAME '=' or_pattern) _loop0_71")); + void *elem; asdl_seq * seq; if ( - (elem = with_item_rule(p)) // with_item + (elem = _tmp_165_rule(p)) // NAME '=' or_pattern && - (seq = _loop0_45_rule(p)) // _loop0_45 + (seq = _loop0_71_rule(p)) // _loop0_71 ) { - D(fprintf(stderr, "%*c+ _gather_44[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_45")); + D(fprintf(stderr, "%*c+ _gather_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(NAME '=' or_pattern) _loop0_71")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_44[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_45")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_46: 'as' target -static void * -_tmp_46_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'as' target - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_46[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' target")); - Token * _keyword; - expr_ty t; - if ( - (_keyword = _PyPegen_expect_token(p, 531)) // token='as' - && - (t = target_rule(p)) // target - ) - { - D(fprintf(stderr, "%*c+ _tmp_46[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' target")); - _res = t; - 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_46[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' target")); + D(fprintf(stderr, "%*c%s _gather_70[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(NAME '=' or_pattern) _loop0_71")); } _res = NULL; done: @@ -17843,9 +20407,9 @@ _tmp_46_rule(Parser *p) return _res; } -// _loop1_47: except_block +// _loop0_73: ',' pattern static asdl_seq * -_loop1_47_rule(Parser *p) +_loop0_73_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -17864,18 +20428,27 @@ _loop1_47_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // except_block + { // ',' pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_47[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block")); - excepthandler_ty except_block_var; + D(fprintf(stderr, "%*c> _loop0_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + Token * _literal; + void *elem; while ( - (except_block_var = except_block_rule(p)) // except_block + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = pattern_rule(p)) // pattern ) { - _res = except_block_var; + _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 *)); @@ -17891,13 +20464,8 @@ _loop1_47_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_47[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_block")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s _loop0_73[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -17909,48 +20477,43 @@ _loop1_47_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_47_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_73_type, _seq); D(p->level--); return _seq; } -// _tmp_48: 'as' NAME -static void * -_tmp_48_rule(Parser *p) +// _gather_72: pattern _loop0_73 +static asdl_seq * +_gather_72_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // 'as' NAME + { // pattern _loop0_73 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_48[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - Token * _keyword; - expr_ty z; + D(fprintf(stderr, "%*c> _gather_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_73")); + void *elem; + asdl_seq * seq; if ( - (_keyword = _PyPegen_expect_token(p, 531)) // token='as' + (elem = pattern_rule(p)) // pattern && - (z = _PyPegen_name_token(p)) // NAME + (seq = _loop0_73_rule(p)) // _loop0_73 ) { - D(fprintf(stderr, "%*c+ _tmp_48[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - _res = z; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _gather_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_73")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_48[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c%s _gather_72[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_73")); } _res = NULL; done: @@ -17958,9 +20521,9 @@ _tmp_48_rule(Parser *p) return _res; } -// _tmp_49: 'from' expression +// _tmp_74: 'from' expression static void * -_tmp_49_rule(Parser *p) +_tmp_74_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -17974,7 +20537,7 @@ _tmp_49_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_49[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); + D(fprintf(stderr, "%*c> _tmp_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); Token * _keyword; expr_ty z; if ( @@ -17983,7 +20546,7 @@ _tmp_49_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_49[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); + D(fprintf(stderr, "%*c+ _tmp_74[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -17993,7 +20556,7 @@ _tmp_49_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_49[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_74[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression")); } _res = NULL; @@ -18002,9 +20565,9 @@ _tmp_49_rule(Parser *p) return _res; } -// _tmp_50: '->' expression +// _tmp_75: '->' expression static void * -_tmp_50_rule(Parser *p) +_tmp_75_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18018,7 +20581,7 @@ _tmp_50_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_50[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -18027,7 +20590,7 @@ _tmp_50_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_50[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_75[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -18037,7 +20600,7 @@ _tmp_50_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_50[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_75[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -18046,9 +20609,9 @@ _tmp_50_rule(Parser *p) return _res; } -// _tmp_51: '->' expression +// _tmp_76: '->' expression static void * -_tmp_51_rule(Parser *p) +_tmp_76_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18062,7 +20625,7 @@ _tmp_51_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_51[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -18071,7 +20634,7 @@ _tmp_51_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_51[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_76[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -18081,7 +20644,7 @@ _tmp_51_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_51[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_76[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -18090,9 +20653,9 @@ _tmp_51_rule(Parser *p) return _res; } -// _tmp_52: NEWLINE INDENT +// _tmp_77: NEWLINE INDENT static void * -_tmp_52_rule(Parser *p) +_tmp_77_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18106,7 +20669,7 @@ _tmp_52_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_52[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c> _tmp_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); Token * indent_var; Token * newline_var; if ( @@ -18115,12 +20678,12 @@ _tmp_52_rule(Parser *p) (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' ) { - D(fprintf(stderr, "%*c+ _tmp_52[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c+ _tmp_77[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); _res = _PyPegen_dummy_name(p, newline_var, indent_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_52[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_77[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); } _res = NULL; @@ -18129,9 +20692,9 @@ _tmp_52_rule(Parser *p) return _res; } -// _loop0_53: param_no_default +// _loop0_78: param_no_default static asdl_seq * -_loop0_53_rule(Parser *p) +_loop0_78_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18155,7 +20718,7 @@ _loop0_53_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_78[%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 @@ -18177,7 +20740,7 @@ _loop0_53_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_53[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_78[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -18190,14 +20753,14 @@ _loop0_53_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_53_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_78_type, _seq); D(p->level--); return _seq; } -// _loop0_54: param_with_default +// _loop0_79: param_with_default static asdl_seq * -_loop0_54_rule(Parser *p) +_loop0_79_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18221,7 +20784,7 @@ _loop0_54_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -18243,7 +20806,7 @@ _loop0_54_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_54[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_79[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -18256,14 +20819,14 @@ _loop0_54_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_54_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq); D(p->level--); return _seq; } -// _loop0_55: param_with_default +// _loop0_80: param_with_default static asdl_seq * -_loop0_55_rule(Parser *p) +_loop0_80_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18287,7 +20850,7 @@ _loop0_55_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -18309,7 +20872,7 @@ _loop0_55_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_55[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_80[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -18322,14 +20885,14 @@ _loop0_55_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_55_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_80_type, _seq); D(p->level--); return _seq; } -// _loop1_56: param_no_default +// _loop1_81: param_no_default static asdl_seq * -_loop1_56_rule(Parser *p) +_loop1_81_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18353,7 +20916,7 @@ _loop1_56_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_81[%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 @@ -18375,7 +20938,7 @@ _loop1_56_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_56[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -18393,14 +20956,14 @@ _loop1_56_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_56_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq); D(p->level--); return _seq; } -// _loop0_57: param_with_default +// _loop0_82: param_with_default static asdl_seq * -_loop0_57_rule(Parser *p) +_loop0_82_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18424,7 +20987,7 @@ _loop0_57_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -18446,7 +21009,7 @@ _loop0_57_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_57[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_82[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -18459,14 +21022,14 @@ _loop0_57_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_57_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_82_type, _seq); D(p->level--); return _seq; } -// _loop1_58: param_with_default +// _loop1_83: param_with_default static asdl_seq * -_loop1_58_rule(Parser *p) +_loop1_83_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18490,7 +21053,7 @@ _loop1_58_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -18512,7 +21075,7 @@ _loop1_58_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_58[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -18530,14 +21093,14 @@ _loop1_58_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_58_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); D(p->level--); return _seq; } -// _loop1_59: param_no_default +// _loop1_84: param_no_default static asdl_seq * -_loop1_59_rule(Parser *p) +_loop1_84_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18561,7 +21124,7 @@ _loop1_59_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_84[%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 @@ -18583,7 +21146,7 @@ _loop1_59_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_59[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -18601,14 +21164,14 @@ _loop1_59_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_59_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); D(p->level--); return _seq; } -// _loop1_60: param_no_default +// _loop1_85: param_no_default static asdl_seq * -_loop1_60_rule(Parser *p) +_loop1_85_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18632,7 +21195,7 @@ _loop1_60_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_85[%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 @@ -18654,7 +21217,7 @@ _loop1_60_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_60[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_85[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -18672,14 +21235,14 @@ _loop1_60_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_60_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_85_type, _seq); D(p->level--); return _seq; } -// _loop0_61: param_no_default +// _loop0_86: param_no_default static asdl_seq * -_loop0_61_rule(Parser *p) +_loop0_86_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18703,7 +21266,7 @@ _loop0_61_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_86[%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 @@ -18725,7 +21288,7 @@ _loop0_61_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_61[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_86[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -18738,14 +21301,14 @@ _loop0_61_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_61_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_86_type, _seq); D(p->level--); return _seq; } -// _loop1_62: param_with_default +// _loop1_87: param_with_default static asdl_seq * -_loop1_62_rule(Parser *p) +_loop1_87_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18769,7 +21332,7 @@ _loop1_62_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -18791,7 +21354,7 @@ _loop1_62_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_62[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -18809,14 +21372,14 @@ _loop1_62_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_62_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_87_type, _seq); D(p->level--); return _seq; } -// _loop0_63: param_no_default +// _loop0_88: param_no_default static asdl_seq * -_loop0_63_rule(Parser *p) +_loop0_88_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18840,7 +21403,7 @@ _loop0_63_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_88[%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 @@ -18862,7 +21425,7 @@ _loop0_63_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_63[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_88[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -18875,14 +21438,14 @@ _loop0_63_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_63_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_88_type, _seq); D(p->level--); return _seq; } -// _loop1_64: param_with_default +// _loop1_89: param_with_default static asdl_seq * -_loop1_64_rule(Parser *p) +_loop1_89_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18906,7 +21469,7 @@ _loop1_64_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -18928,7 +21491,7 @@ _loop1_64_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_64[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -18946,14 +21509,14 @@ _loop1_64_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_64_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq); D(p->level--); return _seq; } -// _loop0_65: param_maybe_default +// _loop0_90: param_maybe_default static asdl_seq * -_loop0_65_rule(Parser *p) +_loop0_90_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18977,7 +21540,7 @@ _loop0_65_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -18999,7 +21562,7 @@ _loop0_65_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_65[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_90[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -19012,14 +21575,14 @@ _loop0_65_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_65_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_90_type, _seq); D(p->level--); return _seq; } -// _loop1_66: param_maybe_default +// _loop1_91: param_maybe_default static asdl_seq * -_loop1_66_rule(Parser *p) +_loop1_91_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19043,7 +21606,7 @@ _loop1_66_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -19065,7 +21628,7 @@ _loop1_66_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_66[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -19083,14 +21646,14 @@ _loop1_66_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_66_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq); D(p->level--); return _seq; } -// _loop1_67: ('@' named_expression NEWLINE) +// _loop1_92: ('@' named_expression NEWLINE) static asdl_seq * -_loop1_67_rule(Parser *p) +_loop1_92_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19114,13 +21677,13 @@ _loop1_67_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); - void *_tmp_138_var; + D(fprintf(stderr, "%*c> _loop1_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); + void *_tmp_166_var; while ( - (_tmp_138_var = _tmp_138_rule(p)) // '@' named_expression NEWLINE + (_tmp_166_var = _tmp_166_rule(p)) // '@' named_expression NEWLINE ) { - _res = _tmp_138_var; + _res = _tmp_166_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -19136,7 +21699,7 @@ _loop1_67_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_67[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_92[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)")); } if (_n == 0 || p->error_indicator) { @@ -19154,14 +21717,14 @@ _loop1_67_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_67_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_92_type, _seq); D(p->level--); return _seq; } -// _tmp_68: '(' arguments? ')' +// _tmp_93: '(' arguments? ')' static void * -_tmp_68_rule(Parser *p) +_tmp_93_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19175,7 +21738,7 @@ _tmp_68_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); Token * _literal; Token * _literal_1; void *z; @@ -19187,7 +21750,7 @@ _tmp_68_rule(Parser *p) (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -19197,7 +21760,7 @@ _tmp_68_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); } _res = NULL; @@ -19206,9 +21769,9 @@ _tmp_68_rule(Parser *p) return _res; } -// _loop0_70: ',' star_expression +// _loop0_95: ',' star_expression static asdl_seq * -_loop0_70_rule(Parser *p) +_loop0_95_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19232,7 +21795,7 @@ _loop0_70_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _loop0_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty elem; while ( @@ -19263,7 +21826,7 @@ _loop0_70_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_70[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -19276,14 +21839,14 @@ _loop0_70_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_70_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_95_type, _seq); D(p->level--); return _seq; } -// _gather_69: star_expression _loop0_70 +// _gather_94: star_expression _loop0_95 static asdl_seq * -_gather_69_rule(Parser *p) +_gather_94_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19292,27 +21855,27 @@ _gather_69_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_expression _loop0_70 + { // star_expression _loop0_95 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_70")); + D(fprintf(stderr, "%*c> _gather_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_95")); expr_ty elem; asdl_seq * seq; if ( (elem = star_expression_rule(p)) // star_expression && - (seq = _loop0_70_rule(p)) // _loop0_70 + (seq = _loop0_95_rule(p)) // _loop0_95 ) { - D(fprintf(stderr, "%*c+ _gather_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_70")); + D(fprintf(stderr, "%*c+ _gather_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_95")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_69[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_70")); + D(fprintf(stderr, "%*c%s _gather_94[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_95")); } _res = NULL; done: @@ -19320,9 +21883,9 @@ _gather_69_rule(Parser *p) return _res; } -// _loop1_71: (',' star_expression) +// _loop1_96: (',' star_expression) static asdl_seq * -_loop1_71_rule(Parser *p) +_loop1_96_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19346,13 +21909,13 @@ _loop1_71_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); - void *_tmp_139_var; + D(fprintf(stderr, "%*c> _loop1_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); + void *_tmp_167_var; while ( - (_tmp_139_var = _tmp_139_rule(p)) // ',' star_expression + (_tmp_167_var = _tmp_167_rule(p)) // ',' star_expression ) { - _res = _tmp_139_var; + _res = _tmp_167_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -19368,7 +21931,7 @@ _loop1_71_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_71[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_96[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); } if (_n == 0 || p->error_indicator) { @@ -19386,14 +21949,14 @@ _loop1_71_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_71_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_96_type, _seq); D(p->level--); return _seq; } -// _loop0_73: ',' star_named_expression +// _loop0_98: ',' star_named_expression static asdl_seq * -_loop0_73_rule(Parser *p) +_loop0_98_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19417,7 +21980,7 @@ _loop0_73_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); + D(fprintf(stderr, "%*c> _loop0_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); Token * _literal; expr_ty elem; while ( @@ -19448,7 +22011,7 @@ _loop0_73_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_73[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_98[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -19461,14 +22024,14 @@ _loop0_73_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_73_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_98_type, _seq); D(p->level--); return _seq; } -// _gather_72: star_named_expression _loop0_73 +// _gather_97: star_named_expression _loop0_98 static asdl_seq * -_gather_72_rule(Parser *p) +_gather_97_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19477,27 +22040,27 @@ _gather_72_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_named_expression _loop0_73 + { // star_named_expression _loop0_98 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_73")); + D(fprintf(stderr, "%*c> _gather_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_98")); expr_ty elem; asdl_seq * seq; if ( (elem = star_named_expression_rule(p)) // star_named_expression && - (seq = _loop0_73_rule(p)) // _loop0_73 + (seq = _loop0_98_rule(p)) // _loop0_98 ) { - D(fprintf(stderr, "%*c+ _gather_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_73")); + D(fprintf(stderr, "%*c+ _gather_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_98")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_72[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_73")); + D(fprintf(stderr, "%*c%s _gather_97[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_98")); } _res = NULL; done: @@ -19505,9 +22068,9 @@ _gather_72_rule(Parser *p) return _res; } -// _loop1_74: (',' expression) +// _loop1_99: (',' expression) static asdl_seq * -_loop1_74_rule(Parser *p) +_loop1_99_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19531,13 +22094,13 @@ _loop1_74_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); - void *_tmp_140_var; + D(fprintf(stderr, "%*c> _loop1_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); + void *_tmp_168_var; while ( - (_tmp_140_var = _tmp_140_rule(p)) // ',' expression + (_tmp_168_var = _tmp_168_rule(p)) // ',' expression ) { - _res = _tmp_140_var; + _res = _tmp_168_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -19553,7 +22116,7 @@ _loop1_74_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_74[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_99[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); } if (_n == 0 || p->error_indicator) { @@ -19571,14 +22134,14 @@ _loop1_74_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_74_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq); D(p->level--); return _seq; } -// _loop0_75: lambda_param_no_default +// _loop0_100: lambda_param_no_default static asdl_seq * -_loop0_75_rule(Parser *p) +_loop0_100_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19602,7 +22165,7 @@ _loop0_75_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_100[%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 @@ -19624,7 +22187,7 @@ _loop0_75_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_75[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_100[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -19637,14 +22200,14 @@ _loop0_75_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_75_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_100_type, _seq); D(p->level--); return _seq; } -// _loop0_76: lambda_param_with_default +// _loop0_101: lambda_param_with_default static asdl_seq * -_loop0_76_rule(Parser *p) +_loop0_101_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19668,7 +22231,7 @@ _loop0_76_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -19690,7 +22253,7 @@ _loop0_76_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_76[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_101[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -19703,14 +22266,14 @@ _loop0_76_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_76_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_101_type, _seq); D(p->level--); return _seq; } -// _loop0_77: lambda_param_with_default +// _loop0_102: lambda_param_with_default static asdl_seq * -_loop0_77_rule(Parser *p) +_loop0_102_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19734,7 +22297,7 @@ _loop0_77_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -19756,7 +22319,7 @@ _loop0_77_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_77[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_102[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -19769,14 +22332,14 @@ _loop0_77_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_77_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_102_type, _seq); D(p->level--); return _seq; } -// _loop1_78: lambda_param_no_default +// _loop1_103: lambda_param_no_default static asdl_seq * -_loop1_78_rule(Parser *p) +_loop1_103_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19800,7 +22363,7 @@ _loop1_78_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_103[%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 @@ -19822,7 +22385,7 @@ _loop1_78_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_78[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_103[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -19840,14 +22403,14 @@ _loop1_78_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_78_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_103_type, _seq); D(p->level--); return _seq; } -// _loop0_79: lambda_param_with_default +// _loop0_104: lambda_param_with_default static asdl_seq * -_loop0_79_rule(Parser *p) +_loop0_104_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19871,7 +22434,7 @@ _loop0_79_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -19893,7 +22456,7 @@ _loop0_79_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_79[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_104[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -19906,14 +22469,14 @@ _loop0_79_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_104_type, _seq); D(p->level--); return _seq; } -// _loop1_80: lambda_param_with_default +// _loop1_105: lambda_param_with_default static asdl_seq * -_loop1_80_rule(Parser *p) +_loop1_105_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19937,7 +22500,7 @@ _loop1_80_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -19959,7 +22522,7 @@ _loop1_80_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_80[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -19977,14 +22540,14 @@ _loop1_80_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_80_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq); D(p->level--); return _seq; } -// _loop1_81: lambda_param_no_default +// _loop1_106: lambda_param_no_default static asdl_seq * -_loop1_81_rule(Parser *p) +_loop1_106_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20008,7 +22571,7 @@ _loop1_81_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_106[%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 @@ -20030,7 +22593,7 @@ _loop1_81_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -20048,14 +22611,14 @@ _loop1_81_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_106_type, _seq); D(p->level--); return _seq; } -// _loop1_82: lambda_param_no_default +// _loop1_107: lambda_param_no_default static asdl_seq * -_loop1_82_rule(Parser *p) +_loop1_107_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20079,7 +22642,7 @@ _loop1_82_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_107[%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 @@ -20101,7 +22664,7 @@ _loop1_82_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_82[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_107[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -20119,14 +22682,14 @@ _loop1_82_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_82_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_107_type, _seq); D(p->level--); return _seq; } -// _loop0_83: lambda_param_no_default +// _loop0_108: lambda_param_no_default static asdl_seq * -_loop0_83_rule(Parser *p) +_loop0_108_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20150,7 +22713,7 @@ _loop0_83_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_108[%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 @@ -20172,7 +22735,7 @@ _loop0_83_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_83[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_108[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20185,14 +22748,14 @@ _loop0_83_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_83_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_108_type, _seq); D(p->level--); return _seq; } -// _loop1_84: lambda_param_with_default +// _loop1_109: lambda_param_with_default static asdl_seq * -_loop1_84_rule(Parser *p) +_loop1_109_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20216,7 +22779,7 @@ _loop1_84_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -20238,7 +22801,7 @@ _loop1_84_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_109[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -20256,14 +22819,14 @@ _loop1_84_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_109_type, _seq); D(p->level--); return _seq; } -// _loop0_85: lambda_param_no_default +// _loop0_110: lambda_param_no_default static asdl_seq * -_loop0_85_rule(Parser *p) +_loop0_110_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20287,7 +22850,7 @@ _loop0_85_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_110[%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 @@ -20309,7 +22872,7 @@ _loop0_85_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_85[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_110[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20322,14 +22885,14 @@ _loop0_85_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_85_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq); D(p->level--); return _seq; } -// _loop1_86: lambda_param_with_default +// _loop1_111: lambda_param_with_default static asdl_seq * -_loop1_86_rule(Parser *p) +_loop1_111_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20353,7 +22916,7 @@ _loop1_86_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -20375,7 +22938,7 @@ _loop1_86_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_111[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -20393,14 +22956,14 @@ _loop1_86_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_86_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_111_type, _seq); D(p->level--); return _seq; } -// _loop0_87: lambda_param_maybe_default +// _loop0_112: lambda_param_maybe_default static asdl_seq * -_loop0_87_rule(Parser *p) +_loop0_112_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20424,7 +22987,7 @@ _loop0_87_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -20446,7 +23009,7 @@ _loop0_87_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_87[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20459,14 +23022,14 @@ _loop0_87_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_87_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq); D(p->level--); return _seq; } -// _loop1_88: lambda_param_maybe_default +// _loop1_113: lambda_param_maybe_default static asdl_seq * -_loop1_88_rule(Parser *p) +_loop1_113_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20490,7 +23053,7 @@ _loop1_88_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -20512,7 +23075,7 @@ _loop1_88_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_88[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_113[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -20530,14 +23093,14 @@ _loop1_88_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_88_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_113_type, _seq); D(p->level--); return _seq; } -// _loop1_89: ('or' conjunction) +// _loop1_114: ('or' conjunction) static asdl_seq * -_loop1_89_rule(Parser *p) +_loop1_114_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20561,13 +23124,13 @@ _loop1_89_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); - void *_tmp_141_var; + D(fprintf(stderr, "%*c> _loop1_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); + void *_tmp_169_var; while ( - (_tmp_141_var = _tmp_141_rule(p)) // 'or' conjunction + (_tmp_169_var = _tmp_169_rule(p)) // 'or' conjunction ) { - _res = _tmp_141_var; + _res = _tmp_169_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -20583,7 +23146,7 @@ _loop1_89_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_114[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); } if (_n == 0 || p->error_indicator) { @@ -20601,14 +23164,14 @@ _loop1_89_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_114_type, _seq); D(p->level--); return _seq; } -// _loop1_90: ('and' inversion) +// _loop1_115: ('and' inversion) static asdl_seq * -_loop1_90_rule(Parser *p) +_loop1_115_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20632,13 +23195,13 @@ _loop1_90_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); - void *_tmp_142_var; + D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); + void *_tmp_170_var; while ( - (_tmp_142_var = _tmp_142_rule(p)) // 'and' inversion + (_tmp_170_var = _tmp_170_rule(p)) // 'and' inversion ) { - _res = _tmp_142_var; + _res = _tmp_170_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -20654,7 +23217,7 @@ _loop1_90_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_90[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); } if (_n == 0 || p->error_indicator) { @@ -20672,14 +23235,14 @@ _loop1_90_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_90_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_115_type, _seq); D(p->level--); return _seq; } -// _loop1_91: compare_op_bitwise_or_pair +// _loop1_116: compare_op_bitwise_or_pair static asdl_seq * -_loop1_91_rule(Parser *p) +_loop1_116_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20703,7 +23266,7 @@ _loop1_91_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); + D(fprintf(stderr, "%*c> _loop1_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); CmpopExprPair* compare_op_bitwise_or_pair_var; while ( (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair @@ -20725,7 +23288,7 @@ _loop1_91_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_116[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); } if (_n == 0 || p->error_indicator) { @@ -20743,14 +23306,14 @@ _loop1_91_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_116_type, _seq); D(p->level--); return _seq; } -// _tmp_92: '!=' +// _tmp_117: '!=' static void * -_tmp_92_rule(Parser *p) +_tmp_117_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20764,13 +23327,13 @@ _tmp_92_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); Token * tok; if ( (tok = _PyPegen_expect_token(p, 28)) // token='!=' ) { - D(fprintf(stderr, "%*c+ _tmp_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -20780,7 +23343,7 @@ _tmp_92_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_92[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); } _res = NULL; @@ -20789,9 +23352,9 @@ _tmp_92_rule(Parser *p) return _res; } -// _loop0_94: ',' slice +// _loop0_119: ',' slice static asdl_seq * -_loop0_94_rule(Parser *p) +_loop0_119_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20815,7 +23378,7 @@ _loop0_94_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); + D(fprintf(stderr, "%*c> _loop0_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); Token * _literal; expr_ty elem; while ( @@ -20846,7 +23409,7 @@ _loop0_94_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_94[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_119[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' slice")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20859,14 +23422,14 @@ _loop0_94_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_94_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq); D(p->level--); return _seq; } -// _gather_93: slice _loop0_94 +// _gather_118: slice _loop0_119 static asdl_seq * -_gather_93_rule(Parser *p) +_gather_118_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20875,27 +23438,27 @@ _gather_93_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // slice _loop0_94 + { // slice _loop0_119 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_94")); + D(fprintf(stderr, "%*c> _gather_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_119")); expr_ty elem; asdl_seq * seq; if ( (elem = slice_rule(p)) // slice && - (seq = _loop0_94_rule(p)) // _loop0_94 + (seq = _loop0_119_rule(p)) // _loop0_119 ) { - D(fprintf(stderr, "%*c+ _gather_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_94")); + D(fprintf(stderr, "%*c+ _gather_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_119")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_93[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_94")); + D(fprintf(stderr, "%*c%s _gather_118[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_119")); } _res = NULL; done: @@ -20903,9 +23466,9 @@ _gather_93_rule(Parser *p) return _res; } -// _tmp_95: ':' expression? +// _tmp_120: ':' expression? static void * -_tmp_95_rule(Parser *p) +_tmp_120_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20919,7 +23482,7 @@ _tmp_95_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); Token * _literal; void *d; if ( @@ -20928,7 +23491,7 @@ _tmp_95_rule(Parser *p) (d = expression_rule(p), 1) // expression? ) { - D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); _res = d; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -20938,7 +23501,7 @@ _tmp_95_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); } _res = NULL; @@ -20947,9 +23510,9 @@ _tmp_95_rule(Parser *p) return _res; } -// _tmp_96: tuple | group | genexp +// _tmp_121: tuple | group | genexp static void * -_tmp_96_rule(Parser *p) +_tmp_121_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20963,18 +23526,18 @@ _tmp_96_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); expr_ty tuple_var; if ( (tuple_var = tuple_rule(p)) // tuple ) { - D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); _res = tuple_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); } { // group @@ -20982,18 +23545,18 @@ _tmp_96_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); expr_ty group_var; if ( (group_var = group_rule(p)) // group ) { - D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); _res = group_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group")); } { // genexp @@ -21001,18 +23564,18 @@ _tmp_96_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); expr_ty genexp_var; if ( (genexp_var = genexp_rule(p)) // genexp ) { - D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); _res = genexp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); } _res = NULL; @@ -21021,9 +23584,9 @@ _tmp_96_rule(Parser *p) return _res; } -// _tmp_97: list | listcomp +// _tmp_122: list | listcomp static void * -_tmp_97_rule(Parser *p) +_tmp_122_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21037,18 +23600,18 @@ _tmp_97_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); expr_ty list_var; if ( (list_var = list_rule(p)) // list ) { - D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); _res = list_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); } { // listcomp @@ -21056,18 +23619,18 @@ _tmp_97_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); expr_ty listcomp_var; if ( (listcomp_var = listcomp_rule(p)) // listcomp ) { - D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); _res = listcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp")); } _res = NULL; @@ -21076,9 +23639,9 @@ _tmp_97_rule(Parser *p) return _res; } -// _tmp_98: dict | set | dictcomp | setcomp +// _tmp_123: dict | set | dictcomp | setcomp static void * -_tmp_98_rule(Parser *p) +_tmp_123_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21092,18 +23655,18 @@ _tmp_98_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); expr_ty dict_var; if ( (dict_var = dict_rule(p)) // dict ) { - D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); _res = dict_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict")); } { // set @@ -21111,18 +23674,18 @@ _tmp_98_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); expr_ty set_var; if ( (set_var = set_rule(p)) // set ) { - D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); _res = set_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set")); } { // dictcomp @@ -21130,18 +23693,18 @@ _tmp_98_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); expr_ty dictcomp_var; if ( (dictcomp_var = dictcomp_rule(p)) // dictcomp ) { - D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); _res = dictcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp")); } { // setcomp @@ -21149,18 +23712,18 @@ _tmp_98_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); expr_ty setcomp_var; if ( (setcomp_var = setcomp_rule(p)) // setcomp ) { - D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); _res = setcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp")); } _res = NULL; @@ -21169,9 +23732,9 @@ _tmp_98_rule(Parser *p) return _res; } -// _loop1_99: STRING +// _loop1_124: STRING static asdl_seq * -_loop1_99_rule(Parser *p) +_loop1_124_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21195,7 +23758,7 @@ _loop1_99_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); + D(fprintf(stderr, "%*c> _loop1_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); expr_ty string_var; while ( (string_var = _PyPegen_string_token(p)) // STRING @@ -21217,7 +23780,7 @@ _loop1_99_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_99[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_124[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); } if (_n == 0 || p->error_indicator) { @@ -21235,14 +23798,14 @@ _loop1_99_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_124_type, _seq); D(p->level--); return _seq; } -// _tmp_100: star_named_expression ',' star_named_expressions? +// _tmp_125: star_named_expression ',' star_named_expressions? static void * -_tmp_100_rule(Parser *p) +_tmp_125_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21256,7 +23819,7 @@ _tmp_100_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); Token * _literal; expr_ty y; void *z; @@ -21268,7 +23831,7 @@ _tmp_100_rule(Parser *p) (z = star_named_expressions_rule(p), 1) // star_named_expressions? ) { - D(fprintf(stderr, "%*c+ _tmp_100[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); _res = _PyPegen_seq_insert_in_front ( p , y , z ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21278,7 +23841,7 @@ _tmp_100_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_100[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); } _res = NULL; @@ -21287,9 +23850,9 @@ _tmp_100_rule(Parser *p) return _res; } -// _tmp_101: yield_expr | named_expression +// _tmp_126: yield_expr | named_expression static void * -_tmp_101_rule(Parser *p) +_tmp_126_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21303,18 +23866,18 @@ _tmp_101_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_101[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_101[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // named_expression @@ -21322,18 +23885,18 @@ _tmp_101_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); expr_ty named_expression_var; if ( (named_expression_var = named_expression_rule(p)) // named_expression ) { - D(fprintf(stderr, "%*c+ _tmp_101[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); _res = named_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_101[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); } _res = NULL; @@ -21342,9 +23905,9 @@ _tmp_101_rule(Parser *p) return _res; } -// _loop0_103: ',' double_starred_kvpair +// _loop0_128: ',' double_starred_kvpair static asdl_seq * -_loop0_103_rule(Parser *p) +_loop0_128_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21368,7 +23931,7 @@ _loop0_103_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); + D(fprintf(stderr, "%*c> _loop0_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); Token * _literal; KeyValuePair* elem; while ( @@ -21399,7 +23962,7 @@ _loop0_103_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_128[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21412,14 +23975,14 @@ _loop0_103_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_103_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_128_type, _seq); D(p->level--); return _seq; } -// _gather_102: double_starred_kvpair _loop0_103 +// _gather_127: double_starred_kvpair _loop0_128 static asdl_seq * -_gather_102_rule(Parser *p) +_gather_127_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21428,27 +23991,27 @@ _gather_102_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // double_starred_kvpair _loop0_103 + { // double_starred_kvpair _loop0_128 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_103")); + D(fprintf(stderr, "%*c> _gather_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_128")); KeyValuePair* elem; asdl_seq * seq; if ( (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair && - (seq = _loop0_103_rule(p)) // _loop0_103 + (seq = _loop0_128_rule(p)) // _loop0_128 ) { - D(fprintf(stderr, "%*c+ _gather_102[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_103")); + D(fprintf(stderr, "%*c+ _gather_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_128")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_102[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_103")); + D(fprintf(stderr, "%*c%s _gather_127[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_128")); } _res = NULL; done: @@ -21456,9 +24019,9 @@ _gather_102_rule(Parser *p) return _res; } -// _loop1_104: for_if_clause +// _loop1_129: for_if_clause static asdl_seq * -_loop1_104_rule(Parser *p) +_loop1_129_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21482,7 +24045,7 @@ _loop1_104_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); + D(fprintf(stderr, "%*c> _loop1_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); comprehension_ty for_if_clause_var; while ( (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause @@ -21504,7 +24067,7 @@ _loop1_104_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_104[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_129[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); } if (_n == 0 || p->error_indicator) { @@ -21522,14 +24085,14 @@ _loop1_104_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_104_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_129_type, _seq); D(p->level--); return _seq; } -// _loop0_105: ('if' disjunction) +// _loop0_130: ('if' disjunction) static asdl_seq * -_loop0_105_rule(Parser *p) +_loop0_130_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21553,13 +24116,13 @@ _loop0_105_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_143_var; + D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_171_var; while ( - (_tmp_143_var = _tmp_143_rule(p)) // 'if' disjunction + (_tmp_171_var = _tmp_171_rule(p)) // 'if' disjunction ) { - _res = _tmp_143_var; + _res = _tmp_171_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -21575,7 +24138,7 @@ _loop0_105_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_105[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21588,14 +24151,14 @@ _loop0_105_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_105_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq); D(p->level--); return _seq; } -// _loop0_106: ('if' disjunction) +// _loop0_131: ('if' disjunction) static asdl_seq * -_loop0_106_rule(Parser *p) +_loop0_131_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21619,13 +24182,13 @@ _loop0_106_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_144_var; + D(fprintf(stderr, "%*c> _loop0_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_172_var; while ( - (_tmp_144_var = _tmp_144_rule(p)) // 'if' disjunction + (_tmp_172_var = _tmp_172_rule(p)) // 'if' disjunction ) { - _res = _tmp_144_var; + _res = _tmp_172_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -21641,7 +24204,7 @@ _loop0_106_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_106[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_131[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21654,14 +24217,14 @@ _loop0_106_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_106_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_131_type, _seq); D(p->level--); return _seq; } -// _tmp_107: ',' args +// _tmp_132: ',' args static void * -_tmp_107_rule(Parser *p) +_tmp_132_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21675,7 +24238,7 @@ _tmp_107_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c> _tmp_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); Token * _literal; expr_ty c; if ( @@ -21684,7 +24247,7 @@ _tmp_107_rule(Parser *p) (c = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_107[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c+ _tmp_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21694,7 +24257,7 @@ _tmp_107_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_107[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_132[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); } _res = NULL; @@ -21703,9 +24266,9 @@ _tmp_107_rule(Parser *p) return _res; } -// _tmp_108: ',' args +// _tmp_133: ',' args static void * -_tmp_108_rule(Parser *p) +_tmp_133_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21719,7 +24282,7 @@ _tmp_108_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); Token * _literal; expr_ty c; if ( @@ -21728,7 +24291,7 @@ _tmp_108_rule(Parser *p) (c = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_108[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21738,7 +24301,7 @@ _tmp_108_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_108[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); } _res = NULL; @@ -21747,9 +24310,9 @@ _tmp_108_rule(Parser *p) return _res; } -// _loop0_110: ',' kwarg_or_starred +// _loop0_135: ',' kwarg_or_starred static asdl_seq * -_loop0_110_rule(Parser *p) +_loop0_135_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21773,7 +24336,7 @@ _loop0_110_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -21804,7 +24367,7 @@ _loop0_110_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_110[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_135[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21817,14 +24380,14 @@ _loop0_110_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_135_type, _seq); D(p->level--); return _seq; } -// _gather_109: kwarg_or_starred _loop0_110 +// _gather_134: kwarg_or_starred _loop0_135 static asdl_seq * -_gather_109_rule(Parser *p) +_gather_134_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21833,27 +24396,27 @@ _gather_109_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_110 + { // kwarg_or_starred _loop0_135 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_110")); + D(fprintf(stderr, "%*c> _gather_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_135")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_110_rule(p)) // _loop0_110 + (seq = _loop0_135_rule(p)) // _loop0_135 ) { - D(fprintf(stderr, "%*c+ _gather_109[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_110")); + D(fprintf(stderr, "%*c+ _gather_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_135")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_109[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_110")); + D(fprintf(stderr, "%*c%s _gather_134[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_135")); } _res = NULL; done: @@ -21861,9 +24424,9 @@ _gather_109_rule(Parser *p) return _res; } -// _loop0_112: ',' kwarg_or_double_starred +// _loop0_137: ',' kwarg_or_double_starred static asdl_seq * -_loop0_112_rule(Parser *p) +_loop0_137_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21887,7 +24450,7 @@ _loop0_112_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -21918,7 +24481,7 @@ _loop0_112_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_137[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21931,14 +24494,14 @@ _loop0_112_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_137_type, _seq); D(p->level--); return _seq; } -// _gather_111: kwarg_or_double_starred _loop0_112 +// _gather_136: kwarg_or_double_starred _loop0_137 static asdl_seq * -_gather_111_rule(Parser *p) +_gather_136_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21947,27 +24510,27 @@ _gather_111_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_112 + { // kwarg_or_double_starred _loop0_137 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_112")); + D(fprintf(stderr, "%*c> _gather_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_137")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_112_rule(p)) // _loop0_112 + (seq = _loop0_137_rule(p)) // _loop0_137 ) { - D(fprintf(stderr, "%*c+ _gather_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_112")); + D(fprintf(stderr, "%*c+ _gather_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_137")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_111[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_112")); + D(fprintf(stderr, "%*c%s _gather_136[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_137")); } _res = NULL; done: @@ -21975,9 +24538,9 @@ _gather_111_rule(Parser *p) return _res; } -// _loop0_114: ',' kwarg_or_starred +// _loop0_139: ',' kwarg_or_starred static asdl_seq * -_loop0_114_rule(Parser *p) +_loop0_139_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22001,7 +24564,7 @@ _loop0_114_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -22032,7 +24595,7 @@ _loop0_114_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_114[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_139[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22045,14 +24608,14 @@ _loop0_114_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_114_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_139_type, _seq); D(p->level--); return _seq; } -// _gather_113: kwarg_or_starred _loop0_114 +// _gather_138: kwarg_or_starred _loop0_139 static asdl_seq * -_gather_113_rule(Parser *p) +_gather_138_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22061,27 +24624,27 @@ _gather_113_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_114 + { // kwarg_or_starred _loop0_139 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_114")); + D(fprintf(stderr, "%*c> _gather_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_139")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_114_rule(p)) // _loop0_114 + (seq = _loop0_139_rule(p)) // _loop0_139 ) { - D(fprintf(stderr, "%*c+ _gather_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_114")); + D(fprintf(stderr, "%*c+ _gather_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_139")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_113[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_114")); + D(fprintf(stderr, "%*c%s _gather_138[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_139")); } _res = NULL; done: @@ -22089,9 +24652,9 @@ _gather_113_rule(Parser *p) return _res; } -// _loop0_116: ',' kwarg_or_double_starred +// _loop0_141: ',' kwarg_or_double_starred static asdl_seq * -_loop0_116_rule(Parser *p) +_loop0_141_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22115,7 +24678,7 @@ _loop0_116_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -22146,7 +24709,7 @@ _loop0_116_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_116[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_141[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22159,14 +24722,14 @@ _loop0_116_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_116_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_141_type, _seq); D(p->level--); return _seq; } -// _gather_115: kwarg_or_double_starred _loop0_116 +// _gather_140: kwarg_or_double_starred _loop0_141 static asdl_seq * -_gather_115_rule(Parser *p) +_gather_140_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22175,27 +24738,27 @@ _gather_115_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_116 + { // kwarg_or_double_starred _loop0_141 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_116")); + D(fprintf(stderr, "%*c> _gather_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_141")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_116_rule(p)) // _loop0_116 + (seq = _loop0_141_rule(p)) // _loop0_141 ) { - D(fprintf(stderr, "%*c+ _gather_115[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_116")); + D(fprintf(stderr, "%*c+ _gather_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_141")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_115[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_116")); + D(fprintf(stderr, "%*c%s _gather_140[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_141")); } _res = NULL; done: @@ -22203,9 +24766,9 @@ _gather_115_rule(Parser *p) return _res; } -// _loop0_117: (',' star_target) +// _loop0_142: (',' star_target) static asdl_seq * -_loop0_117_rule(Parser *p) +_loop0_142_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22229,13 +24792,13 @@ _loop0_117_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_145_var; + D(fprintf(stderr, "%*c> _loop0_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_173_var; while ( - (_tmp_145_var = _tmp_145_rule(p)) // ',' star_target + (_tmp_173_var = _tmp_173_rule(p)) // ',' star_target ) { - _res = _tmp_145_var; + _res = _tmp_173_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22251,7 +24814,7 @@ _loop0_117_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_117[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_142[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22264,14 +24827,14 @@ _loop0_117_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_117_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_142_type, _seq); D(p->level--); return _seq; } -// _loop0_119: ',' star_target +// _loop0_144: ',' star_target static asdl_seq * -_loop0_119_rule(Parser *p) +_loop0_144_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22295,7 +24858,7 @@ _loop0_119_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _loop0_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty elem; while ( @@ -22326,7 +24889,7 @@ _loop0_119_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_119[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_144[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22339,14 +24902,14 @@ _loop0_119_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_144_type, _seq); D(p->level--); return _seq; } -// _gather_118: star_target _loop0_119 +// _gather_143: star_target _loop0_144 static asdl_seq * -_gather_118_rule(Parser *p) +_gather_143_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22355,27 +24918,27 @@ _gather_118_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_target _loop0_119 + { // star_target _loop0_144 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_119")); + D(fprintf(stderr, "%*c> _gather_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_144")); expr_ty elem; asdl_seq * seq; if ( (elem = star_target_rule(p)) // star_target && - (seq = _loop0_119_rule(p)) // _loop0_119 + (seq = _loop0_144_rule(p)) // _loop0_144 ) { - D(fprintf(stderr, "%*c+ _gather_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_119")); + D(fprintf(stderr, "%*c+ _gather_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_144")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_118[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_119")); + D(fprintf(stderr, "%*c%s _gather_143[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_144")); } _res = NULL; done: @@ -22383,9 +24946,9 @@ _gather_118_rule(Parser *p) return _res; } -// _tmp_120: !'*' star_target +// _tmp_145: !'*' star_target static void * -_tmp_120_rule(Parser *p) +_tmp_145_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22399,7 +24962,7 @@ _tmp_120_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); expr_ty star_target_var; if ( _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' @@ -22407,12 +24970,12 @@ _tmp_120_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); _res = star_target_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); } _res = NULL; @@ -22421,9 +24984,9 @@ _tmp_120_rule(Parser *p) return _res; } -// _loop0_122: ',' del_target +// _loop0_147: ',' del_target static asdl_seq * -_loop0_122_rule(Parser *p) +_loop0_147_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22447,7 +25010,7 @@ _loop0_122_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); + D(fprintf(stderr, "%*c> _loop0_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); Token * _literal; expr_ty elem; while ( @@ -22478,7 +25041,7 @@ _loop0_122_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_122[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_147[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22491,14 +25054,14 @@ _loop0_122_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_122_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_147_type, _seq); D(p->level--); return _seq; } -// _gather_121: del_target _loop0_122 +// _gather_146: del_target _loop0_147 static asdl_seq * -_gather_121_rule(Parser *p) +_gather_146_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22507,27 +25070,27 @@ _gather_121_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // del_target _loop0_122 + { // del_target _loop0_147 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_122")); + D(fprintf(stderr, "%*c> _gather_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_147")); expr_ty elem; asdl_seq * seq; if ( (elem = del_target_rule(p)) // del_target && - (seq = _loop0_122_rule(p)) // _loop0_122 + (seq = _loop0_147_rule(p)) // _loop0_147 ) { - D(fprintf(stderr, "%*c+ _gather_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_122")); + D(fprintf(stderr, "%*c+ _gather_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_147")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_121[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_122")); + D(fprintf(stderr, "%*c%s _gather_146[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_147")); } _res = NULL; done: @@ -22535,9 +25098,9 @@ _gather_121_rule(Parser *p) return _res; } -// _loop0_124: ',' target +// _loop0_149: ',' target static asdl_seq * -_loop0_124_rule(Parser *p) +_loop0_149_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22561,7 +25124,7 @@ _loop0_124_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); + D(fprintf(stderr, "%*c> _loop0_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); Token * _literal; expr_ty elem; while ( @@ -22592,7 +25155,7 @@ _loop0_124_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_124[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_149[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22605,14 +25168,14 @@ _loop0_124_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_124_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_149_type, _seq); D(p->level--); return _seq; } -// _gather_123: target _loop0_124 +// _gather_148: target _loop0_149 static asdl_seq * -_gather_123_rule(Parser *p) +_gather_148_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22621,27 +25184,27 @@ _gather_123_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // target _loop0_124 + { // target _loop0_149 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_124")); + D(fprintf(stderr, "%*c> _gather_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_149")); expr_ty elem; asdl_seq * seq; if ( (elem = target_rule(p)) // target && - (seq = _loop0_124_rule(p)) // _loop0_124 + (seq = _loop0_149_rule(p)) // _loop0_149 ) { - D(fprintf(stderr, "%*c+ _gather_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_124")); + D(fprintf(stderr, "%*c+ _gather_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_149")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_123[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_124")); + D(fprintf(stderr, "%*c%s _gather_148[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_149")); } _res = NULL; done: @@ -22649,9 +25212,9 @@ _gather_123_rule(Parser *p) return _res; } -// _tmp_125: args | expression for_if_clauses +// _tmp_150: args | expression for_if_clauses static void * -_tmp_125_rule(Parser *p) +_tmp_150_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22665,18 +25228,18 @@ _tmp_125_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); expr_ty args_var; if ( (args_var = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); _res = args_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); } { // expression for_if_clauses @@ -22684,7 +25247,7 @@ _tmp_125_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); expr_ty expression_var; asdl_seq* for_if_clauses_var; if ( @@ -22693,12 +25256,12 @@ _tmp_125_rule(Parser *p) (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses ) { - D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); } _res = NULL; @@ -22707,9 +25270,9 @@ _tmp_125_rule(Parser *p) return _res; } -// _loop0_126: star_named_expressions +// _loop0_151: star_named_expressions static asdl_seq * -_loop0_126_rule(Parser *p) +_loop0_151_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22733,7 +25296,7 @@ _loop0_126_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); + D(fprintf(stderr, "%*c> _loop0_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); asdl_seq* star_named_expressions_var; while ( (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions @@ -22755,7 +25318,7 @@ _loop0_126_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_126[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_151[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22768,14 +25331,14 @@ _loop0_126_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_126_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_151_type, _seq); D(p->level--); return _seq; } -// _tmp_127: '=' annotated_rhs +// _tmp_152: '=' annotated_rhs static void * -_tmp_127_rule(Parser *p) +_tmp_152_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22789,7 +25352,7 @@ _tmp_127_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); Token * _literal; expr_ty annotated_rhs_var; if ( @@ -22798,12 +25361,12 @@ _tmp_127_rule(Parser *p) (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs ) { - D(fprintf(stderr, "%*c+ _tmp_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_127[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); } _res = NULL; @@ -22812,9 +25375,9 @@ _tmp_127_rule(Parser *p) return _res; } -// _tmp_128: yield_expr | star_expressions +// _tmp_153: yield_expr | star_expressions static void * -_tmp_128_rule(Parser *p) +_tmp_153_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22828,18 +25391,18 @@ _tmp_128_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -22847,18 +25410,18 @@ _tmp_128_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -22867,9 +25430,9 @@ _tmp_128_rule(Parser *p) return _res; } -// _tmp_129: yield_expr | star_expressions +// _tmp_154: yield_expr | star_expressions static void * -_tmp_129_rule(Parser *p) +_tmp_154_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22883,18 +25446,18 @@ _tmp_129_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_129[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -22902,18 +25465,18 @@ _tmp_129_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_129[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -22922,9 +25485,9 @@ _tmp_129_rule(Parser *p) return _res; } -// _tmp_130: '[' | '(' | '{' +// _tmp_155: '[' | '(' | '{' static void * -_tmp_130_rule(Parser *p) +_tmp_155_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22938,18 +25501,18 @@ _tmp_130_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); } { // '(' @@ -22957,18 +25520,18 @@ _tmp_130_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' ) { - D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } { // '{' @@ -22976,18 +25539,18 @@ _tmp_130_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' ) { - D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); } _res = NULL; @@ -22996,9 +25559,9 @@ _tmp_130_rule(Parser *p) return _res; } -// _loop0_131: param_no_default +// _loop0_156: param_no_default static asdl_seq * -_loop0_131_rule(Parser *p) +_loop0_156_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23022,7 +25585,7 @@ _loop0_131_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_156[%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 @@ -23044,7 +25607,7 @@ _loop0_131_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_131[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_156[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23057,14 +25620,14 @@ _loop0_131_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_131_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_156_type, _seq); D(p->level--); return _seq; } -// _tmp_132: slash_with_default | param_with_default+ +// _tmp_157: slash_with_default | param_with_default+ static void * -_tmp_132_rule(Parser *p) +_tmp_157_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23078,18 +25641,18 @@ _tmp_132_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c> _tmp_157[%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_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c+ _tmp_157[%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_132[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); } { // param_with_default+ @@ -23097,18 +25660,18 @@ _tmp_132_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - asdl_seq * _loop1_146_var; + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + asdl_seq * _loop1_174_var; if ( - (_loop1_146_var = _loop1_146_rule(p)) // param_with_default+ + (_loop1_174_var = _loop1_174_rule(p)) // param_with_default+ ) { - D(fprintf(stderr, "%*c+ _tmp_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - _res = _loop1_146_var; + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + _res = _loop1_174_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_132[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+")); } _res = NULL; @@ -23117,9 +25680,9 @@ _tmp_132_rule(Parser *p) return _res; } -// _tmp_133: ')' | ',' (')' | '**') +// _tmp_158: ')' | ',' (')' | '**') static void * -_tmp_133_rule(Parser *p) +_tmp_158_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23133,18 +25696,18 @@ _tmp_133_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // ',' (')' | '**') @@ -23152,21 +25715,21 @@ _tmp_133_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); Token * _literal; - void *_tmp_147_var; + void *_tmp_175_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_147_var = _tmp_147_rule(p)) // ')' | '**' + (_tmp_175_var = _tmp_175_rule(p)) // ')' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_147_var); + D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_175_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); } _res = NULL; @@ -23175,9 +25738,9 @@ _tmp_133_rule(Parser *p) return _res; } -// _tmp_134: ':' | ',' (':' | '**') +// _tmp_159: ':' | ',' (':' | '**') static void * -_tmp_134_rule(Parser *p) +_tmp_159_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23191,18 +25754,18 @@ _tmp_134_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_134[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // ',' (':' | '**') @@ -23210,21 +25773,21 @@ _tmp_134_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); Token * _literal; - void *_tmp_148_var; + void *_tmp_176_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_148_var = _tmp_148_rule(p)) // ':' | '**' + (_tmp_176_var = _tmp_176_rule(p)) // ':' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_148_var); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_176_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_134[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); } _res = NULL; @@ -23233,9 +25796,9 @@ _tmp_134_rule(Parser *p) return _res; } -// _tmp_135: star_targets '=' +// _tmp_160: star_targets '=' static void * -_tmp_135_rule(Parser *p) +_tmp_160_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23249,7 +25812,7 @@ _tmp_135_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty z; if ( @@ -23258,7 +25821,7 @@ _tmp_135_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23268,7 +25831,7 @@ _tmp_135_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_135[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -23277,9 +25840,9 @@ _tmp_135_rule(Parser *p) return _res; } -// _tmp_136: '.' | '...' +// _tmp_161: '.' | '...' static void * -_tmp_136_rule(Parser *p) +_tmp_161_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23293,18 +25856,18 @@ _tmp_136_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -23312,18 +25875,18 @@ _tmp_136_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -23332,9 +25895,9 @@ _tmp_136_rule(Parser *p) return _res; } -// _tmp_137: '.' | '...' +// _tmp_162: '.' | '...' static void * -_tmp_137_rule(Parser *p) +_tmp_162_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23348,18 +25911,18 @@ _tmp_137_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_137[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -23367,18 +25930,18 @@ _tmp_137_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_137[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -23387,9 +25950,135 @@ _tmp_137_rule(Parser *p) return _res; } -// _tmp_138: '@' named_expression NEWLINE +// _tmp_163: key_pattern ':' closed_pattern +static void * +_tmp_163_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // key_pattern ':' closed_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_pattern ':' closed_pattern")); + Token * _literal; + void *closed_pattern_var; + void *key_pattern_var; + if ( + (key_pattern_var = key_pattern_rule(p)) // key_pattern + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (closed_pattern_var = closed_pattern_rule(p)) // closed_pattern + ) + { + D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_pattern ':' closed_pattern")); + _res = _PyPegen_dummy_name(p, key_pattern_var, _literal, closed_pattern_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_pattern ':' closed_pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_164: NAME '=' or_pattern +static void * +_tmp_164_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // NAME '=' or_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' or_pattern")); + Token * _literal; + expr_ty name_var; + void *or_pattern_var; + if ( + (name_var = _PyPegen_name_token(p)) // NAME + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + && + (or_pattern_var = or_pattern_rule(p)) // or_pattern + ) + { + D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' or_pattern")); + _res = _PyPegen_dummy_name(p, name_var, _literal, or_pattern_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' or_pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_165: NAME '=' or_pattern +static void * +_tmp_165_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // NAME '=' or_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' or_pattern")); + Token * _literal; + expr_ty name_var; + void *or_pattern_var; + if ( + (name_var = _PyPegen_name_token(p)) // NAME + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + && + (or_pattern_var = or_pattern_rule(p)) // or_pattern + ) + { + D(fprintf(stderr, "%*c+ _tmp_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' or_pattern")); + _res = _PyPegen_dummy_name(p, name_var, _literal, or_pattern_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_165[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' or_pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_166: '@' named_expression NEWLINE static void * -_tmp_138_rule(Parser *p) +_tmp_166_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23403,7 +26092,7 @@ _tmp_138_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); Token * _literal; expr_ty f; Token * newline_var; @@ -23415,7 +26104,7 @@ _tmp_138_rule(Parser *p) (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); _res = f; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23425,7 +26114,7 @@ _tmp_138_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_138[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); } _res = NULL; @@ -23434,9 +26123,9 @@ _tmp_138_rule(Parser *p) return _res; } -// _tmp_139: ',' star_expression +// _tmp_167: ',' star_expression static void * -_tmp_139_rule(Parser *p) +_tmp_167_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23450,7 +26139,7 @@ _tmp_139_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty c; if ( @@ -23459,7 +26148,7 @@ _tmp_139_rule(Parser *p) (c = star_expression_rule(p)) // star_expression ) { - D(fprintf(stderr, "%*c+ _tmp_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23469,7 +26158,7 @@ _tmp_139_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_139[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } _res = NULL; @@ -23478,9 +26167,9 @@ _tmp_139_rule(Parser *p) return _res; } -// _tmp_140: ',' expression +// _tmp_168: ',' expression static void * -_tmp_140_rule(Parser *p) +_tmp_168_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23494,7 +26183,7 @@ _tmp_140_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty c; if ( @@ -23503,7 +26192,7 @@ _tmp_140_rule(Parser *p) (c = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23513,7 +26202,7 @@ _tmp_140_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_140[%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, "',' expression")); } _res = NULL; @@ -23522,9 +26211,9 @@ _tmp_140_rule(Parser *p) return _res; } -// _tmp_141: 'or' conjunction +// _tmp_169: 'or' conjunction static void * -_tmp_141_rule(Parser *p) +_tmp_169_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23538,7 +26227,7 @@ _tmp_141_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c> _tmp_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); Token * _keyword; expr_ty c; if ( @@ -23547,7 +26236,7 @@ _tmp_141_rule(Parser *p) (c = conjunction_rule(p)) // conjunction ) { - D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c+ _tmp_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23557,7 +26246,7 @@ _tmp_141_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_141[%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, "'or' conjunction")); } _res = NULL; @@ -23566,9 +26255,9 @@ _tmp_141_rule(Parser *p) return _res; } -// _tmp_142: 'and' inversion +// _tmp_170: 'and' inversion static void * -_tmp_142_rule(Parser *p) +_tmp_170_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23582,7 +26271,7 @@ _tmp_142_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c> _tmp_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); Token * _keyword; expr_ty c; if ( @@ -23591,7 +26280,7 @@ _tmp_142_rule(Parser *p) (c = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ _tmp_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23601,7 +26290,7 @@ _tmp_142_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_142[%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, "'and' inversion")); } _res = NULL; @@ -23610,9 +26299,9 @@ _tmp_142_rule(Parser *p) return _res; } -// _tmp_143: 'if' disjunction +// _tmp_171: 'if' disjunction static void * -_tmp_143_rule(Parser *p) +_tmp_171_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23626,7 +26315,7 @@ _tmp_143_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -23635,7 +26324,7 @@ _tmp_143_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23645,7 +26334,7 @@ _tmp_143_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_143[%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, "'if' disjunction")); } _res = NULL; @@ -23654,9 +26343,9 @@ _tmp_143_rule(Parser *p) return _res; } -// _tmp_144: 'if' disjunction +// _tmp_172: 'if' disjunction static void * -_tmp_144_rule(Parser *p) +_tmp_172_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23670,7 +26359,7 @@ _tmp_144_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -23679,7 +26368,7 @@ _tmp_144_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23689,7 +26378,7 @@ _tmp_144_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_144[%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, "'if' disjunction")); } _res = NULL; @@ -23698,9 +26387,9 @@ _tmp_144_rule(Parser *p) return _res; } -// _tmp_145: ',' star_target +// _tmp_173: ',' star_target static void * -_tmp_145_rule(Parser *p) +_tmp_173_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23714,7 +26403,7 @@ _tmp_145_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty c; if ( @@ -23723,7 +26412,7 @@ _tmp_145_rule(Parser *p) (c = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23733,7 +26422,7 @@ _tmp_145_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_145[%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, "',' star_target")); } _res = NULL; @@ -23742,9 +26431,9 @@ _tmp_145_rule(Parser *p) return _res; } -// _loop1_146: param_with_default +// _loop1_174: param_with_default static asdl_seq * -_loop1_146_rule(Parser *p) +_loop1_174_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23768,7 +26457,7 @@ _loop1_146_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -23790,7 +26479,7 @@ _loop1_146_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_146[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_174[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -23808,14 +26497,14 @@ _loop1_146_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_146_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_174_type, _seq); D(p->level--); return _seq; } -// _tmp_147: ')' | '**' +// _tmp_175: ')' | '**' static void * -_tmp_147_rule(Parser *p) +_tmp_175_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23829,18 +26518,18 @@ _tmp_147_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_147[%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, "')'")); } { // '**' @@ -23848,18 +26537,18 @@ _tmp_147_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_147[%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, "'**'")); } _res = NULL; @@ -23868,9 +26557,9 @@ _tmp_147_rule(Parser *p) return _res; } -// _tmp_148: ':' | '**' +// _tmp_176: ':' | '**' static void * -_tmp_148_rule(Parser *p) +_tmp_176_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23884,18 +26573,18 @@ _tmp_148_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_148[%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, "':'")); } { // '**' @@ -23903,18 +26592,18 @@ _tmp_148_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_148[%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, "'**'")); } _res = NULL; From 67354ad6669bc65493a80c4b0dd8585547efaae9 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 25 May 2020 16:33:22 -0700 Subject: [PATCH 010/189] Add tests for or-patterns --- Lib/test/test_patma.py | 64 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 20d8ce23ae3028..daac830273ec51 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -12,7 +12,9 @@ class MatchCase(typing.NamedTuple): guard: typing.Optional[str] = None -class PatMaTests(unittest.TestCase): +class TestAST(unittest.TestCase): + """Tests that predate parser support, and just execute ASTs instead.""" + @staticmethod def parse_stmts(stmts: str) -> typing.List[ast.stmt]: return ast.parse(stmts, FILENAME, "exec").body @@ -191,3 +193,63 @@ def test_walrus_5(self) -> None: self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 0) + + def test_pipe_0(self) -> None: + match_cases = [MatchCase("0 | 1 | 2", "y = 0")] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertEqual(namespace.get("y"), 0) + + def test_pipe_1(self) -> None: + match_cases = [MatchCase("0 | 1 | 2", "y = 0")] + namespace = self.execute_match("x = 1", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 1) + self.assertEqual(namespace.get("y"), 0) + + def test_pipe_2(self) -> None: + match_cases = [MatchCase("0 | 1 | 2", "y = 0")] + namespace = self.execute_match("x = 2", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 2) + self.assertEqual(namespace.get("y"), 0) + + def test_pipe_3(self) -> None: + match_cases = [MatchCase("0 | 1 | 2", "y = 0")] + namespace = self.execute_match("x = 3", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 3) + self.assertNotIn("y", namespace) + + def test_pipe_4(self) -> None: + match_cases = [ + MatchCase("(z := 0) | (z := 1) | (z := 2)", "y = 0", "z == x % 2") + ] + namespace = self.execute_match("x = 0", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 0) + self.assertEqual(namespace.get("y"), 0) + self.assertEqual(namespace.get("z"), 0) + + def test_pipe_5(self) -> None: + match_cases = [ + MatchCase("(z := 0) | (z := 1) | (z := 2)", "y = 0", "z == x % 2") + ] + namespace = self.execute_match("x = 1", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 1) + self.assertEqual(namespace.get("y"), 0) + self.assertEqual(namespace.get("z"), 1) + + def test_pipe_6(self) -> None: + match_cases = [ + MatchCase("(z := 0) | (z := 1) | (z := 2)", "y = 0", "z == x % 2") + ] + namespace = self.execute_match("x = 2", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 2) + self.assertNotIn("y", namespace) + self.assertEqual(namespace.get("z"), 2) + + def test_pipe_7(self) -> None: + match_cases = [ + MatchCase("(z := 0) | (z := 1) | (z := 2)", "y = 0", "z == x % 2") + ] + namespace = self.execute_match("x = 3", "x", match_cases, "") + self.assertEqual(namespace.get("x"), 3) + self.assertNotIn("y", namespace) + self.assertNotIn("z", namespace) From 5d609c7866671f2d5a7ac9e6eb14727e9289ba81 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 25 May 2020 16:33:35 -0700 Subject: [PATCH 011/189] Add support for or-patterns --- Python/ast.c | 6 ++++++ Python/compile.c | 28 ++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Python/ast.c b/Python/ast.c index 207133fee15a01..82f7e3fa53a363 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -310,6 +310,12 @@ validate_pattern(expr_ty p) return validate_constant(p->v.Constant.value); case NamedExpr_kind: return validate_pattern(p->v.NamedExpr.value); + case BinOp_kind: + if (p->v.BinOp.op != BitOr) { + break; + } + return (validate_pattern(p->v.BinOp.left) + && validate_pattern(p->v.BinOp.right)); default: break; } diff --git a/Python/compile.c b/Python/compile.c index 4e2b9ca14b0d0f..eb2129e14efa47 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2747,20 +2747,37 @@ compiler_if(struct compiler *c, stmt_ty s) } static int -compiler_pattern(struct compiler *c, expr_ty p, basicblock *next) +compiler_pattern(struct compiler *c, expr_ty p, basicblock *body, basicblock *next) { + basicblock *block; + // TODO: We can probably simplify some of the jumping-around. switch (p->kind) { case Constant_kind: VISIT(c, expr, p); ADDOP_COMPARE(c, Eq); ADDOP_JABS(c, POP_JUMP_IF_FALSE, next); + ADDOP_JREL(c, JUMP_FORWARD, body); return 1; case NamedExpr_kind: - if (!compiler_pattern(c, p->v.NamedExpr.value, next)) { + block = compiler_new_block(c); + if (!compiler_pattern(c, p->v.NamedExpr.value, block, next)) { return 0; } + compiler_use_next_block(c, block); ADDOP(c, DUP_TOP); VISIT(c, expr, p->v.NamedExpr.target); + ADDOP_JREL(c, JUMP_FORWARD, body); + return 1; + case BinOp_kind: + block = compiler_new_block(c); + if (!compiler_pattern(c, p->v.BinOp.left, body, block)) { + return 0; + } + compiler_use_next_block(c, block); + ADDOP(c, DUP_TOP); + if (!compiler_pattern(c, p->v.BinOp.right, body, next)) { + return 0; + } return 1; default: break; @@ -2775,13 +2792,16 @@ compiler_match(struct compiler *c, stmt_ty s) basicblock *end = compiler_new_block(c); VISIT(c, expr, s->v.Match.target); match_case_ty m; - basicblock *next; + basicblock *body, *next; Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); for (Py_ssize_t i = 0; i < cases; i++) { + // TODO: We can probably simplify some of the jumping-around. m = asdl_seq_GET(s->v.Match.cases, i); + body = compiler_new_block(c); next = compiler_new_block(c); ADDOP(c, DUP_TOP); - compiler_pattern(c, m->pattern, next); + compiler_pattern(c, m->pattern, body, next); + compiler_use_next_block(c, body); if (m->guard && !compiler_jump_if(c, m->guard, next, 0)) { return 0; } From 1f8bcbd737ab1fc7465ea153f16a004c8c821dfe Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 26 May 2020 07:05:52 -0700 Subject: [PATCH 012/189] Clean up pattern matching compiler --- Python/compile.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index eb2129e14efa47..e195f2454bced3 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2747,35 +2747,34 @@ compiler_if(struct compiler *c, stmt_ty s) } static int -compiler_pattern(struct compiler *c, expr_ty p, basicblock *body, basicblock *next) +compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) { basicblock *block; - // TODO: We can probably simplify some of the jumping-around. switch (p->kind) { case Constant_kind: + ADDOP(c, DUP_TOP); VISIT(c, expr, p); ADDOP_COMPARE(c, Eq); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, next); - ADDOP_JREL(c, JUMP_FORWARD, body); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, no); + ADDOP_JREL(c, JUMP_FORWARD, yes); return 1; case NamedExpr_kind: block = compiler_new_block(c); - if (!compiler_pattern(c, p->v.NamedExpr.value, block, next)) { + if (!compiler_pattern(c, p->v.NamedExpr.value, block, no)) { return 0; } compiler_use_next_block(c, block); ADDOP(c, DUP_TOP); VISIT(c, expr, p->v.NamedExpr.target); - ADDOP_JREL(c, JUMP_FORWARD, body); + ADDOP_JREL(c, JUMP_FORWARD, yes); return 1; case BinOp_kind: block = compiler_new_block(c); - if (!compiler_pattern(c, p->v.BinOp.left, body, block)) { + if (!compiler_pattern(c, p->v.BinOp.left, yes, block)) { return 0; } compiler_use_next_block(c, block); - ADDOP(c, DUP_TOP); - if (!compiler_pattern(c, p->v.BinOp.right, body, next)) { + if (!compiler_pattern(c, p->v.BinOp.right, yes, no)) { return 0; } return 1; @@ -2789,17 +2788,14 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *body, basicblock *ne static int compiler_match(struct compiler *c, stmt_ty s) { - basicblock *end = compiler_new_block(c); VISIT(c, expr, s->v.Match.target); match_case_ty m; - basicblock *body, *next; + basicblock *body, *next, *end = compiler_new_block(c); Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); for (Py_ssize_t i = 0; i < cases; i++) { - // TODO: We can probably simplify some of the jumping-around. m = asdl_seq_GET(s->v.Match.cases, i); body = compiler_new_block(c); next = compiler_new_block(c); - ADDOP(c, DUP_TOP); compiler_pattern(c, m->pattern, body, next); compiler_use_next_block(c, body); if (m->guard && !compiler_jump_if(c, m->guard, next, 0)) { From eb704d4284fd1be743faecd7c9ac07dc3978f747 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 26 May 2020 07:35:13 -0700 Subject: [PATCH 013/189] Add attribute/name support --- Python/ast.c | 12 ++++++++---- Python/compile.c | 10 ++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Python/ast.c b/Python/ast.c index 82f7e3fa53a363..da15a9ab1aaa65 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -306,16 +306,20 @@ static int validate_pattern(expr_ty p) { switch (p->kind) { - case Constant_kind: - return validate_constant(p->v.Constant.value); - case NamedExpr_kind: - return validate_pattern(p->v.NamedExpr.value); + case Attribute_kind: + return validate_expr(p, Load); case BinOp_kind: if (p->v.BinOp.op != BitOr) { break; } return (validate_pattern(p->v.BinOp.left) && validate_pattern(p->v.BinOp.right)); + case Constant_kind: + return validate_constant(p->v.Constant.value); + case Name_kind: + return validate_expr(p, p->v.Name.ctx); + case NamedExpr_kind: + return validate_pattern(p->v.NamedExpr.value); default: break; } diff --git a/Python/compile.c b/Python/compile.c index e195f2454bced3..3a230716fd333a 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2751,6 +2751,15 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) { basicblock *block; switch (p->kind) { + // Atomic patterns: + case Name_kind: + if (p->v.Name.ctx == Store) { + ADDOP(c, DUP_TOP); + VISIT(c, expr, p); + ADDOP_JREL(c, JUMP_FORWARD, yes); + return 1; + } // Down we go... + case Attribute_kind: case Constant_kind: ADDOP(c, DUP_TOP); VISIT(c, expr, p); @@ -2758,6 +2767,7 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) ADDOP_JABS(c, POP_JUMP_IF_FALSE, no); ADDOP_JREL(c, JUMP_FORWARD, yes); return 1; + // Nested patterns: case NamedExpr_kind: block = compiler_new_block(c); if (!compiler_pattern(c, p->v.NamedExpr.value, block, no)) { From 5a361bff2ba14a6a5140292c5a7e007c4e547de9 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 26 May 2020 07:59:59 -0700 Subject: [PATCH 014/189] Validate name context --- Python/ast.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Python/ast.c b/Python/ast.c index da15a9ab1aaa65..e8b6d19912b9b0 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -317,6 +317,9 @@ validate_pattern(expr_ty p) case Constant_kind: return validate_constant(p->v.Constant.value); case Name_kind: + if (p->v.Name.ctx != Load && p->v.Name.ctx != Store) { + break; + } return validate_expr(p, p->v.Name.ctx); case NamedExpr_kind: return validate_pattern(p->v.NamedExpr.value); From 9c2e61cb51c052c770baa6e0213eea601cb3ffd9 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 26 May 2020 08:00:42 -0700 Subject: [PATCH 015/189] Clean up pattern compiler --- Python/compile.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 3a230716fd333a..9050a03499d8c9 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2752,32 +2752,18 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) basicblock *block; switch (p->kind) { // Atomic patterns: - case Name_kind: - if (p->v.Name.ctx == Store) { - ADDOP(c, DUP_TOP); - VISIT(c, expr, p); - ADDOP_JREL(c, JUMP_FORWARD, yes); - return 1; - } // Down we go... case Attribute_kind: case Constant_kind: + case Name_kind: ADDOP(c, DUP_TOP); VISIT(c, expr, p); - ADDOP_COMPARE(c, Eq); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, no); - ADDOP_JREL(c, JUMP_FORWARD, yes); - return 1; - // Nested patterns: - case NamedExpr_kind: - block = compiler_new_block(c); - if (!compiler_pattern(c, p->v.NamedExpr.value, block, no)) { - return 0; + if (p->kind != Name_kind || p->v.Name.ctx == Load) { + ADDOP_COMPARE(c, Eq); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, no); } - compiler_use_next_block(c, block); - ADDOP(c, DUP_TOP); - VISIT(c, expr, p->v.NamedExpr.target); ADDOP_JREL(c, JUMP_FORWARD, yes); return 1; + // Nested patterns: case BinOp_kind: block = compiler_new_block(c); if (!compiler_pattern(c, p->v.BinOp.left, yes, block)) { @@ -2788,11 +2774,19 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) return 0; } return 1; + case NamedExpr_kind: + block = compiler_new_block(c); + if (!compiler_pattern(c, p->v.NamedExpr.value, block, no)) { + return 0; + } + compiler_use_next_block(c, block); + ADDOP(c, DUP_TOP); + VISIT(c, expr, p->v.NamedExpr.target); + ADDOP_JREL(c, JUMP_FORWARD, yes); + return 1; default: - break; + Py_UNREACHABLE(); } - PyErr_SetString(PyExc_SystemError, "invalid match pattern"); - return 0; } static int From dddcca8c11fb7eb72fea6aedb75ac57d1828710d Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 26 May 2020 10:29:43 -0700 Subject: [PATCH 016/189] Don't bind _ --- Lib/test/test_patma.py | 6 +++++- Python/compile.c | 16 +++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index daac830273ec51..3de1c1fb4ed9b1 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -13,7 +13,11 @@ class MatchCase(typing.NamedTuple): class TestAST(unittest.TestCase): - """Tests that predate parser support, and just execute ASTs instead.""" + """Tests that predate parser support, and just execute ASTs instead. + + No tests for name loads/stores, since these need a patma parser to + disambiguate. + """ @staticmethod def parse_stmts(stmts: str) -> typing.List[ast.stmt]: diff --git a/Python/compile.c b/Python/compile.c index 9050a03499d8c9..1a58ddeb1c10bf 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2752,15 +2752,21 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) basicblock *block; switch (p->kind) { // Atomic patterns: + case Name_kind: + if (p->v.Name.ctx == Store) { + if (!_PyUnicode_EqualToASCIIString(p->v.Name.id, "_")) { + ADDOP(c, DUP_TOP); + VISIT(c, expr, p); + } + ADDOP_JREL(c, JUMP_FORWARD, yes); + return 1; + } // Loads fall through. case Attribute_kind: case Constant_kind: - case Name_kind: ADDOP(c, DUP_TOP); VISIT(c, expr, p); - if (p->kind != Name_kind || p->v.Name.ctx == Load) { - ADDOP_COMPARE(c, Eq); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, no); - } + ADDOP_COMPARE(c, Eq); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, no); ADDOP_JREL(c, JUMP_FORWARD, yes); return 1; // Nested patterns: From af70c74b47b493da893377e0b06367d9f00b40a6 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 26 May 2020 13:41:47 -0700 Subject: [PATCH 017/189] Add sequence tests --- Lib/test/test_patma.py | 80 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 3de1c1fb4ed9b1..2ff9d08e53d83d 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1,4 +1,5 @@ import ast +import types import typing import unittest @@ -35,15 +36,21 @@ def parse_match_case(cls, match_case: MatchCase) -> ast.expr: return ast.match_case(pattern=pattern, guard=guard, body=body) @classmethod - def execute_match( + def compile_match( cls, pre: str, target: str, match_cases: typing.Iterable[MatchCase], post: str - ) -> typing.Dict[str, typing.Any]: + ) -> types.CodeType: cases = [cls.parse_match_case(case) for case in match_cases] match = ast.Match(target=cls.parse_expr(target), cases=cases) body = [*cls.parse_stmts(pre), match, *cls.parse_stmts(post)] tree = ast.fix_missing_locations(ast.Module(body=body, type_ignores=[])) + return compile(tree, FILENAME, "exec") + + @classmethod + def execute_match( + cls, pre: str, target: str, match_cases: typing.Iterable[MatchCase], post: str + ) -> typing.Dict[str, typing.Any]: namespace = {} - exec(compile(tree, FILENAME, "exec"), None, namespace) + exec(cls.compile_match(pre, target, match_cases, post), None, namespace) return namespace def test_steroid_switch_0(self) -> None: @@ -257,3 +264,70 @@ def test_pipe_7(self) -> None: self.assertEqual(namespace.get("x"), 3) self.assertNotIn("y", namespace) self.assertNotIn("z", namespace) + + def test_iter_0(self) -> None: + match_cases = [MatchCase("()", "y = 0")] + namespace = self.execute_match("x = ()", "x", match_cases, "") + self.assertEqual(namespace.get("x"), ()) + self.assertEqual(namespace.get("y"), 0) + + def test_iter_1(self) -> None: + match_cases = [MatchCase("[]", "y = 0")] + namespace = self.execute_match("x = ()", "x", match_cases, "") + self.assertEqual(namespace.get("x"), ()) + self.assertEqual(namespace.get("y"), 0) + + def test_iter_2(self) -> None: + match_cases = [MatchCase("[0]", "y = 0")] + namespace = self.execute_match("x = (0,)", "x", match_cases, "") + self.assertEqual(namespace.get("x"), (0,)) + self.assertEqual(namespace.get("y"), 0) + + def test_iter_3(self) -> None: + match_cases = [MatchCase("[[]]", "y = 0")] + namespace = self.execute_match("x = ((),)", "x", match_cases, "") + self.assertEqual(namespace.get("x"), ((),)) + self.assertEqual(namespace.get("y"), 0) + + def test_iter_4(self) -> None: + match_cases = [MatchCase("(0, 1) | (1, 0)", "y = 0")] + namespace = self.execute_match("x = [0, 1]", "x", match_cases, "") + self.assertEqual(namespace.get("x"), [0, 1]) + self.assertEqual(namespace.get("y"), 0) + + def test_iter_5(self) -> None: + match_cases = [MatchCase("(0, 1) | (1, 0)", "y = 0")] + namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") + self.assertEqual(namespace.get("x"), [1, 0]) + self.assertEqual(namespace.get("y"), 0) + + def test_iter_6(self) -> None: + match_cases = [MatchCase("(0, 1) | (1, 0)", "y = 0")] + namespace = self.execute_match("x = [0, 0]", "x", match_cases, "") + self.assertEqual(namespace.get("x"), [0, 0]) + self.assertNotIn("y", namespace) + + def test_iter_7(self) -> None: + match_cases = [MatchCase("(w := 0,)", "y = 0"), MatchCase("[] | (1, z := (0 | 1)) | []", "y = 1")] + namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") + self.assertNotIn("w", namespace) + self.assertEqual(namespace.get("x"), [1, 0]) + self.assertEqual(namespace.get("y"), 1) + self.assertEqual(namespace.get("z"), 0) + + def test_iter_8(self) -> None: + match_cases = [ + MatchCase("(0,)", "y = 0"), + MatchCase("(1, 0)", "y = 1", "(x := x[:0])"), + MatchCase("(1, 0)", "y = 2"), + ] + namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") + self.assertEqual(namespace.get("x"), []) + self.assertEqual(namespace.get("y"), 2) + + +if __name__ == "__main__": # XXX: For quick test debugging... + import dis + + match_cases = [MatchCase("(0, 1) | (1, 0)", "y = 0")] + dis.dis(TestAST.compile_match("x = [0, 0]", "x", match_cases, "")) From 4191858df60100d2247fa707fc800ba1655e3231 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 26 May 2020 13:41:56 -0700 Subject: [PATCH 018/189] Add basic sequence support --- Python/ast.c | 12 ++++++++++ Python/compile.c | 58 +++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 60 insertions(+), 10 deletions(-) diff --git a/Python/ast.c b/Python/ast.c index e8b6d19912b9b0..b8a193bdbc8a30 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -305,6 +305,8 @@ validate_expr(expr_ty exp, expr_context_ty ctx) static int validate_pattern(expr_ty p) { + asdl_seq *elts; + Py_ssize_t i, size; switch (p->kind) { case Attribute_kind: return validate_expr(p, Load); @@ -316,6 +318,16 @@ validate_pattern(expr_ty p) && validate_pattern(p->v.BinOp.right)); case Constant_kind: return validate_constant(p->v.Constant.value); + case List_kind: + case Tuple_kind: + elts = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; + size = asdl_seq_LEN(elts); + for (i = 0; i < size; i++) { + if (!validate_pattern(asdl_seq_GET(elts, i))) { + return 0; + } + } + return 1; case Name_kind: if (p->v.Name.ctx != Load && p->v.Name.ctx != Store) { break; diff --git a/Python/compile.c b/Python/compile.c index 1a58ddeb1c10bf..19fb623cd11127 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2749,13 +2749,17 @@ compiler_if(struct compiler *c, stmt_ty s) static int compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) { - basicblock *block; + // TODO: This inital implementation keeps things simple(-ish), but creates a + // TON of blocks and zero-length jumps, especially for sequences. Simplify? + // The zero-length jumps can probably be peep-holed. + basicblock *sub_no, *sub_yes; + asdl_seq *elts; + Py_ssize_t i, size; switch (p->kind) { // Atomic patterns: case Name_kind: if (p->v.Name.ctx == Store) { if (!_PyUnicode_EqualToASCIIString(p->v.Name.id, "_")) { - ADDOP(c, DUP_TOP); VISIT(c, expr, p); } ADDOP_JREL(c, JUMP_FORWARD, yes); @@ -2763,7 +2767,6 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) } // Loads fall through. case Attribute_kind: case Constant_kind: - ADDOP(c, DUP_TOP); VISIT(c, expr, p); ADDOP_COMPARE(c, Eq); ADDOP_JABS(c, POP_JUMP_IF_FALSE, no); @@ -2771,24 +2774,58 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) return 1; // Nested patterns: case BinOp_kind: - block = compiler_new_block(c); - if (!compiler_pattern(c, p->v.BinOp.left, yes, block)) { + ADDOP(c, DUP_TOP); + sub_yes = compiler_new_block(c); + sub_no = compiler_new_block(c); + if (!compiler_pattern(c, p->v.BinOp.left, sub_yes, sub_no)) { return 0; } - compiler_use_next_block(c, block); + compiler_use_next_block(c, sub_no); if (!compiler_pattern(c, p->v.BinOp.right, yes, no)) { return 0; } + compiler_use_next_block(c, sub_yes); + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, yes); + return 1; + case List_kind: + case Tuple_kind: + // TODO: Need to add a MATCH_SEQ that handles checking for + // Sequence (but not str, bytes, bytearray), and popping/jumping to + // "no" on failure: + ADDOP(c, GET_ITER); + sub_no = compiler_new_block(c); + elts = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; + size = asdl_seq_LEN(elts); + for (i = 0; i < size; i++) { + sub_yes = compiler_new_block(c); + ADDOP_JREL(c, FOR_ITER, no); + if (!compiler_pattern(c, asdl_seq_GET(elts, i), sub_yes, sub_no)) { + return 0; + } + compiler_use_next_block(c, sub_yes); + } + ADDOP_JREL(c, FOR_ITER, yes); + ADDOP(c, POP_TOP); + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, no); + compiler_use_next_block(c, sub_no); + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, no); return 1; case NamedExpr_kind: - block = compiler_new_block(c); - if (!compiler_pattern(c, p->v.NamedExpr.value, block, no)) { + ADDOP(c, DUP_TOP); + sub_yes = compiler_new_block(c); + sub_no = compiler_new_block(c); + if (!compiler_pattern(c, p->v.NamedExpr.value, sub_yes, sub_no)) { return 0; } - compiler_use_next_block(c, block); - ADDOP(c, DUP_TOP); + compiler_use_next_block(c, sub_yes); VISIT(c, expr, p->v.NamedExpr.target); ADDOP_JREL(c, JUMP_FORWARD, yes); + compiler_use_next_block(c, sub_no); + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, no); return 1; default: Py_UNREACHABLE(); @@ -2806,6 +2843,7 @@ compiler_match(struct compiler *c, stmt_ty s) m = asdl_seq_GET(s->v.Match.cases, i); body = compiler_new_block(c); next = compiler_new_block(c); + ADDOP(c, DUP_TOP); compiler_pattern(c, m->pattern, body, next); compiler_use_next_block(c, body); if (m->guard && !compiler_jump_if(c, m->guard, next, 0)) { From 33633c17bffb230b17f3187bbe779a6d45afe105 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 26 May 2020 17:34:55 -0700 Subject: [PATCH 019/189] Add support for starred sub-patterns in sequences --- Python/ast.c | 14 +++++++--- Python/compile.c | 68 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 71 insertions(+), 11 deletions(-) diff --git a/Python/ast.c b/Python/ast.c index b8a193bdbc8a30..f5c82d2b1745ad 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -306,13 +306,15 @@ static int validate_pattern(expr_ty p) { asdl_seq *elts; + expr_ty elt; Py_ssize_t i, size; + char *error = "invalid Match pattern"; switch (p->kind) { case Attribute_kind: return validate_expr(p, Load); case BinOp_kind: if (p->v.BinOp.op != BitOr) { - break; + error = "BinOp op in pattern must be BitOr"; } return (validate_pattern(p->v.BinOp.left) && validate_pattern(p->v.BinOp.right)); @@ -323,14 +325,18 @@ validate_pattern(expr_ty p) elts = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; size = asdl_seq_LEN(elts); for (i = 0; i < size; i++) { - if (!validate_pattern(asdl_seq_GET(elts, i))) { + elt = asdl_seq_GET(elts, i); + if (elt->kind == Starred_kind) { + elt = elt->v.Starred.value; + } + if (!validate_pattern(elt)) { return 0; } } return 1; case Name_kind: if (p->v.Name.ctx != Load && p->v.Name.ctx != Store) { - break; + error = "Name ctx in pattern must be either Load or Store"; } return validate_expr(p, p->v.Name.ctx); case NamedExpr_kind: @@ -338,7 +344,7 @@ validate_pattern(expr_ty p) default: break; } - PyErr_SetString(PyExc_SystemError, "invalid match pattern"); + PyErr_SetString(PyExc_ValueError, error); return 0; } diff --git a/Python/compile.c b/Python/compile.c index 19fb623cd11127..248a52f1cc69f5 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2746,6 +2746,20 @@ compiler_if(struct compiler *c, stmt_ty s) return 1; } +static int +compiler_pattern_name_store(struct compiler *c, expr_ty p) +{ + assert(p->kind == Name_kind); + assert(p->v.Name.ctx == Store); + if (_PyUnicode_EqualToASCIIString(p->v.Name.id, "_")) { + ADDOP(c, POP_TOP); + } + else { + VISIT(c, expr, p); + } + return 1; +} + static int compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) { @@ -2753,19 +2767,24 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) // TON of blocks and zero-length jumps, especially for sequences. Simplify? // The zero-length jumps can probably be peep-holed. basicblock *sub_no, *sub_yes; + Py_ssize_t i, size, star; asdl_seq *elts; - Py_ssize_t i, size; + expr_ty elt; switch (p->kind) { // Atomic patterns: case Name_kind: if (p->v.Name.ctx == Store) { - if (!_PyUnicode_EqualToASCIIString(p->v.Name.id, "_")) { - VISIT(c, expr, p); + if (!compiler_pattern_name_store(c, p)) { + return 0; } ADDOP_JREL(c, JUMP_FORWARD, yes); return 1; - } // Loads fall through. + } + assert(p->v.Name.ctx == Load); + // Fall through... case Attribute_kind: + assert(p->kind != Attribute_kind || p->v.Attribute.ctx == Load); + // Fall through.... case Constant_kind: VISIT(c, expr, p); ADDOP_COMPARE(c, Eq); @@ -2774,6 +2793,7 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) return 1; // Nested patterns: case BinOp_kind: + assert(p->v.BinOp.op == BitOr); ADDOP(c, DUP_TOP); sub_yes = compiler_new_block(c); sub_no = compiler_new_block(c); @@ -2797,11 +2817,45 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) sub_no = compiler_new_block(c); elts = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; size = asdl_seq_LEN(elts); + star = -1; + for (i = 0; i < size; i++) { + elt = asdl_seq_GET(elts, i); + if (elt->kind != Starred_kind) { + continue; + } + if (elt->kind != Name_kind || elt->v.Name.ctx != Store) { + return compiler_error(c, + "starred sub-patterns must be names"); + } + if (star >= 0) { + return compiler_error(c, + "multiple starred names in pattern"); + } + if ((size - i - 1) << 8 >= INT_MAX) { + return compiler_error(c, + "too many sub-patterns follow starred sub-pattern"); + } + star = i; + } for (i = 0; i < size; i++) { sub_yes = compiler_new_block(c); - ADDOP_JREL(c, FOR_ITER, no); - if (!compiler_pattern(c, asdl_seq_GET(elts, i), sub_yes, sub_no)) { - return 0; + elt = asdl_seq_GET(elts, i); + if (i == star) { + assert(elt->kind == Starred_kind); + ADDOP_I(c, UNPACK_EX, (size - i - 1) << 8); + if (!compiler_pattern_name_store(c, elt->v.Starred.value)) { + return 0; + } + if (size - i - 1) { + ADDOP_I(c, BUILD_TUPLE, size - i - 1); + ADDOP(c, GET_ITER); + } + } + else { + ADDOP_JREL(c, FOR_ITER, no); + if (!compiler_pattern(c, elt, sub_yes, sub_no)) { + return 0; + } } compiler_use_next_block(c, sub_yes); } From a36542eca04410328beb25f0c0a134faf509f010 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 26 May 2020 17:35:04 -0700 Subject: [PATCH 020/189] Format tests --- Lib/test/test_patma.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 2ff9d08e53d83d..3ee59e620584ea 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -308,7 +308,10 @@ def test_iter_6(self) -> None: self.assertNotIn("y", namespace) def test_iter_7(self) -> None: - match_cases = [MatchCase("(w := 0,)", "y = 0"), MatchCase("[] | (1, z := (0 | 1)) | []", "y = 1")] + match_cases = [ + MatchCase("(w := 0,)", "y = 0"), + MatchCase("[] | (1, z := (0 | 1)) | []", "y = 1"), + ] namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") self.assertNotIn("w", namespace) self.assertEqual(namespace.get("x"), [1, 0]) From 76d108c38c2339c2bc8da3ff75790e1822984cc8 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 27 May 2020 10:26:44 -0700 Subject: [PATCH 021/189] Simplify control-flow --- Python/compile.c | 73 ++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 248a52f1cc69f5..ede1e662867d1e 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2761,12 +2761,9 @@ compiler_pattern_name_store(struct compiler *c, expr_ty p) } static int -compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) +compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) { - // TODO: This inital implementation keeps things simple(-ish), but creates a - // TON of blocks and zero-length jumps, especially for sequences. Simplify? - // The zero-length jumps can probably be peep-holed. - basicblock *sub_no, *sub_yes; + basicblock *sub_yes, *sub_no; Py_ssize_t i, size, star; asdl_seq *elts; expr_ty elt; @@ -2774,11 +2771,7 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) // Atomic patterns: case Name_kind: if (p->v.Name.ctx == Store) { - if (!compiler_pattern_name_store(c, p)) { - return 0; - } - ADDOP_JREL(c, JUMP_FORWARD, yes); - return 1; + return compiler_pattern_name_store(c, p); } assert(p->v.Name.ctx == Load); // Fall through... @@ -2788,33 +2781,27 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) case Constant_kind: VISIT(c, expr, p); ADDOP_COMPARE(c, Eq); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, no); - ADDOP_JREL(c, JUMP_FORWARD, yes); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, fail); return 1; // Nested patterns: case BinOp_kind: assert(p->v.BinOp.op == BitOr); - ADDOP(c, DUP_TOP); sub_yes = compiler_new_block(c); sub_no = compiler_new_block(c); - if (!compiler_pattern(c, p->v.BinOp.left, sub_yes, sub_no)) { + ADDOP(c, DUP_TOP); + if (!compiler_pattern(c, p->v.BinOp.left, sub_no)) { return 0; } + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, sub_yes); compiler_use_next_block(c, sub_no); - if (!compiler_pattern(c, p->v.BinOp.right, yes, no)) { + if (!compiler_pattern(c, p->v.BinOp.right, fail)) { return 0; } compiler_use_next_block(c, sub_yes); - ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, yes); return 1; case List_kind: case Tuple_kind: - // TODO: Need to add a MATCH_SEQ that handles checking for - // Sequence (but not str, bytes, bytearray), and popping/jumping to - // "no" on failure: - ADDOP(c, GET_ITER); - sub_no = compiler_new_block(c); elts = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; size = asdl_seq_LEN(elts); star = -1; @@ -2837,8 +2824,13 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) } star = i; } + sub_yes = compiler_new_block(c); + sub_no = compiler_new_block(c); + // TODO: Need to add a GET_MATCH_ITER that handles checking for + // Sequence (but not str, bytes, bytearray), and popping/jumping to + // "fail" on failure: + ADDOP(c, GET_ITER); for (i = 0; i < size; i++) { - sub_yes = compiler_new_block(c); elt = asdl_seq_GET(elts, i); if (i == star) { assert(elt->kind == Starred_kind); @@ -2848,38 +2840,41 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *yes, basicblock *no) } if (size - i - 1) { ADDOP_I(c, BUILD_TUPLE, size - i - 1); - ADDOP(c, GET_ITER); + ADDOP(c, GET_ITER); // TODO: GET_MATCH_ITER + } + else { + ADDOP_JREL(c, JUMP_FORWARD, sub_yes); } } else { - ADDOP_JREL(c, FOR_ITER, no); - if (!compiler_pattern(c, elt, sub_yes, sub_no)) { + ADDOP_JREL(c, FOR_ITER, fail); + if (!compiler_pattern(c, elt, sub_no)) { return 0; } } - compiler_use_next_block(c, sub_yes); } - ADDOP_JREL(c, FOR_ITER, yes); - ADDOP(c, POP_TOP); + // TODO: This could be simplified with VM support too. Pop top, and + // jump to "fail" if items remain. JUMP_IF_NOT_EMPTY? + ADDOP_JREL(c, FOR_ITER, sub_yes); ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, no); compiler_use_next_block(c, sub_no); ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, no); + ADDOP_JREL(c, JUMP_FORWARD, fail); + compiler_use_next_block(c, sub_yes); return 1; case NamedExpr_kind: - ADDOP(c, DUP_TOP); sub_yes = compiler_new_block(c); sub_no = compiler_new_block(c); - if (!compiler_pattern(c, p->v.NamedExpr.value, sub_yes, sub_no)) { + ADDOP(c, DUP_TOP); + if (!compiler_pattern(c, p->v.NamedExpr.value, sub_no)) { return 0; } - compiler_use_next_block(c, sub_yes); VISIT(c, expr, p->v.NamedExpr.target); - ADDOP_JREL(c, JUMP_FORWARD, yes); + ADDOP_JREL(c, JUMP_FORWARD, sub_yes); compiler_use_next_block(c, sub_no); ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, no); + ADDOP_JREL(c, JUMP_FORWARD, fail); + compiler_use_next_block(c, sub_yes); return 1; default: Py_UNREACHABLE(); @@ -2891,15 +2886,13 @@ compiler_match(struct compiler *c, stmt_ty s) { VISIT(c, expr, s->v.Match.target); match_case_ty m; - basicblock *body, *next, *end = compiler_new_block(c); + basicblock *next, *end = compiler_new_block(c); Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); for (Py_ssize_t i = 0; i < cases; i++) { m = asdl_seq_GET(s->v.Match.cases, i); - body = compiler_new_block(c); next = compiler_new_block(c); ADDOP(c, DUP_TOP); - compiler_pattern(c, m->pattern, body, next); - compiler_use_next_block(c, body); + compiler_pattern(c, m->pattern, next); if (m->guard && !compiler_jump_if(c, m->guard, next, 0)) { return 0; } From 34c54a0f1216788f9992f17d1cc41e35b47904be Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 27 May 2020 11:42:31 -0700 Subject: [PATCH 022/189] Rename blocks --- Python/compile.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index ede1e662867d1e..dfde8c4ce72f95 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2763,7 +2763,7 @@ compiler_pattern_name_store(struct compiler *c, expr_ty p) static int compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) { - basicblock *sub_yes, *sub_no; + basicblock *end, *block; Py_ssize_t i, size, star; asdl_seq *elts; expr_ty elt; @@ -2786,19 +2786,19 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) // Nested patterns: case BinOp_kind: assert(p->v.BinOp.op == BitOr); - sub_yes = compiler_new_block(c); - sub_no = compiler_new_block(c); + end = compiler_new_block(c); + block = compiler_new_block(c); ADDOP(c, DUP_TOP); - if (!compiler_pattern(c, p->v.BinOp.left, sub_no)) { + if (!compiler_pattern(c, p->v.BinOp.left, block)) { return 0; } ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, sub_yes); - compiler_use_next_block(c, sub_no); + ADDOP_JREL(c, JUMP_FORWARD, end); + compiler_use_next_block(c, block); if (!compiler_pattern(c, p->v.BinOp.right, fail)) { return 0; } - compiler_use_next_block(c, sub_yes); + compiler_use_next_block(c, end); return 1; case List_kind: case Tuple_kind: @@ -2824,8 +2824,8 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) } star = i; } - sub_yes = compiler_new_block(c); - sub_no = compiler_new_block(c); + end = compiler_new_block(c); + block = compiler_new_block(c); // TODO: Need to add a GET_MATCH_ITER that handles checking for // Sequence (but not str, bytes, bytearray), and popping/jumping to // "fail" on failure: @@ -2843,38 +2843,38 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) ADDOP(c, GET_ITER); // TODO: GET_MATCH_ITER } else { - ADDOP_JREL(c, JUMP_FORWARD, sub_yes); + ADDOP_JREL(c, JUMP_FORWARD, end); } } else { ADDOP_JREL(c, FOR_ITER, fail); - if (!compiler_pattern(c, elt, sub_no)) { + if (!compiler_pattern(c, elt, block)) { return 0; } } } - // TODO: This could be simplified with VM support too. Pop top, and - // jump to "fail" if items remain. JUMP_IF_NOT_EMPTY? - ADDOP_JREL(c, FOR_ITER, sub_yes); + // TODO: This could be simplified with VM support. Pop top, and jump + // to "fail" if items remain. JUMP_IF_NOT_EMPTY? + ADDOP_JREL(c, FOR_ITER, end); ADDOP(c, POP_TOP); - compiler_use_next_block(c, sub_no); + compiler_use_next_block(c, block); ADDOP(c, POP_TOP); ADDOP_JREL(c, JUMP_FORWARD, fail); - compiler_use_next_block(c, sub_yes); + compiler_use_next_block(c, end); return 1; case NamedExpr_kind: - sub_yes = compiler_new_block(c); - sub_no = compiler_new_block(c); + end = compiler_new_block(c); + block = compiler_new_block(c); ADDOP(c, DUP_TOP); - if (!compiler_pattern(c, p->v.NamedExpr.value, sub_no)) { + if (!compiler_pattern(c, p->v.NamedExpr.value, block)) { return 0; } VISIT(c, expr, p->v.NamedExpr.target); - ADDOP_JREL(c, JUMP_FORWARD, sub_yes); - compiler_use_next_block(c, sub_no); + ADDOP_JREL(c, JUMP_FORWARD, end); + compiler_use_next_block(c, block); ADDOP(c, POP_TOP); ADDOP_JREL(c, JUMP_FORWARD, fail); - compiler_use_next_block(c, sub_yes); + compiler_use_next_block(c, end); return 1; default: Py_UNREACHABLE(); From 8bc9ae5d9f6a9364867dea640f0d4679ff328f06 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 27 May 2020 15:57:11 -0700 Subject: [PATCH 023/189] Add GET_MATCH_ITER opcode --- Doc/library/dis.rst | 9 ++ Include/opcode.h | 1 + Lib/importlib/_bootstrap_external.py | 3 +- Lib/opcode.py | 1 + Python/ceval.c | 13 ++ Python/compile.c | 10 +- Python/importlib_external.h | 230 +++++++++++++-------------- Python/opcode_targets.h | 2 +- 8 files changed, 146 insertions(+), 123 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index f871ec4f13def8..a91ae8c7b65fa1 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -990,6 +990,15 @@ All of the following opcodes use their arguments. code counter is incremented by *delta*. +.. opcode:: GET_MATCH_ITER (delta) + + Used for pattern matching. Much like :opcode:`GET_ITER`, but pops TOS and + increments the byte code counter by *delta* if TOS is not a :term:`sequence` + or is an instance of :class:`str`, :class:`bytes`, or :class:`bytearray`. + + .. versionadded:: 3.10 + + .. opcode:: LOAD_GLOBAL (namei) Loads the global named ``co_names[namei]`` onto the stack. diff --git a/Include/opcode.h b/Include/opcode.h index 19944fac0b9f2b..325e61d3f61142 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -127,6 +127,7 @@ extern "C" { #define SET_UPDATE 163 #define DICT_MERGE 164 #define DICT_UPDATE 165 +#define GET_MATCH_ITER 166 /* EXCEPT_HANDLER is a special, implicit block type which is created when entering an except handler. It is not an opcode but we define it here diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 25a3f8c0e09343..959e8ba45f614f 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,6 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) +# Python 3.10a0 3435 (add GET_MATCH_ITER) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -286,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3425).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3435).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index ac1aa535f66ff6..09a1d079be5524 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -213,5 +213,6 @@ def jabs_op(name, op): def_op('SET_UPDATE', 163) def_op('DICT_MERGE', 164) def_op('DICT_UPDATE', 165) +jrel_op('GET_MATCH_ITER', 166) del def_op, name_op, jrel_op, jabs_op diff --git a/Python/ceval.c b/Python/ceval.c index a79773f85118ad..b8df9b3f5040ec 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3284,6 +3284,19 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) #endif } + case TARGET(GET_MATCH_ITER): { + PyObject *target = TOP(); + if (!PySequence_Check(target) + || PyObject_TypeCheck(target, &PyUnicode_Type) + || PyObject_TypeCheck(target, &PyBytes_Type) + || PyObject_TypeCheck(target, &PyByteArray_Type) + ) { + STACK_SHRINK(1); + Py_DECREF(target); + JUMPBY(oparg); + DISPATCH(); + } + } // Fall... case TARGET(GET_ITER): { /* before: [obj]; after [getiter(obj)] */ PyObject *iterable = TOP(); diff --git a/Python/compile.c b/Python/compile.c index dfde8c4ce72f95..a9a8501c4856db 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -980,7 +980,8 @@ stack_effect(int opcode, int oparg, int jump) case FOR_ITER: /* -1 at end of iterator, 1 if continue iterating. */ return jump > 0 ? -1 : 1; - + case GET_MATCH_ITER: + return -(jump > 0); case STORE_ATTR: return -2; case DELETE_ATTR: @@ -2826,10 +2827,7 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) } end = compiler_new_block(c); block = compiler_new_block(c); - // TODO: Need to add a GET_MATCH_ITER that handles checking for - // Sequence (but not str, bytes, bytearray), and popping/jumping to - // "fail" on failure: - ADDOP(c, GET_ITER); + ADDOP_JREL(c, GET_MATCH_ITER, fail); for (i = 0; i < size; i++) { elt = asdl_seq_GET(elts, i); if (i == star) { @@ -2840,7 +2838,7 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) } if (size - i - 1) { ADDOP_I(c, BUILD_TUPLE, size - i - 1); - ADDOP(c, GET_ITER); // TODO: GET_MATCH_ITER + ADDOP_JREL(c, GET_MATCH_ITER, fail); } else { ADDOP_JREL(c, JUMP_FORWARD, end); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index dd237428867ba7..8010e6e269e67b 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,97,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,107,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, @@ -400,7 +400,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 95,102,105,108,101,110,97,109,101,218,8,102,105,108,101,110, 97,109,101,114,5,0,0,0,114,5,0,0,0,114,8,0, 0,0,218,17,99,97,99,104,101,95,102,114,111,109,95,115, - 111,117,114,99,101,45,1,0,0,115,72,0,0,0,0,18, + 111,117,114,99,101,46,1,0,0,115,72,0,0,0,0,18, 8,1,6,1,2,255,4,2,8,1,4,1,8,1,12,1, 10,1,12,1,16,1,8,1,8,1,8,1,24,1,8,1, 12,1,6,2,8,1,8,1,8,1,8,1,14,1,14,1, @@ -481,7 +481,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,101,118,101,108,90,13,98,97,115,101,95,102,105,108,101, 110,97,109,101,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,17,115,111,117,114,99,101,95,102,114,111,109, - 95,99,97,99,104,101,116,1,0,0,115,68,0,0,0,0, + 95,99,97,99,104,101,117,1,0,0,115,68,0,0,0,0, 9,12,1,8,1,10,1,12,1,4,1,10,1,12,1,14, 1,16,1,4,1,4,1,12,1,8,1,2,1,2,255,4, 1,2,255,8,2,10,1,8,1,16,1,10,1,16,1,10, @@ -517,7 +517,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 120,116,101,110,115,105,111,110,218,11,115,111,117,114,99,101, 95,112,97,116,104,114,5,0,0,0,114,5,0,0,0,114, 8,0,0,0,218,15,95,103,101,116,95,115,111,117,114,99, - 101,102,105,108,101,156,1,0,0,115,20,0,0,0,0,7, + 101,102,105,108,101,157,1,0,0,115,20,0,0,0,0,7, 12,1,4,1,16,1,24,1,4,1,2,1,12,1,16,1, 18,1,114,108,0,0,0,99,1,0,0,0,0,0,0,0, 0,0,0,0,1,0,0,0,8,0,0,0,67,0,0,0, @@ -530,7 +530,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 112,108,101,114,101,0,0,0,114,97,0,0,0,114,82,0, 0,0,114,88,0,0,0,41,1,114,96,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,11,95, - 103,101,116,95,99,97,99,104,101,100,175,1,0,0,115,16, + 103,101,116,95,99,97,99,104,101,100,176,1,0,0,115,16, 0,0,0,0,1,14,1,2,1,10,1,12,1,8,1,14, 1,4,2,114,112,0,0,0,99,1,0,0,0,0,0,0, 0,0,0,0,0,2,0,0,0,8,0,0,0,67,0,0, @@ -545,7 +545,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,51,0,0,0,114,50,0,0,0,41,2,114,44,0,0, 0,114,52,0,0,0,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,10,95,99,97,108,99,95,109,111,100, - 101,187,1,0,0,115,12,0,0,0,0,2,2,1,14,1, + 101,188,1,0,0,115,12,0,0,0,0,2,2,1,14,1, 12,1,10,3,8,1,114,114,0,0,0,99,1,0,0,0, 0,0,0,0,0,0,0,0,3,0,0,0,8,0,0,0, 3,0,0,0,115,66,0,0,0,100,6,135,0,102,1,100, @@ -583,7 +583,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,114,103,115,218,6,107,119,97,114,103,115,169,1,218,6, 109,101,116,104,111,100,114,5,0,0,0,114,8,0,0,0, 218,19,95,99,104,101,99,107,95,110,97,109,101,95,119,114, - 97,112,112,101,114,207,1,0,0,115,18,0,0,0,0,1, + 97,112,112,101,114,208,1,0,0,115,18,0,0,0,0,1, 8,1,8,1,10,1,4,1,8,255,2,1,2,255,6,2, 122,40,95,99,104,101,99,107,95,110,97,109,101,46,60,108, 111,99,97,108,115,62,46,95,99,104,101,99,107,95,110,97, @@ -601,7 +601,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 8,95,95,100,105,99,116,95,95,218,6,117,112,100,97,116, 101,41,3,90,3,110,101,119,90,3,111,108,100,114,67,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,5,95,119,114,97,112,218,1,0,0,115,8,0,0, + 0,218,5,95,119,114,97,112,219,1,0,0,115,8,0,0, 0,0,1,8,1,10,1,20,1,122,26,95,99,104,101,99, 107,95,110,97,109,101,46,60,108,111,99,97,108,115,62,46, 95,119,114,97,112,41,1,78,41,3,218,10,95,98,111,111, @@ -609,7 +609,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,69,114,114,111,114,41,3,114,122,0,0,0,114,123,0, 0,0,114,133,0,0,0,114,5,0,0,0,114,121,0,0, 0,114,8,0,0,0,218,11,95,99,104,101,99,107,95,110, - 97,109,101,199,1,0,0,115,14,0,0,0,0,8,14,7, + 97,109,101,200,1,0,0,115,14,0,0,0,0,8,14,7, 2,1,10,1,12,2,14,5,10,1,114,136,0,0,0,99, 2,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0, 6,0,0,0,67,0,0,0,115,60,0,0,0,124,0,160, @@ -637,7 +637,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 6,108,111,97,100,101,114,218,8,112,111,114,116,105,111,110, 115,218,3,109,115,103,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,17,95,102,105,110,100,95,109,111,100, - 117,108,101,95,115,104,105,109,227,1,0,0,115,10,0,0, + 117,108,101,95,115,104,105,109,228,1,0,0,115,10,0,0, 0,0,10,14,1,16,1,4,1,22,1,114,143,0,0,0, 99,3,0,0,0,0,0,0,0,0,0,0,0,6,0,0, 0,4,0,0,0,67,0,0,0,115,166,0,0,0,124,0, @@ -704,7 +704,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,120,99,95,100,101,116,97,105,108,115,90,5,109,97,103, 105,99,114,92,0,0,0,114,2,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,13,95,99,108, - 97,115,115,105,102,121,95,112,121,99,244,1,0,0,115,28, + 97,115,115,105,102,121,95,112,121,99,245,1,0,0,115,28, 0,0,0,0,16,12,1,8,1,16,1,12,1,16,1,12, 1,10,1,12,1,8,1,16,2,8,1,16,1,16,1,114, 152,0,0,0,99,5,0,0,0,0,0,0,0,0,0,0, @@ -759,7 +759,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 122,101,114,116,0,0,0,114,151,0,0,0,114,92,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, 218,23,95,118,97,108,105,100,97,116,101,95,116,105,109,101, - 115,116,97,109,112,95,112,121,99,21,2,0,0,115,16,0, + 115,116,97,109,112,95,112,121,99,22,2,0,0,115,16,0, 0,0,0,19,24,1,10,1,12,1,16,1,8,1,22,255, 2,2,114,156,0,0,0,99,4,0,0,0,0,0,0,0, 0,0,0,0,4,0,0,0,4,0,0,0,67,0,0,0, @@ -805,7 +805,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,218,11,115,111,117,114,99,101,95,104,97,115,104,114, 116,0,0,0,114,151,0,0,0,114,5,0,0,0,114,5, 0,0,0,114,8,0,0,0,218,18,95,118,97,108,105,100, - 97,116,101,95,104,97,115,104,95,112,121,99,49,2,0,0, + 97,116,101,95,104,97,115,104,95,112,121,99,50,2,0,0, 115,12,0,0,0,0,17,16,1,2,1,8,255,4,2,2, 254,114,158,0,0,0,99,4,0,0,0,0,0,0,0,0, 0,0,0,5,0,0,0,5,0,0,0,67,0,0,0,115, @@ -829,7 +829,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,26,0,0,0,114,116,0,0,0,114,106,0,0,0,114, 107,0,0,0,218,4,99,111,100,101,114,5,0,0,0,114, 5,0,0,0,114,8,0,0,0,218,17,95,99,111,109,112, - 105,108,101,95,98,121,116,101,99,111,100,101,73,2,0,0, + 105,108,101,95,98,121,116,101,99,111,100,101,74,2,0,0, 115,18,0,0,0,0,2,10,1,10,1,12,1,8,1,12, 1,4,2,10,1,4,255,114,165,0,0,0,114,73,0,0, 0,99,3,0,0,0,0,0,0,0,0,0,0,0,4,0, @@ -848,7 +848,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,101,114,155,0,0,0,114,26,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,22,95,99,111, 100,101,95,116,111,95,116,105,109,101,115,116,97,109,112,95, - 112,121,99,86,2,0,0,115,12,0,0,0,0,2,8,1, + 112,121,99,87,2,0,0,115,12,0,0,0,0,2,8,1, 14,1,14,1,14,1,16,1,114,170,0,0,0,84,99,3, 0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,5, 0,0,0,67,0,0,0,115,80,0,0,0,116,0,116,1, @@ -866,7 +866,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,90,7,99,104,101,99,107,101,100,114,26,0,0,0,114, 2,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,17,95,99,111,100,101,95,116,111,95,104,97, - 115,104,95,112,121,99,96,2,0,0,115,14,0,0,0,0, + 115,104,95,112,121,99,97,2,0,0,115,14,0,0,0,0, 2,8,1,12,1,14,1,16,1,10,1,16,1,114,171,0, 0,0,99,1,0,0,0,0,0,0,0,0,0,0,0,5, 0,0,0,6,0,0,0,67,0,0,0,115,62,0,0,0, @@ -893,7 +893,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,100,108,105,110,101,218,8,101,110,99,111,100,105,110,103, 90,15,110,101,119,108,105,110,101,95,100,101,99,111,100,101, 114,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, - 218,13,100,101,99,111,100,101,95,115,111,117,114,99,101,107, + 218,13,100,101,99,111,100,101,95,115,111,117,114,99,101,108, 2,0,0,115,10,0,0,0,0,5,8,1,12,1,10,1, 12,1,114,176,0,0,0,169,2,114,140,0,0,0,218,26, 115,117,98,109,111,100,117,108,101,95,115,101,97,114,99,104, @@ -955,7 +955,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,182,0,0,0,90,7,100,105,114,110,97,109,101,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,23,115, 112,101,99,95,102,114,111,109,95,102,105,108,101,95,108,111, - 99,97,116,105,111,110,124,2,0,0,115,62,0,0,0,0, + 99,97,116,105,111,110,125,2,0,0,115,62,0,0,0,0, 12,8,4,4,1,10,2,2,1,14,1,12,1,8,2,10, 8,16,1,6,3,8,1,14,1,14,1,10,1,6,1,6, 2,4,3,8,2,10,1,2,1,14,1,12,1,6,2,4, @@ -992,7 +992,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 72,75,69,89,95,76,79,67,65,76,95,77,65,67,72,73, 78,69,41,2,218,3,99,108,115,114,7,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,14,95, - 111,112,101,110,95,114,101,103,105,115,116,114,121,204,2,0, + 111,112,101,110,95,114,101,103,105,115,116,114,121,205,2,0, 0,115,8,0,0,0,0,2,2,1,16,1,12,1,122,36, 87,105,110,100,111,119,115,82,101,103,105,115,116,114,121,70, 105,110,100,101,114,46,95,111,112,101,110,95,114,101,103,105, @@ -1020,7 +1020,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,90,4,104,107,101,121,218,8,102,105,108,101,112,97,116, 104,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, 218,16,95,115,101,97,114,99,104,95,114,101,103,105,115,116, - 114,121,211,2,0,0,115,24,0,0,0,0,2,6,1,8, + 114,121,212,2,0,0,115,24,0,0,0,0,2,6,1,8, 2,6,1,6,1,16,255,6,2,2,1,12,1,46,1,12, 1,8,1,122,38,87,105,110,100,111,119,115,82,101,103,105, 115,116,114,121,70,105,110,100,101,114,46,95,115,101,97,114, @@ -1042,7 +1042,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,218,6,116,97,114,103,101,116,114,199,0,0,0,114, 140,0,0,0,114,189,0,0,0,114,187,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,9,102, - 105,110,100,95,115,112,101,99,226,2,0,0,115,28,0,0, + 105,110,100,95,115,112,101,99,227,2,0,0,115,28,0,0, 0,0,2,10,1,8,1,4,1,2,1,12,1,12,1,8, 1,14,1,14,1,6,1,8,1,2,254,6,3,122,31,87, 105,110,100,111,119,115,82,101,103,105,115,116,114,121,70,105, @@ -1061,7 +1061,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 2,114,203,0,0,0,114,140,0,0,0,169,4,114,193,0, 0,0,114,139,0,0,0,114,44,0,0,0,114,187,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, - 218,11,102,105,110,100,95,109,111,100,117,108,101,242,2,0, + 218,11,102,105,110,100,95,109,111,100,117,108,101,243,2,0, 0,115,8,0,0,0,0,7,12,1,8,1,6,2,122,33, 87,105,110,100,111,119,115,82,101,103,105,115,116,114,121,70, 105,110,100,101,114,46,102,105,110,100,95,109,111,100,117,108, @@ -1071,7 +1071,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,97,115,115,109,101,116,104,111,100,114,194,0,0,0,114, 200,0,0,0,114,203,0,0,0,114,206,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,114,191,0,0,0,192,2,0,0,115,28,0,0,0, + 0,0,114,191,0,0,0,193,2,0,0,115,28,0,0,0, 8,2,4,3,2,255,2,4,2,255,2,3,4,2,2,1, 10,6,2,1,10,14,2,1,12,15,2,1,114,191,0,0, 0,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -1107,7 +1107,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 139,0,0,0,114,96,0,0,0,90,13,102,105,108,101,110, 97,109,101,95,98,97,115,101,90,9,116,97,105,108,95,110, 97,109,101,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,114,182,0,0,0,5,3,0,0,115,8,0,0,0, + 0,0,114,182,0,0,0,6,3,0,0,115,8,0,0,0, 0,3,18,1,16,1,14,1,122,24,95,76,111,97,100,101, 114,66,97,115,105,99,115,46,105,115,95,112,97,99,107,97, 103,101,99,2,0,0,0,0,0,0,0,0,0,0,0,2, @@ -1118,7 +1118,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 110,46,78,114,5,0,0,0,169,2,114,118,0,0,0,114, 187,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,13,99,114,101,97,116,101,95,109,111,100,117, - 108,101,13,3,0,0,115,2,0,0,0,0,1,122,27,95, + 108,101,14,3,0,0,115,2,0,0,0,0,1,122,27,95, 76,111,97,100,101,114,66,97,115,105,99,115,46,99,114,101, 97,116,101,95,109,111,100,117,108,101,99,2,0,0,0,0, 0,0,0,0,0,0,0,3,0,0,0,5,0,0,0,67, @@ -1138,7 +1138,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 131,0,0,0,41,3,114,118,0,0,0,218,6,109,111,100, 117,108,101,114,164,0,0,0,114,5,0,0,0,114,5,0, 0,0,114,8,0,0,0,218,11,101,120,101,99,95,109,111, - 100,117,108,101,16,3,0,0,115,12,0,0,0,0,2,12, + 100,117,108,101,17,3,0,0,115,12,0,0,0,0,2,12, 1,8,1,6,1,4,255,6,2,122,25,95,76,111,97,100, 101,114,66,97,115,105,99,115,46,101,120,101,99,95,109,111, 100,117,108,101,99,2,0,0,0,0,0,0,0,0,0,0, @@ -1149,14 +1149,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,218,17,95,108,111,97,100,95,109,111,100,117,108, 101,95,115,104,105,109,169,2,114,118,0,0,0,114,139,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,11,108,111,97,100,95,109,111,100,117,108,101,24,3, + 0,218,11,108,111,97,100,95,109,111,100,117,108,101,25,3, 0,0,115,2,0,0,0,0,2,122,25,95,76,111,97,100, 101,114,66,97,115,105,99,115,46,108,111,97,100,95,109,111, 100,117,108,101,78,41,8,114,125,0,0,0,114,124,0,0, 0,114,126,0,0,0,114,127,0,0,0,114,182,0,0,0, 114,212,0,0,0,114,217,0,0,0,114,220,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8, - 0,0,0,114,208,0,0,0,0,3,0,0,115,10,0,0, + 0,0,0,114,208,0,0,0,1,3,0,0,115,10,0,0, 0,8,2,4,3,8,8,8,3,8,8,114,208,0,0,0, 99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,3,0,0,0,64,0,0,0,115,74,0,0,0,101,0, @@ -1181,7 +1181,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,32,32,32,32,32,32,78,41,1,114,50,0,0,0,169, 2,114,118,0,0,0,114,44,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,8,0,0,0,218,10,112,97,116,104, - 95,109,116,105,109,101,31,3,0,0,115,2,0,0,0,0, + 95,109,116,105,109,101,32,3,0,0,115,2,0,0,0,0, 6,122,23,83,111,117,114,99,101,76,111,97,100,101,114,46, 112,97,116,104,95,109,116,105,109,101,99,2,0,0,0,0, 0,0,0,0,0,0,0,2,0,0,0,4,0,0,0,67, @@ -1215,7 +1215,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,46,10,32,32,32,32,32,32,32,32,114,169,0,0,0, 41,1,114,223,0,0,0,114,222,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,10,112,97,116, - 104,95,115,116,97,116,115,39,3,0,0,115,2,0,0,0, + 104,95,115,116,97,116,115,40,3,0,0,115,2,0,0,0, 0,12,122,23,83,111,117,114,99,101,76,111,97,100,101,114, 46,112,97,116,104,95,115,116,97,116,115,99,4,0,0,0, 0,0,0,0,0,0,0,0,4,0,0,0,4,0,0,0, @@ -1239,7 +1239,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,107,0,0,0,90,10,99,97,99,104,101,95,112,97,116, 104,114,26,0,0,0,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,15,95,99,97,99,104,101,95,98,121, - 116,101,99,111,100,101,53,3,0,0,115,2,0,0,0,0, + 116,101,99,111,100,101,54,3,0,0,115,2,0,0,0,0, 8,122,28,83,111,117,114,99,101,76,111,97,100,101,114,46, 95,99,97,99,104,101,95,98,121,116,101,99,111,100,101,99, 3,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0, @@ -1256,7 +1256,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 115,46,10,32,32,32,32,32,32,32,32,78,114,5,0,0, 0,41,3,114,118,0,0,0,114,44,0,0,0,114,26,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,225,0,0,0,63,3,0,0,115,2,0,0,0,0, + 0,114,225,0,0,0,64,3,0,0,115,2,0,0,0,0, 1,122,21,83,111,117,114,99,101,76,111,97,100,101,114,46, 115,101,116,95,100,97,116,97,99,2,0,0,0,0,0,0, 0,0,0,0,0,5,0,0,0,10,0,0,0,67,0,0, @@ -1277,7 +1277,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,41,5,114,118,0,0,0,114,139,0,0,0,114,44,0, 0,0,114,174,0,0,0,218,3,101,120,99,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,10,103,101,116, - 95,115,111,117,114,99,101,70,3,0,0,115,20,0,0,0, + 95,115,111,117,114,99,101,71,3,0,0,115,20,0,0,0, 0,2,10,1,2,1,14,1,14,1,4,1,2,255,4,1, 2,255,24,2,122,23,83,111,117,114,99,101,76,111,97,100, 101,114,46,103,101,116,95,115,111,117,114,99,101,114,104,0, @@ -1299,7 +1299,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 218,7,99,111,109,112,105,108,101,41,4,114,118,0,0,0, 114,26,0,0,0,114,44,0,0,0,114,230,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,14, - 115,111,117,114,99,101,95,116,111,95,99,111,100,101,80,3, + 115,111,117,114,99,101,95,116,111,95,99,111,100,101,81,3, 0,0,115,6,0,0,0,0,5,12,1,4,255,122,27,83, 111,117,114,99,101,76,111,97,100,101,114,46,115,111,117,114, 99,101,95,116,111,95,99,111,100,101,99,2,0,0,0,0, @@ -1376,7 +1376,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,26,0,0,0,114,151,0,0,0,114,2,0,0,0,90, 10,98,121,116,101,115,95,100,97,116,97,90,11,99,111,100, 101,95,111,98,106,101,99,116,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,213,0,0,0,88,3,0,0, + 0,0,114,8,0,0,0,114,213,0,0,0,89,3,0,0, 115,152,0,0,0,0,7,10,1,4,1,4,1,4,1,4, 1,4,1,2,1,12,1,12,1,12,2,2,1,14,1,12, 1,8,2,12,1,2,1,14,1,12,1,6,3,2,1,2, @@ -1393,7 +1393,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,226,0,0,0,114,225,0,0,0,114,229,0,0,0,114, 233,0,0,0,114,213,0,0,0,114,5,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,221,0, - 0,0,29,3,0,0,115,14,0,0,0,8,2,8,8,8, + 0,0,30,3,0,0,115,14,0,0,0,8,2,8,8,8, 14,8,10,8,7,8,10,14,8,114,221,0,0,0,99,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4, 0,0,0,0,0,0,0,115,124,0,0,0,101,0,90,1, @@ -1422,7 +1422,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,32,32,32,32,102,105,110,100,101,114,46,78,114,159,0, 0,0,41,3,114,118,0,0,0,114,139,0,0,0,114,44, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,114,209,0,0,0,178,3,0,0,115,4,0,0,0, + 0,0,114,209,0,0,0,179,3,0,0,115,4,0,0,0, 0,3,6,1,122,19,70,105,108,101,76,111,97,100,101,114, 46,95,95,105,110,105,116,95,95,99,2,0,0,0,0,0, 0,0,0,0,0,0,2,0,0,0,2,0,0,0,67,0, @@ -1431,7 +1431,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,0,0,0,169,2,218,9,95,95,99,108,97,115,115,95, 95,114,131,0,0,0,169,2,114,118,0,0,0,90,5,111, 116,104,101,114,114,5,0,0,0,114,5,0,0,0,114,8, - 0,0,0,218,6,95,95,101,113,95,95,184,3,0,0,115, + 0,0,0,218,6,95,95,101,113,95,95,185,3,0,0,115, 6,0,0,0,0,1,12,1,10,255,122,17,70,105,108,101, 76,111,97,100,101,114,46,95,95,101,113,95,95,99,1,0, 0,0,0,0,0,0,0,0,0,0,1,0,0,0,3,0, @@ -1440,7 +1440,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,0,0,0,169,3,218,4,104,97,115,104,114,116,0,0, 0,114,44,0,0,0,169,1,114,118,0,0,0,114,5,0, 0,0,114,5,0,0,0,114,8,0,0,0,218,8,95,95, - 104,97,115,104,95,95,188,3,0,0,115,2,0,0,0,0, + 104,97,115,104,95,95,189,3,0,0,115,2,0,0,0,0, 1,122,19,70,105,108,101,76,111,97,100,101,114,46,95,95, 104,97,115,104,95,95,99,2,0,0,0,0,0,0,0,0, 0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,115, @@ -1454,7 +1454,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,46,10,10,32,32,32,32,32,32,32,32,41,3,218,5, 115,117,112,101,114,114,239,0,0,0,114,220,0,0,0,114, 219,0,0,0,169,1,114,241,0,0,0,114,5,0,0,0, - 114,8,0,0,0,114,220,0,0,0,191,3,0,0,115,2, + 114,8,0,0,0,114,220,0,0,0,192,3,0,0,115,2, 0,0,0,0,10,122,22,70,105,108,101,76,111,97,100,101, 114,46,108,111,97,100,95,109,111,100,117,108,101,99,2,0, 0,0,0,0,0,0,0,0,0,0,2,0,0,0,1,0, @@ -1464,7 +1464,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 99,101,32,102,105,108,101,32,97,115,32,102,111,117,110,100, 32,98,121,32,116,104,101,32,102,105,110,100,101,114,46,114, 48,0,0,0,114,219,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,179,0,0,0,203,3,0, + 0,0,0,114,8,0,0,0,114,179,0,0,0,204,3,0, 0,115,2,0,0,0,0,3,122,23,70,105,108,101,76,111, 97,100,101,114,46,103,101,116,95,102,105,108,101,110,97,109, 101,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0, @@ -1486,7 +1486,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,90,4,114,101,97,100,114,65,0,0,0,41,3,114, 118,0,0,0,114,44,0,0,0,114,68,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,227,0, - 0,0,208,3,0,0,115,10,0,0,0,0,2,14,1,16, + 0,0,209,3,0,0,115,10,0,0,0,0,2,14,1,16, 1,40,2,14,1,122,19,70,105,108,101,76,111,97,100,101, 114,46,103,101,116,95,100,97,116,97,99,2,0,0,0,0, 0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,67, @@ -1495,7 +1495,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,114,182,0,0,0,169,2,114,118,0,0,0,114,216,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, 0,218,19,103,101,116,95,114,101,115,111,117,114,99,101,95, - 114,101,97,100,101,114,219,3,0,0,115,6,0,0,0,0, + 114,101,97,100,101,114,220,3,0,0,115,6,0,0,0,0, 2,10,1,4,1,122,30,70,105,108,101,76,111,97,100,101, 114,46,103,101,116,95,114,101,115,111,117,114,99,101,95,114, 101,97,100,101,114,99,2,0,0,0,0,0,0,0,0,0, @@ -1507,7 +1507,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,64,0,0,0,114,65,0,0,0,169,3,114,118,0, 0,0,90,8,114,101,115,111,117,114,99,101,114,44,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, - 218,13,111,112,101,110,95,114,101,115,111,117,114,99,101,225, + 218,13,111,112,101,110,95,114,101,115,111,117,114,99,101,226, 3,0,0,115,4,0,0,0,0,1,20,1,122,24,70,105, 108,101,76,111,97,100,101,114,46,111,112,101,110,95,114,101, 115,111,117,114,99,101,99,2,0,0,0,0,0,0,0,0, @@ -1520,7 +1520,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,114,111,114,114,38,0,0,0,114,47,0,0,0,114,44, 0,0,0,114,255,0,0,0,114,5,0,0,0,114,5,0, 0,0,114,8,0,0,0,218,13,114,101,115,111,117,114,99, - 101,95,112,97,116,104,229,3,0,0,115,8,0,0,0,0, + 101,95,112,97,116,104,230,3,0,0,115,8,0,0,0,0, 1,10,1,4,1,20,1,122,24,70,105,108,101,76,111,97, 100,101,114,46,114,101,115,111,117,114,99,101,95,112,97,116, 104,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0, @@ -1532,7 +1532,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,44,0,0,0,114,54,0,0,0,169,3,114,118,0, 0,0,114,116,0,0,0,114,44,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,2,1,0,0, - 235,3,0,0,115,8,0,0,0,0,1,8,1,4,1,20, + 236,3,0,0,115,8,0,0,0,0,1,8,1,4,1,20, 1,122,22,70,105,108,101,76,111,97,100,101,114,46,105,115, 95,114,101,115,111,117,114,99,101,99,1,0,0,0,0,0, 0,0,0,0,0,0,1,0,0,0,5,0,0,0,67,0, @@ -1542,7 +1542,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,218,7,108,105,115,116,100,105,114,114,47,0,0,0,114, 44,0,0,0,114,246,0,0,0,114,5,0,0,0,114,5, 0,0,0,114,8,0,0,0,218,8,99,111,110,116,101,110, - 116,115,241,3,0,0,115,2,0,0,0,0,1,122,19,70, + 116,115,242,3,0,0,115,2,0,0,0,0,1,122,19,70, 105,108,101,76,111,97,100,101,114,46,99,111,110,116,101,110, 116,115,41,17,114,125,0,0,0,114,124,0,0,0,114,126, 0,0,0,114,127,0,0,0,114,209,0,0,0,114,243,0, @@ -1551,7 +1551,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,0,1,0,0,114,4,1,0,0,114,2,1,0,0,114, 8,1,0,0,90,13,95,95,99,108,97,115,115,99,101,108, 108,95,95,114,5,0,0,0,114,5,0,0,0,114,249,0, - 0,0,114,8,0,0,0,114,239,0,0,0,173,3,0,0, + 0,0,114,8,0,0,0,114,239,0,0,0,174,3,0,0, 115,30,0,0,0,8,2,4,3,8,6,8,4,8,3,2, 1,14,11,2,1,10,4,8,11,2,1,10,5,8,4,8, 6,8,6,114,239,0,0,0,99,0,0,0,0,0,0,0, @@ -1574,7 +1574,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 49,0,0,0,218,8,115,116,95,109,116,105,109,101,90,7, 115,116,95,115,105,122,101,41,3,114,118,0,0,0,114,44, 0,0,0,114,238,0,0,0,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,224,0,0,0,249,3,0,0, + 0,0,114,8,0,0,0,114,224,0,0,0,250,3,0,0, 115,4,0,0,0,0,2,8,1,122,27,83,111,117,114,99, 101,70,105,108,101,76,111,97,100,101,114,46,112,97,116,104, 95,115,116,97,116,115,99,4,0,0,0,0,0,0,0,0, @@ -1585,7 +1585,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 225,0,0,0,41,5,114,118,0,0,0,114,107,0,0,0, 114,106,0,0,0,114,26,0,0,0,114,52,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,226, - 0,0,0,254,3,0,0,115,4,0,0,0,0,2,8,1, + 0,0,0,255,3,0,0,115,4,0,0,0,0,2,8,1, 122,32,83,111,117,114,99,101,70,105,108,101,76,111,97,100, 101,114,46,95,99,97,99,104,101,95,98,121,116,101,99,111, 100,101,114,60,0,0,0,114,11,1,0,0,99,3,0,0, @@ -1620,7 +1620,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,0,0,218,6,112,97,114,101,110,116,114,96,0,0,0, 114,37,0,0,0,114,33,0,0,0,114,228,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,225, - 0,0,0,3,4,0,0,115,46,0,0,0,0,2,12,1, + 0,0,0,4,4,0,0,115,46,0,0,0,0,2,12,1, 4,2,12,1,12,1,12,2,12,1,10,1,2,1,14,1, 12,2,8,1,14,3,6,1,4,255,4,2,28,1,2,1, 12,1,16,1,16,2,8,1,2,255,122,25,83,111,117,114, @@ -1629,7 +1629,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,114,126,0,0,0,114,127,0,0,0,114,224,0,0, 0,114,226,0,0,0,114,225,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 9,1,0,0,245,3,0,0,115,8,0,0,0,8,2,4, + 9,1,0,0,246,3,0,0,115,8,0,0,0,8,2,4, 2,8,5,8,5,114,9,1,0,0,99,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,64, 0,0,0,115,32,0,0,0,101,0,90,1,100,0,90,2, @@ -1651,7 +1651,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,235,0,0,0,41,5,114,118,0,0,0,114,139,0,0, 0,114,44,0,0,0,114,26,0,0,0,114,151,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 213,0,0,0,38,4,0,0,115,22,0,0,0,0,1,10, + 213,0,0,0,39,4,0,0,115,22,0,0,0,0,1,10, 1,10,4,2,1,2,254,6,4,12,1,2,1,14,1,2, 1,2,253,122,29,83,111,117,114,99,101,108,101,115,115,70, 105,108,101,76,111,97,100,101,114,46,103,101,116,95,99,111, @@ -1661,14 +1661,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 111,110,101,32,97,115,32,116,104,101,114,101,32,105,115,32, 110,111,32,115,111,117,114,99,101,32,99,111,100,101,46,78, 114,5,0,0,0,114,219,0,0,0,114,5,0,0,0,114, - 5,0,0,0,114,8,0,0,0,114,229,0,0,0,54,4, + 5,0,0,0,114,8,0,0,0,114,229,0,0,0,55,4, 0,0,115,2,0,0,0,0,2,122,31,83,111,117,114,99, 101,108,101,115,115,70,105,108,101,76,111,97,100,101,114,46, 103,101,116,95,115,111,117,114,99,101,78,41,6,114,125,0, 0,0,114,124,0,0,0,114,126,0,0,0,114,127,0,0, 0,114,213,0,0,0,114,229,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 15,1,0,0,34,4,0,0,115,6,0,0,0,8,2,4, + 15,1,0,0,35,4,0,0,115,6,0,0,0,8,2,4, 2,8,16,114,15,1,0,0,99,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,3,0,0,0,64,0,0, 0,115,92,0,0,0,101,0,90,1,100,0,90,2,100,1, @@ -1688,7 +1688,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,115,16,0,0,0,124,1,124,0,95,0,124,2,124,0, 95,1,100,0,83,0,114,109,0,0,0,114,159,0,0,0, 114,5,1,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,209,0,0,0,71,4,0,0,115,4,0, + 8,0,0,0,114,209,0,0,0,72,4,0,0,115,4,0, 0,0,0,1,6,1,122,28,69,120,116,101,110,115,105,111, 110,70,105,108,101,76,111,97,100,101,114,46,95,95,105,110, 105,116,95,95,99,2,0,0,0,0,0,0,0,0,0,0, @@ -1696,7 +1696,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,124,0,106,0,124,1,106,0,107,2,111,22,124,0, 106,1,124,1,106,1,107,2,83,0,114,109,0,0,0,114, 240,0,0,0,114,242,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,243,0,0,0,75,4,0, + 0,0,0,114,8,0,0,0,114,243,0,0,0,76,4,0, 0,115,6,0,0,0,0,1,12,1,10,255,122,26,69,120, 116,101,110,115,105,111,110,70,105,108,101,76,111,97,100,101, 114,46,95,95,101,113,95,95,99,1,0,0,0,0,0,0, @@ -1704,7 +1704,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,115,20,0,0,0,116,0,124,0,106,1,131,1,116,0, 124,0,106,2,131,1,65,0,83,0,114,109,0,0,0,114, 244,0,0,0,114,246,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,247,0,0,0,79,4,0, + 0,0,0,114,8,0,0,0,114,247,0,0,0,80,4,0, 0,115,2,0,0,0,0,1,122,28,69,120,116,101,110,115, 105,111,110,70,105,108,101,76,111,97,100,101,114,46,95,95, 104,97,115,104,95,95,99,2,0,0,0,0,0,0,0,0, @@ -1721,7 +1721,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,116,101,95,100,121,110,97,109,105,99,114,149,0,0,0, 114,116,0,0,0,114,44,0,0,0,41,3,114,118,0,0, 0,114,187,0,0,0,114,216,0,0,0,114,5,0,0,0, - 114,5,0,0,0,114,8,0,0,0,114,212,0,0,0,82, + 114,5,0,0,0,114,8,0,0,0,114,212,0,0,0,83, 4,0,0,115,14,0,0,0,0,2,4,1,6,255,4,2, 6,1,8,255,4,2,122,33,69,120,116,101,110,115,105,111, 110,70,105,108,101,76,111,97,100,101,114,46,99,114,101,97, @@ -1738,7 +1738,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 214,0,0,0,114,163,0,0,0,90,12,101,120,101,99,95, 100,121,110,97,109,105,99,114,149,0,0,0,114,116,0,0, 0,114,44,0,0,0,114,253,0,0,0,114,5,0,0,0, - 114,5,0,0,0,114,8,0,0,0,114,217,0,0,0,90, + 114,5,0,0,0,114,8,0,0,0,114,217,0,0,0,91, 4,0,0,115,8,0,0,0,0,2,14,1,6,1,8,255, 122,31,69,120,116,101,110,115,105,111,110,70,105,108,101,76, 111,97,100,101,114,46,101,120,101,99,95,109,111,100,117,108, @@ -1757,7 +1757,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,169,2,114,32,0,0,0,218,6,115,117,102,102,105, 120,169,1,90,9,102,105,108,101,95,110,97,109,101,114,5, 0,0,0,114,8,0,0,0,218,9,60,103,101,110,101,120, - 112,114,62,99,4,0,0,115,4,0,0,0,4,1,2,255, + 112,114,62,100,4,0,0,115,4,0,0,0,4,1,2,255, 122,49,69,120,116,101,110,115,105,111,110,70,105,108,101,76, 111,97,100,101,114,46,105,115,95,112,97,99,107,97,103,101, 46,60,108,111,99,97,108,115,62,46,60,103,101,110,101,120, @@ -1765,7 +1765,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 3,97,110,121,218,18,69,88,84,69,78,83,73,79,78,95, 83,85,70,70,73,88,69,83,114,219,0,0,0,114,5,0, 0,0,114,18,1,0,0,114,8,0,0,0,114,182,0,0, - 0,96,4,0,0,115,8,0,0,0,0,2,14,1,12,1, + 0,97,4,0,0,115,8,0,0,0,0,2,14,1,12,1, 2,255,122,30,69,120,116,101,110,115,105,111,110,70,105,108, 101,76,111,97,100,101,114,46,105,115,95,112,97,99,107,97, 103,101,99,2,0,0,0,0,0,0,0,0,0,0,0,2, @@ -1776,7 +1776,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 116,32,99,114,101,97,116,101,32,97,32,99,111,100,101,32, 111,98,106,101,99,116,46,78,114,5,0,0,0,114,219,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,213,0,0,0,102,4,0,0,115,2,0,0,0,0, + 0,114,213,0,0,0,103,4,0,0,115,2,0,0,0,0, 2,122,28,69,120,116,101,110,115,105,111,110,70,105,108,101, 76,111,97,100,101,114,46,103,101,116,95,99,111,100,101,99, 2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0, @@ -1786,14 +1786,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,117,108,101,115,32,104,97,118,101,32,110,111,32,115,111, 117,114,99,101,32,99,111,100,101,46,78,114,5,0,0,0, 114,219,0,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,229,0,0,0,106,4,0,0,115,2,0, + 8,0,0,0,114,229,0,0,0,107,4,0,0,115,2,0, 0,0,0,2,122,30,69,120,116,101,110,115,105,111,110,70, 105,108,101,76,111,97,100,101,114,46,103,101,116,95,115,111, 117,114,99,101,99,2,0,0,0,0,0,0,0,0,0,0, 0,2,0,0,0,1,0,0,0,67,0,0,0,115,6,0, 0,0,124,0,106,0,83,0,114,250,0,0,0,114,48,0, 0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,179,0,0,0,110,4,0,0,115, + 0,114,8,0,0,0,114,179,0,0,0,111,4,0,0,115, 2,0,0,0,0,3,122,32,69,120,116,101,110,115,105,111, 110,70,105,108,101,76,111,97,100,101,114,46,103,101,116,95, 102,105,108,101,110,97,109,101,78,41,14,114,125,0,0,0, @@ -1802,7 +1802,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,217,0,0,0,114,182,0,0,0,114,213,0, 0,0,114,229,0,0,0,114,136,0,0,0,114,179,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,5,0,0,0, - 114,8,0,0,0,114,252,0,0,0,63,4,0,0,115,22, + 114,8,0,0,0,114,252,0,0,0,64,4,0,0,115,22, 0,0,0,8,2,4,6,8,4,8,4,8,3,8,8,8, 6,8,6,8,4,8,4,2,1,114,252,0,0,0,99,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2, @@ -1845,7 +1845,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 169,4,114,118,0,0,0,114,116,0,0,0,114,44,0,0, 0,90,11,112,97,116,104,95,102,105,110,100,101,114,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,209,0, - 0,0,123,4,0,0,115,8,0,0,0,0,1,6,1,6, + 0,0,124,4,0,0,115,8,0,0,0,0,1,6,1,6, 1,14,1,122,23,95,78,97,109,101,115,112,97,99,101,80, 97,116,104,46,95,95,105,110,105,116,95,95,99,1,0,0, 0,0,0,0,0,0,0,0,0,4,0,0,0,3,0,0, @@ -1862,7 +1862,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,118,0,0,0,114,14,1,0,0,218,3,100,111,116,90, 2,109,101,114,5,0,0,0,114,5,0,0,0,114,8,0, 0,0,218,23,95,102,105,110,100,95,112,97,114,101,110,116, - 95,112,97,116,104,95,110,97,109,101,115,129,4,0,0,115, + 95,112,97,116,104,95,110,97,109,101,115,130,4,0,0,115, 8,0,0,0,0,2,18,1,8,2,4,3,122,38,95,78, 97,109,101,115,112,97,99,101,80,97,116,104,46,95,102,105, 110,100,95,112,97,114,101,110,116,95,112,97,116,104,95,110, @@ -1875,7 +1875,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 118,0,0,0,90,18,112,97,114,101,110,116,95,109,111,100, 117,108,101,95,110,97,109,101,90,14,112,97,116,104,95,97, 116,116,114,95,110,97,109,101,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,25,1,0,0,139,4,0,0, + 0,0,114,8,0,0,0,114,25,1,0,0,140,4,0,0, 115,4,0,0,0,0,1,12,1,122,31,95,78,97,109,101, 115,112,97,99,101,80,97,116,104,46,95,103,101,116,95,112, 97,114,101,110,116,95,112,97,116,104,99,1,0,0,0,0, @@ -1891,7 +1891,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,114,24,1,0,0,41,3,114,118,0,0,0,90,11, 112,97,114,101,110,116,95,112,97,116,104,114,187,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218, - 12,95,114,101,99,97,108,99,117,108,97,116,101,143,4,0, + 12,95,114,101,99,97,108,99,117,108,97,116,101,144,4,0, 0,115,16,0,0,0,0,2,12,1,10,1,14,3,18,1, 6,1,8,1,6,1,122,27,95,78,97,109,101,115,112,97, 99,101,80,97,116,104,46,95,114,101,99,97,108,99,117,108, @@ -1900,7 +1900,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,116,0,124,0,160,1,161,0,131,1,83,0,114,109,0, 0,0,41,2,114,6,1,0,0,114,32,1,0,0,114,246, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,218,8,95,95,105,116,101,114,95,95,156,4,0,0, + 0,0,218,8,95,95,105,116,101,114,95,95,157,4,0,0, 115,2,0,0,0,0,1,122,23,95,78,97,109,101,115,112, 97,99,101,80,97,116,104,46,95,95,105,116,101,114,95,95, 99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0, @@ -1909,7 +1909,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,114,32,1,0,0,41,2,114,118,0,0,0,218,5,105, 110,100,101,120,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,11,95,95,103,101,116,105,116,101,109,95,95, - 159,4,0,0,115,2,0,0,0,0,1,122,26,95,78,97, + 160,4,0,0,115,2,0,0,0,0,1,122,26,95,78,97, 109,101,115,112,97,99,101,80,97,116,104,46,95,95,103,101, 116,105,116,101,109,95,95,99,3,0,0,0,0,0,0,0, 0,0,0,0,3,0,0,0,3,0,0,0,67,0,0,0, @@ -1917,7 +1917,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,83,0,114,109,0,0,0,41,1,114,24,1,0,0,41, 3,114,118,0,0,0,114,35,1,0,0,114,44,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218, - 11,95,95,115,101,116,105,116,101,109,95,95,162,4,0,0, + 11,95,95,115,101,116,105,116,101,109,95,95,163,4,0,0, 115,2,0,0,0,0,1,122,26,95,78,97,109,101,115,112, 97,99,101,80,97,116,104,46,95,95,115,101,116,105,116,101, 109,95,95,99,1,0,0,0,0,0,0,0,0,0,0,0, @@ -1925,7 +1925,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,116,0,124,0,160,1,161,0,131,1,83,0,114,109,0, 0,0,41,2,114,23,0,0,0,114,32,1,0,0,114,246, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,218,7,95,95,108,101,110,95,95,165,4,0,0,115, + 0,0,218,7,95,95,108,101,110,95,95,166,4,0,0,115, 2,0,0,0,0,1,122,22,95,78,97,109,101,115,112,97, 99,101,80,97,116,104,46,95,95,108,101,110,95,95,99,1, 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,3, @@ -1934,7 +1934,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,101,115,112,97,99,101,80,97,116,104,40,123,33,114,125, 41,41,2,114,62,0,0,0,114,24,1,0,0,114,246,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,8,95,95,114,101,112,114,95,95,168,4,0,0,115, + 0,218,8,95,95,114,101,112,114,95,95,169,4,0,0,115, 2,0,0,0,0,1,122,23,95,78,97,109,101,115,112,97, 99,101,80,97,116,104,46,95,95,114,101,112,114,95,95,99, 2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0, @@ -1942,7 +1942,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,160,0,161,0,118,0,83,0,114,109,0,0,0,114,34, 1,0,0,169,2,114,118,0,0,0,218,4,105,116,101,109, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218, - 12,95,95,99,111,110,116,97,105,110,115,95,95,171,4,0, + 12,95,95,99,111,110,116,97,105,110,115,95,95,172,4,0, 0,115,2,0,0,0,0,1,122,27,95,78,97,109,101,115, 112,97,99,101,80,97,116,104,46,95,95,99,111,110,116,97, 105,110,115,95,95,99,2,0,0,0,0,0,0,0,0,0, @@ -1950,7 +1950,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,124,0,106,0,160,1,124,1,161,1,1,0,100, 0,83,0,114,109,0,0,0,41,2,114,24,1,0,0,114, 186,0,0,0,114,40,1,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,186,0,0,0,174,4,0, + 0,0,0,114,8,0,0,0,114,186,0,0,0,175,4,0, 0,115,2,0,0,0,0,1,122,21,95,78,97,109,101,115, 112,97,99,101,80,97,116,104,46,97,112,112,101,110,100,78, 41,15,114,125,0,0,0,114,124,0,0,0,114,126,0,0, @@ -1959,7 +1959,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 36,1,0,0,114,37,1,0,0,114,38,1,0,0,114,39, 1,0,0,114,42,1,0,0,114,186,0,0,0,114,5,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,22,1,0,0,116,4,0,0,115,24,0,0,0,8, + 0,114,22,1,0,0,117,4,0,0,115,24,0,0,0,8, 1,4,6,8,6,8,10,8,4,8,13,8,3,8,3,8, 3,8,3,8,3,8,3,114,22,1,0,0,99,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0, @@ -1975,7 +1975,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 124,2,124,3,131,3,124,0,95,1,100,0,83,0,114,109, 0,0,0,41,2,114,22,1,0,0,114,24,1,0,0,114, 28,1,0,0,114,5,0,0,0,114,5,0,0,0,114,8, - 0,0,0,114,209,0,0,0,180,4,0,0,115,2,0,0, + 0,0,0,114,209,0,0,0,181,4,0,0,115,2,0,0, 0,0,1,122,25,95,78,97,109,101,115,112,97,99,101,76, 111,97,100,101,114,46,95,95,105,110,105,116,95,95,99,2, 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,3, @@ -1992,21 +1992,21 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,109,101,115,112,97,99,101,41,62,41,2,114,62,0,0, 0,114,125,0,0,0,41,2,114,193,0,0,0,114,216,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,11,109,111,100,117,108,101,95,114,101,112,114,183,4, + 0,218,11,109,111,100,117,108,101,95,114,101,112,114,184,4, 0,0,115,2,0,0,0,0,7,122,28,95,78,97,109,101, 115,112,97,99,101,76,111,97,100,101,114,46,109,111,100,117, 108,101,95,114,101,112,114,99,2,0,0,0,0,0,0,0, 0,0,0,0,2,0,0,0,1,0,0,0,67,0,0,0, 115,4,0,0,0,100,1,83,0,41,2,78,84,114,5,0, 0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,182,0,0,0,192,4,0,0,115, + 0,114,8,0,0,0,114,182,0,0,0,193,4,0,0,115, 2,0,0,0,0,1,122,27,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,105,115,95,112,97,99,107, 97,103,101,99,2,0,0,0,0,0,0,0,0,0,0,0, 2,0,0,0,1,0,0,0,67,0,0,0,115,4,0,0, 0,100,1,83,0,41,2,78,114,40,0,0,0,114,5,0, 0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,229,0,0,0,195,4,0,0,115, + 0,114,8,0,0,0,114,229,0,0,0,196,4,0,0,115, 2,0,0,0,0,1,122,27,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,103,101,116,95,115,111,117, 114,99,101,99,2,0,0,0,0,0,0,0,0,0,0,0, @@ -2016,20 +2016,20 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 110,103,62,114,215,0,0,0,84,41,1,114,231,0,0,0, 41,1,114,232,0,0,0,114,219,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,213,0,0,0, - 198,4,0,0,115,2,0,0,0,0,1,122,25,95,78,97, + 199,4,0,0,115,2,0,0,0,0,1,122,25,95,78,97, 109,101,115,112,97,99,101,76,111,97,100,101,114,46,103,101, 116,95,99,111,100,101,99,2,0,0,0,0,0,0,0,0, 0,0,0,2,0,0,0,1,0,0,0,67,0,0,0,115, 4,0,0,0,100,1,83,0,114,210,0,0,0,114,5,0, 0,0,114,211,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,212,0,0,0,201,4,0,0,115, + 0,114,8,0,0,0,114,212,0,0,0,202,4,0,0,115, 2,0,0,0,0,1,122,30,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,99,114,101,97,116,101,95, 109,111,100,117,108,101,99,2,0,0,0,0,0,0,0,0, 0,0,0,2,0,0,0,1,0,0,0,67,0,0,0,115, 4,0,0,0,100,0,83,0,114,109,0,0,0,114,5,0, 0,0,114,253,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,217,0,0,0,204,4,0,0,115, + 0,114,8,0,0,0,114,217,0,0,0,205,4,0,0,115, 2,0,0,0,0,1,122,28,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,101,120,101,99,95,109,111, 100,117,108,101,99,2,0,0,0,0,0,0,0,0,0,0, @@ -2047,7 +2047,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,112,97,116,104,32,123,33,114,125,41,4,114,134,0,0, 0,114,149,0,0,0,114,24,1,0,0,114,218,0,0,0, 114,219,0,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,220,0,0,0,207,4,0,0,115,8,0, + 8,0,0,0,114,220,0,0,0,208,4,0,0,115,8,0, 0,0,0,7,6,1,4,255,4,2,122,28,95,78,97,109, 101,115,112,97,99,101,76,111,97,100,101,114,46,108,111,97, 100,95,109,111,100,117,108,101,78,41,12,114,125,0,0,0, @@ -2056,7 +2056,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,213,0,0,0,114,212,0,0,0,114,217,0, 0,0,114,220,0,0,0,114,5,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,43,1,0,0, - 179,4,0,0,115,18,0,0,0,8,1,8,3,2,1,10, + 180,4,0,0,115,18,0,0,0,8,1,8,3,2,1,10, 8,8,3,8,3,8,3,8,3,8,3,114,43,1,0,0, 99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,4,0,0,0,64,0,0,0,115,118,0,0,0,101,0, @@ -2093,7 +2093,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,46,1,0,0,41,3,114,193,0,0,0,114, 116,0,0,0,218,6,102,105,110,100,101,114,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,46,1,0,0, - 225,4,0,0,115,10,0,0,0,0,4,22,1,8,1,10, + 226,4,0,0,115,10,0,0,0,0,4,22,1,8,1,10, 1,10,1,122,28,80,97,116,104,70,105,110,100,101,114,46, 105,110,118,97,108,105,100,97,116,101,95,99,97,99,104,101, 115,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0, @@ -2113,7 +2113,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 117,0,0,0,41,3,114,193,0,0,0,114,44,0,0,0, 90,4,104,111,111,107,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,11,95,112,97,116,104,95,104,111,111, - 107,115,235,4,0,0,115,16,0,0,0,0,3,16,1,12, + 107,115,236,4,0,0,115,16,0,0,0,0,3,16,1,12, 1,10,1,2,1,14,1,12,1,12,2,122,22,80,97,116, 104,70,105,110,100,101,114,46,95,112,97,116,104,95,104,111, 111,107,115,99,2,0,0,0,0,0,0,0,0,0,0,0, @@ -2144,7 +2144,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,114,44,0,0,0,114,50,1,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,20,95,112,97, 116,104,95,105,109,112,111,114,116,101,114,95,99,97,99,104, - 101,248,4,0,0,115,22,0,0,0,0,8,8,1,2,1, + 101,249,4,0,0,115,22,0,0,0,0,8,8,1,2,1, 12,1,12,3,8,1,2,1,14,1,12,1,10,1,16,1, 122,31,80,97,116,104,70,105,110,100,101,114,46,95,112,97, 116,104,95,105,109,112,111,114,116,101,114,95,99,97,99,104, @@ -2161,7 +2161,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,193,0,0,0,114,139,0,0,0,114,50,1,0,0,114, 140,0,0,0,114,141,0,0,0,114,187,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,16,95, - 108,101,103,97,99,121,95,103,101,116,95,115,112,101,99,14, + 108,101,103,97,99,121,95,103,101,116,95,115,112,101,99,15, 5,0,0,115,18,0,0,0,0,4,10,1,16,2,10,1, 4,1,8,1,12,1,12,1,6,1,122,27,80,97,116,104, 70,105,110,100,101,114,46,95,108,101,103,97,99,121,95,103, @@ -2193,7 +2193,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 95,112,97,116,104,90,5,101,110,116,114,121,114,50,1,0, 0,114,187,0,0,0,114,141,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,8,0,0,0,218,9,95,103,101,116, - 95,115,112,101,99,29,5,0,0,115,40,0,0,0,0,5, + 95,115,112,101,99,30,5,0,0,115,40,0,0,0,0,5, 4,1,8,1,14,1,2,1,10,1,8,1,10,1,14,2, 12,1,8,1,2,1,10,1,8,1,6,1,8,1,8,5, 12,2,12,1,6,1,122,20,80,97,116,104,70,105,110,100, @@ -2220,7 +2220,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,22,1,0,0,41,6,114,193,0,0,0,114,139,0,0, 0,114,44,0,0,0,114,202,0,0,0,114,187,0,0,0, 114,57,1,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,203,0,0,0,61,5,0,0,115,26,0, + 8,0,0,0,114,203,0,0,0,62,5,0,0,115,26,0, 0,0,0,6,8,1,6,1,14,1,8,1,4,1,10,1, 6,1,4,3,6,1,16,1,4,2,6,2,122,20,80,97, 116,104,70,105,110,100,101,114,46,102,105,110,100,95,115,112, @@ -2240,7 +2240,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 110,100,95,115,112,101,99,40,41,32,105,110,115,116,101,97, 100,46,10,10,32,32,32,32,32,32,32,32,78,114,204,0, 0,0,114,205,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,206,0,0,0,85,5,0,0,115, + 0,114,8,0,0,0,114,206,0,0,0,86,5,0,0,115, 8,0,0,0,0,8,12,1,8,1,4,1,122,22,80,97, 116,104,70,105,110,100,101,114,46,102,105,110,100,95,109,111, 100,117,108,101,99,1,0,0,0,0,0,0,0,0,0,0, @@ -2272,7 +2272,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,95,100,105,115,116,114,105,98,117,116,105,111,110,115,41, 4,114,193,0,0,0,114,119,0,0,0,114,120,0,0,0, 114,59,1,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,60,1,0,0,98,5,0,0,115,4,0, + 8,0,0,0,114,60,1,0,0,99,5,0,0,115,4,0, 0,0,0,10,12,1,122,29,80,97,116,104,70,105,110,100, 101,114,46,102,105,110,100,95,100,105,115,116,114,105,98,117, 116,105,111,110,115,41,1,78,41,2,78,78,41,1,78,41, @@ -2281,7 +2281,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 52,1,0,0,114,54,1,0,0,114,55,1,0,0,114,58, 1,0,0,114,203,0,0,0,114,206,0,0,0,114,60,1, 0,0,114,5,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,45,1,0,0,221,4,0,0,115, + 0,114,8,0,0,0,114,45,1,0,0,222,4,0,0,115, 34,0,0,0,8,2,4,2,2,1,10,9,2,1,10,12, 2,1,10,21,2,1,10,14,2,1,12,31,2,1,12,23, 2,1,12,12,2,1,114,45,1,0,0,99,0,0,0,0, @@ -2326,7 +2326,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 14,125,1,124,1,136,0,102,2,86,0,1,0,113,2,100, 0,83,0,114,109,0,0,0,114,5,0,0,0,114,16,1, 0,0,169,1,114,140,0,0,0,114,5,0,0,0,114,8, - 0,0,0,114,19,1,0,0,127,5,0,0,243,0,0,0, + 0,0,0,114,19,1,0,0,128,5,0,0,243,0,0,0, 0,122,38,70,105,108,101,70,105,110,100,101,114,46,95,95, 105,110,105,116,95,95,46,60,108,111,99,97,108,115,62,46, 60,103,101,110,101,120,112,114,62,114,71,0,0,0,114,104, @@ -2338,7 +2338,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,118,0,0,0,114,44,0,0,0,218,14,108,111,97,100, 101,114,95,100,101,116,97,105,108,115,90,7,108,111,97,100, 101,114,115,114,189,0,0,0,114,5,0,0,0,114,62,1, - 0,0,114,8,0,0,0,114,209,0,0,0,121,5,0,0, + 0,0,114,8,0,0,0,114,209,0,0,0,122,5,0,0, 115,16,0,0,0,0,4,4,1,12,1,26,1,6,2,10, 1,6,1,8,1,122,19,70,105,108,101,70,105,110,100,101, 114,46,95,95,105,110,105,116,95,95,99,1,0,0,0,0, @@ -2348,7 +2348,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,116,104,101,32,100,105,114,101,99,116,111,114,121,32,109, 116,105,109,101,46,114,104,0,0,0,78,41,1,114,65,1, 0,0,114,246,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,46,1,0,0,135,5,0,0,115, + 0,114,8,0,0,0,114,46,1,0,0,136,5,0,0,115, 2,0,0,0,0,2,122,28,70,105,108,101,70,105,110,100, 101,114,46,105,110,118,97,108,105,100,97,116,101,95,99,97, 99,104,101,115,99,2,0,0,0,0,0,0,0,0,0,0, @@ -2371,7 +2371,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,32,32,32,32,78,41,3,114,203,0,0,0,114,140,0, 0,0,114,178,0,0,0,41,3,114,118,0,0,0,114,139, 0,0,0,114,187,0,0,0,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,137,0,0,0,141,5,0,0, + 0,0,114,8,0,0,0,114,137,0,0,0,142,5,0,0, 115,8,0,0,0,0,7,10,1,8,1,8,1,122,22,70, 105,108,101,70,105,110,100,101,114,46,102,105,110,100,95,108, 111,97,100,101,114,99,6,0,0,0,0,0,0,0,0,0, @@ -2382,7 +2382,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,188,0,0,0,114,139,0,0,0,114,44,0, 0,0,90,4,115,109,115,108,114,202,0,0,0,114,140,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,58,1,0,0,153,5,0,0,115,8,0,0,0,0, + 0,114,58,1,0,0,154,5,0,0,115,8,0,0,0,0, 1,10,1,8,1,2,255,122,20,70,105,108,101,70,105,110, 100,101,114,46,95,103,101,116,95,115,112,101,99,78,99,3, 0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,8, @@ -2436,7 +2436,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 104,114,17,1,0,0,114,188,0,0,0,90,13,105,110,105, 116,95,102,105,108,101,110,97,109,101,90,9,102,117,108,108, 95,112,97,116,104,114,187,0,0,0,114,5,0,0,0,114, - 5,0,0,0,114,8,0,0,0,114,203,0,0,0,158,5, + 5,0,0,0,114,8,0,0,0,114,203,0,0,0,159,5, 0,0,115,72,0,0,0,0,5,4,1,14,1,2,1,24, 1,12,1,10,1,10,1,8,1,6,2,6,1,6,1,10, 2,6,1,4,2,8,1,12,1,14,1,8,1,10,1,8, @@ -2468,7 +2468,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 161,0,146,2,113,4,83,0,114,5,0,0,0,41,1,114, 105,0,0,0,41,2,114,32,0,0,0,90,2,102,110,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,9, - 60,115,101,116,99,111,109,112,62,235,5,0,0,114,63,1, + 60,115,101,116,99,111,109,112,62,236,5,0,0,114,63,1, 0,0,122,41,70,105,108,101,70,105,110,100,101,114,46,95, 102,105,108,108,95,99,97,99,104,101,46,60,108,111,99,97, 108,115,62,46,60,115,101,116,99,111,109,112,62,78,41,18, @@ -2484,7 +2484,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 102,102,105,120,95,99,111,110,116,101,110,116,115,114,41,1, 0,0,114,116,0,0,0,114,29,1,0,0,114,17,1,0, 0,90,8,110,101,119,95,110,97,109,101,114,5,0,0,0, - 114,5,0,0,0,114,8,0,0,0,114,70,1,0,0,206, + 114,5,0,0,0,114,8,0,0,0,114,70,1,0,0,207, 5,0,0,115,34,0,0,0,0,2,6,1,2,1,22,1, 18,3,10,3,12,1,12,7,6,1,8,1,16,1,4,1, 18,2,4,1,12,1,6,1,12,1,122,22,70,105,108,101, @@ -2523,14 +2523,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,48,0,0,0,169,2,114,193,0,0,0,114,69,1, 0,0,114,5,0,0,0,114,8,0,0,0,218,24,112,97, 116,104,95,104,111,111,107,95,102,111,114,95,70,105,108,101, - 70,105,110,100,101,114,247,5,0,0,115,6,0,0,0,0, + 70,105,110,100,101,114,248,5,0,0,115,6,0,0,0,0, 2,8,1,12,1,122,54,70,105,108,101,70,105,110,100,101, 114,46,112,97,116,104,95,104,111,111,107,46,60,108,111,99, 97,108,115,62,46,112,97,116,104,95,104,111,111,107,95,102, 111,114,95,70,105,108,101,70,105,110,100,101,114,114,5,0, 0,0,41,3,114,193,0,0,0,114,69,1,0,0,114,76, 1,0,0,114,5,0,0,0,114,75,1,0,0,114,8,0, - 0,0,218,9,112,97,116,104,95,104,111,111,107,237,5,0, + 0,0,218,9,112,97,116,104,95,104,111,111,107,238,5,0, 0,115,4,0,0,0,0,10,14,6,122,20,70,105,108,101, 70,105,110,100,101,114,46,112,97,116,104,95,104,111,111,107, 99,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0, @@ -2539,7 +2539,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 105,108,101,70,105,110,100,101,114,40,123,33,114,125,41,41, 2,114,62,0,0,0,114,44,0,0,0,114,246,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 39,1,0,0,255,5,0,0,115,2,0,0,0,0,1,122, + 39,1,0,0,0,6,0,0,115,2,0,0,0,0,1,122, 19,70,105,108,101,70,105,110,100,101,114,46,95,95,114,101, 112,114,95,95,41,1,78,41,15,114,125,0,0,0,114,124, 0,0,0,114,126,0,0,0,114,127,0,0,0,114,209,0, @@ -2547,7 +2547,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,137,0,0,0,114,58,1,0,0,114,203,0,0,0, 114,70,1,0,0,114,207,0,0,0,114,77,1,0,0,114, 39,1,0,0,114,5,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,61,1,0,0,112,5,0, + 0,0,0,114,8,0,0,0,114,61,1,0,0,113,5,0, 0,115,22,0,0,0,8,2,4,7,8,14,8,4,4,2, 8,12,8,5,10,48,8,31,2,1,10,17,114,61,1,0, 0,99,4,0,0,0,0,0,0,0,0,0,0,0,6,0, @@ -2571,7 +2571,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 99,112,97,116,104,110,97,109,101,114,140,0,0,0,114,187, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, 0,0,218,14,95,102,105,120,95,117,112,95,109,111,100,117, - 108,101,5,6,0,0,115,34,0,0,0,0,2,10,1,10, + 108,101,6,6,0,0,115,34,0,0,0,0,2,10,1,10, 1,4,1,4,1,8,1,8,1,12,2,10,1,4,1,14, 1,2,1,8,1,8,1,8,1,12,1,12,2,114,82,1, 0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,3, @@ -2591,7 +2591,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 10,101,120,116,101,110,115,105,111,110,115,90,6,115,111,117, 114,99,101,90,8,98,121,116,101,99,111,100,101,114,5,0, 0,0,114,5,0,0,0,114,8,0,0,0,114,184,0,0, - 0,28,6,0,0,115,8,0,0,0,0,5,12,1,8,1, + 0,29,6,0,0,115,8,0,0,0,0,5,12,1,8,1, 8,1,114,184,0,0,0,99,1,0,0,0,0,0,0,0, 0,0,0,0,10,0,0,0,9,0,0,0,67,0,0,0, 115,132,1,0,0,124,0,97,0,116,0,106,1,97,1,116, @@ -2639,7 +2639,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,83,0,41,2,114,39,0,0,0,78,41,1,114,23,0, 0,0,41,2,114,32,0,0,0,114,94,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,19,1, - 0,0,57,6,0,0,114,63,1,0,0,122,25,95,115,101, + 0,0,58,6,0,0,114,63,1,0,0,122,25,95,115,101, 116,117,112,46,60,108,111,99,97,108,115,62,46,60,103,101, 110,101,120,112,114,62,114,73,0,0,0,122,30,105,109,112, 111,114,116,108,105,98,32,114,101,113,117,105,114,101,115,32, @@ -2651,7 +2651,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 157,2,146,2,113,4,83,0,41,1,114,74,0,0,0,114, 5,0,0,0,41,2,114,32,0,0,0,218,1,115,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,71,1, - 0,0,74,6,0,0,114,63,1,0,0,122,25,95,115,101, + 0,0,75,6,0,0,114,63,1,0,0,122,25,95,115,101, 116,117,112,46,60,108,111,99,97,108,115,62,46,60,115,101, 116,99,111,109,112,62,41,3,114,64,0,0,0,114,75,0, 0,0,114,160,0,0,0,114,192,0,0,0,114,9,0,0, @@ -2671,7 +2671,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,116,105,110,95,110,97,109,101,115,90,12,98,117,105,108, 116,105,110,95,110,97,109,101,90,14,98,117,105,108,116,105, 110,95,109,111,100,117,108,101,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,218,6,95,115,101,116,117,112,39, + 0,0,114,8,0,0,0,218,6,95,115,101,116,117,112,40, 6,0,0,115,70,0,0,0,0,8,4,1,6,1,6,2, 10,3,22,1,12,2,22,1,8,1,10,1,10,1,6,2, 2,1,10,1,10,1,12,1,12,2,8,2,12,1,12,1, @@ -2691,7 +2691,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 104,114,186,0,0,0,114,45,1,0,0,41,2,114,88,1, 0,0,90,17,115,117,112,112,111,114,116,101,100,95,108,111, 97,100,101,114,115,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,218,8,95,105,110,115,116,97,108,108,96,6, + 8,0,0,0,218,8,95,105,110,115,116,97,108,108,97,6, 0,0,115,8,0,0,0,0,2,8,1,6,1,20,1,114, 91,1,0,0,41,1,114,60,0,0,0,41,1,78,41,3, 78,78,78,41,2,114,73,0,0,0,114,73,0,0,0,41, @@ -2725,7 +2725,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 218,8,60,109,111,100,117,108,101,62,1,0,0,0,115,126, 0,0,0,4,22,4,1,4,1,2,1,2,255,4,4,8, 17,8,5,8,5,8,6,8,6,8,12,8,10,8,9,8, - 5,8,7,8,9,10,22,10,127,0,20,16,1,12,2,4, + 5,8,7,8,9,10,22,10,127,0,21,16,1,12,2,4, 1,4,2,6,2,6,2,8,2,16,71,8,40,8,19,8, 12,8,12,8,28,8,17,8,33,8,28,8,24,10,13,10, 10,10,11,8,14,6,3,4,1,2,255,12,68,14,64,14, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 538fdbe3e0b5ae..6f2b3e791d1f29 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -165,7 +165,7 @@ static void *opcode_targets[256] = { &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, - &&_unknown_opcode, + &&TARGET_GET_MATCH_ITER, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From 2586ee67ca16b53e44f35d58ffd45771f978086f Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 27 May 2020 16:16:42 -0700 Subject: [PATCH 024/189] Add string tests --- Lib/test/test_patma.py | 58 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 3ee59e620584ea..b1c02c1e060357 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -328,9 +328,63 @@ def test_iter_8(self) -> None: self.assertEqual(namespace.get("x"), []) self.assertEqual(namespace.get("y"), 2) + def test_string_0(self) -> None: + match_cases = [MatchCase("['x']", "y = 0"), MatchCase("'x'", "y = 1")] + namespace = self.execute_match("x = 'x'", "x", match_cases, "") + self.assertEqual(namespace.get("x"), "x") + self.assertEqual(namespace.get("y"), 1) + + def test_string_1(self) -> None: + match_cases = [ + MatchCase("[b'x']", "y = 0"), + MatchCase("['x']", "y = 1"), + MatchCase("[120]", "y = 2"), + MatchCase("120", "y = 3"), + MatchCase("b'x'", "y = 4"), + ] + namespace = self.execute_match("x = b'x'", "x", match_cases, "") + self.assertEqual(namespace.get("x"), b"x") + self.assertEqual(namespace.get("y"), 4) + + def test_string_2(self) -> None: + match_cases = [MatchCase("[120]", "y = 0"), MatchCase("120", "y = 1")] + namespace = self.execute_match("x = bytearray(b'x')", "x", match_cases, "") + self.assertEqual(namespace.get("x"), b"x") + self.assertNotIn("y", namespace) + + def test_string_3(self) -> None: + match_cases = [ + MatchCase("[]", "y = 0"), + MatchCase("['']", "y = 1"), + MatchCase("''", "y = 2"), + ] + namespace = self.execute_match("x = ''", "x", match_cases, "") + self.assertEqual(namespace.get("x"), "") + self.assertEqual(namespace.get("y"), 2) + + def test_string_4(self) -> None: + match_cases = [ + MatchCase("['x', 'x', 'x']", "y = 0"), + MatchCase("['xxx']", "y = 1"), + MatchCase("'xxx'", "y = 2"), + ] + namespace = self.execute_match("x = 'xxx'", "x", match_cases, "") + self.assertEqual(namespace.get("x"), "xxx") + self.assertEqual(namespace.get("y"), 2) + + def test_string_5(self) -> None: + match_cases = [ + MatchCase("[120, 120, 120]", "y = 0"), + MatchCase("[b'xxx']", "y = 1"), + MatchCase("b'xxx'", "y = 2"), + ] + namespace = self.execute_match("x = b'xxx'", "x", match_cases, "") + self.assertEqual(namespace.get("x"), b"xxx") + self.assertEqual(namespace.get("y"), 2) + if __name__ == "__main__": # XXX: For quick test debugging... import dis - match_cases = [MatchCase("(0, 1) | (1, 0)", "y = 0")] - dis.dis(TestAST.compile_match("x = [0, 0]", "x", match_cases, "")) + match_cases = [MatchCase("([0, 1]) | (1 | (z := 2), 0, q, [[[]]])", "pass")] + dis.dis(TestAST.compile_match("", "x", match_cases, "")) From adb04fd3f2bb6dc03593e519a163ddc52942ea36 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 27 May 2020 23:09:21 -0700 Subject: [PATCH 025/189] Rename and add patma tests --- Lib/test/test_patma.py | 122 +++++++++++++++++++++++++---------------- 1 file changed, 76 insertions(+), 46 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index b1c02c1e060357..20e4207ab20fe3 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -53,109 +53,109 @@ def execute_match( exec(cls.compile_match(pre, target, match_cases, post), None, namespace) return namespace - def test_steroid_switch_0(self) -> None: + def test_steroid_switch_00(self) -> None: match_cases = [MatchCase("0", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) - def test_steroid_switch_1(self) -> None: + def test_steroid_switch_01(self) -> None: match_cases = [MatchCase("False", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) - def test_steroid_switch_2(self) -> None: + def test_steroid_switch_02(self) -> None: match_cases = [MatchCase("1", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertNotIn("y", namespace) - def test_steroid_switch_3(self) -> None: + def test_steroid_switch_03(self) -> None: match_cases = [MatchCase("None", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertNotIn("y", namespace) - def test_steroid_switch_4(self) -> None: + def test_steroid_switch_04(self) -> None: match_cases = [MatchCase("0", "y = 0"), MatchCase("0", "y = 1")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) - def test_steroid_switch_5(self) -> None: + def test_steroid_switch_05(self) -> None: match_cases = [MatchCase("1", "y = 0"), MatchCase("1", "y = 1")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertNotIn("y", namespace) - def test_steroid_switch_6(self) -> None: + def test_steroid_switch_06(self) -> None: match_cases = [MatchCase("'x'", "y = 0"), MatchCase("'y'", "y = 1")] namespace = self.execute_match("x = 'x'", "x", match_cases, "") self.assertEqual(namespace.get("x"), "x") self.assertEqual(namespace.get("y"), 0) - def test_steroid_switch_7(self) -> None: + def test_steroid_switch_07(self) -> None: match_cases = [MatchCase("'y'", "y = 0"), MatchCase("'x'", "y = 1")] namespace = self.execute_match("x = 'x'", "x", match_cases, "") self.assertEqual(namespace.get("x"), "x") self.assertEqual(namespace.get("y"), 1) - def test_steroid_switch_8(self) -> None: + def test_steroid_switch_08(self) -> None: match_cases = [MatchCase("'x'", "y = 0"), MatchCase("'y'", "y = 1")] namespace = self.execute_match("x = 'x'", "x", match_cases, "") self.assertEqual(namespace.get("x"), "x") self.assertEqual(namespace.get("y"), 0) - def test_steroid_switch_9(self) -> None: + def test_steroid_switch_09(self) -> None: match_cases = [MatchCase("b'y'", "y = 0"), MatchCase("b'x'", "y = 1")] namespace = self.execute_match("x = b'x'", "x", match_cases, "") self.assertEqual(namespace.get("x"), b"x") self.assertEqual(namespace.get("y"), 1) - def test_steroid_switch_guard_0(self) -> None: + def test_steroid_switch_guard_00(self) -> None: match_cases = [MatchCase("0", "y = 0", "False"), MatchCase("0", "y = 1")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 1) - def test_steroid_switch_guard_1(self) -> None: + def test_steroid_switch_guard_01(self) -> None: match_cases = [MatchCase("0", "y = 0", "0"), MatchCase("0", "y = 1", "0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertNotIn("y", namespace) - def test_steroid_switch_guard_2(self) -> None: + def test_steroid_switch_guard_02(self) -> None: match_cases = [MatchCase("0", "y = 0", "True"), MatchCase("0", "y = 1", "True")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) - def test_steroid_switch_guard_3(self) -> None: + def test_steroid_switch_guard_03(self) -> None: match_cases = [MatchCase("0", "y = 0", "True"), MatchCase("0", "y = 1", "True")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) - def test_steroid_switch_guard_4(self) -> None: + def test_steroid_switch_guard_04(self) -> None: match_cases = [MatchCase("0", "y = 0", "True"), MatchCase("0", "y = 1", "True")] namespace = self.execute_match("x = 0", "x", match_cases, "y = 2") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 2) - def test_steroid_switch_guard_5(self) -> None: + def test_steroid_switch_guard_05(self) -> None: match_cases = [MatchCase("0", "y = 0", "0"), MatchCase("0", "y = 1", "1")] namespace = self.execute_match("x = 0", "x", match_cases, "y = 2") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 2) - def test_steroid_switch_guard_6(self) -> None: + def test_steroid_switch_guard_06(self) -> None: match_cases = [MatchCase("0", "y = 0", "not (x := 1)"), MatchCase("1", "y = 1")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 1) self.assertNotIn("y", namespace) - def test_walrus_0(self) -> None: + def test_walrus_00(self) -> None: match_cases = [ MatchCase("0", "y = 0", "not (x := 1)"), MatchCase("(z := 0)", "y = 1"), @@ -165,7 +165,7 @@ def test_walrus_0(self) -> None: self.assertEqual(namespace.get("y"), 1) self.assertEqual(namespace.get("z"), 0) - def test_walrus_1(self) -> None: + def test_walrus_01(self) -> None: match_cases = [ MatchCase("(z := 1)", "y = 0", "not (x := 1)"), MatchCase("0", "y = 1"), @@ -175,21 +175,21 @@ def test_walrus_1(self) -> None: self.assertEqual(namespace.get("y"), 1) self.assertNotIn("z", namespace) - def test_walrus_2(self) -> None: + def test_walrus_02(self) -> None: match_cases = [MatchCase("(z := 0)", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 0) - def test_walrus_3(self) -> None: + def test_walrus_03(self) -> None: match_cases = [MatchCase("(z := 1)", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertNotIn("y", namespace) self.assertNotIn("z", namespace) - def test_walrus_4(self) -> None: + def test_walrus_04(self) -> None: match_cases = [MatchCase("(z := 0)", "y = 0", "(w := 0)")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("w"), 0) @@ -197,7 +197,7 @@ def test_walrus_4(self) -> None: self.assertNotIn("y", namespace) self.assertEqual(namespace.get("z"), 0) - def test_walrus_5(self) -> None: + def test_walrus_05(self) -> None: match_cases = [MatchCase("(z := (w := 0))", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("w"), 0) @@ -205,31 +205,31 @@ def test_walrus_5(self) -> None: self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 0) - def test_pipe_0(self) -> None: + def test_pipe_00(self) -> None: match_cases = [MatchCase("0 | 1 | 2", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) - def test_pipe_1(self) -> None: + def test_pipe_01(self) -> None: match_cases = [MatchCase("0 | 1 | 2", "y = 0")] namespace = self.execute_match("x = 1", "x", match_cases, "") self.assertEqual(namespace.get("x"), 1) self.assertEqual(namespace.get("y"), 0) - def test_pipe_2(self) -> None: + def test_pipe_02(self) -> None: match_cases = [MatchCase("0 | 1 | 2", "y = 0")] namespace = self.execute_match("x = 2", "x", match_cases, "") self.assertEqual(namespace.get("x"), 2) self.assertEqual(namespace.get("y"), 0) - def test_pipe_3(self) -> None: + def test_pipe_03(self) -> None: match_cases = [MatchCase("0 | 1 | 2", "y = 0")] namespace = self.execute_match("x = 3", "x", match_cases, "") self.assertEqual(namespace.get("x"), 3) self.assertNotIn("y", namespace) - def test_pipe_4(self) -> None: + def test_pipe_04(self) -> None: match_cases = [ MatchCase("(z := 0) | (z := 1) | (z := 2)", "y = 0", "z == x % 2") ] @@ -238,7 +238,7 @@ def test_pipe_4(self) -> None: self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 0) - def test_pipe_5(self) -> None: + def test_pipe_05(self) -> None: match_cases = [ MatchCase("(z := 0) | (z := 1) | (z := 2)", "y = 0", "z == x % 2") ] @@ -247,7 +247,7 @@ def test_pipe_5(self) -> None: self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 1) - def test_pipe_6(self) -> None: + def test_pipe_06(self) -> None: match_cases = [ MatchCase("(z := 0) | (z := 1) | (z := 2)", "y = 0", "z == x % 2") ] @@ -256,7 +256,7 @@ def test_pipe_6(self) -> None: self.assertNotIn("y", namespace) self.assertEqual(namespace.get("z"), 2) - def test_pipe_7(self) -> None: + def test_pipe_07(self) -> None: match_cases = [ MatchCase("(z := 0) | (z := 1) | (z := 2)", "y = 0", "z == x % 2") ] @@ -265,49 +265,49 @@ def test_pipe_7(self) -> None: self.assertNotIn("y", namespace) self.assertNotIn("z", namespace) - def test_iter_0(self) -> None: + def test_iter_00(self) -> None: match_cases = [MatchCase("()", "y = 0")] namespace = self.execute_match("x = ()", "x", match_cases, "") self.assertEqual(namespace.get("x"), ()) self.assertEqual(namespace.get("y"), 0) - def test_iter_1(self) -> None: + def test_iter_01(self) -> None: match_cases = [MatchCase("[]", "y = 0")] namespace = self.execute_match("x = ()", "x", match_cases, "") self.assertEqual(namespace.get("x"), ()) self.assertEqual(namespace.get("y"), 0) - def test_iter_2(self) -> None: + def test_iter_02(self) -> None: match_cases = [MatchCase("[0]", "y = 0")] namespace = self.execute_match("x = (0,)", "x", match_cases, "") self.assertEqual(namespace.get("x"), (0,)) self.assertEqual(namespace.get("y"), 0) - def test_iter_3(self) -> None: + def test_iter_03(self) -> None: match_cases = [MatchCase("[[]]", "y = 0")] namespace = self.execute_match("x = ((),)", "x", match_cases, "") self.assertEqual(namespace.get("x"), ((),)) self.assertEqual(namespace.get("y"), 0) - def test_iter_4(self) -> None: + def test_iter_04(self) -> None: match_cases = [MatchCase("(0, 1) | (1, 0)", "y = 0")] namespace = self.execute_match("x = [0, 1]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [0, 1]) self.assertEqual(namespace.get("y"), 0) - def test_iter_5(self) -> None: + def test_iter_05(self) -> None: match_cases = [MatchCase("(0, 1) | (1, 0)", "y = 0")] namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [1, 0]) self.assertEqual(namespace.get("y"), 0) - def test_iter_6(self) -> None: + def test_iter_06(self) -> None: match_cases = [MatchCase("(0, 1) | (1, 0)", "y = 0")] namespace = self.execute_match("x = [0, 0]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [0, 0]) self.assertNotIn("y", namespace) - def test_iter_7(self) -> None: + def test_iter_07(self) -> None: match_cases = [ MatchCase("(w := 0,)", "y = 0"), MatchCase("[] | (1, z := (0 | 1)) | []", "y = 1"), @@ -318,7 +318,7 @@ def test_iter_7(self) -> None: self.assertEqual(namespace.get("y"), 1) self.assertEqual(namespace.get("z"), 0) - def test_iter_8(self) -> None: + def test_iter_08(self) -> None: match_cases = [ MatchCase("(0,)", "y = 0"), MatchCase("(1, 0)", "y = 1", "(x := x[:0])"), @@ -328,13 +328,43 @@ def test_iter_8(self) -> None: self.assertEqual(namespace.get("x"), []) self.assertEqual(namespace.get("y"), 2) - def test_string_0(self) -> None: + def test_iter_09(self) -> None: + match_cases = [MatchCase("[0]", "y = 0")] + namespace = self.execute_match("x = {0}", "x", match_cases, "") + self.assertEqual(namespace.get("x"), {0}) + self.assertNotIn("y", namespace) + + def test_iter_10(self) -> None: + match_cases = [MatchCase("()", "y = 0")] + namespace = self.execute_match("x = set()", "x", match_cases, "") + self.assertEqual(namespace.get("x"), set()) + self.assertNotIn("y", namespace) + + def test_iter_11(self) -> None: + match_cases = [MatchCase("[]", "y = 0")] + namespace = self.execute_match("x = iter([1,2,3])", "x", match_cases, "") + self.assertEqual(list(namespace.get("x")), [1, 2, 3]) + self.assertNotIn("y", namespace) + + def test_iter_12(self) -> None: + match_cases = [MatchCase("[]", "y = 0")] + namespace = self.execute_match("x = {}", "x", match_cases, "") + self.assertEqual(namespace.get("x"), {}) + self.assertNotIn("y", namespace) + + def test_iter_13(self) -> None: + match_cases = [MatchCase("(0, 1)", "y = 0")] + namespace = self.execute_match("x = {0: False, 1: True}", "x", match_cases, "") + self.assertEqual(namespace.get("x"), {0: False, 1: True}) + self.assertNotIn("y", namespace) + + def test_string_00(self) -> None: match_cases = [MatchCase("['x']", "y = 0"), MatchCase("'x'", "y = 1")] namespace = self.execute_match("x = 'x'", "x", match_cases, "") self.assertEqual(namespace.get("x"), "x") self.assertEqual(namespace.get("y"), 1) - def test_string_1(self) -> None: + def test_string_01(self) -> None: match_cases = [ MatchCase("[b'x']", "y = 0"), MatchCase("['x']", "y = 1"), @@ -346,13 +376,13 @@ def test_string_1(self) -> None: self.assertEqual(namespace.get("x"), b"x") self.assertEqual(namespace.get("y"), 4) - def test_string_2(self) -> None: + def test_string_02(self) -> None: match_cases = [MatchCase("[120]", "y = 0"), MatchCase("120", "y = 1")] namespace = self.execute_match("x = bytearray(b'x')", "x", match_cases, "") self.assertEqual(namespace.get("x"), b"x") self.assertNotIn("y", namespace) - def test_string_3(self) -> None: + def test_string_03(self) -> None: match_cases = [ MatchCase("[]", "y = 0"), MatchCase("['']", "y = 1"), @@ -362,7 +392,7 @@ def test_string_3(self) -> None: self.assertEqual(namespace.get("x"), "") self.assertEqual(namespace.get("y"), 2) - def test_string_4(self) -> None: + def test_string_04(self) -> None: match_cases = [ MatchCase("['x', 'x', 'x']", "y = 0"), MatchCase("['xxx']", "y = 1"), @@ -372,7 +402,7 @@ def test_string_4(self) -> None: self.assertEqual(namespace.get("x"), "xxx") self.assertEqual(namespace.get("y"), 2) - def test_string_5(self) -> None: + def test_string_05(self) -> None: match_cases = [ MatchCase("[120, 120, 120]", "y = 0"), MatchCase("[b'xxx']", "y = 1"), From 6eb67836273a75c7910f902f3847c22a37158ef8 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 27 May 2020 23:21:21 -0700 Subject: [PATCH 026/189] Cleanup --- Lib/test/test_patma.py | 1 - Python/compile.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 20e4207ab20fe3..a3398b8fc444f6 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -369,7 +369,6 @@ def test_string_01(self) -> None: MatchCase("[b'x']", "y = 0"), MatchCase("['x']", "y = 1"), MatchCase("[120]", "y = 2"), - MatchCase("120", "y = 3"), MatchCase("b'x'", "y = 4"), ] namespace = self.execute_match("x = b'x'", "x", match_cases, "") diff --git a/Python/compile.c b/Python/compile.c index a9a8501c4856db..f1b3fd8e960d70 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -982,6 +982,7 @@ stack_effect(int opcode, int oparg, int jump) return jump > 0 ? -1 : 1; case GET_MATCH_ITER: return -(jump > 0); + case STORE_ATTR: return -2; case DELETE_ATTR: From f3c513d3647360e32ec4009d29c7bed4a78c1455 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 27 May 2020 23:38:12 -0700 Subject: [PATCH 027/189] Use Mapping/Sequence _collections_abc --- Include/internal/pycore_interp.h | 5 ++- Python/ceval.c | 54 +++++++++++++++++++++++++++++--- Python/pystate.c | 2 ++ 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h index f04ea330d04571..072cb1b69939e5 100644 --- a/Include/internal/pycore_interp.h +++ b/Include/internal/pycore_interp.h @@ -97,6 +97,10 @@ struct _is { PyObject *builtins; PyObject *importlib; + // Kept handy for pattern matching: + PyObject *map_abc; // _collections_abc.Mapping + PyObject *seq_abc; // _collections_abc.Sequence + /* Used in Modules/_threadmodule.c. */ long num_threads; /* Support for runtime thread stack size tuning. @@ -192,4 +196,3 @@ PyAPI_FUNC(void) _PyInterpreterState_IDDecref(struct _is *); } #endif #endif /* !Py_INTERNAL_INTERP_H */ - diff --git a/Python/ceval.c b/Python/ceval.c index b8df9b3f5040ec..90f6b83ae54641 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -848,6 +848,50 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) return 0; } +// Need these for pattern matching: + +// static int +// check_match_mapping_type(PyObject *target) +// { +// PyInterpreterState *interp = PyInterpreterState_Get(); +// if (!interp) { +// return -1; +// } +// if (!interp->map_abc) { +// PyObject *abc = PyImport_ImportModule("_collections_abc"); +// if (!abc) { +// return -1; +// } +// interp->map_abc = PyObject_GetAttrString(abc, "Mapping"); +// Py_DECREF(abc); +// } +// return PyObject_IsInstance(target, interp->map_abc); +// } + +static int +check_match_sequence_type(PyObject *target) +{ + PyInterpreterState *interp = PyInterpreterState_Get(); + if (!interp) { + return -1; + } + if (!interp->seq_abc) { + PyObject *abc = PyImport_ImportModule("_collections_abc"); + if (!abc) { + return -1; + } + interp->seq_abc = PyObject_GetAttrString(abc, "Sequence"); + Py_DECREF(abc); + } + return ( + PyObject_IsInstance(target, interp->seq_abc) + && !PyIter_Check(target) + && !PyObject_TypeCheck(target, &PyUnicode_Type) + && !PyObject_TypeCheck(target, &PyBytes_Type) + && !PyObject_TypeCheck(target, &PyByteArray_Type) + ); +} + static int do_raise(PyThreadState *tstate, PyObject *exc, PyObject *cause); static int unpack_iterable(PyThreadState *, PyObject *, int, int, PyObject **); @@ -3286,11 +3330,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(GET_MATCH_ITER): { PyObject *target = TOP(); - if (!PySequence_Check(target) - || PyObject_TypeCheck(target, &PyUnicode_Type) - || PyObject_TypeCheck(target, &PyBytes_Type) - || PyObject_TypeCheck(target, &PyByteArray_Type) - ) { + int check = check_match_sequence_type(target); + if (check < 0) { + goto error; + } + if (!check) { STACK_SHRINK(1); Py_DECREF(target); JUMPBY(oparg); diff --git a/Python/pystate.c b/Python/pystate.c index 119fe31a84ba12..25c1deec8211dd 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -315,6 +315,8 @@ PyInterpreterState_Clear(PyInterpreterState *interp) Py_CLEAR(interp->importlib); Py_CLEAR(interp->import_func); Py_CLEAR(interp->dict); + Py_CLEAR(interp->map_abc); + Py_CLEAR(interp->seq_abc); #ifdef HAVE_FORK Py_CLEAR(interp->before_forkers); Py_CLEAR(interp->after_forkers_parent); From fc472c7bc42ca88575c6d897a1e3ac219e97b892 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 28 May 2020 07:46:11 -0700 Subject: [PATCH 028/189] Add missing error handling --- Python/ceval.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Python/ceval.c b/Python/ceval.c index 90f6b83ae54641..9efa875da4b31b 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -864,6 +864,9 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) // } // interp->map_abc = PyObject_GetAttrString(abc, "Mapping"); // Py_DECREF(abc); +// if (!interp->map_abc) { +// return -1; +// } // } // return PyObject_IsInstance(target, interp->map_abc); // } @@ -882,6 +885,9 @@ check_match_sequence_type(PyObject *target) } interp->seq_abc = PyObject_GetAttrString(abc, "Sequence"); Py_DECREF(abc); + if (!interp->seq_abc) { + return -1; + } } return ( PyObject_IsInstance(target, interp->seq_abc) From 26dd4fdfe28c5c092b573615968420e9f030ff11 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 28 May 2020 08:36:07 -0700 Subject: [PATCH 029/189] Add GET_MATCH_MAP --- Doc/library/dis.rst | 14 +- Include/opcode.h | 1 + Lib/importlib/_bootstrap_external.py | 1 + Lib/opcode.py | 1 + Python/ceval.c | 61 ++++--- Python/compile.c | 1 + Python/importlib_external.h | 228 +++++++++++++-------------- Python/opcode_targets.h | 2 +- 8 files changed, 172 insertions(+), 137 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index a91ae8c7b65fa1..1141a79ae9d335 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -993,8 +993,18 @@ All of the following opcodes use their arguments. .. opcode:: GET_MATCH_ITER (delta) Used for pattern matching. Much like :opcode:`GET_ITER`, but pops TOS and - increments the byte code counter by *delta* if TOS is not a :term:`sequence` - or is an instance of :class:`str`, :class:`bytes`, or :class:`bytearray`. + increments the byte code counter by *delta* if TOS *is not* an instance of + :class:`collections.abc.Sequence` or *is* an instance of + :class:`str`/:class:`bytes`/:class:`bytearray`. + + .. versionadded:: 3.10 + + +.. opcode:: GET_MATCH_MAP (delta) + + Used for pattern matching. TOS is popped. If it is an instance of + :class:`collections.abc.Mapping`, a :class:`dict` is built from it and pushed + in its place. Otherwise, the byte code counter is incremented by *delta*. .. versionadded:: 3.10 diff --git a/Include/opcode.h b/Include/opcode.h index 325e61d3f61142..d5865a0b8c7ce5 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -128,6 +128,7 @@ extern "C" { #define DICT_MERGE 164 #define DICT_UPDATE 165 #define GET_MATCH_ITER 166 +#define GET_MATCH_MAP 167 /* EXCEPT_HANDLER is a special, implicit block type which is created when entering an except handler. It is not an opcode but we define it here diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 959e8ba45f614f..31db5026e76d36 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -278,6 +278,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) # Python 3.10a0 3435 (add GET_MATCH_ITER) +# Python 3.10a0 3436 (add GET_MATCH_MAP) # # MAGIC must change whenever the bytecode emitted by the compiler may no diff --git a/Lib/opcode.py b/Lib/opcode.py index 09a1d079be5524..0ac03b373ffa88 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -214,5 +214,6 @@ def jabs_op(name, op): def_op('DICT_MERGE', 164) def_op('DICT_UPDATE', 165) jrel_op('GET_MATCH_ITER', 166) +jrel_op('GET_MATCH_MAP', 167) del def_op, name_op, jrel_op, jabs_op diff --git a/Python/ceval.c b/Python/ceval.c index 9efa875da4b31b..abc042ecca430f 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -850,26 +850,26 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) // Need these for pattern matching: -// static int -// check_match_mapping_type(PyObject *target) -// { -// PyInterpreterState *interp = PyInterpreterState_Get(); -// if (!interp) { -// return -1; -// } -// if (!interp->map_abc) { -// PyObject *abc = PyImport_ImportModule("_collections_abc"); -// if (!abc) { -// return -1; -// } -// interp->map_abc = PyObject_GetAttrString(abc, "Mapping"); -// Py_DECREF(abc); -// if (!interp->map_abc) { -// return -1; -// } -// } -// return PyObject_IsInstance(target, interp->map_abc); -// } +static int +check_match_mapping_type(PyObject *target) +{ + PyInterpreterState *interp = PyInterpreterState_Get(); + if (!interp) { + return -1; + } + if (!interp->map_abc) { + PyObject *abc = PyImport_ImportModule("_collections_abc"); + if (!abc) { + return -1; + } + interp->map_abc = PyObject_GetAttrString(abc, "Mapping"); + Py_DECREF(abc); + if (!interp->map_abc) { + return -1; + } + } + return PyObject_IsInstance(target, interp->map_abc); +} static int check_match_sequence_type(PyObject *target) @@ -3334,6 +3334,27 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) #endif } + case TARGET(GET_MATCH_MAP): { + PyObject *target = TOP(); + int check = check_match_mapping_type(target); + if (check < 0) { + goto error; + } + if (!check) { + STACK_SHRINK(1); + Py_DECREF(target); + JUMPBY(oparg); + DISPATCH(); + } + PyObject *map = PyDict_New(); + if (!map || PyDict_Update(map, target)) { + goto error; + } + Py_DECREF(target); + SET_TOP(map); + DISPATCH(); + } + case TARGET(GET_MATCH_ITER): { PyObject *target = TOP(); int check = check_match_sequence_type(target); diff --git a/Python/compile.c b/Python/compile.c index f1b3fd8e960d70..6dfc2d9695887d 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -981,6 +981,7 @@ stack_effect(int opcode, int oparg, int jump) /* -1 at end of iterator, 1 if continue iterating. */ return jump > 0 ? -1 : 1; case GET_MATCH_ITER: + case GET_MATCH_MAP: return -(jump > 0); case STORE_ATTR: diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 8010e6e269e67b..96ccf461abd2d8 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -400,7 +400,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 95,102,105,108,101,110,97,109,101,218,8,102,105,108,101,110, 97,109,101,114,5,0,0,0,114,5,0,0,0,114,8,0, 0,0,218,17,99,97,99,104,101,95,102,114,111,109,95,115, - 111,117,114,99,101,46,1,0,0,115,72,0,0,0,0,18, + 111,117,114,99,101,47,1,0,0,115,72,0,0,0,0,18, 8,1,6,1,2,255,4,2,8,1,4,1,8,1,12,1, 10,1,12,1,16,1,8,1,8,1,8,1,24,1,8,1, 12,1,6,2,8,1,8,1,8,1,8,1,14,1,14,1, @@ -481,7 +481,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,101,118,101,108,90,13,98,97,115,101,95,102,105,108,101, 110,97,109,101,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,17,115,111,117,114,99,101,95,102,114,111,109, - 95,99,97,99,104,101,117,1,0,0,115,68,0,0,0,0, + 95,99,97,99,104,101,118,1,0,0,115,68,0,0,0,0, 9,12,1,8,1,10,1,12,1,4,1,10,1,12,1,14, 1,16,1,4,1,4,1,12,1,8,1,2,1,2,255,4, 1,2,255,8,2,10,1,8,1,16,1,10,1,16,1,10, @@ -517,7 +517,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 120,116,101,110,115,105,111,110,218,11,115,111,117,114,99,101, 95,112,97,116,104,114,5,0,0,0,114,5,0,0,0,114, 8,0,0,0,218,15,95,103,101,116,95,115,111,117,114,99, - 101,102,105,108,101,157,1,0,0,115,20,0,0,0,0,7, + 101,102,105,108,101,158,1,0,0,115,20,0,0,0,0,7, 12,1,4,1,16,1,24,1,4,1,2,1,12,1,16,1, 18,1,114,108,0,0,0,99,1,0,0,0,0,0,0,0, 0,0,0,0,1,0,0,0,8,0,0,0,67,0,0,0, @@ -530,7 +530,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 112,108,101,114,101,0,0,0,114,97,0,0,0,114,82,0, 0,0,114,88,0,0,0,41,1,114,96,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,11,95, - 103,101,116,95,99,97,99,104,101,100,176,1,0,0,115,16, + 103,101,116,95,99,97,99,104,101,100,177,1,0,0,115,16, 0,0,0,0,1,14,1,2,1,10,1,12,1,8,1,14, 1,4,2,114,112,0,0,0,99,1,0,0,0,0,0,0, 0,0,0,0,0,2,0,0,0,8,0,0,0,67,0,0, @@ -545,7 +545,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,51,0,0,0,114,50,0,0,0,41,2,114,44,0,0, 0,114,52,0,0,0,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,10,95,99,97,108,99,95,109,111,100, - 101,188,1,0,0,115,12,0,0,0,0,2,2,1,14,1, + 101,189,1,0,0,115,12,0,0,0,0,2,2,1,14,1, 12,1,10,3,8,1,114,114,0,0,0,99,1,0,0,0, 0,0,0,0,0,0,0,0,3,0,0,0,8,0,0,0, 3,0,0,0,115,66,0,0,0,100,6,135,0,102,1,100, @@ -583,7 +583,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,114,103,115,218,6,107,119,97,114,103,115,169,1,218,6, 109,101,116,104,111,100,114,5,0,0,0,114,8,0,0,0, 218,19,95,99,104,101,99,107,95,110,97,109,101,95,119,114, - 97,112,112,101,114,208,1,0,0,115,18,0,0,0,0,1, + 97,112,112,101,114,209,1,0,0,115,18,0,0,0,0,1, 8,1,8,1,10,1,4,1,8,255,2,1,2,255,6,2, 122,40,95,99,104,101,99,107,95,110,97,109,101,46,60,108, 111,99,97,108,115,62,46,95,99,104,101,99,107,95,110,97, @@ -601,7 +601,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 8,95,95,100,105,99,116,95,95,218,6,117,112,100,97,116, 101,41,3,90,3,110,101,119,90,3,111,108,100,114,67,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,5,95,119,114,97,112,219,1,0,0,115,8,0,0, + 0,218,5,95,119,114,97,112,220,1,0,0,115,8,0,0, 0,0,1,8,1,10,1,20,1,122,26,95,99,104,101,99, 107,95,110,97,109,101,46,60,108,111,99,97,108,115,62,46, 95,119,114,97,112,41,1,78,41,3,218,10,95,98,111,111, @@ -609,7 +609,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,69,114,114,111,114,41,3,114,122,0,0,0,114,123,0, 0,0,114,133,0,0,0,114,5,0,0,0,114,121,0,0, 0,114,8,0,0,0,218,11,95,99,104,101,99,107,95,110, - 97,109,101,200,1,0,0,115,14,0,0,0,0,8,14,7, + 97,109,101,201,1,0,0,115,14,0,0,0,0,8,14,7, 2,1,10,1,12,2,14,5,10,1,114,136,0,0,0,99, 2,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0, 6,0,0,0,67,0,0,0,115,60,0,0,0,124,0,160, @@ -637,7 +637,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 6,108,111,97,100,101,114,218,8,112,111,114,116,105,111,110, 115,218,3,109,115,103,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,17,95,102,105,110,100,95,109,111,100, - 117,108,101,95,115,104,105,109,228,1,0,0,115,10,0,0, + 117,108,101,95,115,104,105,109,229,1,0,0,115,10,0,0, 0,0,10,14,1,16,1,4,1,22,1,114,143,0,0,0, 99,3,0,0,0,0,0,0,0,0,0,0,0,6,0,0, 0,4,0,0,0,67,0,0,0,115,166,0,0,0,124,0, @@ -704,7 +704,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,120,99,95,100,101,116,97,105,108,115,90,5,109,97,103, 105,99,114,92,0,0,0,114,2,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,13,95,99,108, - 97,115,115,105,102,121,95,112,121,99,245,1,0,0,115,28, + 97,115,115,105,102,121,95,112,121,99,246,1,0,0,115,28, 0,0,0,0,16,12,1,8,1,16,1,12,1,16,1,12, 1,10,1,12,1,8,1,16,2,8,1,16,1,16,1,114, 152,0,0,0,99,5,0,0,0,0,0,0,0,0,0,0, @@ -759,7 +759,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 122,101,114,116,0,0,0,114,151,0,0,0,114,92,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, 218,23,95,118,97,108,105,100,97,116,101,95,116,105,109,101, - 115,116,97,109,112,95,112,121,99,22,2,0,0,115,16,0, + 115,116,97,109,112,95,112,121,99,23,2,0,0,115,16,0, 0,0,0,19,24,1,10,1,12,1,16,1,8,1,22,255, 2,2,114,156,0,0,0,99,4,0,0,0,0,0,0,0, 0,0,0,0,4,0,0,0,4,0,0,0,67,0,0,0, @@ -805,7 +805,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,218,11,115,111,117,114,99,101,95,104,97,115,104,114, 116,0,0,0,114,151,0,0,0,114,5,0,0,0,114,5, 0,0,0,114,8,0,0,0,218,18,95,118,97,108,105,100, - 97,116,101,95,104,97,115,104,95,112,121,99,50,2,0,0, + 97,116,101,95,104,97,115,104,95,112,121,99,51,2,0,0, 115,12,0,0,0,0,17,16,1,2,1,8,255,4,2,2, 254,114,158,0,0,0,99,4,0,0,0,0,0,0,0,0, 0,0,0,5,0,0,0,5,0,0,0,67,0,0,0,115, @@ -829,7 +829,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,26,0,0,0,114,116,0,0,0,114,106,0,0,0,114, 107,0,0,0,218,4,99,111,100,101,114,5,0,0,0,114, 5,0,0,0,114,8,0,0,0,218,17,95,99,111,109,112, - 105,108,101,95,98,121,116,101,99,111,100,101,74,2,0,0, + 105,108,101,95,98,121,116,101,99,111,100,101,75,2,0,0, 115,18,0,0,0,0,2,10,1,10,1,12,1,8,1,12, 1,4,2,10,1,4,255,114,165,0,0,0,114,73,0,0, 0,99,3,0,0,0,0,0,0,0,0,0,0,0,4,0, @@ -848,7 +848,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,101,114,155,0,0,0,114,26,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,22,95,99,111, 100,101,95,116,111,95,116,105,109,101,115,116,97,109,112,95, - 112,121,99,87,2,0,0,115,12,0,0,0,0,2,8,1, + 112,121,99,88,2,0,0,115,12,0,0,0,0,2,8,1, 14,1,14,1,14,1,16,1,114,170,0,0,0,84,99,3, 0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,5, 0,0,0,67,0,0,0,115,80,0,0,0,116,0,116,1, @@ -866,7 +866,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,90,7,99,104,101,99,107,101,100,114,26,0,0,0,114, 2,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,17,95,99,111,100,101,95,116,111,95,104,97, - 115,104,95,112,121,99,97,2,0,0,115,14,0,0,0,0, + 115,104,95,112,121,99,98,2,0,0,115,14,0,0,0,0, 2,8,1,12,1,14,1,16,1,10,1,16,1,114,171,0, 0,0,99,1,0,0,0,0,0,0,0,0,0,0,0,5, 0,0,0,6,0,0,0,67,0,0,0,115,62,0,0,0, @@ -893,7 +893,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,100,108,105,110,101,218,8,101,110,99,111,100,105,110,103, 90,15,110,101,119,108,105,110,101,95,100,101,99,111,100,101, 114,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, - 218,13,100,101,99,111,100,101,95,115,111,117,114,99,101,108, + 218,13,100,101,99,111,100,101,95,115,111,117,114,99,101,109, 2,0,0,115,10,0,0,0,0,5,8,1,12,1,10,1, 12,1,114,176,0,0,0,169,2,114,140,0,0,0,218,26, 115,117,98,109,111,100,117,108,101,95,115,101,97,114,99,104, @@ -955,7 +955,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,182,0,0,0,90,7,100,105,114,110,97,109,101,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,23,115, 112,101,99,95,102,114,111,109,95,102,105,108,101,95,108,111, - 99,97,116,105,111,110,125,2,0,0,115,62,0,0,0,0, + 99,97,116,105,111,110,126,2,0,0,115,62,0,0,0,0, 12,8,4,4,1,10,2,2,1,14,1,12,1,8,2,10, 8,16,1,6,3,8,1,14,1,14,1,10,1,6,1,6, 2,4,3,8,2,10,1,2,1,14,1,12,1,6,2,4, @@ -992,7 +992,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 72,75,69,89,95,76,79,67,65,76,95,77,65,67,72,73, 78,69,41,2,218,3,99,108,115,114,7,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,14,95, - 111,112,101,110,95,114,101,103,105,115,116,114,121,205,2,0, + 111,112,101,110,95,114,101,103,105,115,116,114,121,206,2,0, 0,115,8,0,0,0,0,2,2,1,16,1,12,1,122,36, 87,105,110,100,111,119,115,82,101,103,105,115,116,114,121,70, 105,110,100,101,114,46,95,111,112,101,110,95,114,101,103,105, @@ -1020,7 +1020,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,90,4,104,107,101,121,218,8,102,105,108,101,112,97,116, 104,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, 218,16,95,115,101,97,114,99,104,95,114,101,103,105,115,116, - 114,121,212,2,0,0,115,24,0,0,0,0,2,6,1,8, + 114,121,213,2,0,0,115,24,0,0,0,0,2,6,1,8, 2,6,1,6,1,16,255,6,2,2,1,12,1,46,1,12, 1,8,1,122,38,87,105,110,100,111,119,115,82,101,103,105, 115,116,114,121,70,105,110,100,101,114,46,95,115,101,97,114, @@ -1042,7 +1042,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,218,6,116,97,114,103,101,116,114,199,0,0,0,114, 140,0,0,0,114,189,0,0,0,114,187,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,9,102, - 105,110,100,95,115,112,101,99,227,2,0,0,115,28,0,0, + 105,110,100,95,115,112,101,99,228,2,0,0,115,28,0,0, 0,0,2,10,1,8,1,4,1,2,1,12,1,12,1,8, 1,14,1,14,1,6,1,8,1,2,254,6,3,122,31,87, 105,110,100,111,119,115,82,101,103,105,115,116,114,121,70,105, @@ -1061,7 +1061,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 2,114,203,0,0,0,114,140,0,0,0,169,4,114,193,0, 0,0,114,139,0,0,0,114,44,0,0,0,114,187,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, - 218,11,102,105,110,100,95,109,111,100,117,108,101,243,2,0, + 218,11,102,105,110,100,95,109,111,100,117,108,101,244,2,0, 0,115,8,0,0,0,0,7,12,1,8,1,6,2,122,33, 87,105,110,100,111,119,115,82,101,103,105,115,116,114,121,70, 105,110,100,101,114,46,102,105,110,100,95,109,111,100,117,108, @@ -1071,7 +1071,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,97,115,115,109,101,116,104,111,100,114,194,0,0,0,114, 200,0,0,0,114,203,0,0,0,114,206,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,114,191,0,0,0,193,2,0,0,115,28,0,0,0, + 0,0,114,191,0,0,0,194,2,0,0,115,28,0,0,0, 8,2,4,3,2,255,2,4,2,255,2,3,4,2,2,1, 10,6,2,1,10,14,2,1,12,15,2,1,114,191,0,0, 0,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -1107,7 +1107,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 139,0,0,0,114,96,0,0,0,90,13,102,105,108,101,110, 97,109,101,95,98,97,115,101,90,9,116,97,105,108,95,110, 97,109,101,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,114,182,0,0,0,6,3,0,0,115,8,0,0,0, + 0,0,114,182,0,0,0,7,3,0,0,115,8,0,0,0, 0,3,18,1,16,1,14,1,122,24,95,76,111,97,100,101, 114,66,97,115,105,99,115,46,105,115,95,112,97,99,107,97, 103,101,99,2,0,0,0,0,0,0,0,0,0,0,0,2, @@ -1118,7 +1118,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 110,46,78,114,5,0,0,0,169,2,114,118,0,0,0,114, 187,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,13,99,114,101,97,116,101,95,109,111,100,117, - 108,101,14,3,0,0,115,2,0,0,0,0,1,122,27,95, + 108,101,15,3,0,0,115,2,0,0,0,0,1,122,27,95, 76,111,97,100,101,114,66,97,115,105,99,115,46,99,114,101, 97,116,101,95,109,111,100,117,108,101,99,2,0,0,0,0, 0,0,0,0,0,0,0,3,0,0,0,5,0,0,0,67, @@ -1138,7 +1138,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 131,0,0,0,41,3,114,118,0,0,0,218,6,109,111,100, 117,108,101,114,164,0,0,0,114,5,0,0,0,114,5,0, 0,0,114,8,0,0,0,218,11,101,120,101,99,95,109,111, - 100,117,108,101,17,3,0,0,115,12,0,0,0,0,2,12, + 100,117,108,101,18,3,0,0,115,12,0,0,0,0,2,12, 1,8,1,6,1,4,255,6,2,122,25,95,76,111,97,100, 101,114,66,97,115,105,99,115,46,101,120,101,99,95,109,111, 100,117,108,101,99,2,0,0,0,0,0,0,0,0,0,0, @@ -1149,14 +1149,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,218,17,95,108,111,97,100,95,109,111,100,117,108, 101,95,115,104,105,109,169,2,114,118,0,0,0,114,139,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,11,108,111,97,100,95,109,111,100,117,108,101,25,3, + 0,218,11,108,111,97,100,95,109,111,100,117,108,101,26,3, 0,0,115,2,0,0,0,0,2,122,25,95,76,111,97,100, 101,114,66,97,115,105,99,115,46,108,111,97,100,95,109,111, 100,117,108,101,78,41,8,114,125,0,0,0,114,124,0,0, 0,114,126,0,0,0,114,127,0,0,0,114,182,0,0,0, 114,212,0,0,0,114,217,0,0,0,114,220,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8, - 0,0,0,114,208,0,0,0,1,3,0,0,115,10,0,0, + 0,0,0,114,208,0,0,0,2,3,0,0,115,10,0,0, 0,8,2,4,3,8,8,8,3,8,8,114,208,0,0,0, 99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,3,0,0,0,64,0,0,0,115,74,0,0,0,101,0, @@ -1181,7 +1181,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,32,32,32,32,32,32,78,41,1,114,50,0,0,0,169, 2,114,118,0,0,0,114,44,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,8,0,0,0,218,10,112,97,116,104, - 95,109,116,105,109,101,32,3,0,0,115,2,0,0,0,0, + 95,109,116,105,109,101,33,3,0,0,115,2,0,0,0,0, 6,122,23,83,111,117,114,99,101,76,111,97,100,101,114,46, 112,97,116,104,95,109,116,105,109,101,99,2,0,0,0,0, 0,0,0,0,0,0,0,2,0,0,0,4,0,0,0,67, @@ -1215,7 +1215,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,46,10,32,32,32,32,32,32,32,32,114,169,0,0,0, 41,1,114,223,0,0,0,114,222,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,10,112,97,116, - 104,95,115,116,97,116,115,40,3,0,0,115,2,0,0,0, + 104,95,115,116,97,116,115,41,3,0,0,115,2,0,0,0, 0,12,122,23,83,111,117,114,99,101,76,111,97,100,101,114, 46,112,97,116,104,95,115,116,97,116,115,99,4,0,0,0, 0,0,0,0,0,0,0,0,4,0,0,0,4,0,0,0, @@ -1239,7 +1239,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,107,0,0,0,90,10,99,97,99,104,101,95,112,97,116, 104,114,26,0,0,0,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,15,95,99,97,99,104,101,95,98,121, - 116,101,99,111,100,101,54,3,0,0,115,2,0,0,0,0, + 116,101,99,111,100,101,55,3,0,0,115,2,0,0,0,0, 8,122,28,83,111,117,114,99,101,76,111,97,100,101,114,46, 95,99,97,99,104,101,95,98,121,116,101,99,111,100,101,99, 3,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0, @@ -1256,7 +1256,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 115,46,10,32,32,32,32,32,32,32,32,78,114,5,0,0, 0,41,3,114,118,0,0,0,114,44,0,0,0,114,26,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,225,0,0,0,64,3,0,0,115,2,0,0,0,0, + 0,114,225,0,0,0,65,3,0,0,115,2,0,0,0,0, 1,122,21,83,111,117,114,99,101,76,111,97,100,101,114,46, 115,101,116,95,100,97,116,97,99,2,0,0,0,0,0,0, 0,0,0,0,0,5,0,0,0,10,0,0,0,67,0,0, @@ -1277,7 +1277,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,41,5,114,118,0,0,0,114,139,0,0,0,114,44,0, 0,0,114,174,0,0,0,218,3,101,120,99,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,10,103,101,116, - 95,115,111,117,114,99,101,71,3,0,0,115,20,0,0,0, + 95,115,111,117,114,99,101,72,3,0,0,115,20,0,0,0, 0,2,10,1,2,1,14,1,14,1,4,1,2,255,4,1, 2,255,24,2,122,23,83,111,117,114,99,101,76,111,97,100, 101,114,46,103,101,116,95,115,111,117,114,99,101,114,104,0, @@ -1299,7 +1299,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 218,7,99,111,109,112,105,108,101,41,4,114,118,0,0,0, 114,26,0,0,0,114,44,0,0,0,114,230,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,14, - 115,111,117,114,99,101,95,116,111,95,99,111,100,101,81,3, + 115,111,117,114,99,101,95,116,111,95,99,111,100,101,82,3, 0,0,115,6,0,0,0,0,5,12,1,4,255,122,27,83, 111,117,114,99,101,76,111,97,100,101,114,46,115,111,117,114, 99,101,95,116,111,95,99,111,100,101,99,2,0,0,0,0, @@ -1376,7 +1376,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,26,0,0,0,114,151,0,0,0,114,2,0,0,0,90, 10,98,121,116,101,115,95,100,97,116,97,90,11,99,111,100, 101,95,111,98,106,101,99,116,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,213,0,0,0,89,3,0,0, + 0,0,114,8,0,0,0,114,213,0,0,0,90,3,0,0, 115,152,0,0,0,0,7,10,1,4,1,4,1,4,1,4, 1,4,1,2,1,12,1,12,1,12,2,2,1,14,1,12, 1,8,2,12,1,2,1,14,1,12,1,6,3,2,1,2, @@ -1393,7 +1393,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,226,0,0,0,114,225,0,0,0,114,229,0,0,0,114, 233,0,0,0,114,213,0,0,0,114,5,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,221,0, - 0,0,30,3,0,0,115,14,0,0,0,8,2,8,8,8, + 0,0,31,3,0,0,115,14,0,0,0,8,2,8,8,8, 14,8,10,8,7,8,10,14,8,114,221,0,0,0,99,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4, 0,0,0,0,0,0,0,115,124,0,0,0,101,0,90,1, @@ -1422,7 +1422,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,32,32,32,32,102,105,110,100,101,114,46,78,114,159,0, 0,0,41,3,114,118,0,0,0,114,139,0,0,0,114,44, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,114,209,0,0,0,179,3,0,0,115,4,0,0,0, + 0,0,114,209,0,0,0,180,3,0,0,115,4,0,0,0, 0,3,6,1,122,19,70,105,108,101,76,111,97,100,101,114, 46,95,95,105,110,105,116,95,95,99,2,0,0,0,0,0, 0,0,0,0,0,0,2,0,0,0,2,0,0,0,67,0, @@ -1431,7 +1431,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,0,0,0,169,2,218,9,95,95,99,108,97,115,115,95, 95,114,131,0,0,0,169,2,114,118,0,0,0,90,5,111, 116,104,101,114,114,5,0,0,0,114,5,0,0,0,114,8, - 0,0,0,218,6,95,95,101,113,95,95,185,3,0,0,115, + 0,0,0,218,6,95,95,101,113,95,95,186,3,0,0,115, 6,0,0,0,0,1,12,1,10,255,122,17,70,105,108,101, 76,111,97,100,101,114,46,95,95,101,113,95,95,99,1,0, 0,0,0,0,0,0,0,0,0,0,1,0,0,0,3,0, @@ -1440,7 +1440,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,0,0,0,169,3,218,4,104,97,115,104,114,116,0,0, 0,114,44,0,0,0,169,1,114,118,0,0,0,114,5,0, 0,0,114,5,0,0,0,114,8,0,0,0,218,8,95,95, - 104,97,115,104,95,95,189,3,0,0,115,2,0,0,0,0, + 104,97,115,104,95,95,190,3,0,0,115,2,0,0,0,0, 1,122,19,70,105,108,101,76,111,97,100,101,114,46,95,95, 104,97,115,104,95,95,99,2,0,0,0,0,0,0,0,0, 0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,115, @@ -1454,7 +1454,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,46,10,10,32,32,32,32,32,32,32,32,41,3,218,5, 115,117,112,101,114,114,239,0,0,0,114,220,0,0,0,114, 219,0,0,0,169,1,114,241,0,0,0,114,5,0,0,0, - 114,8,0,0,0,114,220,0,0,0,192,3,0,0,115,2, + 114,8,0,0,0,114,220,0,0,0,193,3,0,0,115,2, 0,0,0,0,10,122,22,70,105,108,101,76,111,97,100,101, 114,46,108,111,97,100,95,109,111,100,117,108,101,99,2,0, 0,0,0,0,0,0,0,0,0,0,2,0,0,0,1,0, @@ -1464,7 +1464,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 99,101,32,102,105,108,101,32,97,115,32,102,111,117,110,100, 32,98,121,32,116,104,101,32,102,105,110,100,101,114,46,114, 48,0,0,0,114,219,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,179,0,0,0,204,3,0, + 0,0,0,114,8,0,0,0,114,179,0,0,0,205,3,0, 0,115,2,0,0,0,0,3,122,23,70,105,108,101,76,111, 97,100,101,114,46,103,101,116,95,102,105,108,101,110,97,109, 101,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0, @@ -1486,7 +1486,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,90,4,114,101,97,100,114,65,0,0,0,41,3,114, 118,0,0,0,114,44,0,0,0,114,68,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,227,0, - 0,0,209,3,0,0,115,10,0,0,0,0,2,14,1,16, + 0,0,210,3,0,0,115,10,0,0,0,0,2,14,1,16, 1,40,2,14,1,122,19,70,105,108,101,76,111,97,100,101, 114,46,103,101,116,95,100,97,116,97,99,2,0,0,0,0, 0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,67, @@ -1495,7 +1495,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,114,182,0,0,0,169,2,114,118,0,0,0,114,216,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, 0,218,19,103,101,116,95,114,101,115,111,117,114,99,101,95, - 114,101,97,100,101,114,220,3,0,0,115,6,0,0,0,0, + 114,101,97,100,101,114,221,3,0,0,115,6,0,0,0,0, 2,10,1,4,1,122,30,70,105,108,101,76,111,97,100,101, 114,46,103,101,116,95,114,101,115,111,117,114,99,101,95,114, 101,97,100,101,114,99,2,0,0,0,0,0,0,0,0,0, @@ -1507,7 +1507,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,64,0,0,0,114,65,0,0,0,169,3,114,118,0, 0,0,90,8,114,101,115,111,117,114,99,101,114,44,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, - 218,13,111,112,101,110,95,114,101,115,111,117,114,99,101,226, + 218,13,111,112,101,110,95,114,101,115,111,117,114,99,101,227, 3,0,0,115,4,0,0,0,0,1,20,1,122,24,70,105, 108,101,76,111,97,100,101,114,46,111,112,101,110,95,114,101, 115,111,117,114,99,101,99,2,0,0,0,0,0,0,0,0, @@ -1520,7 +1520,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,114,111,114,114,38,0,0,0,114,47,0,0,0,114,44, 0,0,0,114,255,0,0,0,114,5,0,0,0,114,5,0, 0,0,114,8,0,0,0,218,13,114,101,115,111,117,114,99, - 101,95,112,97,116,104,230,3,0,0,115,8,0,0,0,0, + 101,95,112,97,116,104,231,3,0,0,115,8,0,0,0,0, 1,10,1,4,1,20,1,122,24,70,105,108,101,76,111,97, 100,101,114,46,114,101,115,111,117,114,99,101,95,112,97,116, 104,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0, @@ -1532,7 +1532,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,44,0,0,0,114,54,0,0,0,169,3,114,118,0, 0,0,114,116,0,0,0,114,44,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,2,1,0,0, - 236,3,0,0,115,8,0,0,0,0,1,8,1,4,1,20, + 237,3,0,0,115,8,0,0,0,0,1,8,1,4,1,20, 1,122,22,70,105,108,101,76,111,97,100,101,114,46,105,115, 95,114,101,115,111,117,114,99,101,99,1,0,0,0,0,0, 0,0,0,0,0,0,1,0,0,0,5,0,0,0,67,0, @@ -1542,7 +1542,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,218,7,108,105,115,116,100,105,114,114,47,0,0,0,114, 44,0,0,0,114,246,0,0,0,114,5,0,0,0,114,5, 0,0,0,114,8,0,0,0,218,8,99,111,110,116,101,110, - 116,115,242,3,0,0,115,2,0,0,0,0,1,122,19,70, + 116,115,243,3,0,0,115,2,0,0,0,0,1,122,19,70, 105,108,101,76,111,97,100,101,114,46,99,111,110,116,101,110, 116,115,41,17,114,125,0,0,0,114,124,0,0,0,114,126, 0,0,0,114,127,0,0,0,114,209,0,0,0,114,243,0, @@ -1551,7 +1551,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,0,1,0,0,114,4,1,0,0,114,2,1,0,0,114, 8,1,0,0,90,13,95,95,99,108,97,115,115,99,101,108, 108,95,95,114,5,0,0,0,114,5,0,0,0,114,249,0, - 0,0,114,8,0,0,0,114,239,0,0,0,174,3,0,0, + 0,0,114,8,0,0,0,114,239,0,0,0,175,3,0,0, 115,30,0,0,0,8,2,4,3,8,6,8,4,8,3,2, 1,14,11,2,1,10,4,8,11,2,1,10,5,8,4,8, 6,8,6,114,239,0,0,0,99,0,0,0,0,0,0,0, @@ -1574,7 +1574,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 49,0,0,0,218,8,115,116,95,109,116,105,109,101,90,7, 115,116,95,115,105,122,101,41,3,114,118,0,0,0,114,44, 0,0,0,114,238,0,0,0,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,224,0,0,0,250,3,0,0, + 0,0,114,8,0,0,0,114,224,0,0,0,251,3,0,0, 115,4,0,0,0,0,2,8,1,122,27,83,111,117,114,99, 101,70,105,108,101,76,111,97,100,101,114,46,112,97,116,104, 95,115,116,97,116,115,99,4,0,0,0,0,0,0,0,0, @@ -1585,7 +1585,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 225,0,0,0,41,5,114,118,0,0,0,114,107,0,0,0, 114,106,0,0,0,114,26,0,0,0,114,52,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,226, - 0,0,0,255,3,0,0,115,4,0,0,0,0,2,8,1, + 0,0,0,0,4,0,0,115,4,0,0,0,0,2,8,1, 122,32,83,111,117,114,99,101,70,105,108,101,76,111,97,100, 101,114,46,95,99,97,99,104,101,95,98,121,116,101,99,111, 100,101,114,60,0,0,0,114,11,1,0,0,99,3,0,0, @@ -1620,7 +1620,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,0,0,218,6,112,97,114,101,110,116,114,96,0,0,0, 114,37,0,0,0,114,33,0,0,0,114,228,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,225, - 0,0,0,4,4,0,0,115,46,0,0,0,0,2,12,1, + 0,0,0,5,4,0,0,115,46,0,0,0,0,2,12,1, 4,2,12,1,12,1,12,2,12,1,10,1,2,1,14,1, 12,2,8,1,14,3,6,1,4,255,4,2,28,1,2,1, 12,1,16,1,16,2,8,1,2,255,122,25,83,111,117,114, @@ -1629,7 +1629,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,114,126,0,0,0,114,127,0,0,0,114,224,0,0, 0,114,226,0,0,0,114,225,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 9,1,0,0,246,3,0,0,115,8,0,0,0,8,2,4, + 9,1,0,0,247,3,0,0,115,8,0,0,0,8,2,4, 2,8,5,8,5,114,9,1,0,0,99,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,64, 0,0,0,115,32,0,0,0,101,0,90,1,100,0,90,2, @@ -1651,7 +1651,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,235,0,0,0,41,5,114,118,0,0,0,114,139,0,0, 0,114,44,0,0,0,114,26,0,0,0,114,151,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 213,0,0,0,39,4,0,0,115,22,0,0,0,0,1,10, + 213,0,0,0,40,4,0,0,115,22,0,0,0,0,1,10, 1,10,4,2,1,2,254,6,4,12,1,2,1,14,1,2, 1,2,253,122,29,83,111,117,114,99,101,108,101,115,115,70, 105,108,101,76,111,97,100,101,114,46,103,101,116,95,99,111, @@ -1661,14 +1661,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 111,110,101,32,97,115,32,116,104,101,114,101,32,105,115,32, 110,111,32,115,111,117,114,99,101,32,99,111,100,101,46,78, 114,5,0,0,0,114,219,0,0,0,114,5,0,0,0,114, - 5,0,0,0,114,8,0,0,0,114,229,0,0,0,55,4, + 5,0,0,0,114,8,0,0,0,114,229,0,0,0,56,4, 0,0,115,2,0,0,0,0,2,122,31,83,111,117,114,99, 101,108,101,115,115,70,105,108,101,76,111,97,100,101,114,46, 103,101,116,95,115,111,117,114,99,101,78,41,6,114,125,0, 0,0,114,124,0,0,0,114,126,0,0,0,114,127,0,0, 0,114,213,0,0,0,114,229,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 15,1,0,0,35,4,0,0,115,6,0,0,0,8,2,4, + 15,1,0,0,36,4,0,0,115,6,0,0,0,8,2,4, 2,8,16,114,15,1,0,0,99,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,3,0,0,0,64,0,0, 0,115,92,0,0,0,101,0,90,1,100,0,90,2,100,1, @@ -1688,7 +1688,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,115,16,0,0,0,124,1,124,0,95,0,124,2,124,0, 95,1,100,0,83,0,114,109,0,0,0,114,159,0,0,0, 114,5,1,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,209,0,0,0,72,4,0,0,115,4,0, + 8,0,0,0,114,209,0,0,0,73,4,0,0,115,4,0, 0,0,0,1,6,1,122,28,69,120,116,101,110,115,105,111, 110,70,105,108,101,76,111,97,100,101,114,46,95,95,105,110, 105,116,95,95,99,2,0,0,0,0,0,0,0,0,0,0, @@ -1696,7 +1696,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,124,0,106,0,124,1,106,0,107,2,111,22,124,0, 106,1,124,1,106,1,107,2,83,0,114,109,0,0,0,114, 240,0,0,0,114,242,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,243,0,0,0,76,4,0, + 0,0,0,114,8,0,0,0,114,243,0,0,0,77,4,0, 0,115,6,0,0,0,0,1,12,1,10,255,122,26,69,120, 116,101,110,115,105,111,110,70,105,108,101,76,111,97,100,101, 114,46,95,95,101,113,95,95,99,1,0,0,0,0,0,0, @@ -1704,7 +1704,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,115,20,0,0,0,116,0,124,0,106,1,131,1,116,0, 124,0,106,2,131,1,65,0,83,0,114,109,0,0,0,114, 244,0,0,0,114,246,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,247,0,0,0,80,4,0, + 0,0,0,114,8,0,0,0,114,247,0,0,0,81,4,0, 0,115,2,0,0,0,0,1,122,28,69,120,116,101,110,115, 105,111,110,70,105,108,101,76,111,97,100,101,114,46,95,95, 104,97,115,104,95,95,99,2,0,0,0,0,0,0,0,0, @@ -1721,7 +1721,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,116,101,95,100,121,110,97,109,105,99,114,149,0,0,0, 114,116,0,0,0,114,44,0,0,0,41,3,114,118,0,0, 0,114,187,0,0,0,114,216,0,0,0,114,5,0,0,0, - 114,5,0,0,0,114,8,0,0,0,114,212,0,0,0,83, + 114,5,0,0,0,114,8,0,0,0,114,212,0,0,0,84, 4,0,0,115,14,0,0,0,0,2,4,1,6,255,4,2, 6,1,8,255,4,2,122,33,69,120,116,101,110,115,105,111, 110,70,105,108,101,76,111,97,100,101,114,46,99,114,101,97, @@ -1738,7 +1738,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 214,0,0,0,114,163,0,0,0,90,12,101,120,101,99,95, 100,121,110,97,109,105,99,114,149,0,0,0,114,116,0,0, 0,114,44,0,0,0,114,253,0,0,0,114,5,0,0,0, - 114,5,0,0,0,114,8,0,0,0,114,217,0,0,0,91, + 114,5,0,0,0,114,8,0,0,0,114,217,0,0,0,92, 4,0,0,115,8,0,0,0,0,2,14,1,6,1,8,255, 122,31,69,120,116,101,110,115,105,111,110,70,105,108,101,76, 111,97,100,101,114,46,101,120,101,99,95,109,111,100,117,108, @@ -1757,7 +1757,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,169,2,114,32,0,0,0,218,6,115,117,102,102,105, 120,169,1,90,9,102,105,108,101,95,110,97,109,101,114,5, 0,0,0,114,8,0,0,0,218,9,60,103,101,110,101,120, - 112,114,62,100,4,0,0,115,4,0,0,0,4,1,2,255, + 112,114,62,101,4,0,0,115,4,0,0,0,4,1,2,255, 122,49,69,120,116,101,110,115,105,111,110,70,105,108,101,76, 111,97,100,101,114,46,105,115,95,112,97,99,107,97,103,101, 46,60,108,111,99,97,108,115,62,46,60,103,101,110,101,120, @@ -1765,7 +1765,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 3,97,110,121,218,18,69,88,84,69,78,83,73,79,78,95, 83,85,70,70,73,88,69,83,114,219,0,0,0,114,5,0, 0,0,114,18,1,0,0,114,8,0,0,0,114,182,0,0, - 0,97,4,0,0,115,8,0,0,0,0,2,14,1,12,1, + 0,98,4,0,0,115,8,0,0,0,0,2,14,1,12,1, 2,255,122,30,69,120,116,101,110,115,105,111,110,70,105,108, 101,76,111,97,100,101,114,46,105,115,95,112,97,99,107,97, 103,101,99,2,0,0,0,0,0,0,0,0,0,0,0,2, @@ -1776,7 +1776,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 116,32,99,114,101,97,116,101,32,97,32,99,111,100,101,32, 111,98,106,101,99,116,46,78,114,5,0,0,0,114,219,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,213,0,0,0,103,4,0,0,115,2,0,0,0,0, + 0,114,213,0,0,0,104,4,0,0,115,2,0,0,0,0, 2,122,28,69,120,116,101,110,115,105,111,110,70,105,108,101, 76,111,97,100,101,114,46,103,101,116,95,99,111,100,101,99, 2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0, @@ -1786,14 +1786,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,117,108,101,115,32,104,97,118,101,32,110,111,32,115,111, 117,114,99,101,32,99,111,100,101,46,78,114,5,0,0,0, 114,219,0,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,229,0,0,0,107,4,0,0,115,2,0, + 8,0,0,0,114,229,0,0,0,108,4,0,0,115,2,0, 0,0,0,2,122,30,69,120,116,101,110,115,105,111,110,70, 105,108,101,76,111,97,100,101,114,46,103,101,116,95,115,111, 117,114,99,101,99,2,0,0,0,0,0,0,0,0,0,0, 0,2,0,0,0,1,0,0,0,67,0,0,0,115,6,0, 0,0,124,0,106,0,83,0,114,250,0,0,0,114,48,0, 0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,179,0,0,0,111,4,0,0,115, + 0,114,8,0,0,0,114,179,0,0,0,112,4,0,0,115, 2,0,0,0,0,3,122,32,69,120,116,101,110,115,105,111, 110,70,105,108,101,76,111,97,100,101,114,46,103,101,116,95, 102,105,108,101,110,97,109,101,78,41,14,114,125,0,0,0, @@ -1802,7 +1802,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,217,0,0,0,114,182,0,0,0,114,213,0, 0,0,114,229,0,0,0,114,136,0,0,0,114,179,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,5,0,0,0, - 114,8,0,0,0,114,252,0,0,0,64,4,0,0,115,22, + 114,8,0,0,0,114,252,0,0,0,65,4,0,0,115,22, 0,0,0,8,2,4,6,8,4,8,4,8,3,8,8,8, 6,8,6,8,4,8,4,2,1,114,252,0,0,0,99,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2, @@ -1845,7 +1845,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 169,4,114,118,0,0,0,114,116,0,0,0,114,44,0,0, 0,90,11,112,97,116,104,95,102,105,110,100,101,114,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,209,0, - 0,0,124,4,0,0,115,8,0,0,0,0,1,6,1,6, + 0,0,125,4,0,0,115,8,0,0,0,0,1,6,1,6, 1,14,1,122,23,95,78,97,109,101,115,112,97,99,101,80, 97,116,104,46,95,95,105,110,105,116,95,95,99,1,0,0, 0,0,0,0,0,0,0,0,0,4,0,0,0,3,0,0, @@ -1862,7 +1862,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,118,0,0,0,114,14,1,0,0,218,3,100,111,116,90, 2,109,101,114,5,0,0,0,114,5,0,0,0,114,8,0, 0,0,218,23,95,102,105,110,100,95,112,97,114,101,110,116, - 95,112,97,116,104,95,110,97,109,101,115,130,4,0,0,115, + 95,112,97,116,104,95,110,97,109,101,115,131,4,0,0,115, 8,0,0,0,0,2,18,1,8,2,4,3,122,38,95,78, 97,109,101,115,112,97,99,101,80,97,116,104,46,95,102,105, 110,100,95,112,97,114,101,110,116,95,112,97,116,104,95,110, @@ -1875,7 +1875,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 118,0,0,0,90,18,112,97,114,101,110,116,95,109,111,100, 117,108,101,95,110,97,109,101,90,14,112,97,116,104,95,97, 116,116,114,95,110,97,109,101,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,25,1,0,0,140,4,0,0, + 0,0,114,8,0,0,0,114,25,1,0,0,141,4,0,0, 115,4,0,0,0,0,1,12,1,122,31,95,78,97,109,101, 115,112,97,99,101,80,97,116,104,46,95,103,101,116,95,112, 97,114,101,110,116,95,112,97,116,104,99,1,0,0,0,0, @@ -1891,7 +1891,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,114,24,1,0,0,41,3,114,118,0,0,0,90,11, 112,97,114,101,110,116,95,112,97,116,104,114,187,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218, - 12,95,114,101,99,97,108,99,117,108,97,116,101,144,4,0, + 12,95,114,101,99,97,108,99,117,108,97,116,101,145,4,0, 0,115,16,0,0,0,0,2,12,1,10,1,14,3,18,1, 6,1,8,1,6,1,122,27,95,78,97,109,101,115,112,97, 99,101,80,97,116,104,46,95,114,101,99,97,108,99,117,108, @@ -1900,7 +1900,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,116,0,124,0,160,1,161,0,131,1,83,0,114,109,0, 0,0,41,2,114,6,1,0,0,114,32,1,0,0,114,246, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,218,8,95,95,105,116,101,114,95,95,157,4,0,0, + 0,0,218,8,95,95,105,116,101,114,95,95,158,4,0,0, 115,2,0,0,0,0,1,122,23,95,78,97,109,101,115,112, 97,99,101,80,97,116,104,46,95,95,105,116,101,114,95,95, 99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0, @@ -1909,7 +1909,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,114,32,1,0,0,41,2,114,118,0,0,0,218,5,105, 110,100,101,120,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,11,95,95,103,101,116,105,116,101,109,95,95, - 160,4,0,0,115,2,0,0,0,0,1,122,26,95,78,97, + 161,4,0,0,115,2,0,0,0,0,1,122,26,95,78,97, 109,101,115,112,97,99,101,80,97,116,104,46,95,95,103,101, 116,105,116,101,109,95,95,99,3,0,0,0,0,0,0,0, 0,0,0,0,3,0,0,0,3,0,0,0,67,0,0,0, @@ -1917,7 +1917,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,83,0,114,109,0,0,0,41,1,114,24,1,0,0,41, 3,114,118,0,0,0,114,35,1,0,0,114,44,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218, - 11,95,95,115,101,116,105,116,101,109,95,95,163,4,0,0, + 11,95,95,115,101,116,105,116,101,109,95,95,164,4,0,0, 115,2,0,0,0,0,1,122,26,95,78,97,109,101,115,112, 97,99,101,80,97,116,104,46,95,95,115,101,116,105,116,101, 109,95,95,99,1,0,0,0,0,0,0,0,0,0,0,0, @@ -1925,7 +1925,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,116,0,124,0,160,1,161,0,131,1,83,0,114,109,0, 0,0,41,2,114,23,0,0,0,114,32,1,0,0,114,246, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,218,7,95,95,108,101,110,95,95,166,4,0,0,115, + 0,0,218,7,95,95,108,101,110,95,95,167,4,0,0,115, 2,0,0,0,0,1,122,22,95,78,97,109,101,115,112,97, 99,101,80,97,116,104,46,95,95,108,101,110,95,95,99,1, 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,3, @@ -1934,7 +1934,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,101,115,112,97,99,101,80,97,116,104,40,123,33,114,125, 41,41,2,114,62,0,0,0,114,24,1,0,0,114,246,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,8,95,95,114,101,112,114,95,95,169,4,0,0,115, + 0,218,8,95,95,114,101,112,114,95,95,170,4,0,0,115, 2,0,0,0,0,1,122,23,95,78,97,109,101,115,112,97, 99,101,80,97,116,104,46,95,95,114,101,112,114,95,95,99, 2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0, @@ -1942,7 +1942,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,160,0,161,0,118,0,83,0,114,109,0,0,0,114,34, 1,0,0,169,2,114,118,0,0,0,218,4,105,116,101,109, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218, - 12,95,95,99,111,110,116,97,105,110,115,95,95,172,4,0, + 12,95,95,99,111,110,116,97,105,110,115,95,95,173,4,0, 0,115,2,0,0,0,0,1,122,27,95,78,97,109,101,115, 112,97,99,101,80,97,116,104,46,95,95,99,111,110,116,97, 105,110,115,95,95,99,2,0,0,0,0,0,0,0,0,0, @@ -1950,7 +1950,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,124,0,106,0,160,1,124,1,161,1,1,0,100, 0,83,0,114,109,0,0,0,41,2,114,24,1,0,0,114, 186,0,0,0,114,40,1,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,186,0,0,0,175,4,0, + 0,0,0,114,8,0,0,0,114,186,0,0,0,176,4,0, 0,115,2,0,0,0,0,1,122,21,95,78,97,109,101,115, 112,97,99,101,80,97,116,104,46,97,112,112,101,110,100,78, 41,15,114,125,0,0,0,114,124,0,0,0,114,126,0,0, @@ -1959,7 +1959,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 36,1,0,0,114,37,1,0,0,114,38,1,0,0,114,39, 1,0,0,114,42,1,0,0,114,186,0,0,0,114,5,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,22,1,0,0,117,4,0,0,115,24,0,0,0,8, + 0,114,22,1,0,0,118,4,0,0,115,24,0,0,0,8, 1,4,6,8,6,8,10,8,4,8,13,8,3,8,3,8, 3,8,3,8,3,8,3,114,22,1,0,0,99,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0, @@ -1975,7 +1975,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 124,2,124,3,131,3,124,0,95,1,100,0,83,0,114,109, 0,0,0,41,2,114,22,1,0,0,114,24,1,0,0,114, 28,1,0,0,114,5,0,0,0,114,5,0,0,0,114,8, - 0,0,0,114,209,0,0,0,181,4,0,0,115,2,0,0, + 0,0,0,114,209,0,0,0,182,4,0,0,115,2,0,0, 0,0,1,122,25,95,78,97,109,101,115,112,97,99,101,76, 111,97,100,101,114,46,95,95,105,110,105,116,95,95,99,2, 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,3, @@ -1992,21 +1992,21 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,109,101,115,112,97,99,101,41,62,41,2,114,62,0,0, 0,114,125,0,0,0,41,2,114,193,0,0,0,114,216,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,11,109,111,100,117,108,101,95,114,101,112,114,184,4, + 0,218,11,109,111,100,117,108,101,95,114,101,112,114,185,4, 0,0,115,2,0,0,0,0,7,122,28,95,78,97,109,101, 115,112,97,99,101,76,111,97,100,101,114,46,109,111,100,117, 108,101,95,114,101,112,114,99,2,0,0,0,0,0,0,0, 0,0,0,0,2,0,0,0,1,0,0,0,67,0,0,0, 115,4,0,0,0,100,1,83,0,41,2,78,84,114,5,0, 0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,182,0,0,0,193,4,0,0,115, + 0,114,8,0,0,0,114,182,0,0,0,194,4,0,0,115, 2,0,0,0,0,1,122,27,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,105,115,95,112,97,99,107, 97,103,101,99,2,0,0,0,0,0,0,0,0,0,0,0, 2,0,0,0,1,0,0,0,67,0,0,0,115,4,0,0, 0,100,1,83,0,41,2,78,114,40,0,0,0,114,5,0, 0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,229,0,0,0,196,4,0,0,115, + 0,114,8,0,0,0,114,229,0,0,0,197,4,0,0,115, 2,0,0,0,0,1,122,27,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,103,101,116,95,115,111,117, 114,99,101,99,2,0,0,0,0,0,0,0,0,0,0,0, @@ -2016,20 +2016,20 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 110,103,62,114,215,0,0,0,84,41,1,114,231,0,0,0, 41,1,114,232,0,0,0,114,219,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,213,0,0,0, - 199,4,0,0,115,2,0,0,0,0,1,122,25,95,78,97, + 200,4,0,0,115,2,0,0,0,0,1,122,25,95,78,97, 109,101,115,112,97,99,101,76,111,97,100,101,114,46,103,101, 116,95,99,111,100,101,99,2,0,0,0,0,0,0,0,0, 0,0,0,2,0,0,0,1,0,0,0,67,0,0,0,115, 4,0,0,0,100,1,83,0,114,210,0,0,0,114,5,0, 0,0,114,211,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,212,0,0,0,202,4,0,0,115, + 0,114,8,0,0,0,114,212,0,0,0,203,4,0,0,115, 2,0,0,0,0,1,122,30,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,99,114,101,97,116,101,95, 109,111,100,117,108,101,99,2,0,0,0,0,0,0,0,0, 0,0,0,2,0,0,0,1,0,0,0,67,0,0,0,115, 4,0,0,0,100,0,83,0,114,109,0,0,0,114,5,0, 0,0,114,253,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,217,0,0,0,205,4,0,0,115, + 0,114,8,0,0,0,114,217,0,0,0,206,4,0,0,115, 2,0,0,0,0,1,122,28,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,101,120,101,99,95,109,111, 100,117,108,101,99,2,0,0,0,0,0,0,0,0,0,0, @@ -2047,7 +2047,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,112,97,116,104,32,123,33,114,125,41,4,114,134,0,0, 0,114,149,0,0,0,114,24,1,0,0,114,218,0,0,0, 114,219,0,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,220,0,0,0,208,4,0,0,115,8,0, + 8,0,0,0,114,220,0,0,0,209,4,0,0,115,8,0, 0,0,0,7,6,1,4,255,4,2,122,28,95,78,97,109, 101,115,112,97,99,101,76,111,97,100,101,114,46,108,111,97, 100,95,109,111,100,117,108,101,78,41,12,114,125,0,0,0, @@ -2056,7 +2056,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,213,0,0,0,114,212,0,0,0,114,217,0, 0,0,114,220,0,0,0,114,5,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,43,1,0,0, - 180,4,0,0,115,18,0,0,0,8,1,8,3,2,1,10, + 181,4,0,0,115,18,0,0,0,8,1,8,3,2,1,10, 8,8,3,8,3,8,3,8,3,8,3,114,43,1,0,0, 99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,4,0,0,0,64,0,0,0,115,118,0,0,0,101,0, @@ -2093,7 +2093,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,46,1,0,0,41,3,114,193,0,0,0,114, 116,0,0,0,218,6,102,105,110,100,101,114,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,46,1,0,0, - 226,4,0,0,115,10,0,0,0,0,4,22,1,8,1,10, + 227,4,0,0,115,10,0,0,0,0,4,22,1,8,1,10, 1,10,1,122,28,80,97,116,104,70,105,110,100,101,114,46, 105,110,118,97,108,105,100,97,116,101,95,99,97,99,104,101, 115,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0, @@ -2113,7 +2113,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 117,0,0,0,41,3,114,193,0,0,0,114,44,0,0,0, 90,4,104,111,111,107,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,11,95,112,97,116,104,95,104,111,111, - 107,115,236,4,0,0,115,16,0,0,0,0,3,16,1,12, + 107,115,237,4,0,0,115,16,0,0,0,0,3,16,1,12, 1,10,1,2,1,14,1,12,1,12,2,122,22,80,97,116, 104,70,105,110,100,101,114,46,95,112,97,116,104,95,104,111, 111,107,115,99,2,0,0,0,0,0,0,0,0,0,0,0, @@ -2144,7 +2144,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,114,44,0,0,0,114,50,1,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,20,95,112,97, 116,104,95,105,109,112,111,114,116,101,114,95,99,97,99,104, - 101,249,4,0,0,115,22,0,0,0,0,8,8,1,2,1, + 101,250,4,0,0,115,22,0,0,0,0,8,8,1,2,1, 12,1,12,3,8,1,2,1,14,1,12,1,10,1,16,1, 122,31,80,97,116,104,70,105,110,100,101,114,46,95,112,97, 116,104,95,105,109,112,111,114,116,101,114,95,99,97,99,104, @@ -2161,7 +2161,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,193,0,0,0,114,139,0,0,0,114,50,1,0,0,114, 140,0,0,0,114,141,0,0,0,114,187,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,16,95, - 108,101,103,97,99,121,95,103,101,116,95,115,112,101,99,15, + 108,101,103,97,99,121,95,103,101,116,95,115,112,101,99,16, 5,0,0,115,18,0,0,0,0,4,10,1,16,2,10,1, 4,1,8,1,12,1,12,1,6,1,122,27,80,97,116,104, 70,105,110,100,101,114,46,95,108,101,103,97,99,121,95,103, @@ -2193,7 +2193,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 95,112,97,116,104,90,5,101,110,116,114,121,114,50,1,0, 0,114,187,0,0,0,114,141,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,8,0,0,0,218,9,95,103,101,116, - 95,115,112,101,99,30,5,0,0,115,40,0,0,0,0,5, + 95,115,112,101,99,31,5,0,0,115,40,0,0,0,0,5, 4,1,8,1,14,1,2,1,10,1,8,1,10,1,14,2, 12,1,8,1,2,1,10,1,8,1,6,1,8,1,8,5, 12,2,12,1,6,1,122,20,80,97,116,104,70,105,110,100, @@ -2220,7 +2220,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,22,1,0,0,41,6,114,193,0,0,0,114,139,0,0, 0,114,44,0,0,0,114,202,0,0,0,114,187,0,0,0, 114,57,1,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,203,0,0,0,62,5,0,0,115,26,0, + 8,0,0,0,114,203,0,0,0,63,5,0,0,115,26,0, 0,0,0,6,8,1,6,1,14,1,8,1,4,1,10,1, 6,1,4,3,6,1,16,1,4,2,6,2,122,20,80,97, 116,104,70,105,110,100,101,114,46,102,105,110,100,95,115,112, @@ -2240,7 +2240,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 110,100,95,115,112,101,99,40,41,32,105,110,115,116,101,97, 100,46,10,10,32,32,32,32,32,32,32,32,78,114,204,0, 0,0,114,205,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,206,0,0,0,86,5,0,0,115, + 0,114,8,0,0,0,114,206,0,0,0,87,5,0,0,115, 8,0,0,0,0,8,12,1,8,1,4,1,122,22,80,97, 116,104,70,105,110,100,101,114,46,102,105,110,100,95,109,111, 100,117,108,101,99,1,0,0,0,0,0,0,0,0,0,0, @@ -2272,7 +2272,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,95,100,105,115,116,114,105,98,117,116,105,111,110,115,41, 4,114,193,0,0,0,114,119,0,0,0,114,120,0,0,0, 114,59,1,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,60,1,0,0,99,5,0,0,115,4,0, + 8,0,0,0,114,60,1,0,0,100,5,0,0,115,4,0, 0,0,0,10,12,1,122,29,80,97,116,104,70,105,110,100, 101,114,46,102,105,110,100,95,100,105,115,116,114,105,98,117, 116,105,111,110,115,41,1,78,41,2,78,78,41,1,78,41, @@ -2281,7 +2281,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 52,1,0,0,114,54,1,0,0,114,55,1,0,0,114,58, 1,0,0,114,203,0,0,0,114,206,0,0,0,114,60,1, 0,0,114,5,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,45,1,0,0,222,4,0,0,115, + 0,114,8,0,0,0,114,45,1,0,0,223,4,0,0,115, 34,0,0,0,8,2,4,2,2,1,10,9,2,1,10,12, 2,1,10,21,2,1,10,14,2,1,12,31,2,1,12,23, 2,1,12,12,2,1,114,45,1,0,0,99,0,0,0,0, @@ -2326,7 +2326,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 14,125,1,124,1,136,0,102,2,86,0,1,0,113,2,100, 0,83,0,114,109,0,0,0,114,5,0,0,0,114,16,1, 0,0,169,1,114,140,0,0,0,114,5,0,0,0,114,8, - 0,0,0,114,19,1,0,0,128,5,0,0,243,0,0,0, + 0,0,0,114,19,1,0,0,129,5,0,0,243,0,0,0, 0,122,38,70,105,108,101,70,105,110,100,101,114,46,95,95, 105,110,105,116,95,95,46,60,108,111,99,97,108,115,62,46, 60,103,101,110,101,120,112,114,62,114,71,0,0,0,114,104, @@ -2338,7 +2338,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,118,0,0,0,114,44,0,0,0,218,14,108,111,97,100, 101,114,95,100,101,116,97,105,108,115,90,7,108,111,97,100, 101,114,115,114,189,0,0,0,114,5,0,0,0,114,62,1, - 0,0,114,8,0,0,0,114,209,0,0,0,122,5,0,0, + 0,0,114,8,0,0,0,114,209,0,0,0,123,5,0,0, 115,16,0,0,0,0,4,4,1,12,1,26,1,6,2,10, 1,6,1,8,1,122,19,70,105,108,101,70,105,110,100,101, 114,46,95,95,105,110,105,116,95,95,99,1,0,0,0,0, @@ -2348,7 +2348,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,116,104,101,32,100,105,114,101,99,116,111,114,121,32,109, 116,105,109,101,46,114,104,0,0,0,78,41,1,114,65,1, 0,0,114,246,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,46,1,0,0,136,5,0,0,115, + 0,114,8,0,0,0,114,46,1,0,0,137,5,0,0,115, 2,0,0,0,0,2,122,28,70,105,108,101,70,105,110,100, 101,114,46,105,110,118,97,108,105,100,97,116,101,95,99,97, 99,104,101,115,99,2,0,0,0,0,0,0,0,0,0,0, @@ -2371,7 +2371,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,32,32,32,32,78,41,3,114,203,0,0,0,114,140,0, 0,0,114,178,0,0,0,41,3,114,118,0,0,0,114,139, 0,0,0,114,187,0,0,0,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,137,0,0,0,142,5,0,0, + 0,0,114,8,0,0,0,114,137,0,0,0,143,5,0,0, 115,8,0,0,0,0,7,10,1,8,1,8,1,122,22,70, 105,108,101,70,105,110,100,101,114,46,102,105,110,100,95,108, 111,97,100,101,114,99,6,0,0,0,0,0,0,0,0,0, @@ -2382,7 +2382,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,188,0,0,0,114,139,0,0,0,114,44,0, 0,0,90,4,115,109,115,108,114,202,0,0,0,114,140,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,58,1,0,0,154,5,0,0,115,8,0,0,0,0, + 0,114,58,1,0,0,155,5,0,0,115,8,0,0,0,0, 1,10,1,8,1,2,255,122,20,70,105,108,101,70,105,110, 100,101,114,46,95,103,101,116,95,115,112,101,99,78,99,3, 0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,8, @@ -2436,7 +2436,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 104,114,17,1,0,0,114,188,0,0,0,90,13,105,110,105, 116,95,102,105,108,101,110,97,109,101,90,9,102,117,108,108, 95,112,97,116,104,114,187,0,0,0,114,5,0,0,0,114, - 5,0,0,0,114,8,0,0,0,114,203,0,0,0,159,5, + 5,0,0,0,114,8,0,0,0,114,203,0,0,0,160,5, 0,0,115,72,0,0,0,0,5,4,1,14,1,2,1,24, 1,12,1,10,1,10,1,8,1,6,2,6,1,6,1,10, 2,6,1,4,2,8,1,12,1,14,1,8,1,10,1,8, @@ -2468,7 +2468,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 161,0,146,2,113,4,83,0,114,5,0,0,0,41,1,114, 105,0,0,0,41,2,114,32,0,0,0,90,2,102,110,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,9, - 60,115,101,116,99,111,109,112,62,236,5,0,0,114,63,1, + 60,115,101,116,99,111,109,112,62,237,5,0,0,114,63,1, 0,0,122,41,70,105,108,101,70,105,110,100,101,114,46,95, 102,105,108,108,95,99,97,99,104,101,46,60,108,111,99,97, 108,115,62,46,60,115,101,116,99,111,109,112,62,78,41,18, @@ -2484,7 +2484,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 102,102,105,120,95,99,111,110,116,101,110,116,115,114,41,1, 0,0,114,116,0,0,0,114,29,1,0,0,114,17,1,0, 0,90,8,110,101,119,95,110,97,109,101,114,5,0,0,0, - 114,5,0,0,0,114,8,0,0,0,114,70,1,0,0,207, + 114,5,0,0,0,114,8,0,0,0,114,70,1,0,0,208, 5,0,0,115,34,0,0,0,0,2,6,1,2,1,22,1, 18,3,10,3,12,1,12,7,6,1,8,1,16,1,4,1, 18,2,4,1,12,1,6,1,12,1,122,22,70,105,108,101, @@ -2523,14 +2523,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,48,0,0,0,169,2,114,193,0,0,0,114,69,1, 0,0,114,5,0,0,0,114,8,0,0,0,218,24,112,97, 116,104,95,104,111,111,107,95,102,111,114,95,70,105,108,101, - 70,105,110,100,101,114,248,5,0,0,115,6,0,0,0,0, + 70,105,110,100,101,114,249,5,0,0,115,6,0,0,0,0, 2,8,1,12,1,122,54,70,105,108,101,70,105,110,100,101, 114,46,112,97,116,104,95,104,111,111,107,46,60,108,111,99, 97,108,115,62,46,112,97,116,104,95,104,111,111,107,95,102, 111,114,95,70,105,108,101,70,105,110,100,101,114,114,5,0, 0,0,41,3,114,193,0,0,0,114,69,1,0,0,114,76, 1,0,0,114,5,0,0,0,114,75,1,0,0,114,8,0, - 0,0,218,9,112,97,116,104,95,104,111,111,107,238,5,0, + 0,0,218,9,112,97,116,104,95,104,111,111,107,239,5,0, 0,115,4,0,0,0,0,10,14,6,122,20,70,105,108,101, 70,105,110,100,101,114,46,112,97,116,104,95,104,111,111,107, 99,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0, @@ -2539,7 +2539,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 105,108,101,70,105,110,100,101,114,40,123,33,114,125,41,41, 2,114,62,0,0,0,114,44,0,0,0,114,246,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 39,1,0,0,0,6,0,0,115,2,0,0,0,0,1,122, + 39,1,0,0,1,6,0,0,115,2,0,0,0,0,1,122, 19,70,105,108,101,70,105,110,100,101,114,46,95,95,114,101, 112,114,95,95,41,1,78,41,15,114,125,0,0,0,114,124, 0,0,0,114,126,0,0,0,114,127,0,0,0,114,209,0, @@ -2547,7 +2547,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,137,0,0,0,114,58,1,0,0,114,203,0,0,0, 114,70,1,0,0,114,207,0,0,0,114,77,1,0,0,114, 39,1,0,0,114,5,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,61,1,0,0,113,5,0, + 0,0,0,114,8,0,0,0,114,61,1,0,0,114,5,0, 0,115,22,0,0,0,8,2,4,7,8,14,8,4,4,2, 8,12,8,5,10,48,8,31,2,1,10,17,114,61,1,0, 0,99,4,0,0,0,0,0,0,0,0,0,0,0,6,0, @@ -2571,7 +2571,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 99,112,97,116,104,110,97,109,101,114,140,0,0,0,114,187, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, 0,0,218,14,95,102,105,120,95,117,112,95,109,111,100,117, - 108,101,6,6,0,0,115,34,0,0,0,0,2,10,1,10, + 108,101,7,6,0,0,115,34,0,0,0,0,2,10,1,10, 1,4,1,4,1,8,1,8,1,12,2,10,1,4,1,14, 1,2,1,8,1,8,1,8,1,12,1,12,2,114,82,1, 0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,3, @@ -2591,7 +2591,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 10,101,120,116,101,110,115,105,111,110,115,90,6,115,111,117, 114,99,101,90,8,98,121,116,101,99,111,100,101,114,5,0, 0,0,114,5,0,0,0,114,8,0,0,0,114,184,0,0, - 0,29,6,0,0,115,8,0,0,0,0,5,12,1,8,1, + 0,30,6,0,0,115,8,0,0,0,0,5,12,1,8,1, 8,1,114,184,0,0,0,99,1,0,0,0,0,0,0,0, 0,0,0,0,10,0,0,0,9,0,0,0,67,0,0,0, 115,132,1,0,0,124,0,97,0,116,0,106,1,97,1,116, @@ -2639,7 +2639,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,83,0,41,2,114,39,0,0,0,78,41,1,114,23,0, 0,0,41,2,114,32,0,0,0,114,94,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,19,1, - 0,0,58,6,0,0,114,63,1,0,0,122,25,95,115,101, + 0,0,59,6,0,0,114,63,1,0,0,122,25,95,115,101, 116,117,112,46,60,108,111,99,97,108,115,62,46,60,103,101, 110,101,120,112,114,62,114,73,0,0,0,122,30,105,109,112, 111,114,116,108,105,98,32,114,101,113,117,105,114,101,115,32, @@ -2651,7 +2651,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 157,2,146,2,113,4,83,0,41,1,114,74,0,0,0,114, 5,0,0,0,41,2,114,32,0,0,0,218,1,115,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,71,1, - 0,0,75,6,0,0,114,63,1,0,0,122,25,95,115,101, + 0,0,76,6,0,0,114,63,1,0,0,122,25,95,115,101, 116,117,112,46,60,108,111,99,97,108,115,62,46,60,115,101, 116,99,111,109,112,62,41,3,114,64,0,0,0,114,75,0, 0,0,114,160,0,0,0,114,192,0,0,0,114,9,0,0, @@ -2671,7 +2671,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,116,105,110,95,110,97,109,101,115,90,12,98,117,105,108, 116,105,110,95,110,97,109,101,90,14,98,117,105,108,116,105, 110,95,109,111,100,117,108,101,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,218,6,95,115,101,116,117,112,40, + 0,0,114,8,0,0,0,218,6,95,115,101,116,117,112,41, 6,0,0,115,70,0,0,0,0,8,4,1,6,1,6,2, 10,3,22,1,12,2,22,1,8,1,10,1,10,1,6,2, 2,1,10,1,10,1,12,1,12,2,8,2,12,1,12,1, @@ -2691,7 +2691,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 104,114,186,0,0,0,114,45,1,0,0,41,2,114,88,1, 0,0,90,17,115,117,112,112,111,114,116,101,100,95,108,111, 97,100,101,114,115,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,218,8,95,105,110,115,116,97,108,108,97,6, + 8,0,0,0,218,8,95,105,110,115,116,97,108,108,98,6, 0,0,115,8,0,0,0,0,2,8,1,6,1,20,1,114, 91,1,0,0,41,1,114,60,0,0,0,41,1,78,41,3, 78,78,78,41,2,114,73,0,0,0,114,73,0,0,0,41, @@ -2725,7 +2725,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 218,8,60,109,111,100,117,108,101,62,1,0,0,0,115,126, 0,0,0,4,22,4,1,4,1,2,1,2,255,4,4,8, 17,8,5,8,5,8,6,8,6,8,12,8,10,8,9,8, - 5,8,7,8,9,10,22,10,127,0,21,16,1,12,2,4, + 5,8,7,8,9,10,22,10,127,0,22,16,1,12,2,4, 1,4,2,6,2,6,2,8,2,16,71,8,40,8,19,8, 12,8,12,8,28,8,17,8,33,8,28,8,24,10,13,10, 10,10,11,8,14,6,3,4,1,2,255,12,68,14,64,14, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 6f2b3e791d1f29..92f2e4004120e4 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -166,7 +166,7 @@ static void *opcode_targets[256] = { &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, &&TARGET_GET_MATCH_ITER, - &&_unknown_opcode, + &&TARGET_GET_MATCH_MAP, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From 6ce6c345ce484b2ffa973fe44d5c735f6db4081d Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 28 May 2020 09:07:04 -0700 Subject: [PATCH 030/189] Simplify new opcodes --- Doc/library/dis.rst | 15 +- Include/opcode.h | 4 +- Lib/importlib/_bootstrap_external.py | 1 + Lib/opcode.py | 4 +- Python/ceval.c | 112 ++++++------- Python/compile.c | 10 +- Python/importlib_external.h | 228 +++++++++++++-------------- Python/opcode_targets.h | 4 +- 8 files changed, 179 insertions(+), 199 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 1141a79ae9d335..853eb46fdfc602 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -990,21 +990,20 @@ All of the following opcodes use their arguments. code counter is incremented by *delta*. -.. opcode:: GET_MATCH_ITER (delta) +.. opcode:: MATCH_SEQ_TYPE (delta) - Used for pattern matching. Much like :opcode:`GET_ITER`, but pops TOS and - increments the byte code counter by *delta* if TOS *is not* an instance of - :class:`collections.abc.Sequence` or *is* an instance of + Used for pattern matching. Pops TOS and increments the byte code counter by + *delta* if TOS is not an instance of :class:`collections.abc.Sequence`, is an + :term:`iterator`, or is an instance of :class:`str`/:class:`bytes`/:class:`bytearray`. .. versionadded:: 3.10 -.. opcode:: GET_MATCH_MAP (delta) +.. opcode:: MATCH_MAP_TYPE (delta) - Used for pattern matching. TOS is popped. If it is an instance of - :class:`collections.abc.Mapping`, a :class:`dict` is built from it and pushed - in its place. Otherwise, the byte code counter is incremented by *delta*. + Used for pattern matching. Pops TOS and increments the byte code counter by + *delta* if TOS is not an instance of :class:`collections.abc.Mapping`. .. versionadded:: 3.10 diff --git a/Include/opcode.h b/Include/opcode.h index d5865a0b8c7ce5..826dc864125ad5 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -127,8 +127,8 @@ extern "C" { #define SET_UPDATE 163 #define DICT_MERGE 164 #define DICT_UPDATE 165 -#define GET_MATCH_ITER 166 -#define GET_MATCH_MAP 167 +#define MATCH_SEQ_TYPE 166 +#define MATCH_MAP_TYPE 167 /* EXCEPT_HANDLER is a special, implicit block type which is created when entering an except handler. It is not an opcode but we define it here diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 31db5026e76d36..1262a27aca0a02 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -279,6 +279,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) # Python 3.10a0 3435 (add GET_MATCH_ITER) # Python 3.10a0 3436 (add GET_MATCH_MAP) +# Python 3.10a0 3437 (GET_MATCH_* -> MATCH_*_TYPE) # # MAGIC must change whenever the bytecode emitted by the compiler may no diff --git a/Lib/opcode.py b/Lib/opcode.py index 0ac03b373ffa88..da3f4ac1aa69b6 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -213,7 +213,7 @@ def jabs_op(name, op): def_op('SET_UPDATE', 163) def_op('DICT_MERGE', 164) def_op('DICT_UPDATE', 165) -jrel_op('GET_MATCH_ITER', 166) -jrel_op('GET_MATCH_MAP', 167) +jrel_op('MATCH_SEQ_TYPE', 166) +jrel_op('MATCH_MAP_TYPE', 167) del def_op, name_op, jrel_op, jabs_op diff --git a/Python/ceval.c b/Python/ceval.c index abc042ecca430f..cf4bf374773869 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -848,56 +848,6 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) return 0; } -// Need these for pattern matching: - -static int -check_match_mapping_type(PyObject *target) -{ - PyInterpreterState *interp = PyInterpreterState_Get(); - if (!interp) { - return -1; - } - if (!interp->map_abc) { - PyObject *abc = PyImport_ImportModule("_collections_abc"); - if (!abc) { - return -1; - } - interp->map_abc = PyObject_GetAttrString(abc, "Mapping"); - Py_DECREF(abc); - if (!interp->map_abc) { - return -1; - } - } - return PyObject_IsInstance(target, interp->map_abc); -} - -static int -check_match_sequence_type(PyObject *target) -{ - PyInterpreterState *interp = PyInterpreterState_Get(); - if (!interp) { - return -1; - } - if (!interp->seq_abc) { - PyObject *abc = PyImport_ImportModule("_collections_abc"); - if (!abc) { - return -1; - } - interp->seq_abc = PyObject_GetAttrString(abc, "Sequence"); - Py_DECREF(abc); - if (!interp->seq_abc) { - return -1; - } - } - return ( - PyObject_IsInstance(target, interp->seq_abc) - && !PyIter_Check(target) - && !PyObject_TypeCheck(target, &PyUnicode_Type) - && !PyObject_TypeCheck(target, &PyBytes_Type) - && !PyObject_TypeCheck(target, &PyByteArray_Type) - ); -} - static int do_raise(PyThreadState *tstate, PyObject *exc, PyObject *cause); static int unpack_iterable(PyThreadState *, PyObject *, int, int, PyObject **); @@ -2903,6 +2853,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(BUILD_MAP): { + PREDICTED(BUILD_MAP); Py_ssize_t i; PyObject *map = _PyDict_NewPresized((Py_ssize_t)oparg); if (map == NULL) @@ -3334,41 +3285,68 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) #endif } - case TARGET(GET_MATCH_MAP): { - PyObject *target = TOP(); - int check = check_match_mapping_type(target); - if (check < 0) { + case TARGET(MATCH_MAP_TYPE): { + PyInterpreterState *interp = PyInterpreterState_Get(); + if (!interp) { goto error; } - if (!check) { + if (!interp->map_abc) { + PyObject *abc = PyImport_ImportModule("_collections_abc"); + if (!abc) { + goto error; + } + interp->map_abc = PyObject_GetAttrString(abc, "Mapping"); + Py_DECREF(abc); + if (!interp->map_abc) { + goto error; + } + } + PyObject *target = TOP(); + if (!PyObject_IsInstance(target, interp->map_abc)) { STACK_SHRINK(1); Py_DECREF(target); JUMPBY(oparg); DISPATCH(); } - PyObject *map = PyDict_New(); - if (!map || PyDict_Update(map, target)) { - goto error; - } - Py_DECREF(target); - SET_TOP(map); + PREDICT(BUILD_MAP); DISPATCH(); } - case TARGET(GET_MATCH_ITER): { - PyObject *target = TOP(); - int check = check_match_sequence_type(target); - if (check < 0) { + case TARGET(MATCH_SEQ_TYPE): { + PyInterpreterState *interp = PyInterpreterState_Get(); + if (!interp) { goto error; } - if (!check) { + if (!interp->seq_abc) { + PyObject *abc = PyImport_ImportModule("_collections_abc"); + if (!abc) { + goto error; + } + interp->seq_abc = PyObject_GetAttrString(abc, "Sequence"); + Py_DECREF(abc); + if (!interp->seq_abc) { + goto error; + } + } + PyObject *target = TOP(); + if ( + !PyObject_IsInstance(target, interp->seq_abc) + || PyIter_Check(target) + || PyObject_TypeCheck(target, &PyUnicode_Type) + || PyObject_TypeCheck(target, &PyBytes_Type) + || PyObject_TypeCheck(target, &PyByteArray_Type) + ) { STACK_SHRINK(1); Py_DECREF(target); JUMPBY(oparg); DISPATCH(); } - } // Fall... + PREDICT(GET_ITER); + DISPATCH(); + } + case TARGET(GET_ITER): { + PREDICTED(GET_ITER); /* before: [obj]; after [getiter(obj)] */ PyObject *iterable = TOP(); PyObject *iter = PyObject_GetIter(iterable); diff --git a/Python/compile.c b/Python/compile.c index 6dfc2d9695887d..93951550d0db4c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -980,8 +980,8 @@ stack_effect(int opcode, int oparg, int jump) case FOR_ITER: /* -1 at end of iterator, 1 if continue iterating. */ return jump > 0 ? -1 : 1; - case GET_MATCH_ITER: - case GET_MATCH_MAP: + case MATCH_SEQ_TYPE: + case MATCH_MAP_TYPE: return -(jump > 0); case STORE_ATTR: @@ -2829,7 +2829,8 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) } end = compiler_new_block(c); block = compiler_new_block(c); - ADDOP_JREL(c, GET_MATCH_ITER, fail); + ADDOP_JREL(c, MATCH_SEQ_TYPE, fail); + ADDOP(c, GET_ITER); for (i = 0; i < size; i++) { elt = asdl_seq_GET(elts, i); if (i == star) { @@ -2840,7 +2841,8 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) } if (size - i - 1) { ADDOP_I(c, BUILD_TUPLE, size - i - 1); - ADDOP_JREL(c, GET_MATCH_ITER, fail); + ADDOP_JREL(c, MATCH_SEQ_TYPE, fail); + ADDOP(c, GET_ITER); } else { ADDOP_JREL(c, JUMP_FORWARD, end); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 96ccf461abd2d8..91843aad11f15c 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -400,7 +400,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 95,102,105,108,101,110,97,109,101,218,8,102,105,108,101,110, 97,109,101,114,5,0,0,0,114,5,0,0,0,114,8,0, 0,0,218,17,99,97,99,104,101,95,102,114,111,109,95,115, - 111,117,114,99,101,47,1,0,0,115,72,0,0,0,0,18, + 111,117,114,99,101,48,1,0,0,115,72,0,0,0,0,18, 8,1,6,1,2,255,4,2,8,1,4,1,8,1,12,1, 10,1,12,1,16,1,8,1,8,1,8,1,24,1,8,1, 12,1,6,2,8,1,8,1,8,1,8,1,14,1,14,1, @@ -481,7 +481,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,101,118,101,108,90,13,98,97,115,101,95,102,105,108,101, 110,97,109,101,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,17,115,111,117,114,99,101,95,102,114,111,109, - 95,99,97,99,104,101,118,1,0,0,115,68,0,0,0,0, + 95,99,97,99,104,101,119,1,0,0,115,68,0,0,0,0, 9,12,1,8,1,10,1,12,1,4,1,10,1,12,1,14, 1,16,1,4,1,4,1,12,1,8,1,2,1,2,255,4, 1,2,255,8,2,10,1,8,1,16,1,10,1,16,1,10, @@ -517,7 +517,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 120,116,101,110,115,105,111,110,218,11,115,111,117,114,99,101, 95,112,97,116,104,114,5,0,0,0,114,5,0,0,0,114, 8,0,0,0,218,15,95,103,101,116,95,115,111,117,114,99, - 101,102,105,108,101,158,1,0,0,115,20,0,0,0,0,7, + 101,102,105,108,101,159,1,0,0,115,20,0,0,0,0,7, 12,1,4,1,16,1,24,1,4,1,2,1,12,1,16,1, 18,1,114,108,0,0,0,99,1,0,0,0,0,0,0,0, 0,0,0,0,1,0,0,0,8,0,0,0,67,0,0,0, @@ -530,7 +530,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 112,108,101,114,101,0,0,0,114,97,0,0,0,114,82,0, 0,0,114,88,0,0,0,41,1,114,96,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,11,95, - 103,101,116,95,99,97,99,104,101,100,177,1,0,0,115,16, + 103,101,116,95,99,97,99,104,101,100,178,1,0,0,115,16, 0,0,0,0,1,14,1,2,1,10,1,12,1,8,1,14, 1,4,2,114,112,0,0,0,99,1,0,0,0,0,0,0, 0,0,0,0,0,2,0,0,0,8,0,0,0,67,0,0, @@ -545,7 +545,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,51,0,0,0,114,50,0,0,0,41,2,114,44,0,0, 0,114,52,0,0,0,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,10,95,99,97,108,99,95,109,111,100, - 101,189,1,0,0,115,12,0,0,0,0,2,2,1,14,1, + 101,190,1,0,0,115,12,0,0,0,0,2,2,1,14,1, 12,1,10,3,8,1,114,114,0,0,0,99,1,0,0,0, 0,0,0,0,0,0,0,0,3,0,0,0,8,0,0,0, 3,0,0,0,115,66,0,0,0,100,6,135,0,102,1,100, @@ -583,7 +583,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,114,103,115,218,6,107,119,97,114,103,115,169,1,218,6, 109,101,116,104,111,100,114,5,0,0,0,114,8,0,0,0, 218,19,95,99,104,101,99,107,95,110,97,109,101,95,119,114, - 97,112,112,101,114,209,1,0,0,115,18,0,0,0,0,1, + 97,112,112,101,114,210,1,0,0,115,18,0,0,0,0,1, 8,1,8,1,10,1,4,1,8,255,2,1,2,255,6,2, 122,40,95,99,104,101,99,107,95,110,97,109,101,46,60,108, 111,99,97,108,115,62,46,95,99,104,101,99,107,95,110,97, @@ -601,7 +601,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 8,95,95,100,105,99,116,95,95,218,6,117,112,100,97,116, 101,41,3,90,3,110,101,119,90,3,111,108,100,114,67,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,5,95,119,114,97,112,220,1,0,0,115,8,0,0, + 0,218,5,95,119,114,97,112,221,1,0,0,115,8,0,0, 0,0,1,8,1,10,1,20,1,122,26,95,99,104,101,99, 107,95,110,97,109,101,46,60,108,111,99,97,108,115,62,46, 95,119,114,97,112,41,1,78,41,3,218,10,95,98,111,111, @@ -609,7 +609,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,69,114,114,111,114,41,3,114,122,0,0,0,114,123,0, 0,0,114,133,0,0,0,114,5,0,0,0,114,121,0,0, 0,114,8,0,0,0,218,11,95,99,104,101,99,107,95,110, - 97,109,101,201,1,0,0,115,14,0,0,0,0,8,14,7, + 97,109,101,202,1,0,0,115,14,0,0,0,0,8,14,7, 2,1,10,1,12,2,14,5,10,1,114,136,0,0,0,99, 2,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0, 6,0,0,0,67,0,0,0,115,60,0,0,0,124,0,160, @@ -637,7 +637,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 6,108,111,97,100,101,114,218,8,112,111,114,116,105,111,110, 115,218,3,109,115,103,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,17,95,102,105,110,100,95,109,111,100, - 117,108,101,95,115,104,105,109,229,1,0,0,115,10,0,0, + 117,108,101,95,115,104,105,109,230,1,0,0,115,10,0,0, 0,0,10,14,1,16,1,4,1,22,1,114,143,0,0,0, 99,3,0,0,0,0,0,0,0,0,0,0,0,6,0,0, 0,4,0,0,0,67,0,0,0,115,166,0,0,0,124,0, @@ -704,7 +704,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,120,99,95,100,101,116,97,105,108,115,90,5,109,97,103, 105,99,114,92,0,0,0,114,2,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,13,95,99,108, - 97,115,115,105,102,121,95,112,121,99,246,1,0,0,115,28, + 97,115,115,105,102,121,95,112,121,99,247,1,0,0,115,28, 0,0,0,0,16,12,1,8,1,16,1,12,1,16,1,12, 1,10,1,12,1,8,1,16,2,8,1,16,1,16,1,114, 152,0,0,0,99,5,0,0,0,0,0,0,0,0,0,0, @@ -759,7 +759,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 122,101,114,116,0,0,0,114,151,0,0,0,114,92,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, 218,23,95,118,97,108,105,100,97,116,101,95,116,105,109,101, - 115,116,97,109,112,95,112,121,99,23,2,0,0,115,16,0, + 115,116,97,109,112,95,112,121,99,24,2,0,0,115,16,0, 0,0,0,19,24,1,10,1,12,1,16,1,8,1,22,255, 2,2,114,156,0,0,0,99,4,0,0,0,0,0,0,0, 0,0,0,0,4,0,0,0,4,0,0,0,67,0,0,0, @@ -805,7 +805,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,218,11,115,111,117,114,99,101,95,104,97,115,104,114, 116,0,0,0,114,151,0,0,0,114,5,0,0,0,114,5, 0,0,0,114,8,0,0,0,218,18,95,118,97,108,105,100, - 97,116,101,95,104,97,115,104,95,112,121,99,51,2,0,0, + 97,116,101,95,104,97,115,104,95,112,121,99,52,2,0,0, 115,12,0,0,0,0,17,16,1,2,1,8,255,4,2,2, 254,114,158,0,0,0,99,4,0,0,0,0,0,0,0,0, 0,0,0,5,0,0,0,5,0,0,0,67,0,0,0,115, @@ -829,7 +829,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,26,0,0,0,114,116,0,0,0,114,106,0,0,0,114, 107,0,0,0,218,4,99,111,100,101,114,5,0,0,0,114, 5,0,0,0,114,8,0,0,0,218,17,95,99,111,109,112, - 105,108,101,95,98,121,116,101,99,111,100,101,75,2,0,0, + 105,108,101,95,98,121,116,101,99,111,100,101,76,2,0,0, 115,18,0,0,0,0,2,10,1,10,1,12,1,8,1,12, 1,4,2,10,1,4,255,114,165,0,0,0,114,73,0,0, 0,99,3,0,0,0,0,0,0,0,0,0,0,0,4,0, @@ -848,7 +848,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,101,114,155,0,0,0,114,26,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,22,95,99,111, 100,101,95,116,111,95,116,105,109,101,115,116,97,109,112,95, - 112,121,99,88,2,0,0,115,12,0,0,0,0,2,8,1, + 112,121,99,89,2,0,0,115,12,0,0,0,0,2,8,1, 14,1,14,1,14,1,16,1,114,170,0,0,0,84,99,3, 0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,5, 0,0,0,67,0,0,0,115,80,0,0,0,116,0,116,1, @@ -866,7 +866,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,90,7,99,104,101,99,107,101,100,114,26,0,0,0,114, 2,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,17,95,99,111,100,101,95,116,111,95,104,97, - 115,104,95,112,121,99,98,2,0,0,115,14,0,0,0,0, + 115,104,95,112,121,99,99,2,0,0,115,14,0,0,0,0, 2,8,1,12,1,14,1,16,1,10,1,16,1,114,171,0, 0,0,99,1,0,0,0,0,0,0,0,0,0,0,0,5, 0,0,0,6,0,0,0,67,0,0,0,115,62,0,0,0, @@ -893,7 +893,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,100,108,105,110,101,218,8,101,110,99,111,100,105,110,103, 90,15,110,101,119,108,105,110,101,95,100,101,99,111,100,101, 114,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, - 218,13,100,101,99,111,100,101,95,115,111,117,114,99,101,109, + 218,13,100,101,99,111,100,101,95,115,111,117,114,99,101,110, 2,0,0,115,10,0,0,0,0,5,8,1,12,1,10,1, 12,1,114,176,0,0,0,169,2,114,140,0,0,0,218,26, 115,117,98,109,111,100,117,108,101,95,115,101,97,114,99,104, @@ -955,7 +955,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,182,0,0,0,90,7,100,105,114,110,97,109,101,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,23,115, 112,101,99,95,102,114,111,109,95,102,105,108,101,95,108,111, - 99,97,116,105,111,110,126,2,0,0,115,62,0,0,0,0, + 99,97,116,105,111,110,127,2,0,0,115,62,0,0,0,0, 12,8,4,4,1,10,2,2,1,14,1,12,1,8,2,10, 8,16,1,6,3,8,1,14,1,14,1,10,1,6,1,6, 2,4,3,8,2,10,1,2,1,14,1,12,1,6,2,4, @@ -992,7 +992,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 72,75,69,89,95,76,79,67,65,76,95,77,65,67,72,73, 78,69,41,2,218,3,99,108,115,114,7,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,14,95, - 111,112,101,110,95,114,101,103,105,115,116,114,121,206,2,0, + 111,112,101,110,95,114,101,103,105,115,116,114,121,207,2,0, 0,115,8,0,0,0,0,2,2,1,16,1,12,1,122,36, 87,105,110,100,111,119,115,82,101,103,105,115,116,114,121,70, 105,110,100,101,114,46,95,111,112,101,110,95,114,101,103,105, @@ -1020,7 +1020,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,90,4,104,107,101,121,218,8,102,105,108,101,112,97,116, 104,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, 218,16,95,115,101,97,114,99,104,95,114,101,103,105,115,116, - 114,121,213,2,0,0,115,24,0,0,0,0,2,6,1,8, + 114,121,214,2,0,0,115,24,0,0,0,0,2,6,1,8, 2,6,1,6,1,16,255,6,2,2,1,12,1,46,1,12, 1,8,1,122,38,87,105,110,100,111,119,115,82,101,103,105, 115,116,114,121,70,105,110,100,101,114,46,95,115,101,97,114, @@ -1042,7 +1042,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,218,6,116,97,114,103,101,116,114,199,0,0,0,114, 140,0,0,0,114,189,0,0,0,114,187,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,9,102, - 105,110,100,95,115,112,101,99,228,2,0,0,115,28,0,0, + 105,110,100,95,115,112,101,99,229,2,0,0,115,28,0,0, 0,0,2,10,1,8,1,4,1,2,1,12,1,12,1,8, 1,14,1,14,1,6,1,8,1,2,254,6,3,122,31,87, 105,110,100,111,119,115,82,101,103,105,115,116,114,121,70,105, @@ -1061,7 +1061,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 2,114,203,0,0,0,114,140,0,0,0,169,4,114,193,0, 0,0,114,139,0,0,0,114,44,0,0,0,114,187,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, - 218,11,102,105,110,100,95,109,111,100,117,108,101,244,2,0, + 218,11,102,105,110,100,95,109,111,100,117,108,101,245,2,0, 0,115,8,0,0,0,0,7,12,1,8,1,6,2,122,33, 87,105,110,100,111,119,115,82,101,103,105,115,116,114,121,70, 105,110,100,101,114,46,102,105,110,100,95,109,111,100,117,108, @@ -1071,7 +1071,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,97,115,115,109,101,116,104,111,100,114,194,0,0,0,114, 200,0,0,0,114,203,0,0,0,114,206,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,114,191,0,0,0,194,2,0,0,115,28,0,0,0, + 0,0,114,191,0,0,0,195,2,0,0,115,28,0,0,0, 8,2,4,3,2,255,2,4,2,255,2,3,4,2,2,1, 10,6,2,1,10,14,2,1,12,15,2,1,114,191,0,0, 0,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -1107,7 +1107,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 139,0,0,0,114,96,0,0,0,90,13,102,105,108,101,110, 97,109,101,95,98,97,115,101,90,9,116,97,105,108,95,110, 97,109,101,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,114,182,0,0,0,7,3,0,0,115,8,0,0,0, + 0,0,114,182,0,0,0,8,3,0,0,115,8,0,0,0, 0,3,18,1,16,1,14,1,122,24,95,76,111,97,100,101, 114,66,97,115,105,99,115,46,105,115,95,112,97,99,107,97, 103,101,99,2,0,0,0,0,0,0,0,0,0,0,0,2, @@ -1118,7 +1118,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 110,46,78,114,5,0,0,0,169,2,114,118,0,0,0,114, 187,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,13,99,114,101,97,116,101,95,109,111,100,117, - 108,101,15,3,0,0,115,2,0,0,0,0,1,122,27,95, + 108,101,16,3,0,0,115,2,0,0,0,0,1,122,27,95, 76,111,97,100,101,114,66,97,115,105,99,115,46,99,114,101, 97,116,101,95,109,111,100,117,108,101,99,2,0,0,0,0, 0,0,0,0,0,0,0,3,0,0,0,5,0,0,0,67, @@ -1138,7 +1138,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 131,0,0,0,41,3,114,118,0,0,0,218,6,109,111,100, 117,108,101,114,164,0,0,0,114,5,0,0,0,114,5,0, 0,0,114,8,0,0,0,218,11,101,120,101,99,95,109,111, - 100,117,108,101,18,3,0,0,115,12,0,0,0,0,2,12, + 100,117,108,101,19,3,0,0,115,12,0,0,0,0,2,12, 1,8,1,6,1,4,255,6,2,122,25,95,76,111,97,100, 101,114,66,97,115,105,99,115,46,101,120,101,99,95,109,111, 100,117,108,101,99,2,0,0,0,0,0,0,0,0,0,0, @@ -1149,14 +1149,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,218,17,95,108,111,97,100,95,109,111,100,117,108, 101,95,115,104,105,109,169,2,114,118,0,0,0,114,139,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,11,108,111,97,100,95,109,111,100,117,108,101,26,3, + 0,218,11,108,111,97,100,95,109,111,100,117,108,101,27,3, 0,0,115,2,0,0,0,0,2,122,25,95,76,111,97,100, 101,114,66,97,115,105,99,115,46,108,111,97,100,95,109,111, 100,117,108,101,78,41,8,114,125,0,0,0,114,124,0,0, 0,114,126,0,0,0,114,127,0,0,0,114,182,0,0,0, 114,212,0,0,0,114,217,0,0,0,114,220,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8, - 0,0,0,114,208,0,0,0,2,3,0,0,115,10,0,0, + 0,0,0,114,208,0,0,0,3,3,0,0,115,10,0,0, 0,8,2,4,3,8,8,8,3,8,8,114,208,0,0,0, 99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,3,0,0,0,64,0,0,0,115,74,0,0,0,101,0, @@ -1181,7 +1181,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,32,32,32,32,32,32,78,41,1,114,50,0,0,0,169, 2,114,118,0,0,0,114,44,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,8,0,0,0,218,10,112,97,116,104, - 95,109,116,105,109,101,33,3,0,0,115,2,0,0,0,0, + 95,109,116,105,109,101,34,3,0,0,115,2,0,0,0,0, 6,122,23,83,111,117,114,99,101,76,111,97,100,101,114,46, 112,97,116,104,95,109,116,105,109,101,99,2,0,0,0,0, 0,0,0,0,0,0,0,2,0,0,0,4,0,0,0,67, @@ -1215,7 +1215,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,46,10,32,32,32,32,32,32,32,32,114,169,0,0,0, 41,1,114,223,0,0,0,114,222,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,10,112,97,116, - 104,95,115,116,97,116,115,41,3,0,0,115,2,0,0,0, + 104,95,115,116,97,116,115,42,3,0,0,115,2,0,0,0, 0,12,122,23,83,111,117,114,99,101,76,111,97,100,101,114, 46,112,97,116,104,95,115,116,97,116,115,99,4,0,0,0, 0,0,0,0,0,0,0,0,4,0,0,0,4,0,0,0, @@ -1239,7 +1239,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,107,0,0,0,90,10,99,97,99,104,101,95,112,97,116, 104,114,26,0,0,0,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,15,95,99,97,99,104,101,95,98,121, - 116,101,99,111,100,101,55,3,0,0,115,2,0,0,0,0, + 116,101,99,111,100,101,56,3,0,0,115,2,0,0,0,0, 8,122,28,83,111,117,114,99,101,76,111,97,100,101,114,46, 95,99,97,99,104,101,95,98,121,116,101,99,111,100,101,99, 3,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0, @@ -1256,7 +1256,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 115,46,10,32,32,32,32,32,32,32,32,78,114,5,0,0, 0,41,3,114,118,0,0,0,114,44,0,0,0,114,26,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,225,0,0,0,65,3,0,0,115,2,0,0,0,0, + 0,114,225,0,0,0,66,3,0,0,115,2,0,0,0,0, 1,122,21,83,111,117,114,99,101,76,111,97,100,101,114,46, 115,101,116,95,100,97,116,97,99,2,0,0,0,0,0,0, 0,0,0,0,0,5,0,0,0,10,0,0,0,67,0,0, @@ -1277,7 +1277,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,41,5,114,118,0,0,0,114,139,0,0,0,114,44,0, 0,0,114,174,0,0,0,218,3,101,120,99,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,10,103,101,116, - 95,115,111,117,114,99,101,72,3,0,0,115,20,0,0,0, + 95,115,111,117,114,99,101,73,3,0,0,115,20,0,0,0, 0,2,10,1,2,1,14,1,14,1,4,1,2,255,4,1, 2,255,24,2,122,23,83,111,117,114,99,101,76,111,97,100, 101,114,46,103,101,116,95,115,111,117,114,99,101,114,104,0, @@ -1299,7 +1299,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 218,7,99,111,109,112,105,108,101,41,4,114,118,0,0,0, 114,26,0,0,0,114,44,0,0,0,114,230,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,14, - 115,111,117,114,99,101,95,116,111,95,99,111,100,101,82,3, + 115,111,117,114,99,101,95,116,111,95,99,111,100,101,83,3, 0,0,115,6,0,0,0,0,5,12,1,4,255,122,27,83, 111,117,114,99,101,76,111,97,100,101,114,46,115,111,117,114, 99,101,95,116,111,95,99,111,100,101,99,2,0,0,0,0, @@ -1376,7 +1376,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,26,0,0,0,114,151,0,0,0,114,2,0,0,0,90, 10,98,121,116,101,115,95,100,97,116,97,90,11,99,111,100, 101,95,111,98,106,101,99,116,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,213,0,0,0,90,3,0,0, + 0,0,114,8,0,0,0,114,213,0,0,0,91,3,0,0, 115,152,0,0,0,0,7,10,1,4,1,4,1,4,1,4, 1,4,1,2,1,12,1,12,1,12,2,2,1,14,1,12, 1,8,2,12,1,2,1,14,1,12,1,6,3,2,1,2, @@ -1393,7 +1393,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,226,0,0,0,114,225,0,0,0,114,229,0,0,0,114, 233,0,0,0,114,213,0,0,0,114,5,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,221,0, - 0,0,31,3,0,0,115,14,0,0,0,8,2,8,8,8, + 0,0,32,3,0,0,115,14,0,0,0,8,2,8,8,8, 14,8,10,8,7,8,10,14,8,114,221,0,0,0,99,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4, 0,0,0,0,0,0,0,115,124,0,0,0,101,0,90,1, @@ -1422,7 +1422,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,32,32,32,32,102,105,110,100,101,114,46,78,114,159,0, 0,0,41,3,114,118,0,0,0,114,139,0,0,0,114,44, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,114,209,0,0,0,180,3,0,0,115,4,0,0,0, + 0,0,114,209,0,0,0,181,3,0,0,115,4,0,0,0, 0,3,6,1,122,19,70,105,108,101,76,111,97,100,101,114, 46,95,95,105,110,105,116,95,95,99,2,0,0,0,0,0, 0,0,0,0,0,0,2,0,0,0,2,0,0,0,67,0, @@ -1431,7 +1431,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,0,0,0,169,2,218,9,95,95,99,108,97,115,115,95, 95,114,131,0,0,0,169,2,114,118,0,0,0,90,5,111, 116,104,101,114,114,5,0,0,0,114,5,0,0,0,114,8, - 0,0,0,218,6,95,95,101,113,95,95,186,3,0,0,115, + 0,0,0,218,6,95,95,101,113,95,95,187,3,0,0,115, 6,0,0,0,0,1,12,1,10,255,122,17,70,105,108,101, 76,111,97,100,101,114,46,95,95,101,113,95,95,99,1,0, 0,0,0,0,0,0,0,0,0,0,1,0,0,0,3,0, @@ -1440,7 +1440,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,0,0,0,169,3,218,4,104,97,115,104,114,116,0,0, 0,114,44,0,0,0,169,1,114,118,0,0,0,114,5,0, 0,0,114,5,0,0,0,114,8,0,0,0,218,8,95,95, - 104,97,115,104,95,95,190,3,0,0,115,2,0,0,0,0, + 104,97,115,104,95,95,191,3,0,0,115,2,0,0,0,0, 1,122,19,70,105,108,101,76,111,97,100,101,114,46,95,95, 104,97,115,104,95,95,99,2,0,0,0,0,0,0,0,0, 0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,115, @@ -1454,7 +1454,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,46,10,10,32,32,32,32,32,32,32,32,41,3,218,5, 115,117,112,101,114,114,239,0,0,0,114,220,0,0,0,114, 219,0,0,0,169,1,114,241,0,0,0,114,5,0,0,0, - 114,8,0,0,0,114,220,0,0,0,193,3,0,0,115,2, + 114,8,0,0,0,114,220,0,0,0,194,3,0,0,115,2, 0,0,0,0,10,122,22,70,105,108,101,76,111,97,100,101, 114,46,108,111,97,100,95,109,111,100,117,108,101,99,2,0, 0,0,0,0,0,0,0,0,0,0,2,0,0,0,1,0, @@ -1464,7 +1464,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 99,101,32,102,105,108,101,32,97,115,32,102,111,117,110,100, 32,98,121,32,116,104,101,32,102,105,110,100,101,114,46,114, 48,0,0,0,114,219,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,179,0,0,0,205,3,0, + 0,0,0,114,8,0,0,0,114,179,0,0,0,206,3,0, 0,115,2,0,0,0,0,3,122,23,70,105,108,101,76,111, 97,100,101,114,46,103,101,116,95,102,105,108,101,110,97,109, 101,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0, @@ -1486,7 +1486,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,90,4,114,101,97,100,114,65,0,0,0,41,3,114, 118,0,0,0,114,44,0,0,0,114,68,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,227,0, - 0,0,210,3,0,0,115,10,0,0,0,0,2,14,1,16, + 0,0,211,3,0,0,115,10,0,0,0,0,2,14,1,16, 1,40,2,14,1,122,19,70,105,108,101,76,111,97,100,101, 114,46,103,101,116,95,100,97,116,97,99,2,0,0,0,0, 0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,67, @@ -1495,7 +1495,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,114,182,0,0,0,169,2,114,118,0,0,0,114,216,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, 0,218,19,103,101,116,95,114,101,115,111,117,114,99,101,95, - 114,101,97,100,101,114,221,3,0,0,115,6,0,0,0,0, + 114,101,97,100,101,114,222,3,0,0,115,6,0,0,0,0, 2,10,1,4,1,122,30,70,105,108,101,76,111,97,100,101, 114,46,103,101,116,95,114,101,115,111,117,114,99,101,95,114, 101,97,100,101,114,99,2,0,0,0,0,0,0,0,0,0, @@ -1507,7 +1507,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,64,0,0,0,114,65,0,0,0,169,3,114,118,0, 0,0,90,8,114,101,115,111,117,114,99,101,114,44,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, - 218,13,111,112,101,110,95,114,101,115,111,117,114,99,101,227, + 218,13,111,112,101,110,95,114,101,115,111,117,114,99,101,228, 3,0,0,115,4,0,0,0,0,1,20,1,122,24,70,105, 108,101,76,111,97,100,101,114,46,111,112,101,110,95,114,101, 115,111,117,114,99,101,99,2,0,0,0,0,0,0,0,0, @@ -1520,7 +1520,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,114,111,114,114,38,0,0,0,114,47,0,0,0,114,44, 0,0,0,114,255,0,0,0,114,5,0,0,0,114,5,0, 0,0,114,8,0,0,0,218,13,114,101,115,111,117,114,99, - 101,95,112,97,116,104,231,3,0,0,115,8,0,0,0,0, + 101,95,112,97,116,104,232,3,0,0,115,8,0,0,0,0, 1,10,1,4,1,20,1,122,24,70,105,108,101,76,111,97, 100,101,114,46,114,101,115,111,117,114,99,101,95,112,97,116, 104,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0, @@ -1532,7 +1532,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,44,0,0,0,114,54,0,0,0,169,3,114,118,0, 0,0,114,116,0,0,0,114,44,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,2,1,0,0, - 237,3,0,0,115,8,0,0,0,0,1,8,1,4,1,20, + 238,3,0,0,115,8,0,0,0,0,1,8,1,4,1,20, 1,122,22,70,105,108,101,76,111,97,100,101,114,46,105,115, 95,114,101,115,111,117,114,99,101,99,1,0,0,0,0,0, 0,0,0,0,0,0,1,0,0,0,5,0,0,0,67,0, @@ -1542,7 +1542,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,218,7,108,105,115,116,100,105,114,114,47,0,0,0,114, 44,0,0,0,114,246,0,0,0,114,5,0,0,0,114,5, 0,0,0,114,8,0,0,0,218,8,99,111,110,116,101,110, - 116,115,243,3,0,0,115,2,0,0,0,0,1,122,19,70, + 116,115,244,3,0,0,115,2,0,0,0,0,1,122,19,70, 105,108,101,76,111,97,100,101,114,46,99,111,110,116,101,110, 116,115,41,17,114,125,0,0,0,114,124,0,0,0,114,126, 0,0,0,114,127,0,0,0,114,209,0,0,0,114,243,0, @@ -1551,7 +1551,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,0,1,0,0,114,4,1,0,0,114,2,1,0,0,114, 8,1,0,0,90,13,95,95,99,108,97,115,115,99,101,108, 108,95,95,114,5,0,0,0,114,5,0,0,0,114,249,0, - 0,0,114,8,0,0,0,114,239,0,0,0,175,3,0,0, + 0,0,114,8,0,0,0,114,239,0,0,0,176,3,0,0, 115,30,0,0,0,8,2,4,3,8,6,8,4,8,3,2, 1,14,11,2,1,10,4,8,11,2,1,10,5,8,4,8, 6,8,6,114,239,0,0,0,99,0,0,0,0,0,0,0, @@ -1574,7 +1574,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 49,0,0,0,218,8,115,116,95,109,116,105,109,101,90,7, 115,116,95,115,105,122,101,41,3,114,118,0,0,0,114,44, 0,0,0,114,238,0,0,0,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,224,0,0,0,251,3,0,0, + 0,0,114,8,0,0,0,114,224,0,0,0,252,3,0,0, 115,4,0,0,0,0,2,8,1,122,27,83,111,117,114,99, 101,70,105,108,101,76,111,97,100,101,114,46,112,97,116,104, 95,115,116,97,116,115,99,4,0,0,0,0,0,0,0,0, @@ -1585,7 +1585,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 225,0,0,0,41,5,114,118,0,0,0,114,107,0,0,0, 114,106,0,0,0,114,26,0,0,0,114,52,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,226, - 0,0,0,0,4,0,0,115,4,0,0,0,0,2,8,1, + 0,0,0,1,4,0,0,115,4,0,0,0,0,2,8,1, 122,32,83,111,117,114,99,101,70,105,108,101,76,111,97,100, 101,114,46,95,99,97,99,104,101,95,98,121,116,101,99,111, 100,101,114,60,0,0,0,114,11,1,0,0,99,3,0,0, @@ -1620,7 +1620,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,0,0,218,6,112,97,114,101,110,116,114,96,0,0,0, 114,37,0,0,0,114,33,0,0,0,114,228,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,225, - 0,0,0,5,4,0,0,115,46,0,0,0,0,2,12,1, + 0,0,0,6,4,0,0,115,46,0,0,0,0,2,12,1, 4,2,12,1,12,1,12,2,12,1,10,1,2,1,14,1, 12,2,8,1,14,3,6,1,4,255,4,2,28,1,2,1, 12,1,16,1,16,2,8,1,2,255,122,25,83,111,117,114, @@ -1629,7 +1629,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,114,126,0,0,0,114,127,0,0,0,114,224,0,0, 0,114,226,0,0,0,114,225,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 9,1,0,0,247,3,0,0,115,8,0,0,0,8,2,4, + 9,1,0,0,248,3,0,0,115,8,0,0,0,8,2,4, 2,8,5,8,5,114,9,1,0,0,99,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,64, 0,0,0,115,32,0,0,0,101,0,90,1,100,0,90,2, @@ -1651,7 +1651,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,235,0,0,0,41,5,114,118,0,0,0,114,139,0,0, 0,114,44,0,0,0,114,26,0,0,0,114,151,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 213,0,0,0,40,4,0,0,115,22,0,0,0,0,1,10, + 213,0,0,0,41,4,0,0,115,22,0,0,0,0,1,10, 1,10,4,2,1,2,254,6,4,12,1,2,1,14,1,2, 1,2,253,122,29,83,111,117,114,99,101,108,101,115,115,70, 105,108,101,76,111,97,100,101,114,46,103,101,116,95,99,111, @@ -1661,14 +1661,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 111,110,101,32,97,115,32,116,104,101,114,101,32,105,115,32, 110,111,32,115,111,117,114,99,101,32,99,111,100,101,46,78, 114,5,0,0,0,114,219,0,0,0,114,5,0,0,0,114, - 5,0,0,0,114,8,0,0,0,114,229,0,0,0,56,4, + 5,0,0,0,114,8,0,0,0,114,229,0,0,0,57,4, 0,0,115,2,0,0,0,0,2,122,31,83,111,117,114,99, 101,108,101,115,115,70,105,108,101,76,111,97,100,101,114,46, 103,101,116,95,115,111,117,114,99,101,78,41,6,114,125,0, 0,0,114,124,0,0,0,114,126,0,0,0,114,127,0,0, 0,114,213,0,0,0,114,229,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 15,1,0,0,36,4,0,0,115,6,0,0,0,8,2,4, + 15,1,0,0,37,4,0,0,115,6,0,0,0,8,2,4, 2,8,16,114,15,1,0,0,99,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,3,0,0,0,64,0,0, 0,115,92,0,0,0,101,0,90,1,100,0,90,2,100,1, @@ -1688,7 +1688,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,115,16,0,0,0,124,1,124,0,95,0,124,2,124,0, 95,1,100,0,83,0,114,109,0,0,0,114,159,0,0,0, 114,5,1,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,209,0,0,0,73,4,0,0,115,4,0, + 8,0,0,0,114,209,0,0,0,74,4,0,0,115,4,0, 0,0,0,1,6,1,122,28,69,120,116,101,110,115,105,111, 110,70,105,108,101,76,111,97,100,101,114,46,95,95,105,110, 105,116,95,95,99,2,0,0,0,0,0,0,0,0,0,0, @@ -1696,7 +1696,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,124,0,106,0,124,1,106,0,107,2,111,22,124,0, 106,1,124,1,106,1,107,2,83,0,114,109,0,0,0,114, 240,0,0,0,114,242,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,243,0,0,0,77,4,0, + 0,0,0,114,8,0,0,0,114,243,0,0,0,78,4,0, 0,115,6,0,0,0,0,1,12,1,10,255,122,26,69,120, 116,101,110,115,105,111,110,70,105,108,101,76,111,97,100,101, 114,46,95,95,101,113,95,95,99,1,0,0,0,0,0,0, @@ -1704,7 +1704,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,115,20,0,0,0,116,0,124,0,106,1,131,1,116,0, 124,0,106,2,131,1,65,0,83,0,114,109,0,0,0,114, 244,0,0,0,114,246,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,247,0,0,0,81,4,0, + 0,0,0,114,8,0,0,0,114,247,0,0,0,82,4,0, 0,115,2,0,0,0,0,1,122,28,69,120,116,101,110,115, 105,111,110,70,105,108,101,76,111,97,100,101,114,46,95,95, 104,97,115,104,95,95,99,2,0,0,0,0,0,0,0,0, @@ -1721,7 +1721,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,116,101,95,100,121,110,97,109,105,99,114,149,0,0,0, 114,116,0,0,0,114,44,0,0,0,41,3,114,118,0,0, 0,114,187,0,0,0,114,216,0,0,0,114,5,0,0,0, - 114,5,0,0,0,114,8,0,0,0,114,212,0,0,0,84, + 114,5,0,0,0,114,8,0,0,0,114,212,0,0,0,85, 4,0,0,115,14,0,0,0,0,2,4,1,6,255,4,2, 6,1,8,255,4,2,122,33,69,120,116,101,110,115,105,111, 110,70,105,108,101,76,111,97,100,101,114,46,99,114,101,97, @@ -1738,7 +1738,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 214,0,0,0,114,163,0,0,0,90,12,101,120,101,99,95, 100,121,110,97,109,105,99,114,149,0,0,0,114,116,0,0, 0,114,44,0,0,0,114,253,0,0,0,114,5,0,0,0, - 114,5,0,0,0,114,8,0,0,0,114,217,0,0,0,92, + 114,5,0,0,0,114,8,0,0,0,114,217,0,0,0,93, 4,0,0,115,8,0,0,0,0,2,14,1,6,1,8,255, 122,31,69,120,116,101,110,115,105,111,110,70,105,108,101,76, 111,97,100,101,114,46,101,120,101,99,95,109,111,100,117,108, @@ -1757,7 +1757,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,169,2,114,32,0,0,0,218,6,115,117,102,102,105, 120,169,1,90,9,102,105,108,101,95,110,97,109,101,114,5, 0,0,0,114,8,0,0,0,218,9,60,103,101,110,101,120, - 112,114,62,101,4,0,0,115,4,0,0,0,4,1,2,255, + 112,114,62,102,4,0,0,115,4,0,0,0,4,1,2,255, 122,49,69,120,116,101,110,115,105,111,110,70,105,108,101,76, 111,97,100,101,114,46,105,115,95,112,97,99,107,97,103,101, 46,60,108,111,99,97,108,115,62,46,60,103,101,110,101,120, @@ -1765,7 +1765,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 3,97,110,121,218,18,69,88,84,69,78,83,73,79,78,95, 83,85,70,70,73,88,69,83,114,219,0,0,0,114,5,0, 0,0,114,18,1,0,0,114,8,0,0,0,114,182,0,0, - 0,98,4,0,0,115,8,0,0,0,0,2,14,1,12,1, + 0,99,4,0,0,115,8,0,0,0,0,2,14,1,12,1, 2,255,122,30,69,120,116,101,110,115,105,111,110,70,105,108, 101,76,111,97,100,101,114,46,105,115,95,112,97,99,107,97, 103,101,99,2,0,0,0,0,0,0,0,0,0,0,0,2, @@ -1776,7 +1776,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 116,32,99,114,101,97,116,101,32,97,32,99,111,100,101,32, 111,98,106,101,99,116,46,78,114,5,0,0,0,114,219,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,213,0,0,0,104,4,0,0,115,2,0,0,0,0, + 0,114,213,0,0,0,105,4,0,0,115,2,0,0,0,0, 2,122,28,69,120,116,101,110,115,105,111,110,70,105,108,101, 76,111,97,100,101,114,46,103,101,116,95,99,111,100,101,99, 2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0, @@ -1786,14 +1786,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,117,108,101,115,32,104,97,118,101,32,110,111,32,115,111, 117,114,99,101,32,99,111,100,101,46,78,114,5,0,0,0, 114,219,0,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,229,0,0,0,108,4,0,0,115,2,0, + 8,0,0,0,114,229,0,0,0,109,4,0,0,115,2,0, 0,0,0,2,122,30,69,120,116,101,110,115,105,111,110,70, 105,108,101,76,111,97,100,101,114,46,103,101,116,95,115,111, 117,114,99,101,99,2,0,0,0,0,0,0,0,0,0,0, 0,2,0,0,0,1,0,0,0,67,0,0,0,115,6,0, 0,0,124,0,106,0,83,0,114,250,0,0,0,114,48,0, 0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,179,0,0,0,112,4,0,0,115, + 0,114,8,0,0,0,114,179,0,0,0,113,4,0,0,115, 2,0,0,0,0,3,122,32,69,120,116,101,110,115,105,111, 110,70,105,108,101,76,111,97,100,101,114,46,103,101,116,95, 102,105,108,101,110,97,109,101,78,41,14,114,125,0,0,0, @@ -1802,7 +1802,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,217,0,0,0,114,182,0,0,0,114,213,0, 0,0,114,229,0,0,0,114,136,0,0,0,114,179,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,5,0,0,0, - 114,8,0,0,0,114,252,0,0,0,65,4,0,0,115,22, + 114,8,0,0,0,114,252,0,0,0,66,4,0,0,115,22, 0,0,0,8,2,4,6,8,4,8,4,8,3,8,8,8, 6,8,6,8,4,8,4,2,1,114,252,0,0,0,99,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2, @@ -1845,7 +1845,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 169,4,114,118,0,0,0,114,116,0,0,0,114,44,0,0, 0,90,11,112,97,116,104,95,102,105,110,100,101,114,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,209,0, - 0,0,125,4,0,0,115,8,0,0,0,0,1,6,1,6, + 0,0,126,4,0,0,115,8,0,0,0,0,1,6,1,6, 1,14,1,122,23,95,78,97,109,101,115,112,97,99,101,80, 97,116,104,46,95,95,105,110,105,116,95,95,99,1,0,0, 0,0,0,0,0,0,0,0,0,4,0,0,0,3,0,0, @@ -1862,7 +1862,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,118,0,0,0,114,14,1,0,0,218,3,100,111,116,90, 2,109,101,114,5,0,0,0,114,5,0,0,0,114,8,0, 0,0,218,23,95,102,105,110,100,95,112,97,114,101,110,116, - 95,112,97,116,104,95,110,97,109,101,115,131,4,0,0,115, + 95,112,97,116,104,95,110,97,109,101,115,132,4,0,0,115, 8,0,0,0,0,2,18,1,8,2,4,3,122,38,95,78, 97,109,101,115,112,97,99,101,80,97,116,104,46,95,102,105, 110,100,95,112,97,114,101,110,116,95,112,97,116,104,95,110, @@ -1875,7 +1875,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 118,0,0,0,90,18,112,97,114,101,110,116,95,109,111,100, 117,108,101,95,110,97,109,101,90,14,112,97,116,104,95,97, 116,116,114,95,110,97,109,101,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,25,1,0,0,141,4,0,0, + 0,0,114,8,0,0,0,114,25,1,0,0,142,4,0,0, 115,4,0,0,0,0,1,12,1,122,31,95,78,97,109,101, 115,112,97,99,101,80,97,116,104,46,95,103,101,116,95,112, 97,114,101,110,116,95,112,97,116,104,99,1,0,0,0,0, @@ -1891,7 +1891,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,114,24,1,0,0,41,3,114,118,0,0,0,90,11, 112,97,114,101,110,116,95,112,97,116,104,114,187,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218, - 12,95,114,101,99,97,108,99,117,108,97,116,101,145,4,0, + 12,95,114,101,99,97,108,99,117,108,97,116,101,146,4,0, 0,115,16,0,0,0,0,2,12,1,10,1,14,3,18,1, 6,1,8,1,6,1,122,27,95,78,97,109,101,115,112,97, 99,101,80,97,116,104,46,95,114,101,99,97,108,99,117,108, @@ -1900,7 +1900,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,116,0,124,0,160,1,161,0,131,1,83,0,114,109,0, 0,0,41,2,114,6,1,0,0,114,32,1,0,0,114,246, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,218,8,95,95,105,116,101,114,95,95,158,4,0,0, + 0,0,218,8,95,95,105,116,101,114,95,95,159,4,0,0, 115,2,0,0,0,0,1,122,23,95,78,97,109,101,115,112, 97,99,101,80,97,116,104,46,95,95,105,116,101,114,95,95, 99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0, @@ -1909,7 +1909,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,114,32,1,0,0,41,2,114,118,0,0,0,218,5,105, 110,100,101,120,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,11,95,95,103,101,116,105,116,101,109,95,95, - 161,4,0,0,115,2,0,0,0,0,1,122,26,95,78,97, + 162,4,0,0,115,2,0,0,0,0,1,122,26,95,78,97, 109,101,115,112,97,99,101,80,97,116,104,46,95,95,103,101, 116,105,116,101,109,95,95,99,3,0,0,0,0,0,0,0, 0,0,0,0,3,0,0,0,3,0,0,0,67,0,0,0, @@ -1917,7 +1917,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,83,0,114,109,0,0,0,41,1,114,24,1,0,0,41, 3,114,118,0,0,0,114,35,1,0,0,114,44,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218, - 11,95,95,115,101,116,105,116,101,109,95,95,164,4,0,0, + 11,95,95,115,101,116,105,116,101,109,95,95,165,4,0,0, 115,2,0,0,0,0,1,122,26,95,78,97,109,101,115,112, 97,99,101,80,97,116,104,46,95,95,115,101,116,105,116,101, 109,95,95,99,1,0,0,0,0,0,0,0,0,0,0,0, @@ -1925,7 +1925,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,116,0,124,0,160,1,161,0,131,1,83,0,114,109,0, 0,0,41,2,114,23,0,0,0,114,32,1,0,0,114,246, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,218,7,95,95,108,101,110,95,95,167,4,0,0,115, + 0,0,218,7,95,95,108,101,110,95,95,168,4,0,0,115, 2,0,0,0,0,1,122,22,95,78,97,109,101,115,112,97, 99,101,80,97,116,104,46,95,95,108,101,110,95,95,99,1, 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,3, @@ -1934,7 +1934,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,101,115,112,97,99,101,80,97,116,104,40,123,33,114,125, 41,41,2,114,62,0,0,0,114,24,1,0,0,114,246,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,8,95,95,114,101,112,114,95,95,170,4,0,0,115, + 0,218,8,95,95,114,101,112,114,95,95,171,4,0,0,115, 2,0,0,0,0,1,122,23,95,78,97,109,101,115,112,97, 99,101,80,97,116,104,46,95,95,114,101,112,114,95,95,99, 2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0, @@ -1942,7 +1942,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,160,0,161,0,118,0,83,0,114,109,0,0,0,114,34, 1,0,0,169,2,114,118,0,0,0,218,4,105,116,101,109, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218, - 12,95,95,99,111,110,116,97,105,110,115,95,95,173,4,0, + 12,95,95,99,111,110,116,97,105,110,115,95,95,174,4,0, 0,115,2,0,0,0,0,1,122,27,95,78,97,109,101,115, 112,97,99,101,80,97,116,104,46,95,95,99,111,110,116,97, 105,110,115,95,95,99,2,0,0,0,0,0,0,0,0,0, @@ -1950,7 +1950,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,124,0,106,0,160,1,124,1,161,1,1,0,100, 0,83,0,114,109,0,0,0,41,2,114,24,1,0,0,114, 186,0,0,0,114,40,1,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,186,0,0,0,176,4,0, + 0,0,0,114,8,0,0,0,114,186,0,0,0,177,4,0, 0,115,2,0,0,0,0,1,122,21,95,78,97,109,101,115, 112,97,99,101,80,97,116,104,46,97,112,112,101,110,100,78, 41,15,114,125,0,0,0,114,124,0,0,0,114,126,0,0, @@ -1959,7 +1959,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 36,1,0,0,114,37,1,0,0,114,38,1,0,0,114,39, 1,0,0,114,42,1,0,0,114,186,0,0,0,114,5,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,22,1,0,0,118,4,0,0,115,24,0,0,0,8, + 0,114,22,1,0,0,119,4,0,0,115,24,0,0,0,8, 1,4,6,8,6,8,10,8,4,8,13,8,3,8,3,8, 3,8,3,8,3,8,3,114,22,1,0,0,99,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0, @@ -1975,7 +1975,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 124,2,124,3,131,3,124,0,95,1,100,0,83,0,114,109, 0,0,0,41,2,114,22,1,0,0,114,24,1,0,0,114, 28,1,0,0,114,5,0,0,0,114,5,0,0,0,114,8, - 0,0,0,114,209,0,0,0,182,4,0,0,115,2,0,0, + 0,0,0,114,209,0,0,0,183,4,0,0,115,2,0,0, 0,0,1,122,25,95,78,97,109,101,115,112,97,99,101,76, 111,97,100,101,114,46,95,95,105,110,105,116,95,95,99,2, 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,3, @@ -1992,21 +1992,21 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,109,101,115,112,97,99,101,41,62,41,2,114,62,0,0, 0,114,125,0,0,0,41,2,114,193,0,0,0,114,216,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,11,109,111,100,117,108,101,95,114,101,112,114,185,4, + 0,218,11,109,111,100,117,108,101,95,114,101,112,114,186,4, 0,0,115,2,0,0,0,0,7,122,28,95,78,97,109,101, 115,112,97,99,101,76,111,97,100,101,114,46,109,111,100,117, 108,101,95,114,101,112,114,99,2,0,0,0,0,0,0,0, 0,0,0,0,2,0,0,0,1,0,0,0,67,0,0,0, 115,4,0,0,0,100,1,83,0,41,2,78,84,114,5,0, 0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,182,0,0,0,194,4,0,0,115, + 0,114,8,0,0,0,114,182,0,0,0,195,4,0,0,115, 2,0,0,0,0,1,122,27,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,105,115,95,112,97,99,107, 97,103,101,99,2,0,0,0,0,0,0,0,0,0,0,0, 2,0,0,0,1,0,0,0,67,0,0,0,115,4,0,0, 0,100,1,83,0,41,2,78,114,40,0,0,0,114,5,0, 0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,229,0,0,0,197,4,0,0,115, + 0,114,8,0,0,0,114,229,0,0,0,198,4,0,0,115, 2,0,0,0,0,1,122,27,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,103,101,116,95,115,111,117, 114,99,101,99,2,0,0,0,0,0,0,0,0,0,0,0, @@ -2016,20 +2016,20 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 110,103,62,114,215,0,0,0,84,41,1,114,231,0,0,0, 41,1,114,232,0,0,0,114,219,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,213,0,0,0, - 200,4,0,0,115,2,0,0,0,0,1,122,25,95,78,97, + 201,4,0,0,115,2,0,0,0,0,1,122,25,95,78,97, 109,101,115,112,97,99,101,76,111,97,100,101,114,46,103,101, 116,95,99,111,100,101,99,2,0,0,0,0,0,0,0,0, 0,0,0,2,0,0,0,1,0,0,0,67,0,0,0,115, 4,0,0,0,100,1,83,0,114,210,0,0,0,114,5,0, 0,0,114,211,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,212,0,0,0,203,4,0,0,115, + 0,114,8,0,0,0,114,212,0,0,0,204,4,0,0,115, 2,0,0,0,0,1,122,30,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,99,114,101,97,116,101,95, 109,111,100,117,108,101,99,2,0,0,0,0,0,0,0,0, 0,0,0,2,0,0,0,1,0,0,0,67,0,0,0,115, 4,0,0,0,100,0,83,0,114,109,0,0,0,114,5,0, 0,0,114,253,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,217,0,0,0,206,4,0,0,115, + 0,114,8,0,0,0,114,217,0,0,0,207,4,0,0,115, 2,0,0,0,0,1,122,28,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,101,120,101,99,95,109,111, 100,117,108,101,99,2,0,0,0,0,0,0,0,0,0,0, @@ -2047,7 +2047,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,112,97,116,104,32,123,33,114,125,41,4,114,134,0,0, 0,114,149,0,0,0,114,24,1,0,0,114,218,0,0,0, 114,219,0,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,220,0,0,0,209,4,0,0,115,8,0, + 8,0,0,0,114,220,0,0,0,210,4,0,0,115,8,0, 0,0,0,7,6,1,4,255,4,2,122,28,95,78,97,109, 101,115,112,97,99,101,76,111,97,100,101,114,46,108,111,97, 100,95,109,111,100,117,108,101,78,41,12,114,125,0,0,0, @@ -2056,7 +2056,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,213,0,0,0,114,212,0,0,0,114,217,0, 0,0,114,220,0,0,0,114,5,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,43,1,0,0, - 181,4,0,0,115,18,0,0,0,8,1,8,3,2,1,10, + 182,4,0,0,115,18,0,0,0,8,1,8,3,2,1,10, 8,8,3,8,3,8,3,8,3,8,3,114,43,1,0,0, 99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,4,0,0,0,64,0,0,0,115,118,0,0,0,101,0, @@ -2093,7 +2093,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,46,1,0,0,41,3,114,193,0,0,0,114, 116,0,0,0,218,6,102,105,110,100,101,114,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,46,1,0,0, - 227,4,0,0,115,10,0,0,0,0,4,22,1,8,1,10, + 228,4,0,0,115,10,0,0,0,0,4,22,1,8,1,10, 1,10,1,122,28,80,97,116,104,70,105,110,100,101,114,46, 105,110,118,97,108,105,100,97,116,101,95,99,97,99,104,101, 115,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0, @@ -2113,7 +2113,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 117,0,0,0,41,3,114,193,0,0,0,114,44,0,0,0, 90,4,104,111,111,107,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,11,95,112,97,116,104,95,104,111,111, - 107,115,237,4,0,0,115,16,0,0,0,0,3,16,1,12, + 107,115,238,4,0,0,115,16,0,0,0,0,3,16,1,12, 1,10,1,2,1,14,1,12,1,12,2,122,22,80,97,116, 104,70,105,110,100,101,114,46,95,112,97,116,104,95,104,111, 111,107,115,99,2,0,0,0,0,0,0,0,0,0,0,0, @@ -2144,7 +2144,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,114,44,0,0,0,114,50,1,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,20,95,112,97, 116,104,95,105,109,112,111,114,116,101,114,95,99,97,99,104, - 101,250,4,0,0,115,22,0,0,0,0,8,8,1,2,1, + 101,251,4,0,0,115,22,0,0,0,0,8,8,1,2,1, 12,1,12,3,8,1,2,1,14,1,12,1,10,1,16,1, 122,31,80,97,116,104,70,105,110,100,101,114,46,95,112,97, 116,104,95,105,109,112,111,114,116,101,114,95,99,97,99,104, @@ -2161,7 +2161,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,193,0,0,0,114,139,0,0,0,114,50,1,0,0,114, 140,0,0,0,114,141,0,0,0,114,187,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,16,95, - 108,101,103,97,99,121,95,103,101,116,95,115,112,101,99,16, + 108,101,103,97,99,121,95,103,101,116,95,115,112,101,99,17, 5,0,0,115,18,0,0,0,0,4,10,1,16,2,10,1, 4,1,8,1,12,1,12,1,6,1,122,27,80,97,116,104, 70,105,110,100,101,114,46,95,108,101,103,97,99,121,95,103, @@ -2193,7 +2193,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 95,112,97,116,104,90,5,101,110,116,114,121,114,50,1,0, 0,114,187,0,0,0,114,141,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,8,0,0,0,218,9,95,103,101,116, - 95,115,112,101,99,31,5,0,0,115,40,0,0,0,0,5, + 95,115,112,101,99,32,5,0,0,115,40,0,0,0,0,5, 4,1,8,1,14,1,2,1,10,1,8,1,10,1,14,2, 12,1,8,1,2,1,10,1,8,1,6,1,8,1,8,5, 12,2,12,1,6,1,122,20,80,97,116,104,70,105,110,100, @@ -2220,7 +2220,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,22,1,0,0,41,6,114,193,0,0,0,114,139,0,0, 0,114,44,0,0,0,114,202,0,0,0,114,187,0,0,0, 114,57,1,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,203,0,0,0,63,5,0,0,115,26,0, + 8,0,0,0,114,203,0,0,0,64,5,0,0,115,26,0, 0,0,0,6,8,1,6,1,14,1,8,1,4,1,10,1, 6,1,4,3,6,1,16,1,4,2,6,2,122,20,80,97, 116,104,70,105,110,100,101,114,46,102,105,110,100,95,115,112, @@ -2240,7 +2240,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 110,100,95,115,112,101,99,40,41,32,105,110,115,116,101,97, 100,46,10,10,32,32,32,32,32,32,32,32,78,114,204,0, 0,0,114,205,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,206,0,0,0,87,5,0,0,115, + 0,114,8,0,0,0,114,206,0,0,0,88,5,0,0,115, 8,0,0,0,0,8,12,1,8,1,4,1,122,22,80,97, 116,104,70,105,110,100,101,114,46,102,105,110,100,95,109,111, 100,117,108,101,99,1,0,0,0,0,0,0,0,0,0,0, @@ -2272,7 +2272,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,95,100,105,115,116,114,105,98,117,116,105,111,110,115,41, 4,114,193,0,0,0,114,119,0,0,0,114,120,0,0,0, 114,59,1,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,60,1,0,0,100,5,0,0,115,4,0, + 8,0,0,0,114,60,1,0,0,101,5,0,0,115,4,0, 0,0,0,10,12,1,122,29,80,97,116,104,70,105,110,100, 101,114,46,102,105,110,100,95,100,105,115,116,114,105,98,117, 116,105,111,110,115,41,1,78,41,2,78,78,41,1,78,41, @@ -2281,7 +2281,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 52,1,0,0,114,54,1,0,0,114,55,1,0,0,114,58, 1,0,0,114,203,0,0,0,114,206,0,0,0,114,60,1, 0,0,114,5,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,45,1,0,0,223,4,0,0,115, + 0,114,8,0,0,0,114,45,1,0,0,224,4,0,0,115, 34,0,0,0,8,2,4,2,2,1,10,9,2,1,10,12, 2,1,10,21,2,1,10,14,2,1,12,31,2,1,12,23, 2,1,12,12,2,1,114,45,1,0,0,99,0,0,0,0, @@ -2326,7 +2326,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 14,125,1,124,1,136,0,102,2,86,0,1,0,113,2,100, 0,83,0,114,109,0,0,0,114,5,0,0,0,114,16,1, 0,0,169,1,114,140,0,0,0,114,5,0,0,0,114,8, - 0,0,0,114,19,1,0,0,129,5,0,0,243,0,0,0, + 0,0,0,114,19,1,0,0,130,5,0,0,243,0,0,0, 0,122,38,70,105,108,101,70,105,110,100,101,114,46,95,95, 105,110,105,116,95,95,46,60,108,111,99,97,108,115,62,46, 60,103,101,110,101,120,112,114,62,114,71,0,0,0,114,104, @@ -2338,7 +2338,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,118,0,0,0,114,44,0,0,0,218,14,108,111,97,100, 101,114,95,100,101,116,97,105,108,115,90,7,108,111,97,100, 101,114,115,114,189,0,0,0,114,5,0,0,0,114,62,1, - 0,0,114,8,0,0,0,114,209,0,0,0,123,5,0,0, + 0,0,114,8,0,0,0,114,209,0,0,0,124,5,0,0, 115,16,0,0,0,0,4,4,1,12,1,26,1,6,2,10, 1,6,1,8,1,122,19,70,105,108,101,70,105,110,100,101, 114,46,95,95,105,110,105,116,95,95,99,1,0,0,0,0, @@ -2348,7 +2348,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,116,104,101,32,100,105,114,101,99,116,111,114,121,32,109, 116,105,109,101,46,114,104,0,0,0,78,41,1,114,65,1, 0,0,114,246,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,46,1,0,0,137,5,0,0,115, + 0,114,8,0,0,0,114,46,1,0,0,138,5,0,0,115, 2,0,0,0,0,2,122,28,70,105,108,101,70,105,110,100, 101,114,46,105,110,118,97,108,105,100,97,116,101,95,99,97, 99,104,101,115,99,2,0,0,0,0,0,0,0,0,0,0, @@ -2371,7 +2371,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,32,32,32,32,78,41,3,114,203,0,0,0,114,140,0, 0,0,114,178,0,0,0,41,3,114,118,0,0,0,114,139, 0,0,0,114,187,0,0,0,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,137,0,0,0,143,5,0,0, + 0,0,114,8,0,0,0,114,137,0,0,0,144,5,0,0, 115,8,0,0,0,0,7,10,1,8,1,8,1,122,22,70, 105,108,101,70,105,110,100,101,114,46,102,105,110,100,95,108, 111,97,100,101,114,99,6,0,0,0,0,0,0,0,0,0, @@ -2382,7 +2382,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,188,0,0,0,114,139,0,0,0,114,44,0, 0,0,90,4,115,109,115,108,114,202,0,0,0,114,140,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,58,1,0,0,155,5,0,0,115,8,0,0,0,0, + 0,114,58,1,0,0,156,5,0,0,115,8,0,0,0,0, 1,10,1,8,1,2,255,122,20,70,105,108,101,70,105,110, 100,101,114,46,95,103,101,116,95,115,112,101,99,78,99,3, 0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,8, @@ -2436,7 +2436,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 104,114,17,1,0,0,114,188,0,0,0,90,13,105,110,105, 116,95,102,105,108,101,110,97,109,101,90,9,102,117,108,108, 95,112,97,116,104,114,187,0,0,0,114,5,0,0,0,114, - 5,0,0,0,114,8,0,0,0,114,203,0,0,0,160,5, + 5,0,0,0,114,8,0,0,0,114,203,0,0,0,161,5, 0,0,115,72,0,0,0,0,5,4,1,14,1,2,1,24, 1,12,1,10,1,10,1,8,1,6,2,6,1,6,1,10, 2,6,1,4,2,8,1,12,1,14,1,8,1,10,1,8, @@ -2468,7 +2468,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 161,0,146,2,113,4,83,0,114,5,0,0,0,41,1,114, 105,0,0,0,41,2,114,32,0,0,0,90,2,102,110,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,9, - 60,115,101,116,99,111,109,112,62,237,5,0,0,114,63,1, + 60,115,101,116,99,111,109,112,62,238,5,0,0,114,63,1, 0,0,122,41,70,105,108,101,70,105,110,100,101,114,46,95, 102,105,108,108,95,99,97,99,104,101,46,60,108,111,99,97, 108,115,62,46,60,115,101,116,99,111,109,112,62,78,41,18, @@ -2484,7 +2484,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 102,102,105,120,95,99,111,110,116,101,110,116,115,114,41,1, 0,0,114,116,0,0,0,114,29,1,0,0,114,17,1,0, 0,90,8,110,101,119,95,110,97,109,101,114,5,0,0,0, - 114,5,0,0,0,114,8,0,0,0,114,70,1,0,0,208, + 114,5,0,0,0,114,8,0,0,0,114,70,1,0,0,209, 5,0,0,115,34,0,0,0,0,2,6,1,2,1,22,1, 18,3,10,3,12,1,12,7,6,1,8,1,16,1,4,1, 18,2,4,1,12,1,6,1,12,1,122,22,70,105,108,101, @@ -2523,14 +2523,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,48,0,0,0,169,2,114,193,0,0,0,114,69,1, 0,0,114,5,0,0,0,114,8,0,0,0,218,24,112,97, 116,104,95,104,111,111,107,95,102,111,114,95,70,105,108,101, - 70,105,110,100,101,114,249,5,0,0,115,6,0,0,0,0, + 70,105,110,100,101,114,250,5,0,0,115,6,0,0,0,0, 2,8,1,12,1,122,54,70,105,108,101,70,105,110,100,101, 114,46,112,97,116,104,95,104,111,111,107,46,60,108,111,99, 97,108,115,62,46,112,97,116,104,95,104,111,111,107,95,102, 111,114,95,70,105,108,101,70,105,110,100,101,114,114,5,0, 0,0,41,3,114,193,0,0,0,114,69,1,0,0,114,76, 1,0,0,114,5,0,0,0,114,75,1,0,0,114,8,0, - 0,0,218,9,112,97,116,104,95,104,111,111,107,239,5,0, + 0,0,218,9,112,97,116,104,95,104,111,111,107,240,5,0, 0,115,4,0,0,0,0,10,14,6,122,20,70,105,108,101, 70,105,110,100,101,114,46,112,97,116,104,95,104,111,111,107, 99,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0, @@ -2539,7 +2539,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 105,108,101,70,105,110,100,101,114,40,123,33,114,125,41,41, 2,114,62,0,0,0,114,44,0,0,0,114,246,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 39,1,0,0,1,6,0,0,115,2,0,0,0,0,1,122, + 39,1,0,0,2,6,0,0,115,2,0,0,0,0,1,122, 19,70,105,108,101,70,105,110,100,101,114,46,95,95,114,101, 112,114,95,95,41,1,78,41,15,114,125,0,0,0,114,124, 0,0,0,114,126,0,0,0,114,127,0,0,0,114,209,0, @@ -2547,7 +2547,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,137,0,0,0,114,58,1,0,0,114,203,0,0,0, 114,70,1,0,0,114,207,0,0,0,114,77,1,0,0,114, 39,1,0,0,114,5,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,61,1,0,0,114,5,0, + 0,0,0,114,8,0,0,0,114,61,1,0,0,115,5,0, 0,115,22,0,0,0,8,2,4,7,8,14,8,4,4,2, 8,12,8,5,10,48,8,31,2,1,10,17,114,61,1,0, 0,99,4,0,0,0,0,0,0,0,0,0,0,0,6,0, @@ -2571,7 +2571,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 99,112,97,116,104,110,97,109,101,114,140,0,0,0,114,187, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, 0,0,218,14,95,102,105,120,95,117,112,95,109,111,100,117, - 108,101,7,6,0,0,115,34,0,0,0,0,2,10,1,10, + 108,101,8,6,0,0,115,34,0,0,0,0,2,10,1,10, 1,4,1,4,1,8,1,8,1,12,2,10,1,4,1,14, 1,2,1,8,1,8,1,8,1,12,1,12,2,114,82,1, 0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,3, @@ -2591,7 +2591,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 10,101,120,116,101,110,115,105,111,110,115,90,6,115,111,117, 114,99,101,90,8,98,121,116,101,99,111,100,101,114,5,0, 0,0,114,5,0,0,0,114,8,0,0,0,114,184,0,0, - 0,30,6,0,0,115,8,0,0,0,0,5,12,1,8,1, + 0,31,6,0,0,115,8,0,0,0,0,5,12,1,8,1, 8,1,114,184,0,0,0,99,1,0,0,0,0,0,0,0, 0,0,0,0,10,0,0,0,9,0,0,0,67,0,0,0, 115,132,1,0,0,124,0,97,0,116,0,106,1,97,1,116, @@ -2639,7 +2639,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,83,0,41,2,114,39,0,0,0,78,41,1,114,23,0, 0,0,41,2,114,32,0,0,0,114,94,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,19,1, - 0,0,59,6,0,0,114,63,1,0,0,122,25,95,115,101, + 0,0,60,6,0,0,114,63,1,0,0,122,25,95,115,101, 116,117,112,46,60,108,111,99,97,108,115,62,46,60,103,101, 110,101,120,112,114,62,114,73,0,0,0,122,30,105,109,112, 111,114,116,108,105,98,32,114,101,113,117,105,114,101,115,32, @@ -2651,7 +2651,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 157,2,146,2,113,4,83,0,41,1,114,74,0,0,0,114, 5,0,0,0,41,2,114,32,0,0,0,218,1,115,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,71,1, - 0,0,76,6,0,0,114,63,1,0,0,122,25,95,115,101, + 0,0,77,6,0,0,114,63,1,0,0,122,25,95,115,101, 116,117,112,46,60,108,111,99,97,108,115,62,46,60,115,101, 116,99,111,109,112,62,41,3,114,64,0,0,0,114,75,0, 0,0,114,160,0,0,0,114,192,0,0,0,114,9,0,0, @@ -2671,7 +2671,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,116,105,110,95,110,97,109,101,115,90,12,98,117,105,108, 116,105,110,95,110,97,109,101,90,14,98,117,105,108,116,105, 110,95,109,111,100,117,108,101,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,218,6,95,115,101,116,117,112,41, + 0,0,114,8,0,0,0,218,6,95,115,101,116,117,112,42, 6,0,0,115,70,0,0,0,0,8,4,1,6,1,6,2, 10,3,22,1,12,2,22,1,8,1,10,1,10,1,6,2, 2,1,10,1,10,1,12,1,12,2,8,2,12,1,12,1, @@ -2691,7 +2691,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 104,114,186,0,0,0,114,45,1,0,0,41,2,114,88,1, 0,0,90,17,115,117,112,112,111,114,116,101,100,95,108,111, 97,100,101,114,115,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,218,8,95,105,110,115,116,97,108,108,98,6, + 8,0,0,0,218,8,95,105,110,115,116,97,108,108,99,6, 0,0,115,8,0,0,0,0,2,8,1,6,1,20,1,114, 91,1,0,0,41,1,114,60,0,0,0,41,1,78,41,3, 78,78,78,41,2,114,73,0,0,0,114,73,0,0,0,41, @@ -2725,7 +2725,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 218,8,60,109,111,100,117,108,101,62,1,0,0,0,115,126, 0,0,0,4,22,4,1,4,1,2,1,2,255,4,4,8, 17,8,5,8,5,8,6,8,6,8,12,8,10,8,9,8, - 5,8,7,8,9,10,22,10,127,0,22,16,1,12,2,4, + 5,8,7,8,9,10,22,10,127,0,23,16,1,12,2,4, 1,4,2,6,2,6,2,8,2,16,71,8,40,8,19,8, 12,8,12,8,28,8,17,8,33,8,28,8,24,10,13,10, 10,10,11,8,14,6,3,4,1,2,255,12,68,14,64,14, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 92f2e4004120e4..09a0c12e5f9c4f 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -165,8 +165,8 @@ static void *opcode_targets[256] = { &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, - &&TARGET_GET_MATCH_ITER, - &&TARGET_GET_MATCH_MAP, + &&TARGET_MATCH_SEQ_TYPE, + &&TARGET_MATCH_MAP_TYPE, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From ea0de16e323c3e68329b7624cc4f6d384cba55d6 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 28 May 2020 10:23:58 -0700 Subject: [PATCH 031/189] Bump MAGIC_NUMBER --- Lib/importlib/_bootstrap_external.py | 2 +- Python/importlib_external.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 1262a27aca0a02..c799f8f002a415 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -289,7 +289,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3435).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3437).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 91843aad11f15c..4c7277b19b62f9 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,107,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,109,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, From 880a7c2b53b433de0b5cbfa48cf17b07d0157844 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 28 May 2020 19:44:08 -0700 Subject: [PATCH 032/189] Add mapping support --- Doc/library/dis.rst | 27 +++- Include/opcode.h | 5 +- Lib/importlib/_bootstrap_external.py | 6 +- Lib/opcode.py | 5 +- Python/ast.c | 68 ++++++-- Python/ceval.c | 52 ++++-- Python/compile.c | 97 ++++++++--- Python/importlib_external.h | 230 +++++++++++++-------------- Python/opcode_targets.h | 6 +- 9 files changed, 311 insertions(+), 185 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 853eb46fdfc602..fbd71e24ee5da9 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -990,20 +990,31 @@ All of the following opcodes use their arguments. code counter is incremented by *delta*. -.. opcode:: MATCH_SEQ_TYPE (delta) +.. opcode:: MATCH_SEQ (delta) - Used for pattern matching. Pops TOS and increments the byte code counter by - *delta* if TOS is not an instance of :class:`collections.abc.Sequence`, is an - :term:`iterator`, or is an instance of - :class:`str`/:class:`bytes`/:class:`bytearray`. + Used to implement pattern matching. Pop TOS. If it is an instance of + :class:`collections.abc.Sequence`, is not an :term:`iterator`, and is not an + instance of :class:`str`/:class:`bytes`/:class:`bytearray`, get an iterator + from it and push that onto the stack. Otherwise, increment the bytecode + counter by ``delta``. .. versionadded:: 3.10 -.. opcode:: MATCH_MAP_TYPE (delta) +.. opcode:: MATCH_MAP (delta) - Used for pattern matching. Pops TOS and increments the byte code counter by - *delta* if TOS is not an instance of :class:`collections.abc.Mapping`. + Used to implement pattern matching. Pop TOS. If it is an instance of + :class:`collections.abc.Mapping`, copy it into a :class:`dict` and push that + onto the stack. Otherwise, increment the bytecode counter by *delta*. + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_KEY (delta) + + Used to implement pattern matching. Pop TOS. If it is a key in the dict at + TOS1, remove it and push the associated value onto the stack. Otherwise, + increment the bytecode counter by *delta*. .. versionadded:: 3.10 diff --git a/Include/opcode.h b/Include/opcode.h index 826dc864125ad5..6cff79517cccb7 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -127,8 +127,9 @@ extern "C" { #define SET_UPDATE 163 #define DICT_MERGE 164 #define DICT_UPDATE 165 -#define MATCH_SEQ_TYPE 166 -#define MATCH_MAP_TYPE 167 +#define MATCH_SEQ 166 +#define MATCH_MAP 167 +#define MATCH_KEY 168 /* EXCEPT_HANDLER is a special, implicit block type which is created when entering an except handler. It is not an opcode but we define it here diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index c799f8f002a415..eb3100b41dae4d 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,9 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3435 (add GET_MATCH_ITER) -# Python 3.10a0 3436 (add GET_MATCH_MAP) -# Python 3.10a0 3437 (GET_MATCH_* -> MATCH_*_TYPE) +# Python 3.10a0 3438 (add MATCH_KEY, MATCH_MAP, MATCH_SEQ) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -289,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3437).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3438).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index da3f4ac1aa69b6..67f0e3149aaf18 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -213,7 +213,8 @@ def jabs_op(name, op): def_op('SET_UPDATE', 163) def_op('DICT_MERGE', 164) def_op('DICT_UPDATE', 165) -jrel_op('MATCH_SEQ_TYPE', 166) -jrel_op('MATCH_MAP_TYPE', 167) +jrel_op('MATCH_SEQ', 166) +jrel_op('MATCH_MAP', 167) +jrel_op('MATCH_KEY', 168) del def_op, name_op, jrel_op, jabs_op diff --git a/Python/ast.c b/Python/ast.c index f5c82d2b1745ad..9d4df2a41f9a31 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -305,47 +305,81 @@ validate_expr(expr_ty exp, expr_context_ty ctx) static int validate_pattern(expr_ty p) { - asdl_seq *elts; - expr_ty elt; + asdl_seq *keys, *values; + expr_ty key, value; Py_ssize_t i, size; - char *error = "invalid Match pattern"; switch (p->kind) { case Attribute_kind: return validate_expr(p, Load); case BinOp_kind: if (p->v.BinOp.op != BitOr) { - error = "BinOp op in pattern must be BitOr"; + PyErr_SetString(PyExc_ValueError, + "BinOp op in pattern must be BitOr"); + return 0; } return (validate_pattern(p->v.BinOp.left) && validate_pattern(p->v.BinOp.right)); case Constant_kind: - return validate_constant(p->v.Constant.value); + return validate_expr(p, Load); + case Dict_kind: + keys = p->v.Dict.keys; + values = p->v.Dict.values; + size = asdl_seq_LEN(values); + if (asdl_seq_LEN(keys) != size) { + PyErr_SetString(PyExc_ValueError, + "Dict keys and values must be equal-length"); + return 0; + } + for (i = 0; i < size; i++) { + key = asdl_seq_GET(keys, i); + if (key) { + if (key->kind == Name_kind) { + if (key->v.Name.ctx != Load) { + PyErr_SetString(PyExc_ValueError, + "Name ctx in Dict keys pattern must be Load"); + return 0; + } + } + else if (key->kind != Constant_kind) { + PyErr_SetString(PyExc_ValueError, + "Dict keys pattern must be Constant or Name"); + return 0; + } + return validate_expr(key, Load); + } + if (!validate_pattern(asdl_seq_GET(values, i))) { + return 0; + } + } + return 0; case List_kind: - case Tuple_kind: - elts = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; - size = asdl_seq_LEN(elts); + case Tuple_kind: // TODO: Undecided yet if tuple syntax is legal. + values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; + size = asdl_seq_LEN(values); for (i = 0; i < size; i++) { - elt = asdl_seq_GET(elts, i); - if (elt->kind == Starred_kind) { - elt = elt->v.Starred.value; + value = asdl_seq_GET(values, i); + if (value->kind == Starred_kind) { + value = value->v.Starred.value; } - if (!validate_pattern(elt)) { + if (!validate_pattern(value)) { return 0; } } return 1; case Name_kind: if (p->v.Name.ctx != Load && p->v.Name.ctx != Store) { - error = "Name ctx in pattern must be either Load or Store"; + PyErr_SetString(PyExc_ValueError, + "Name ctx in pattern must be Load or Store"); + return 0; } return validate_expr(p, p->v.Name.ctx); case NamedExpr_kind: - return validate_pattern(p->v.NamedExpr.value); + return (validate_pattern(p->v.NamedExpr.value) + && validate_expr(p->v.NamedExpr.target, Store)); default: - break; + PyErr_SetString(PyExc_ValueError, "invalid Match pattern"); + return 0; } - PyErr_SetString(PyExc_ValueError, error); - return 0; } static int diff --git a/Python/ceval.c b/Python/ceval.c index cf4bf374773869..7ecb7d5756e064 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2853,7 +2853,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(BUILD_MAP): { - PREDICTED(BUILD_MAP); Py_ssize_t i; PyObject *map = _PyDict_NewPresized((Py_ssize_t)oparg); if (map == NULL) @@ -3285,7 +3284,31 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) #endif } - case TARGET(MATCH_MAP_TYPE): { + case TARGET(MATCH_KEY): { + PyObject *key = TOP(); + PyObject *map = SECOND(); + assert(PyDict_CheckExact(map)); + PyObject *value = PyDict_GetItemWithError(map, key); + if (!value) { + if (_PyErr_Occurred(tstate)) { + goto error; + } + STACK_SHRINK(1); + Py_DECREF(key); + JUMPBY(oparg); + DISPATCH(); + } + Py_INCREF(value); + if (PyDict_DelItem(map, key)) { + Py_DECREF(value); + goto error; + } + Py_DECREF(key); + SET_TOP(value); + DISPATCH(); + } + + case TARGET(MATCH_MAP): { PyInterpreterState *interp = PyInterpreterState_Get(); if (!interp) { goto error; @@ -3308,11 +3331,26 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) JUMPBY(oparg); DISPATCH(); } - PREDICT(BUILD_MAP); + PyObject *copy; + if (PyDict_CheckExact(target)) { + copy = PyDict_Copy(target); + if (!copy) { + goto error; + } + } + else { + copy = PyDict_New(); + if (!copy || PyDict_Update(copy, target)) { + Py_XDECREF(copy); + goto error; + } + } + Py_DECREF(target); + SET_TOP(copy); DISPATCH(); } - case TARGET(MATCH_SEQ_TYPE): { + case TARGET(MATCH_SEQ): { PyInterpreterState *interp = PyInterpreterState_Get(); if (!interp) { goto error; @@ -3341,12 +3379,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) JUMPBY(oparg); DISPATCH(); } - PREDICT(GET_ITER); - DISPATCH(); - } - + } // Fall... case TARGET(GET_ITER): { - PREDICTED(GET_ITER); /* before: [obj]; after [getiter(obj)] */ PyObject *iterable = TOP(); PyObject *iter = PyObject_GetIter(iterable); diff --git a/Python/compile.c b/Python/compile.c index 93951550d0db4c..510ff8346a162b 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -980,8 +980,9 @@ stack_effect(int opcode, int oparg, int jump) case FOR_ITER: /* -1 at end of iterator, 1 if continue iterating. */ return jump > 0 ? -1 : 1; - case MATCH_SEQ_TYPE: - case MATCH_MAP_TYPE: + case MATCH_SEQ: + case MATCH_MAP: + case MATCH_KEY: return -(jump > 0); case STORE_ATTR: @@ -2750,7 +2751,7 @@ compiler_if(struct compiler *c, stmt_ty s) } static int -compiler_pattern_name_store(struct compiler *c, expr_ty p) +pattern_store_helper(struct compiler *c, expr_ty p) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); @@ -2768,19 +2769,19 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) { basicblock *end, *block; Py_ssize_t i, size, star; - asdl_seq *elts; - expr_ty elt; + asdl_seq *keys, *values; + expr_ty key, value; switch (p->kind) { // Atomic patterns: case Name_kind: if (p->v.Name.ctx == Store) { - return compiler_pattern_name_store(c, p); + return pattern_store_helper(c, p); } assert(p->v.Name.ctx == Load); - // Fall through... + // Fall... case Attribute_kind: assert(p->kind != Attribute_kind || p->v.Attribute.ctx == Load); - // Fall through.... + // Fall.... case Constant_kind: VISIT(c, expr, p); ADDOP_COMPARE(c, Eq); @@ -2803,17 +2804,66 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) } compiler_use_next_block(c, end); return 1; + case Dict_kind: + keys = p->v.Dict.keys; + values = p->v.Dict.values; + size = asdl_seq_LEN(values); + star = 0; + // TODO: Rely on parser/validation for this? + for (i = 0; i < size; i++) { + if (asdl_seq_GET(keys, i)) { + continue; + } + value = asdl_seq_GET(values, i); + if (value->kind != Name_kind || value->v.Name.ctx != Store) { + return compiler_error(c, + "starred sub-patterns must be names"); + } + if (i != size - 1) { + return compiler_error(c, + "sub-patterns cannot follow starred name"); + } + star = 1; + } + end = compiler_new_block(c); + block = compiler_new_block(c); + ADDOP_JREL(c, MATCH_MAP, fail); + for (i = 0; i < size - star; i++) { + key = asdl_seq_GET(keys, i); + value = asdl_seq_GET(values, i); + assert(key); + assert(key->kind == Name_kind && key->v.Name.ctx == Load + || key->kind == Constant_kind); + VISIT(c, expr, key); + ADDOP_JREL(c, MATCH_KEY, block); + if (!compiler_pattern(c, value, block)) { + return 0; + } + } + if (!star) { + ADDOP(c, POP_TOP); + } + else if (!pattern_store_helper(c, asdl_seq_GET(values, size - 1))) { + return 0; + } + ADDOP_JREL(c, JUMP_FORWARD, end); + compiler_use_next_block(c, block); + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, fail); + compiler_use_next_block(c, end); + return 1; case List_kind: - case Tuple_kind: - elts = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; - size = asdl_seq_LEN(elts); + case Tuple_kind: // TODO: Undecided yet if tuple syntax is legal. + values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; + size = asdl_seq_LEN(values); star = -1; for (i = 0; i < size; i++) { - elt = asdl_seq_GET(elts, i); - if (elt->kind != Starred_kind) { + value = asdl_seq_GET(values, i); + if (value->kind != Starred_kind) { continue; } - if (elt->kind != Name_kind || elt->v.Name.ctx != Store) { + // TODO: Rely on parser/validation for this? + if (value->kind != Name_kind || value->v.Name.ctx != Store) { return compiler_error(c, "starred sub-patterns must be names"); } @@ -2821,28 +2871,27 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) return compiler_error(c, "multiple starred names in pattern"); } + // TODO: Test this math: if ((size - i - 1) << 8 >= INT_MAX) { return compiler_error(c, - "too many sub-patterns follow starred sub-pattern"); + "too many sub-patterns follow starred name"); } star = i; } end = compiler_new_block(c); block = compiler_new_block(c); - ADDOP_JREL(c, MATCH_SEQ_TYPE, fail); - ADDOP(c, GET_ITER); + ADDOP_JREL(c, MATCH_SEQ, fail); for (i = 0; i < size; i++) { - elt = asdl_seq_GET(elts, i); + value = asdl_seq_GET(values, i); if (i == star) { - assert(elt->kind == Starred_kind); + assert(value->kind == Starred_kind); ADDOP_I(c, UNPACK_EX, (size - i - 1) << 8); - if (!compiler_pattern_name_store(c, elt->v.Starred.value)) { + if (!pattern_store_helper(c, value->v.Starred.value)) { return 0; } if (size - i - 1) { ADDOP_I(c, BUILD_TUPLE, size - i - 1); - ADDOP_JREL(c, MATCH_SEQ_TYPE, fail); - ADDOP(c, GET_ITER); + ADDOP_JREL(c, MATCH_SEQ, fail); } else { ADDOP_JREL(c, JUMP_FORWARD, end); @@ -2850,13 +2899,11 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) } else { ADDOP_JREL(c, FOR_ITER, fail); - if (!compiler_pattern(c, elt, block)) { + if (!compiler_pattern(c, value, block)) { return 0; } } } - // TODO: This could be simplified with VM support. Pop top, and jump - // to "fail" if items remain. JUMP_IF_NOT_EMPTY? ADDOP_JREL(c, FOR_ITER, end); ADDOP(c, POP_TOP); compiler_use_next_block(c, block); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 4c7277b19b62f9..ea266c93abde41 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,109,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,110,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, @@ -400,7 +400,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 95,102,105,108,101,110,97,109,101,218,8,102,105,108,101,110, 97,109,101,114,5,0,0,0,114,5,0,0,0,114,8,0, 0,0,218,17,99,97,99,104,101,95,102,114,111,109,95,115, - 111,117,114,99,101,48,1,0,0,115,72,0,0,0,0,18, + 111,117,114,99,101,46,1,0,0,115,72,0,0,0,0,18, 8,1,6,1,2,255,4,2,8,1,4,1,8,1,12,1, 10,1,12,1,16,1,8,1,8,1,8,1,24,1,8,1, 12,1,6,2,8,1,8,1,8,1,8,1,14,1,14,1, @@ -481,7 +481,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,101,118,101,108,90,13,98,97,115,101,95,102,105,108,101, 110,97,109,101,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,17,115,111,117,114,99,101,95,102,114,111,109, - 95,99,97,99,104,101,119,1,0,0,115,68,0,0,0,0, + 95,99,97,99,104,101,117,1,0,0,115,68,0,0,0,0, 9,12,1,8,1,10,1,12,1,4,1,10,1,12,1,14, 1,16,1,4,1,4,1,12,1,8,1,2,1,2,255,4, 1,2,255,8,2,10,1,8,1,16,1,10,1,16,1,10, @@ -517,7 +517,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 120,116,101,110,115,105,111,110,218,11,115,111,117,114,99,101, 95,112,97,116,104,114,5,0,0,0,114,5,0,0,0,114, 8,0,0,0,218,15,95,103,101,116,95,115,111,117,114,99, - 101,102,105,108,101,159,1,0,0,115,20,0,0,0,0,7, + 101,102,105,108,101,157,1,0,0,115,20,0,0,0,0,7, 12,1,4,1,16,1,24,1,4,1,2,1,12,1,16,1, 18,1,114,108,0,0,0,99,1,0,0,0,0,0,0,0, 0,0,0,0,1,0,0,0,8,0,0,0,67,0,0,0, @@ -530,7 +530,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 112,108,101,114,101,0,0,0,114,97,0,0,0,114,82,0, 0,0,114,88,0,0,0,41,1,114,96,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,11,95, - 103,101,116,95,99,97,99,104,101,100,178,1,0,0,115,16, + 103,101,116,95,99,97,99,104,101,100,176,1,0,0,115,16, 0,0,0,0,1,14,1,2,1,10,1,12,1,8,1,14, 1,4,2,114,112,0,0,0,99,1,0,0,0,0,0,0, 0,0,0,0,0,2,0,0,0,8,0,0,0,67,0,0, @@ -545,7 +545,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,51,0,0,0,114,50,0,0,0,41,2,114,44,0,0, 0,114,52,0,0,0,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,10,95,99,97,108,99,95,109,111,100, - 101,190,1,0,0,115,12,0,0,0,0,2,2,1,14,1, + 101,188,1,0,0,115,12,0,0,0,0,2,2,1,14,1, 12,1,10,3,8,1,114,114,0,0,0,99,1,0,0,0, 0,0,0,0,0,0,0,0,3,0,0,0,8,0,0,0, 3,0,0,0,115,66,0,0,0,100,6,135,0,102,1,100, @@ -583,7 +583,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,114,103,115,218,6,107,119,97,114,103,115,169,1,218,6, 109,101,116,104,111,100,114,5,0,0,0,114,8,0,0,0, 218,19,95,99,104,101,99,107,95,110,97,109,101,95,119,114, - 97,112,112,101,114,210,1,0,0,115,18,0,0,0,0,1, + 97,112,112,101,114,208,1,0,0,115,18,0,0,0,0,1, 8,1,8,1,10,1,4,1,8,255,2,1,2,255,6,2, 122,40,95,99,104,101,99,107,95,110,97,109,101,46,60,108, 111,99,97,108,115,62,46,95,99,104,101,99,107,95,110,97, @@ -601,7 +601,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 8,95,95,100,105,99,116,95,95,218,6,117,112,100,97,116, 101,41,3,90,3,110,101,119,90,3,111,108,100,114,67,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,5,95,119,114,97,112,221,1,0,0,115,8,0,0, + 0,218,5,95,119,114,97,112,219,1,0,0,115,8,0,0, 0,0,1,8,1,10,1,20,1,122,26,95,99,104,101,99, 107,95,110,97,109,101,46,60,108,111,99,97,108,115,62,46, 95,119,114,97,112,41,1,78,41,3,218,10,95,98,111,111, @@ -609,7 +609,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,69,114,114,111,114,41,3,114,122,0,0,0,114,123,0, 0,0,114,133,0,0,0,114,5,0,0,0,114,121,0,0, 0,114,8,0,0,0,218,11,95,99,104,101,99,107,95,110, - 97,109,101,202,1,0,0,115,14,0,0,0,0,8,14,7, + 97,109,101,200,1,0,0,115,14,0,0,0,0,8,14,7, 2,1,10,1,12,2,14,5,10,1,114,136,0,0,0,99, 2,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0, 6,0,0,0,67,0,0,0,115,60,0,0,0,124,0,160, @@ -637,7 +637,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 6,108,111,97,100,101,114,218,8,112,111,114,116,105,111,110, 115,218,3,109,115,103,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,17,95,102,105,110,100,95,109,111,100, - 117,108,101,95,115,104,105,109,230,1,0,0,115,10,0,0, + 117,108,101,95,115,104,105,109,228,1,0,0,115,10,0,0, 0,0,10,14,1,16,1,4,1,22,1,114,143,0,0,0, 99,3,0,0,0,0,0,0,0,0,0,0,0,6,0,0, 0,4,0,0,0,67,0,0,0,115,166,0,0,0,124,0, @@ -704,7 +704,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,120,99,95,100,101,116,97,105,108,115,90,5,109,97,103, 105,99,114,92,0,0,0,114,2,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,13,95,99,108, - 97,115,115,105,102,121,95,112,121,99,247,1,0,0,115,28, + 97,115,115,105,102,121,95,112,121,99,245,1,0,0,115,28, 0,0,0,0,16,12,1,8,1,16,1,12,1,16,1,12, 1,10,1,12,1,8,1,16,2,8,1,16,1,16,1,114, 152,0,0,0,99,5,0,0,0,0,0,0,0,0,0,0, @@ -759,7 +759,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 122,101,114,116,0,0,0,114,151,0,0,0,114,92,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, 218,23,95,118,97,108,105,100,97,116,101,95,116,105,109,101, - 115,116,97,109,112,95,112,121,99,24,2,0,0,115,16,0, + 115,116,97,109,112,95,112,121,99,22,2,0,0,115,16,0, 0,0,0,19,24,1,10,1,12,1,16,1,8,1,22,255, 2,2,114,156,0,0,0,99,4,0,0,0,0,0,0,0, 0,0,0,0,4,0,0,0,4,0,0,0,67,0,0,0, @@ -805,7 +805,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,218,11,115,111,117,114,99,101,95,104,97,115,104,114, 116,0,0,0,114,151,0,0,0,114,5,0,0,0,114,5, 0,0,0,114,8,0,0,0,218,18,95,118,97,108,105,100, - 97,116,101,95,104,97,115,104,95,112,121,99,52,2,0,0, + 97,116,101,95,104,97,115,104,95,112,121,99,50,2,0,0, 115,12,0,0,0,0,17,16,1,2,1,8,255,4,2,2, 254,114,158,0,0,0,99,4,0,0,0,0,0,0,0,0, 0,0,0,5,0,0,0,5,0,0,0,67,0,0,0,115, @@ -829,7 +829,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,26,0,0,0,114,116,0,0,0,114,106,0,0,0,114, 107,0,0,0,218,4,99,111,100,101,114,5,0,0,0,114, 5,0,0,0,114,8,0,0,0,218,17,95,99,111,109,112, - 105,108,101,95,98,121,116,101,99,111,100,101,76,2,0,0, + 105,108,101,95,98,121,116,101,99,111,100,101,74,2,0,0, 115,18,0,0,0,0,2,10,1,10,1,12,1,8,1,12, 1,4,2,10,1,4,255,114,165,0,0,0,114,73,0,0, 0,99,3,0,0,0,0,0,0,0,0,0,0,0,4,0, @@ -848,7 +848,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,101,114,155,0,0,0,114,26,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,22,95,99,111, 100,101,95,116,111,95,116,105,109,101,115,116,97,109,112,95, - 112,121,99,89,2,0,0,115,12,0,0,0,0,2,8,1, + 112,121,99,87,2,0,0,115,12,0,0,0,0,2,8,1, 14,1,14,1,14,1,16,1,114,170,0,0,0,84,99,3, 0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,5, 0,0,0,67,0,0,0,115,80,0,0,0,116,0,116,1, @@ -866,7 +866,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,90,7,99,104,101,99,107,101,100,114,26,0,0,0,114, 2,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,17,95,99,111,100,101,95,116,111,95,104,97, - 115,104,95,112,121,99,99,2,0,0,115,14,0,0,0,0, + 115,104,95,112,121,99,97,2,0,0,115,14,0,0,0,0, 2,8,1,12,1,14,1,16,1,10,1,16,1,114,171,0, 0,0,99,1,0,0,0,0,0,0,0,0,0,0,0,5, 0,0,0,6,0,0,0,67,0,0,0,115,62,0,0,0, @@ -893,7 +893,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,100,108,105,110,101,218,8,101,110,99,111,100,105,110,103, 90,15,110,101,119,108,105,110,101,95,100,101,99,111,100,101, 114,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, - 218,13,100,101,99,111,100,101,95,115,111,117,114,99,101,110, + 218,13,100,101,99,111,100,101,95,115,111,117,114,99,101,108, 2,0,0,115,10,0,0,0,0,5,8,1,12,1,10,1, 12,1,114,176,0,0,0,169,2,114,140,0,0,0,218,26, 115,117,98,109,111,100,117,108,101,95,115,101,97,114,99,104, @@ -955,7 +955,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,182,0,0,0,90,7,100,105,114,110,97,109,101,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,23,115, 112,101,99,95,102,114,111,109,95,102,105,108,101,95,108,111, - 99,97,116,105,111,110,127,2,0,0,115,62,0,0,0,0, + 99,97,116,105,111,110,125,2,0,0,115,62,0,0,0,0, 12,8,4,4,1,10,2,2,1,14,1,12,1,8,2,10, 8,16,1,6,3,8,1,14,1,14,1,10,1,6,1,6, 2,4,3,8,2,10,1,2,1,14,1,12,1,6,2,4, @@ -992,7 +992,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 72,75,69,89,95,76,79,67,65,76,95,77,65,67,72,73, 78,69,41,2,218,3,99,108,115,114,7,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,14,95, - 111,112,101,110,95,114,101,103,105,115,116,114,121,207,2,0, + 111,112,101,110,95,114,101,103,105,115,116,114,121,205,2,0, 0,115,8,0,0,0,0,2,2,1,16,1,12,1,122,36, 87,105,110,100,111,119,115,82,101,103,105,115,116,114,121,70, 105,110,100,101,114,46,95,111,112,101,110,95,114,101,103,105, @@ -1020,7 +1020,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,90,4,104,107,101,121,218,8,102,105,108,101,112,97,116, 104,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, 218,16,95,115,101,97,114,99,104,95,114,101,103,105,115,116, - 114,121,214,2,0,0,115,24,0,0,0,0,2,6,1,8, + 114,121,212,2,0,0,115,24,0,0,0,0,2,6,1,8, 2,6,1,6,1,16,255,6,2,2,1,12,1,46,1,12, 1,8,1,122,38,87,105,110,100,111,119,115,82,101,103,105, 115,116,114,121,70,105,110,100,101,114,46,95,115,101,97,114, @@ -1042,7 +1042,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,218,6,116,97,114,103,101,116,114,199,0,0,0,114, 140,0,0,0,114,189,0,0,0,114,187,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,9,102, - 105,110,100,95,115,112,101,99,229,2,0,0,115,28,0,0, + 105,110,100,95,115,112,101,99,227,2,0,0,115,28,0,0, 0,0,2,10,1,8,1,4,1,2,1,12,1,12,1,8, 1,14,1,14,1,6,1,8,1,2,254,6,3,122,31,87, 105,110,100,111,119,115,82,101,103,105,115,116,114,121,70,105, @@ -1061,7 +1061,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 2,114,203,0,0,0,114,140,0,0,0,169,4,114,193,0, 0,0,114,139,0,0,0,114,44,0,0,0,114,187,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, - 218,11,102,105,110,100,95,109,111,100,117,108,101,245,2,0, + 218,11,102,105,110,100,95,109,111,100,117,108,101,243,2,0, 0,115,8,0,0,0,0,7,12,1,8,1,6,2,122,33, 87,105,110,100,111,119,115,82,101,103,105,115,116,114,121,70, 105,110,100,101,114,46,102,105,110,100,95,109,111,100,117,108, @@ -1071,7 +1071,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,97,115,115,109,101,116,104,111,100,114,194,0,0,0,114, 200,0,0,0,114,203,0,0,0,114,206,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,114,191,0,0,0,195,2,0,0,115,28,0,0,0, + 0,0,114,191,0,0,0,193,2,0,0,115,28,0,0,0, 8,2,4,3,2,255,2,4,2,255,2,3,4,2,2,1, 10,6,2,1,10,14,2,1,12,15,2,1,114,191,0,0, 0,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -1107,7 +1107,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 139,0,0,0,114,96,0,0,0,90,13,102,105,108,101,110, 97,109,101,95,98,97,115,101,90,9,116,97,105,108,95,110, 97,109,101,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,114,182,0,0,0,8,3,0,0,115,8,0,0,0, + 0,0,114,182,0,0,0,6,3,0,0,115,8,0,0,0, 0,3,18,1,16,1,14,1,122,24,95,76,111,97,100,101, 114,66,97,115,105,99,115,46,105,115,95,112,97,99,107,97, 103,101,99,2,0,0,0,0,0,0,0,0,0,0,0,2, @@ -1118,7 +1118,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 110,46,78,114,5,0,0,0,169,2,114,118,0,0,0,114, 187,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,13,99,114,101,97,116,101,95,109,111,100,117, - 108,101,16,3,0,0,115,2,0,0,0,0,1,122,27,95, + 108,101,14,3,0,0,115,2,0,0,0,0,1,122,27,95, 76,111,97,100,101,114,66,97,115,105,99,115,46,99,114,101, 97,116,101,95,109,111,100,117,108,101,99,2,0,0,0,0, 0,0,0,0,0,0,0,3,0,0,0,5,0,0,0,67, @@ -1138,7 +1138,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 131,0,0,0,41,3,114,118,0,0,0,218,6,109,111,100, 117,108,101,114,164,0,0,0,114,5,0,0,0,114,5,0, 0,0,114,8,0,0,0,218,11,101,120,101,99,95,109,111, - 100,117,108,101,19,3,0,0,115,12,0,0,0,0,2,12, + 100,117,108,101,17,3,0,0,115,12,0,0,0,0,2,12, 1,8,1,6,1,4,255,6,2,122,25,95,76,111,97,100, 101,114,66,97,115,105,99,115,46,101,120,101,99,95,109,111, 100,117,108,101,99,2,0,0,0,0,0,0,0,0,0,0, @@ -1149,14 +1149,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,218,17,95,108,111,97,100,95,109,111,100,117,108, 101,95,115,104,105,109,169,2,114,118,0,0,0,114,139,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,11,108,111,97,100,95,109,111,100,117,108,101,27,3, + 0,218,11,108,111,97,100,95,109,111,100,117,108,101,25,3, 0,0,115,2,0,0,0,0,2,122,25,95,76,111,97,100, 101,114,66,97,115,105,99,115,46,108,111,97,100,95,109,111, 100,117,108,101,78,41,8,114,125,0,0,0,114,124,0,0, 0,114,126,0,0,0,114,127,0,0,0,114,182,0,0,0, 114,212,0,0,0,114,217,0,0,0,114,220,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,5,0,0,0,114,8, - 0,0,0,114,208,0,0,0,3,3,0,0,115,10,0,0, + 0,0,0,114,208,0,0,0,1,3,0,0,115,10,0,0, 0,8,2,4,3,8,8,8,3,8,8,114,208,0,0,0, 99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,3,0,0,0,64,0,0,0,115,74,0,0,0,101,0, @@ -1181,7 +1181,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,32,32,32,32,32,32,78,41,1,114,50,0,0,0,169, 2,114,118,0,0,0,114,44,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,8,0,0,0,218,10,112,97,116,104, - 95,109,116,105,109,101,34,3,0,0,115,2,0,0,0,0, + 95,109,116,105,109,101,32,3,0,0,115,2,0,0,0,0, 6,122,23,83,111,117,114,99,101,76,111,97,100,101,114,46, 112,97,116,104,95,109,116,105,109,101,99,2,0,0,0,0, 0,0,0,0,0,0,0,2,0,0,0,4,0,0,0,67, @@ -1215,7 +1215,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,46,10,32,32,32,32,32,32,32,32,114,169,0,0,0, 41,1,114,223,0,0,0,114,222,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,10,112,97,116, - 104,95,115,116,97,116,115,42,3,0,0,115,2,0,0,0, + 104,95,115,116,97,116,115,40,3,0,0,115,2,0,0,0, 0,12,122,23,83,111,117,114,99,101,76,111,97,100,101,114, 46,112,97,116,104,95,115,116,97,116,115,99,4,0,0,0, 0,0,0,0,0,0,0,0,4,0,0,0,4,0,0,0, @@ -1239,7 +1239,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,107,0,0,0,90,10,99,97,99,104,101,95,112,97,116, 104,114,26,0,0,0,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,15,95,99,97,99,104,101,95,98,121, - 116,101,99,111,100,101,56,3,0,0,115,2,0,0,0,0, + 116,101,99,111,100,101,54,3,0,0,115,2,0,0,0,0, 8,122,28,83,111,117,114,99,101,76,111,97,100,101,114,46, 95,99,97,99,104,101,95,98,121,116,101,99,111,100,101,99, 3,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0, @@ -1256,7 +1256,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 115,46,10,32,32,32,32,32,32,32,32,78,114,5,0,0, 0,41,3,114,118,0,0,0,114,44,0,0,0,114,26,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,225,0,0,0,66,3,0,0,115,2,0,0,0,0, + 0,114,225,0,0,0,64,3,0,0,115,2,0,0,0,0, 1,122,21,83,111,117,114,99,101,76,111,97,100,101,114,46, 115,101,116,95,100,97,116,97,99,2,0,0,0,0,0,0, 0,0,0,0,0,5,0,0,0,10,0,0,0,67,0,0, @@ -1277,7 +1277,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,41,5,114,118,0,0,0,114,139,0,0,0,114,44,0, 0,0,114,174,0,0,0,218,3,101,120,99,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,10,103,101,116, - 95,115,111,117,114,99,101,73,3,0,0,115,20,0,0,0, + 95,115,111,117,114,99,101,71,3,0,0,115,20,0,0,0, 0,2,10,1,2,1,14,1,14,1,4,1,2,255,4,1, 2,255,24,2,122,23,83,111,117,114,99,101,76,111,97,100, 101,114,46,103,101,116,95,115,111,117,114,99,101,114,104,0, @@ -1299,7 +1299,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 218,7,99,111,109,112,105,108,101,41,4,114,118,0,0,0, 114,26,0,0,0,114,44,0,0,0,114,230,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,14, - 115,111,117,114,99,101,95,116,111,95,99,111,100,101,83,3, + 115,111,117,114,99,101,95,116,111,95,99,111,100,101,81,3, 0,0,115,6,0,0,0,0,5,12,1,4,255,122,27,83, 111,117,114,99,101,76,111,97,100,101,114,46,115,111,117,114, 99,101,95,116,111,95,99,111,100,101,99,2,0,0,0,0, @@ -1376,7 +1376,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,26,0,0,0,114,151,0,0,0,114,2,0,0,0,90, 10,98,121,116,101,115,95,100,97,116,97,90,11,99,111,100, 101,95,111,98,106,101,99,116,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,213,0,0,0,91,3,0,0, + 0,0,114,8,0,0,0,114,213,0,0,0,89,3,0,0, 115,152,0,0,0,0,7,10,1,4,1,4,1,4,1,4, 1,4,1,2,1,12,1,12,1,12,2,2,1,14,1,12, 1,8,2,12,1,2,1,14,1,12,1,6,3,2,1,2, @@ -1393,7 +1393,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,226,0,0,0,114,225,0,0,0,114,229,0,0,0,114, 233,0,0,0,114,213,0,0,0,114,5,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,221,0, - 0,0,32,3,0,0,115,14,0,0,0,8,2,8,8,8, + 0,0,30,3,0,0,115,14,0,0,0,8,2,8,8,8, 14,8,10,8,7,8,10,14,8,114,221,0,0,0,99,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4, 0,0,0,0,0,0,0,115,124,0,0,0,101,0,90,1, @@ -1422,7 +1422,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,32,32,32,32,102,105,110,100,101,114,46,78,114,159,0, 0,0,41,3,114,118,0,0,0,114,139,0,0,0,114,44, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,114,209,0,0,0,181,3,0,0,115,4,0,0,0, + 0,0,114,209,0,0,0,179,3,0,0,115,4,0,0,0, 0,3,6,1,122,19,70,105,108,101,76,111,97,100,101,114, 46,95,95,105,110,105,116,95,95,99,2,0,0,0,0,0, 0,0,0,0,0,0,2,0,0,0,2,0,0,0,67,0, @@ -1431,7 +1431,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,0,0,0,169,2,218,9,95,95,99,108,97,115,115,95, 95,114,131,0,0,0,169,2,114,118,0,0,0,90,5,111, 116,104,101,114,114,5,0,0,0,114,5,0,0,0,114,8, - 0,0,0,218,6,95,95,101,113,95,95,187,3,0,0,115, + 0,0,0,218,6,95,95,101,113,95,95,185,3,0,0,115, 6,0,0,0,0,1,12,1,10,255,122,17,70,105,108,101, 76,111,97,100,101,114,46,95,95,101,113,95,95,99,1,0, 0,0,0,0,0,0,0,0,0,0,1,0,0,0,3,0, @@ -1440,7 +1440,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,0,0,0,169,3,218,4,104,97,115,104,114,116,0,0, 0,114,44,0,0,0,169,1,114,118,0,0,0,114,5,0, 0,0,114,5,0,0,0,114,8,0,0,0,218,8,95,95, - 104,97,115,104,95,95,191,3,0,0,115,2,0,0,0,0, + 104,97,115,104,95,95,189,3,0,0,115,2,0,0,0,0, 1,122,19,70,105,108,101,76,111,97,100,101,114,46,95,95, 104,97,115,104,95,95,99,2,0,0,0,0,0,0,0,0, 0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,115, @@ -1454,7 +1454,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,46,10,10,32,32,32,32,32,32,32,32,41,3,218,5, 115,117,112,101,114,114,239,0,0,0,114,220,0,0,0,114, 219,0,0,0,169,1,114,241,0,0,0,114,5,0,0,0, - 114,8,0,0,0,114,220,0,0,0,194,3,0,0,115,2, + 114,8,0,0,0,114,220,0,0,0,192,3,0,0,115,2, 0,0,0,0,10,122,22,70,105,108,101,76,111,97,100,101, 114,46,108,111,97,100,95,109,111,100,117,108,101,99,2,0, 0,0,0,0,0,0,0,0,0,0,2,0,0,0,1,0, @@ -1464,7 +1464,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 99,101,32,102,105,108,101,32,97,115,32,102,111,117,110,100, 32,98,121,32,116,104,101,32,102,105,110,100,101,114,46,114, 48,0,0,0,114,219,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,179,0,0,0,206,3,0, + 0,0,0,114,8,0,0,0,114,179,0,0,0,204,3,0, 0,115,2,0,0,0,0,3,122,23,70,105,108,101,76,111, 97,100,101,114,46,103,101,116,95,102,105,108,101,110,97,109, 101,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0, @@ -1486,7 +1486,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,90,4,114,101,97,100,114,65,0,0,0,41,3,114, 118,0,0,0,114,44,0,0,0,114,68,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,227,0, - 0,0,211,3,0,0,115,10,0,0,0,0,2,14,1,16, + 0,0,209,3,0,0,115,10,0,0,0,0,2,14,1,16, 1,40,2,14,1,122,19,70,105,108,101,76,111,97,100,101, 114,46,103,101,116,95,100,97,116,97,99,2,0,0,0,0, 0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,67, @@ -1495,7 +1495,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,114,182,0,0,0,169,2,114,118,0,0,0,114,216,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, 0,218,19,103,101,116,95,114,101,115,111,117,114,99,101,95, - 114,101,97,100,101,114,222,3,0,0,115,6,0,0,0,0, + 114,101,97,100,101,114,220,3,0,0,115,6,0,0,0,0, 2,10,1,4,1,122,30,70,105,108,101,76,111,97,100,101, 114,46,103,101,116,95,114,101,115,111,117,114,99,101,95,114, 101,97,100,101,114,99,2,0,0,0,0,0,0,0,0,0, @@ -1507,7 +1507,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,64,0,0,0,114,65,0,0,0,169,3,114,118,0, 0,0,90,8,114,101,115,111,117,114,99,101,114,44,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,8,0,0,0, - 218,13,111,112,101,110,95,114,101,115,111,117,114,99,101,228, + 218,13,111,112,101,110,95,114,101,115,111,117,114,99,101,226, 3,0,0,115,4,0,0,0,0,1,20,1,122,24,70,105, 108,101,76,111,97,100,101,114,46,111,112,101,110,95,114,101, 115,111,117,114,99,101,99,2,0,0,0,0,0,0,0,0, @@ -1520,7 +1520,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,114,111,114,114,38,0,0,0,114,47,0,0,0,114,44, 0,0,0,114,255,0,0,0,114,5,0,0,0,114,5,0, 0,0,114,8,0,0,0,218,13,114,101,115,111,117,114,99, - 101,95,112,97,116,104,232,3,0,0,115,8,0,0,0,0, + 101,95,112,97,116,104,230,3,0,0,115,8,0,0,0,0, 1,10,1,4,1,20,1,122,24,70,105,108,101,76,111,97, 100,101,114,46,114,101,115,111,117,114,99,101,95,112,97,116, 104,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0, @@ -1532,7 +1532,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,44,0,0,0,114,54,0,0,0,169,3,114,118,0, 0,0,114,116,0,0,0,114,44,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,2,1,0,0, - 238,3,0,0,115,8,0,0,0,0,1,8,1,4,1,20, + 236,3,0,0,115,8,0,0,0,0,1,8,1,4,1,20, 1,122,22,70,105,108,101,76,111,97,100,101,114,46,105,115, 95,114,101,115,111,117,114,99,101,99,1,0,0,0,0,0, 0,0,0,0,0,0,1,0,0,0,5,0,0,0,67,0, @@ -1542,7 +1542,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,218,7,108,105,115,116,100,105,114,114,47,0,0,0,114, 44,0,0,0,114,246,0,0,0,114,5,0,0,0,114,5, 0,0,0,114,8,0,0,0,218,8,99,111,110,116,101,110, - 116,115,244,3,0,0,115,2,0,0,0,0,1,122,19,70, + 116,115,242,3,0,0,115,2,0,0,0,0,1,122,19,70, 105,108,101,76,111,97,100,101,114,46,99,111,110,116,101,110, 116,115,41,17,114,125,0,0,0,114,124,0,0,0,114,126, 0,0,0,114,127,0,0,0,114,209,0,0,0,114,243,0, @@ -1551,7 +1551,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,0,1,0,0,114,4,1,0,0,114,2,1,0,0,114, 8,1,0,0,90,13,95,95,99,108,97,115,115,99,101,108, 108,95,95,114,5,0,0,0,114,5,0,0,0,114,249,0, - 0,0,114,8,0,0,0,114,239,0,0,0,176,3,0,0, + 0,0,114,8,0,0,0,114,239,0,0,0,174,3,0,0, 115,30,0,0,0,8,2,4,3,8,6,8,4,8,3,2, 1,14,11,2,1,10,4,8,11,2,1,10,5,8,4,8, 6,8,6,114,239,0,0,0,99,0,0,0,0,0,0,0, @@ -1574,7 +1574,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 49,0,0,0,218,8,115,116,95,109,116,105,109,101,90,7, 115,116,95,115,105,122,101,41,3,114,118,0,0,0,114,44, 0,0,0,114,238,0,0,0,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,224,0,0,0,252,3,0,0, + 0,0,114,8,0,0,0,114,224,0,0,0,250,3,0,0, 115,4,0,0,0,0,2,8,1,122,27,83,111,117,114,99, 101,70,105,108,101,76,111,97,100,101,114,46,112,97,116,104, 95,115,116,97,116,115,99,4,0,0,0,0,0,0,0,0, @@ -1585,7 +1585,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 225,0,0,0,41,5,114,118,0,0,0,114,107,0,0,0, 114,106,0,0,0,114,26,0,0,0,114,52,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,226, - 0,0,0,1,4,0,0,115,4,0,0,0,0,2,8,1, + 0,0,0,255,3,0,0,115,4,0,0,0,0,2,8,1, 122,32,83,111,117,114,99,101,70,105,108,101,76,111,97,100, 101,114,46,95,99,97,99,104,101,95,98,121,116,101,99,111, 100,101,114,60,0,0,0,114,11,1,0,0,99,3,0,0, @@ -1620,7 +1620,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,0,0,218,6,112,97,114,101,110,116,114,96,0,0,0, 114,37,0,0,0,114,33,0,0,0,114,228,0,0,0,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,114,225, - 0,0,0,6,4,0,0,115,46,0,0,0,0,2,12,1, + 0,0,0,4,4,0,0,115,46,0,0,0,0,2,12,1, 4,2,12,1,12,1,12,2,12,1,10,1,2,1,14,1, 12,2,8,1,14,3,6,1,4,255,4,2,28,1,2,1, 12,1,16,1,16,2,8,1,2,255,122,25,83,111,117,114, @@ -1629,7 +1629,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,114,126,0,0,0,114,127,0,0,0,114,224,0,0, 0,114,226,0,0,0,114,225,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 9,1,0,0,248,3,0,0,115,8,0,0,0,8,2,4, + 9,1,0,0,246,3,0,0,115,8,0,0,0,8,2,4, 2,8,5,8,5,114,9,1,0,0,99,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,64, 0,0,0,115,32,0,0,0,101,0,90,1,100,0,90,2, @@ -1651,7 +1651,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,235,0,0,0,41,5,114,118,0,0,0,114,139,0,0, 0,114,44,0,0,0,114,26,0,0,0,114,151,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 213,0,0,0,41,4,0,0,115,22,0,0,0,0,1,10, + 213,0,0,0,39,4,0,0,115,22,0,0,0,0,1,10, 1,10,4,2,1,2,254,6,4,12,1,2,1,14,1,2, 1,2,253,122,29,83,111,117,114,99,101,108,101,115,115,70, 105,108,101,76,111,97,100,101,114,46,103,101,116,95,99,111, @@ -1661,14 +1661,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 111,110,101,32,97,115,32,116,104,101,114,101,32,105,115,32, 110,111,32,115,111,117,114,99,101,32,99,111,100,101,46,78, 114,5,0,0,0,114,219,0,0,0,114,5,0,0,0,114, - 5,0,0,0,114,8,0,0,0,114,229,0,0,0,57,4, + 5,0,0,0,114,8,0,0,0,114,229,0,0,0,55,4, 0,0,115,2,0,0,0,0,2,122,31,83,111,117,114,99, 101,108,101,115,115,70,105,108,101,76,111,97,100,101,114,46, 103,101,116,95,115,111,117,114,99,101,78,41,6,114,125,0, 0,0,114,124,0,0,0,114,126,0,0,0,114,127,0,0, 0,114,213,0,0,0,114,229,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 15,1,0,0,37,4,0,0,115,6,0,0,0,8,2,4, + 15,1,0,0,35,4,0,0,115,6,0,0,0,8,2,4, 2,8,16,114,15,1,0,0,99,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,3,0,0,0,64,0,0, 0,115,92,0,0,0,101,0,90,1,100,0,90,2,100,1, @@ -1688,7 +1688,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,115,16,0,0,0,124,1,124,0,95,0,124,2,124,0, 95,1,100,0,83,0,114,109,0,0,0,114,159,0,0,0, 114,5,1,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,209,0,0,0,74,4,0,0,115,4,0, + 8,0,0,0,114,209,0,0,0,72,4,0,0,115,4,0, 0,0,0,1,6,1,122,28,69,120,116,101,110,115,105,111, 110,70,105,108,101,76,111,97,100,101,114,46,95,95,105,110, 105,116,95,95,99,2,0,0,0,0,0,0,0,0,0,0, @@ -1696,7 +1696,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,124,0,106,0,124,1,106,0,107,2,111,22,124,0, 106,1,124,1,106,1,107,2,83,0,114,109,0,0,0,114, 240,0,0,0,114,242,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,243,0,0,0,78,4,0, + 0,0,0,114,8,0,0,0,114,243,0,0,0,76,4,0, 0,115,6,0,0,0,0,1,12,1,10,255,122,26,69,120, 116,101,110,115,105,111,110,70,105,108,101,76,111,97,100,101, 114,46,95,95,101,113,95,95,99,1,0,0,0,0,0,0, @@ -1704,7 +1704,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,115,20,0,0,0,116,0,124,0,106,1,131,1,116,0, 124,0,106,2,131,1,65,0,83,0,114,109,0,0,0,114, 244,0,0,0,114,246,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,247,0,0,0,82,4,0, + 0,0,0,114,8,0,0,0,114,247,0,0,0,80,4,0, 0,115,2,0,0,0,0,1,122,28,69,120,116,101,110,115, 105,111,110,70,105,108,101,76,111,97,100,101,114,46,95,95, 104,97,115,104,95,95,99,2,0,0,0,0,0,0,0,0, @@ -1721,7 +1721,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,116,101,95,100,121,110,97,109,105,99,114,149,0,0,0, 114,116,0,0,0,114,44,0,0,0,41,3,114,118,0,0, 0,114,187,0,0,0,114,216,0,0,0,114,5,0,0,0, - 114,5,0,0,0,114,8,0,0,0,114,212,0,0,0,85, + 114,5,0,0,0,114,8,0,0,0,114,212,0,0,0,83, 4,0,0,115,14,0,0,0,0,2,4,1,6,255,4,2, 6,1,8,255,4,2,122,33,69,120,116,101,110,115,105,111, 110,70,105,108,101,76,111,97,100,101,114,46,99,114,101,97, @@ -1738,7 +1738,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 214,0,0,0,114,163,0,0,0,90,12,101,120,101,99,95, 100,121,110,97,109,105,99,114,149,0,0,0,114,116,0,0, 0,114,44,0,0,0,114,253,0,0,0,114,5,0,0,0, - 114,5,0,0,0,114,8,0,0,0,114,217,0,0,0,93, + 114,5,0,0,0,114,8,0,0,0,114,217,0,0,0,91, 4,0,0,115,8,0,0,0,0,2,14,1,6,1,8,255, 122,31,69,120,116,101,110,115,105,111,110,70,105,108,101,76, 111,97,100,101,114,46,101,120,101,99,95,109,111,100,117,108, @@ -1757,7 +1757,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,169,2,114,32,0,0,0,218,6,115,117,102,102,105, 120,169,1,90,9,102,105,108,101,95,110,97,109,101,114,5, 0,0,0,114,8,0,0,0,218,9,60,103,101,110,101,120, - 112,114,62,102,4,0,0,115,4,0,0,0,4,1,2,255, + 112,114,62,100,4,0,0,115,4,0,0,0,4,1,2,255, 122,49,69,120,116,101,110,115,105,111,110,70,105,108,101,76, 111,97,100,101,114,46,105,115,95,112,97,99,107,97,103,101, 46,60,108,111,99,97,108,115,62,46,60,103,101,110,101,120, @@ -1765,7 +1765,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 3,97,110,121,218,18,69,88,84,69,78,83,73,79,78,95, 83,85,70,70,73,88,69,83,114,219,0,0,0,114,5,0, 0,0,114,18,1,0,0,114,8,0,0,0,114,182,0,0, - 0,99,4,0,0,115,8,0,0,0,0,2,14,1,12,1, + 0,97,4,0,0,115,8,0,0,0,0,2,14,1,12,1, 2,255,122,30,69,120,116,101,110,115,105,111,110,70,105,108, 101,76,111,97,100,101,114,46,105,115,95,112,97,99,107,97, 103,101,99,2,0,0,0,0,0,0,0,0,0,0,0,2, @@ -1776,7 +1776,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 116,32,99,114,101,97,116,101,32,97,32,99,111,100,101,32, 111,98,106,101,99,116,46,78,114,5,0,0,0,114,219,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,213,0,0,0,105,4,0,0,115,2,0,0,0,0, + 0,114,213,0,0,0,103,4,0,0,115,2,0,0,0,0, 2,122,28,69,120,116,101,110,115,105,111,110,70,105,108,101, 76,111,97,100,101,114,46,103,101,116,95,99,111,100,101,99, 2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0, @@ -1786,14 +1786,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,117,108,101,115,32,104,97,118,101,32,110,111,32,115,111, 117,114,99,101,32,99,111,100,101,46,78,114,5,0,0,0, 114,219,0,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,229,0,0,0,109,4,0,0,115,2,0, + 8,0,0,0,114,229,0,0,0,107,4,0,0,115,2,0, 0,0,0,2,122,30,69,120,116,101,110,115,105,111,110,70, 105,108,101,76,111,97,100,101,114,46,103,101,116,95,115,111, 117,114,99,101,99,2,0,0,0,0,0,0,0,0,0,0, 0,2,0,0,0,1,0,0,0,67,0,0,0,115,6,0, 0,0,124,0,106,0,83,0,114,250,0,0,0,114,48,0, 0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,179,0,0,0,113,4,0,0,115, + 0,114,8,0,0,0,114,179,0,0,0,111,4,0,0,115, 2,0,0,0,0,3,122,32,69,120,116,101,110,115,105,111, 110,70,105,108,101,76,111,97,100,101,114,46,103,101,116,95, 102,105,108,101,110,97,109,101,78,41,14,114,125,0,0,0, @@ -1802,7 +1802,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,217,0,0,0,114,182,0,0,0,114,213,0, 0,0,114,229,0,0,0,114,136,0,0,0,114,179,0,0, 0,114,5,0,0,0,114,5,0,0,0,114,5,0,0,0, - 114,8,0,0,0,114,252,0,0,0,66,4,0,0,115,22, + 114,8,0,0,0,114,252,0,0,0,64,4,0,0,115,22, 0,0,0,8,2,4,6,8,4,8,4,8,3,8,8,8, 6,8,6,8,4,8,4,2,1,114,252,0,0,0,99,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2, @@ -1845,7 +1845,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 169,4,114,118,0,0,0,114,116,0,0,0,114,44,0,0, 0,90,11,112,97,116,104,95,102,105,110,100,101,114,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,209,0, - 0,0,126,4,0,0,115,8,0,0,0,0,1,6,1,6, + 0,0,124,4,0,0,115,8,0,0,0,0,1,6,1,6, 1,14,1,122,23,95,78,97,109,101,115,112,97,99,101,80, 97,116,104,46,95,95,105,110,105,116,95,95,99,1,0,0, 0,0,0,0,0,0,0,0,0,4,0,0,0,3,0,0, @@ -1862,7 +1862,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,118,0,0,0,114,14,1,0,0,218,3,100,111,116,90, 2,109,101,114,5,0,0,0,114,5,0,0,0,114,8,0, 0,0,218,23,95,102,105,110,100,95,112,97,114,101,110,116, - 95,112,97,116,104,95,110,97,109,101,115,132,4,0,0,115, + 95,112,97,116,104,95,110,97,109,101,115,130,4,0,0,115, 8,0,0,0,0,2,18,1,8,2,4,3,122,38,95,78, 97,109,101,115,112,97,99,101,80,97,116,104,46,95,102,105, 110,100,95,112,97,114,101,110,116,95,112,97,116,104,95,110, @@ -1875,7 +1875,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 118,0,0,0,90,18,112,97,114,101,110,116,95,109,111,100, 117,108,101,95,110,97,109,101,90,14,112,97,116,104,95,97, 116,116,114,95,110,97,109,101,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,25,1,0,0,142,4,0,0, + 0,0,114,8,0,0,0,114,25,1,0,0,140,4,0,0, 115,4,0,0,0,0,1,12,1,122,31,95,78,97,109,101, 115,112,97,99,101,80,97,116,104,46,95,103,101,116,95,112, 97,114,101,110,116,95,112,97,116,104,99,1,0,0,0,0, @@ -1891,7 +1891,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,114,24,1,0,0,41,3,114,118,0,0,0,90,11, 112,97,114,101,110,116,95,112,97,116,104,114,187,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218, - 12,95,114,101,99,97,108,99,117,108,97,116,101,146,4,0, + 12,95,114,101,99,97,108,99,117,108,97,116,101,144,4,0, 0,115,16,0,0,0,0,2,12,1,10,1,14,3,18,1, 6,1,8,1,6,1,122,27,95,78,97,109,101,115,112,97, 99,101,80,97,116,104,46,95,114,101,99,97,108,99,117,108, @@ -1900,7 +1900,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,116,0,124,0,160,1,161,0,131,1,83,0,114,109,0, 0,0,41,2,114,6,1,0,0,114,32,1,0,0,114,246, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,218,8,95,95,105,116,101,114,95,95,159,4,0,0, + 0,0,218,8,95,95,105,116,101,114,95,95,157,4,0,0, 115,2,0,0,0,0,1,122,23,95,78,97,109,101,115,112, 97,99,101,80,97,116,104,46,95,95,105,116,101,114,95,95, 99,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0, @@ -1909,7 +1909,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,114,32,1,0,0,41,2,114,118,0,0,0,218,5,105, 110,100,101,120,114,5,0,0,0,114,5,0,0,0,114,8, 0,0,0,218,11,95,95,103,101,116,105,116,101,109,95,95, - 162,4,0,0,115,2,0,0,0,0,1,122,26,95,78,97, + 160,4,0,0,115,2,0,0,0,0,1,122,26,95,78,97, 109,101,115,112,97,99,101,80,97,116,104,46,95,95,103,101, 116,105,116,101,109,95,95,99,3,0,0,0,0,0,0,0, 0,0,0,0,3,0,0,0,3,0,0,0,67,0,0,0, @@ -1917,7 +1917,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,83,0,114,109,0,0,0,41,1,114,24,1,0,0,41, 3,114,118,0,0,0,114,35,1,0,0,114,44,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218, - 11,95,95,115,101,116,105,116,101,109,95,95,165,4,0,0, + 11,95,95,115,101,116,105,116,101,109,95,95,163,4,0,0, 115,2,0,0,0,0,1,122,26,95,78,97,109,101,115,112, 97,99,101,80,97,116,104,46,95,95,115,101,116,105,116,101, 109,95,95,99,1,0,0,0,0,0,0,0,0,0,0,0, @@ -1925,7 +1925,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,116,0,124,0,160,1,161,0,131,1,83,0,114,109,0, 0,0,41,2,114,23,0,0,0,114,32,1,0,0,114,246, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, - 0,0,218,7,95,95,108,101,110,95,95,168,4,0,0,115, + 0,0,218,7,95,95,108,101,110,95,95,166,4,0,0,115, 2,0,0,0,0,1,122,22,95,78,97,109,101,115,112,97, 99,101,80,97,116,104,46,95,95,108,101,110,95,95,99,1, 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,3, @@ -1934,7 +1934,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 109,101,115,112,97,99,101,80,97,116,104,40,123,33,114,125, 41,41,2,114,62,0,0,0,114,24,1,0,0,114,246,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,8,95,95,114,101,112,114,95,95,171,4,0,0,115, + 0,218,8,95,95,114,101,112,114,95,95,169,4,0,0,115, 2,0,0,0,0,1,122,23,95,78,97,109,101,115,112,97, 99,101,80,97,116,104,46,95,95,114,101,112,114,95,95,99, 2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0, @@ -1942,7 +1942,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,160,0,161,0,118,0,83,0,114,109,0,0,0,114,34, 1,0,0,169,2,114,118,0,0,0,218,4,105,116,101,109, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,218, - 12,95,95,99,111,110,116,97,105,110,115,95,95,174,4,0, + 12,95,95,99,111,110,116,97,105,110,115,95,95,172,4,0, 0,115,2,0,0,0,0,1,122,27,95,78,97,109,101,115, 112,97,99,101,80,97,116,104,46,95,95,99,111,110,116,97, 105,110,115,95,95,99,2,0,0,0,0,0,0,0,0,0, @@ -1950,7 +1950,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,124,0,106,0,160,1,124,1,161,1,1,0,100, 0,83,0,114,109,0,0,0,41,2,114,24,1,0,0,114, 186,0,0,0,114,40,1,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,186,0,0,0,177,4,0, + 0,0,0,114,8,0,0,0,114,186,0,0,0,175,4,0, 0,115,2,0,0,0,0,1,122,21,95,78,97,109,101,115, 112,97,99,101,80,97,116,104,46,97,112,112,101,110,100,78, 41,15,114,125,0,0,0,114,124,0,0,0,114,126,0,0, @@ -1959,7 +1959,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 36,1,0,0,114,37,1,0,0,114,38,1,0,0,114,39, 1,0,0,114,42,1,0,0,114,186,0,0,0,114,5,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,22,1,0,0,119,4,0,0,115,24,0,0,0,8, + 0,114,22,1,0,0,117,4,0,0,115,24,0,0,0,8, 1,4,6,8,6,8,10,8,4,8,13,8,3,8,3,8, 3,8,3,8,3,8,3,114,22,1,0,0,99,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0, @@ -1975,7 +1975,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 124,2,124,3,131,3,124,0,95,1,100,0,83,0,114,109, 0,0,0,41,2,114,22,1,0,0,114,24,1,0,0,114, 28,1,0,0,114,5,0,0,0,114,5,0,0,0,114,8, - 0,0,0,114,209,0,0,0,183,4,0,0,115,2,0,0, + 0,0,0,114,209,0,0,0,181,4,0,0,115,2,0,0, 0,0,1,122,25,95,78,97,109,101,115,112,97,99,101,76, 111,97,100,101,114,46,95,95,105,110,105,116,95,95,99,2, 0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,3, @@ -1992,21 +1992,21 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,109,101,115,112,97,99,101,41,62,41,2,114,62,0,0, 0,114,125,0,0,0,41,2,114,193,0,0,0,114,216,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,218,11,109,111,100,117,108,101,95,114,101,112,114,186,4, + 0,218,11,109,111,100,117,108,101,95,114,101,112,114,184,4, 0,0,115,2,0,0,0,0,7,122,28,95,78,97,109,101, 115,112,97,99,101,76,111,97,100,101,114,46,109,111,100,117, 108,101,95,114,101,112,114,99,2,0,0,0,0,0,0,0, 0,0,0,0,2,0,0,0,1,0,0,0,67,0,0,0, 115,4,0,0,0,100,1,83,0,41,2,78,84,114,5,0, 0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,182,0,0,0,195,4,0,0,115, + 0,114,8,0,0,0,114,182,0,0,0,193,4,0,0,115, 2,0,0,0,0,1,122,27,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,105,115,95,112,97,99,107, 97,103,101,99,2,0,0,0,0,0,0,0,0,0,0,0, 2,0,0,0,1,0,0,0,67,0,0,0,115,4,0,0, 0,100,1,83,0,41,2,78,114,40,0,0,0,114,5,0, 0,0,114,219,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,229,0,0,0,198,4,0,0,115, + 0,114,8,0,0,0,114,229,0,0,0,196,4,0,0,115, 2,0,0,0,0,1,122,27,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,103,101,116,95,115,111,117, 114,99,101,99,2,0,0,0,0,0,0,0,0,0,0,0, @@ -2016,20 +2016,20 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 110,103,62,114,215,0,0,0,84,41,1,114,231,0,0,0, 41,1,114,232,0,0,0,114,219,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,213,0,0,0, - 201,4,0,0,115,2,0,0,0,0,1,122,25,95,78,97, + 199,4,0,0,115,2,0,0,0,0,1,122,25,95,78,97, 109,101,115,112,97,99,101,76,111,97,100,101,114,46,103,101, 116,95,99,111,100,101,99,2,0,0,0,0,0,0,0,0, 0,0,0,2,0,0,0,1,0,0,0,67,0,0,0,115, 4,0,0,0,100,1,83,0,114,210,0,0,0,114,5,0, 0,0,114,211,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,212,0,0,0,204,4,0,0,115, + 0,114,8,0,0,0,114,212,0,0,0,202,4,0,0,115, 2,0,0,0,0,1,122,30,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,99,114,101,97,116,101,95, 109,111,100,117,108,101,99,2,0,0,0,0,0,0,0,0, 0,0,0,2,0,0,0,1,0,0,0,67,0,0,0,115, 4,0,0,0,100,0,83,0,114,109,0,0,0,114,5,0, 0,0,114,253,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,217,0,0,0,207,4,0,0,115, + 0,114,8,0,0,0,114,217,0,0,0,205,4,0,0,115, 2,0,0,0,0,1,122,28,95,78,97,109,101,115,112,97, 99,101,76,111,97,100,101,114,46,101,120,101,99,95,109,111, 100,117,108,101,99,2,0,0,0,0,0,0,0,0,0,0, @@ -2047,7 +2047,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,112,97,116,104,32,123,33,114,125,41,4,114,134,0,0, 0,114,149,0,0,0,114,24,1,0,0,114,218,0,0,0, 114,219,0,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,220,0,0,0,210,4,0,0,115,8,0, + 8,0,0,0,114,220,0,0,0,208,4,0,0,115,8,0, 0,0,0,7,6,1,4,255,4,2,122,28,95,78,97,109, 101,115,112,97,99,101,76,111,97,100,101,114,46,108,111,97, 100,95,109,111,100,117,108,101,78,41,12,114,125,0,0,0, @@ -2056,7 +2056,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,213,0,0,0,114,212,0,0,0,114,217,0, 0,0,114,220,0,0,0,114,5,0,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,43,1,0,0, - 182,4,0,0,115,18,0,0,0,8,1,8,3,2,1,10, + 180,4,0,0,115,18,0,0,0,8,1,8,3,2,1,10, 8,8,3,8,3,8,3,8,3,8,3,114,43,1,0,0, 99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,4,0,0,0,64,0,0,0,115,118,0,0,0,101,0, @@ -2093,7 +2093,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,46,1,0,0,41,3,114,193,0,0,0,114, 116,0,0,0,218,6,102,105,110,100,101,114,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,114,46,1,0,0, - 228,4,0,0,115,10,0,0,0,0,4,22,1,8,1,10, + 226,4,0,0,115,10,0,0,0,0,4,22,1,8,1,10, 1,10,1,122,28,80,97,116,104,70,105,110,100,101,114,46, 105,110,118,97,108,105,100,97,116,101,95,99,97,99,104,101, 115,99,2,0,0,0,0,0,0,0,0,0,0,0,3,0, @@ -2113,7 +2113,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 117,0,0,0,41,3,114,193,0,0,0,114,44,0,0,0, 90,4,104,111,111,107,114,5,0,0,0,114,5,0,0,0, 114,8,0,0,0,218,11,95,112,97,116,104,95,104,111,111, - 107,115,238,4,0,0,115,16,0,0,0,0,3,16,1,12, + 107,115,236,4,0,0,115,16,0,0,0,0,3,16,1,12, 1,10,1,2,1,14,1,12,1,12,2,122,22,80,97,116, 104,70,105,110,100,101,114,46,95,112,97,116,104,95,104,111, 111,107,115,99,2,0,0,0,0,0,0,0,0,0,0,0, @@ -2144,7 +2144,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,114,44,0,0,0,114,50,1,0,0,114,5,0,0, 0,114,5,0,0,0,114,8,0,0,0,218,20,95,112,97, 116,104,95,105,109,112,111,114,116,101,114,95,99,97,99,104, - 101,251,4,0,0,115,22,0,0,0,0,8,8,1,2,1, + 101,249,4,0,0,115,22,0,0,0,0,8,8,1,2,1, 12,1,12,3,8,1,2,1,14,1,12,1,10,1,16,1, 122,31,80,97,116,104,70,105,110,100,101,114,46,95,112,97, 116,104,95,105,109,112,111,114,116,101,114,95,99,97,99,104, @@ -2161,7 +2161,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,193,0,0,0,114,139,0,0,0,114,50,1,0,0,114, 140,0,0,0,114,141,0,0,0,114,187,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,218,16,95, - 108,101,103,97,99,121,95,103,101,116,95,115,112,101,99,17, + 108,101,103,97,99,121,95,103,101,116,95,115,112,101,99,15, 5,0,0,115,18,0,0,0,0,4,10,1,16,2,10,1, 4,1,8,1,12,1,12,1,6,1,122,27,80,97,116,104, 70,105,110,100,101,114,46,95,108,101,103,97,99,121,95,103, @@ -2193,7 +2193,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 95,112,97,116,104,90,5,101,110,116,114,121,114,50,1,0, 0,114,187,0,0,0,114,141,0,0,0,114,5,0,0,0, 114,5,0,0,0,114,8,0,0,0,218,9,95,103,101,116, - 95,115,112,101,99,32,5,0,0,115,40,0,0,0,0,5, + 95,115,112,101,99,30,5,0,0,115,40,0,0,0,0,5, 4,1,8,1,14,1,2,1,10,1,8,1,10,1,14,2, 12,1,8,1,2,1,10,1,8,1,6,1,8,1,8,5, 12,2,12,1,6,1,122,20,80,97,116,104,70,105,110,100, @@ -2220,7 +2220,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,22,1,0,0,41,6,114,193,0,0,0,114,139,0,0, 0,114,44,0,0,0,114,202,0,0,0,114,187,0,0,0, 114,57,1,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,203,0,0,0,64,5,0,0,115,26,0, + 8,0,0,0,114,203,0,0,0,62,5,0,0,115,26,0, 0,0,0,6,8,1,6,1,14,1,8,1,4,1,10,1, 6,1,4,3,6,1,16,1,4,2,6,2,122,20,80,97, 116,104,70,105,110,100,101,114,46,102,105,110,100,95,115,112, @@ -2240,7 +2240,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 110,100,95,115,112,101,99,40,41,32,105,110,115,116,101,97, 100,46,10,10,32,32,32,32,32,32,32,32,78,114,204,0, 0,0,114,205,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,206,0,0,0,88,5,0,0,115, + 0,114,8,0,0,0,114,206,0,0,0,86,5,0,0,115, 8,0,0,0,0,8,12,1,8,1,4,1,122,22,80,97, 116,104,70,105,110,100,101,114,46,102,105,110,100,95,109,111, 100,117,108,101,99,1,0,0,0,0,0,0,0,0,0,0, @@ -2272,7 +2272,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,95,100,105,115,116,114,105,98,117,116,105,111,110,115,41, 4,114,193,0,0,0,114,119,0,0,0,114,120,0,0,0, 114,59,1,0,0,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,114,60,1,0,0,101,5,0,0,115,4,0, + 8,0,0,0,114,60,1,0,0,99,5,0,0,115,4,0, 0,0,0,10,12,1,122,29,80,97,116,104,70,105,110,100, 101,114,46,102,105,110,100,95,100,105,115,116,114,105,98,117, 116,105,111,110,115,41,1,78,41,2,78,78,41,1,78,41, @@ -2281,7 +2281,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 52,1,0,0,114,54,1,0,0,114,55,1,0,0,114,58, 1,0,0,114,203,0,0,0,114,206,0,0,0,114,60,1, 0,0,114,5,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,45,1,0,0,224,4,0,0,115, + 0,114,8,0,0,0,114,45,1,0,0,222,4,0,0,115, 34,0,0,0,8,2,4,2,2,1,10,9,2,1,10,12, 2,1,10,21,2,1,10,14,2,1,12,31,2,1,12,23, 2,1,12,12,2,1,114,45,1,0,0,99,0,0,0,0, @@ -2326,7 +2326,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 14,125,1,124,1,136,0,102,2,86,0,1,0,113,2,100, 0,83,0,114,109,0,0,0,114,5,0,0,0,114,16,1, 0,0,169,1,114,140,0,0,0,114,5,0,0,0,114,8, - 0,0,0,114,19,1,0,0,130,5,0,0,243,0,0,0, + 0,0,0,114,19,1,0,0,128,5,0,0,243,0,0,0, 0,122,38,70,105,108,101,70,105,110,100,101,114,46,95,95, 105,110,105,116,95,95,46,60,108,111,99,97,108,115,62,46, 60,103,101,110,101,120,112,114,62,114,71,0,0,0,114,104, @@ -2338,7 +2338,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,118,0,0,0,114,44,0,0,0,218,14,108,111,97,100, 101,114,95,100,101,116,97,105,108,115,90,7,108,111,97,100, 101,114,115,114,189,0,0,0,114,5,0,0,0,114,62,1, - 0,0,114,8,0,0,0,114,209,0,0,0,124,5,0,0, + 0,0,114,8,0,0,0,114,209,0,0,0,122,5,0,0, 115,16,0,0,0,0,4,4,1,12,1,26,1,6,2,10, 1,6,1,8,1,122,19,70,105,108,101,70,105,110,100,101, 114,46,95,95,105,110,105,116,95,95,99,1,0,0,0,0, @@ -2348,7 +2348,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,116,104,101,32,100,105,114,101,99,116,111,114,121,32,109, 116,105,109,101,46,114,104,0,0,0,78,41,1,114,65,1, 0,0,114,246,0,0,0,114,5,0,0,0,114,5,0,0, - 0,114,8,0,0,0,114,46,1,0,0,138,5,0,0,115, + 0,114,8,0,0,0,114,46,1,0,0,136,5,0,0,115, 2,0,0,0,0,2,122,28,70,105,108,101,70,105,110,100, 101,114,46,105,110,118,97,108,105,100,97,116,101,95,99,97, 99,104,101,115,99,2,0,0,0,0,0,0,0,0,0,0, @@ -2371,7 +2371,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,32,32,32,32,78,41,3,114,203,0,0,0,114,140,0, 0,0,114,178,0,0,0,41,3,114,118,0,0,0,114,139, 0,0,0,114,187,0,0,0,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,114,137,0,0,0,144,5,0,0, + 0,0,114,8,0,0,0,114,137,0,0,0,142,5,0,0, 115,8,0,0,0,0,7,10,1,8,1,8,1,122,22,70, 105,108,101,70,105,110,100,101,114,46,102,105,110,100,95,108, 111,97,100,101,114,99,6,0,0,0,0,0,0,0,0,0, @@ -2382,7 +2382,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,188,0,0,0,114,139,0,0,0,114,44,0, 0,0,90,4,115,109,115,108,114,202,0,0,0,114,140,0, 0,0,114,5,0,0,0,114,5,0,0,0,114,8,0,0, - 0,114,58,1,0,0,156,5,0,0,115,8,0,0,0,0, + 0,114,58,1,0,0,154,5,0,0,115,8,0,0,0,0, 1,10,1,8,1,2,255,122,20,70,105,108,101,70,105,110, 100,101,114,46,95,103,101,116,95,115,112,101,99,78,99,3, 0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,8, @@ -2436,7 +2436,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 104,114,17,1,0,0,114,188,0,0,0,90,13,105,110,105, 116,95,102,105,108,101,110,97,109,101,90,9,102,117,108,108, 95,112,97,116,104,114,187,0,0,0,114,5,0,0,0,114, - 5,0,0,0,114,8,0,0,0,114,203,0,0,0,161,5, + 5,0,0,0,114,8,0,0,0,114,203,0,0,0,159,5, 0,0,115,72,0,0,0,0,5,4,1,14,1,2,1,24, 1,12,1,10,1,10,1,8,1,6,2,6,1,6,1,10, 2,6,1,4,2,8,1,12,1,14,1,8,1,10,1,8, @@ -2468,7 +2468,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 161,0,146,2,113,4,83,0,114,5,0,0,0,41,1,114, 105,0,0,0,41,2,114,32,0,0,0,90,2,102,110,114, 5,0,0,0,114,5,0,0,0,114,8,0,0,0,218,9, - 60,115,101,116,99,111,109,112,62,238,5,0,0,114,63,1, + 60,115,101,116,99,111,109,112,62,236,5,0,0,114,63,1, 0,0,122,41,70,105,108,101,70,105,110,100,101,114,46,95, 102,105,108,108,95,99,97,99,104,101,46,60,108,111,99,97, 108,115,62,46,60,115,101,116,99,111,109,112,62,78,41,18, @@ -2484,7 +2484,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 102,102,105,120,95,99,111,110,116,101,110,116,115,114,41,1, 0,0,114,116,0,0,0,114,29,1,0,0,114,17,1,0, 0,90,8,110,101,119,95,110,97,109,101,114,5,0,0,0, - 114,5,0,0,0,114,8,0,0,0,114,70,1,0,0,209, + 114,5,0,0,0,114,8,0,0,0,114,70,1,0,0,207, 5,0,0,115,34,0,0,0,0,2,6,1,2,1,22,1, 18,3,10,3,12,1,12,7,6,1,8,1,16,1,4,1, 18,2,4,1,12,1,6,1,12,1,122,22,70,105,108,101, @@ -2523,14 +2523,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,48,0,0,0,169,2,114,193,0,0,0,114,69,1, 0,0,114,5,0,0,0,114,8,0,0,0,218,24,112,97, 116,104,95,104,111,111,107,95,102,111,114,95,70,105,108,101, - 70,105,110,100,101,114,250,5,0,0,115,6,0,0,0,0, + 70,105,110,100,101,114,248,5,0,0,115,6,0,0,0,0, 2,8,1,12,1,122,54,70,105,108,101,70,105,110,100,101, 114,46,112,97,116,104,95,104,111,111,107,46,60,108,111,99, 97,108,115,62,46,112,97,116,104,95,104,111,111,107,95,102, 111,114,95,70,105,108,101,70,105,110,100,101,114,114,5,0, 0,0,41,3,114,193,0,0,0,114,69,1,0,0,114,76, 1,0,0,114,5,0,0,0,114,75,1,0,0,114,8,0, - 0,0,218,9,112,97,116,104,95,104,111,111,107,240,5,0, + 0,0,218,9,112,97,116,104,95,104,111,111,107,238,5,0, 0,115,4,0,0,0,0,10,14,6,122,20,70,105,108,101, 70,105,110,100,101,114,46,112,97,116,104,95,104,111,111,107, 99,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0, @@ -2539,7 +2539,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 105,108,101,70,105,110,100,101,114,40,123,33,114,125,41,41, 2,114,62,0,0,0,114,44,0,0,0,114,246,0,0,0, 114,5,0,0,0,114,5,0,0,0,114,8,0,0,0,114, - 39,1,0,0,2,6,0,0,115,2,0,0,0,0,1,122, + 39,1,0,0,0,6,0,0,115,2,0,0,0,0,1,122, 19,70,105,108,101,70,105,110,100,101,114,46,95,95,114,101, 112,114,95,95,41,1,78,41,15,114,125,0,0,0,114,124, 0,0,0,114,126,0,0,0,114,127,0,0,0,114,209,0, @@ -2547,7 +2547,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,137,0,0,0,114,58,1,0,0,114,203,0,0,0, 114,70,1,0,0,114,207,0,0,0,114,77,1,0,0,114, 39,1,0,0,114,5,0,0,0,114,5,0,0,0,114,5, - 0,0,0,114,8,0,0,0,114,61,1,0,0,115,5,0, + 0,0,0,114,8,0,0,0,114,61,1,0,0,113,5,0, 0,115,22,0,0,0,8,2,4,7,8,14,8,4,4,2, 8,12,8,5,10,48,8,31,2,1,10,17,114,61,1,0, 0,99,4,0,0,0,0,0,0,0,0,0,0,0,6,0, @@ -2571,7 +2571,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 99,112,97,116,104,110,97,109,101,114,140,0,0,0,114,187, 0,0,0,114,5,0,0,0,114,5,0,0,0,114,8,0, 0,0,218,14,95,102,105,120,95,117,112,95,109,111,100,117, - 108,101,8,6,0,0,115,34,0,0,0,0,2,10,1,10, + 108,101,6,6,0,0,115,34,0,0,0,0,2,10,1,10, 1,4,1,4,1,8,1,8,1,12,2,10,1,4,1,14, 1,2,1,8,1,8,1,8,1,12,1,12,2,114,82,1, 0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,3, @@ -2591,7 +2591,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 10,101,120,116,101,110,115,105,111,110,115,90,6,115,111,117, 114,99,101,90,8,98,121,116,101,99,111,100,101,114,5,0, 0,0,114,5,0,0,0,114,8,0,0,0,114,184,0,0, - 0,31,6,0,0,115,8,0,0,0,0,5,12,1,8,1, + 0,29,6,0,0,115,8,0,0,0,0,5,12,1,8,1, 8,1,114,184,0,0,0,99,1,0,0,0,0,0,0,0, 0,0,0,0,10,0,0,0,9,0,0,0,67,0,0,0, 115,132,1,0,0,124,0,97,0,116,0,106,1,97,1,116, @@ -2639,7 +2639,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,83,0,41,2,114,39,0,0,0,78,41,1,114,23,0, 0,0,41,2,114,32,0,0,0,114,94,0,0,0,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,19,1, - 0,0,60,6,0,0,114,63,1,0,0,122,25,95,115,101, + 0,0,58,6,0,0,114,63,1,0,0,122,25,95,115,101, 116,117,112,46,60,108,111,99,97,108,115,62,46,60,103,101, 110,101,120,112,114,62,114,73,0,0,0,122,30,105,109,112, 111,114,116,108,105,98,32,114,101,113,117,105,114,101,115,32, @@ -2651,7 +2651,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 157,2,146,2,113,4,83,0,41,1,114,74,0,0,0,114, 5,0,0,0,41,2,114,32,0,0,0,218,1,115,114,5, 0,0,0,114,5,0,0,0,114,8,0,0,0,114,71,1, - 0,0,77,6,0,0,114,63,1,0,0,122,25,95,115,101, + 0,0,75,6,0,0,114,63,1,0,0,122,25,95,115,101, 116,117,112,46,60,108,111,99,97,108,115,62,46,60,115,101, 116,99,111,109,112,62,41,3,114,64,0,0,0,114,75,0, 0,0,114,160,0,0,0,114,192,0,0,0,114,9,0,0, @@ -2671,7 +2671,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,116,105,110,95,110,97,109,101,115,90,12,98,117,105,108, 116,105,110,95,110,97,109,101,90,14,98,117,105,108,116,105, 110,95,109,111,100,117,108,101,114,5,0,0,0,114,5,0, - 0,0,114,8,0,0,0,218,6,95,115,101,116,117,112,42, + 0,0,114,8,0,0,0,218,6,95,115,101,116,117,112,40, 6,0,0,115,70,0,0,0,0,8,4,1,6,1,6,2, 10,3,22,1,12,2,22,1,8,1,10,1,10,1,6,2, 2,1,10,1,10,1,12,1,12,2,8,2,12,1,12,1, @@ -2691,7 +2691,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 104,114,186,0,0,0,114,45,1,0,0,41,2,114,88,1, 0,0,90,17,115,117,112,112,111,114,116,101,100,95,108,111, 97,100,101,114,115,114,5,0,0,0,114,5,0,0,0,114, - 8,0,0,0,218,8,95,105,110,115,116,97,108,108,99,6, + 8,0,0,0,218,8,95,105,110,115,116,97,108,108,97,6, 0,0,115,8,0,0,0,0,2,8,1,6,1,20,1,114, 91,1,0,0,41,1,114,60,0,0,0,41,1,78,41,3, 78,78,78,41,2,114,73,0,0,0,114,73,0,0,0,41, @@ -2725,7 +2725,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 218,8,60,109,111,100,117,108,101,62,1,0,0,0,115,126, 0,0,0,4,22,4,1,4,1,2,1,2,255,4,4,8, 17,8,5,8,5,8,6,8,6,8,12,8,10,8,9,8, - 5,8,7,8,9,10,22,10,127,0,23,16,1,12,2,4, + 5,8,7,8,9,10,22,10,127,0,21,16,1,12,2,4, 1,4,2,6,2,6,2,8,2,16,71,8,40,8,19,8, 12,8,12,8,28,8,17,8,33,8,28,8,24,10,13,10, 10,10,11,8,14,6,3,4,1,2,255,12,68,14,64,14, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 09a0c12e5f9c4f..955fa3bf1668c7 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -165,9 +165,9 @@ static void *opcode_targets[256] = { &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, - &&TARGET_MATCH_SEQ_TYPE, - &&TARGET_MATCH_MAP_TYPE, - &&_unknown_opcode, + &&TARGET_MATCH_SEQ, + &&TARGET_MATCH_MAP, + &&TARGET_MATCH_KEY, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From 297ceb2b8a625dfbefe570e110efa574f28fbb30 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 28 May 2020 22:13:39 -0700 Subject: [PATCH 033/189] Add a bunch of mapping tests, plus cleanup --- Lib/test/test_patma.py | 160 +++++++++++++++++++++++++++++++++++++---- Python/ast.c | 2 +- 2 files changed, 146 insertions(+), 16 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index a3398b8fc444f6..3fcb430f48f513 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -265,49 +265,49 @@ def test_pipe_07(self) -> None: self.assertNotIn("y", namespace) self.assertNotIn("z", namespace) - def test_iter_00(self) -> None: + def test_sequence_00(self) -> None: match_cases = [MatchCase("()", "y = 0")] namespace = self.execute_match("x = ()", "x", match_cases, "") self.assertEqual(namespace.get("x"), ()) self.assertEqual(namespace.get("y"), 0) - def test_iter_01(self) -> None: + def test_sequence_01(self) -> None: match_cases = [MatchCase("[]", "y = 0")] namespace = self.execute_match("x = ()", "x", match_cases, "") self.assertEqual(namespace.get("x"), ()) self.assertEqual(namespace.get("y"), 0) - def test_iter_02(self) -> None: + def test_sequence_02(self) -> None: match_cases = [MatchCase("[0]", "y = 0")] namespace = self.execute_match("x = (0,)", "x", match_cases, "") self.assertEqual(namespace.get("x"), (0,)) self.assertEqual(namespace.get("y"), 0) - def test_iter_03(self) -> None: + def test_sequence_03(self) -> None: match_cases = [MatchCase("[[]]", "y = 0")] namespace = self.execute_match("x = ((),)", "x", match_cases, "") self.assertEqual(namespace.get("x"), ((),)) self.assertEqual(namespace.get("y"), 0) - def test_iter_04(self) -> None: + def test_sequence_04(self) -> None: match_cases = [MatchCase("(0, 1) | (1, 0)", "y = 0")] namespace = self.execute_match("x = [0, 1]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [0, 1]) self.assertEqual(namespace.get("y"), 0) - def test_iter_05(self) -> None: + def test_sequence_05(self) -> None: match_cases = [MatchCase("(0, 1) | (1, 0)", "y = 0")] namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [1, 0]) self.assertEqual(namespace.get("y"), 0) - def test_iter_06(self) -> None: + def test_sequence_06(self) -> None: match_cases = [MatchCase("(0, 1) | (1, 0)", "y = 0")] namespace = self.execute_match("x = [0, 0]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [0, 0]) self.assertNotIn("y", namespace) - def test_iter_07(self) -> None: + def test_sequence_07(self) -> None: match_cases = [ MatchCase("(w := 0,)", "y = 0"), MatchCase("[] | (1, z := (0 | 1)) | []", "y = 1"), @@ -318,7 +318,7 @@ def test_iter_07(self) -> None: self.assertEqual(namespace.get("y"), 1) self.assertEqual(namespace.get("z"), 0) - def test_iter_08(self) -> None: + def test_sequence_08(self) -> None: match_cases = [ MatchCase("(0,)", "y = 0"), MatchCase("(1, 0)", "y = 1", "(x := x[:0])"), @@ -328,31 +328,31 @@ def test_iter_08(self) -> None: self.assertEqual(namespace.get("x"), []) self.assertEqual(namespace.get("y"), 2) - def test_iter_09(self) -> None: + def test_sequence_09(self) -> None: match_cases = [MatchCase("[0]", "y = 0")] namespace = self.execute_match("x = {0}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0}) self.assertNotIn("y", namespace) - def test_iter_10(self) -> None: + def test_sequence_10(self) -> None: match_cases = [MatchCase("()", "y = 0")] namespace = self.execute_match("x = set()", "x", match_cases, "") self.assertEqual(namespace.get("x"), set()) self.assertNotIn("y", namespace) - def test_iter_11(self) -> None: + def test_sequence_11(self) -> None: match_cases = [MatchCase("[]", "y = 0")] namespace = self.execute_match("x = iter([1,2,3])", "x", match_cases, "") self.assertEqual(list(namespace.get("x")), [1, 2, 3]) self.assertNotIn("y", namespace) - def test_iter_12(self) -> None: + def test_sequence_12(self) -> None: match_cases = [MatchCase("[]", "y = 0")] namespace = self.execute_match("x = {}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {}) self.assertNotIn("y", namespace) - def test_iter_13(self) -> None: + def test_sequence_13(self) -> None: match_cases = [MatchCase("(0, 1)", "y = 0")] namespace = self.execute_match("x = {0: False, 1: True}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0: False, 1: True}) @@ -411,9 +411,139 @@ def test_string_05(self) -> None: self.assertEqual(namespace.get("x"), b"xxx") self.assertEqual(namespace.get("y"), 2) + def test_mapping_00(self) -> None: + match_cases = [MatchCase("{}", "y = 0")] + namespace = self.execute_match("x = {}", "x", match_cases, "") + self.assertEqual(namespace.get("x"), {}) + self.assertEqual(namespace.get("y"), 0) + + def test_mapping_01(self) -> None: + match_cases = [MatchCase("{}", "y = 0")] + namespace = self.execute_match("x = {0: 0}", "x", match_cases, "") + self.assertEqual(namespace.get("x"), {0: 0}) + self.assertEqual(namespace.get("y"), 0) + + def test_mapping_02(self) -> None: + match_cases = [MatchCase("{0: 0}", "y = 0")] + namespace = self.execute_match("x = {}", "x", match_cases, "") + self.assertEqual(namespace.get("x"), {}) + self.assertNotIn("y", namespace) + + def test_mapping_03(self) -> None: + match_cases = [MatchCase("{0: (z := (0 | 1 | 2))}", "y = 0")] + namespace = self.execute_match("x = {0: 0}", "x", match_cases, "") + self.assertEqual(namespace.get("x"), {0: 0}) + self.assertEqual(namespace.get("y"), 0) + self.assertEqual(namespace.get("z"), 0) + + def test_mapping_04(self) -> None: + match_cases = [MatchCase("{0: (z := (0 | 1 | 2))}", "y = 0")] + namespace = self.execute_match("x = {0: 1}", "x", match_cases, "") + self.assertEqual(namespace.get("x"), {0: 1}) + self.assertEqual(namespace.get("y"), 0) + self.assertEqual(namespace.get("z"), 1) + + def test_mapping_05(self) -> None: + match_cases = [MatchCase("{0: (z := (0 | 1 | 2))}", "y = 0")] + namespace = self.execute_match("x = {0: 2}", "x", match_cases, "") + self.assertEqual(namespace.get("x"), {0: 2}) + self.assertEqual(namespace.get("y"), 0) + self.assertEqual(namespace.get("z"), 2) + + def test_mapping_06(self) -> None: + match_cases = [MatchCase("{0: (z := (0 | 1 | 2))}", "y = 0")] + namespace = self.execute_match("x = {0: 3}", "x", match_cases, "") + self.assertEqual(namespace.get("x"), {0: 3}) + self.assertNotIn("y", namespace) + self.assertNotIn("z", namespace) + + def test_mapping_07(self) -> None: + match_cases = [ + MatchCase("{0: [1, 2, {}]}", "y = 0"), + MatchCase("{0: [1, 2, {}], 1: [()]}", "y = 1"), + MatchCase("()", "y = 2"), + ] + namespace = self.execute_match("x = {}", "x", match_cases, "") + self.assertEqual(namespace.get("x"), {}) + self.assertNotIn("y", namespace) + + def test_mapping_08(self) -> None: + match_cases = [ + MatchCase("{0: [1, 2, {}]}", "y = 0"), + MatchCase("{0: [1, 2, {}], 1: [()]}", "y = 1"), + MatchCase("()", "y = 2"), + ] + namespace = self.execute_match( + "x = {False: (True, 2.0, {})}", "x", match_cases, "" + ) + self.assertEqual(namespace.get("x"), {False: (True, 2.0, {})}) + self.assertEqual(namespace.get("y"), 0) + + def test_mapping_09(self) -> None: + match_cases = [ + MatchCase("{0: [1, 2, {}]}", "y = 0"), + MatchCase("{0: [1, 2, {}], 1: [()]}", "y = 1"), + MatchCase("()", "y = 2"), + ] + namespace = self.execute_match( + "x = {False: (True, 2.0, {}), 1: [[]], 2: 0}", "x", match_cases, "" + ) + self.assertEqual(namespace.get("x"), {False: (True, 2.0, {}), 1: [[]], 2: 0}) + self.assertEqual(namespace.get("y"), 0) + + def test_mapping_10(self) -> None: + match_cases = [ + MatchCase("{0: [1, 2]}", "y = 0"), + MatchCase("{0: [1, 2, {}], 1: [()]}", "y = 1"), + MatchCase("()", "y = 2"), + ] + namespace = self.execute_match( + "x = {False: (True, 2.0, {}), 1: [[]], 2: 0}", "x", match_cases, "" + ) + self.assertEqual(namespace.get("x"), {False: (True, 2.0, {}), 1: [[]], 2: 0}) + self.assertEqual(namespace.get("y"), 1) + + def test_mapping_11(self) -> None: + match_cases = [ + MatchCase("{0: [1, 2, {}]}", "y = 0"), + MatchCase("{0: [1, 2, {}], 1: [()]}", "y = 1"), + MatchCase("()", "y = 2"), + ] + namespace = self.execute_match("x = []", "x", match_cases, "") + self.assertEqual(namespace.get("x"), []) + self.assertEqual(namespace.get("y"), 2) + + def test_mapping_12(self) -> None: + match_cases = [ + MatchCase("{0: [1, 2, {}]}", "y = 0"), + MatchCase( + "{0: [1, 2, {}] | False} | {1: [()]} | {0: [1, 2, {}]} | [] | 'X' | {}", + "y = 1", + ), + MatchCase("()", "y = 2"), + ] + namespace = self.execute_match("x = {0: 0}", "x", match_cases, "") + self.assertEqual(namespace.get("x"), {0: 0}) + self.assertEqual(namespace.get("y"), 1) + + def test_mapping_13(self) -> None: + match_cases = [ + MatchCase("{0: [1, 2, {}]}", "y = 0"), + MatchCase( + "{0: [1, 2, {}] | True} | {1: [()]} | {0: [1, 2, {}]} | [] | 'X' | {}", + "y = 1", + ), + MatchCase("()", "y = 2"), + ] + namespace = self.execute_match("x = {0: 0}", "x", match_cases, "") + self.assertEqual(namespace.get("x"), {0: 0}) + self.assertEqual(namespace.get("y"), 1) + if __name__ == "__main__": # XXX: For quick test debugging... import dis - match_cases = [MatchCase("([0, 1]) | (1 | (z := 2), 0, q, [[[]]])", "pass")] + match_cases = [ + MatchCase("([0, 1]) | {'XXX': (1 | (z := 2))} | (0, q, [[[{}]]])", "pass") + ] dis.dis(TestAST.compile_match("", "x", match_cases, "")) diff --git a/Python/ast.c b/Python/ast.c index 9d4df2a41f9a31..7d06aeed048c9d 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -351,7 +351,7 @@ validate_pattern(expr_ty p) return 0; } } - return 0; + return 1; case List_kind: case Tuple_kind: // TODO: Undecided yet if tuple syntax is legal. values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; From 1902b2143937534aa29649ce154f7194a5f14f81 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 28 May 2020 23:37:22 -0700 Subject: [PATCH 034/189] Reorganize pattern compiler --- Python/compile.c | 325 ++++++++++++++++++++++++----------------------- 1 file changed, 165 insertions(+), 160 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 510ff8346a162b..8048301f27f3e4 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -222,6 +222,8 @@ static int compiler_async_comprehension_generator( int depth, expr_ty elt, expr_ty val, int type); +static int compiler_pattern(struct compiler *, expr_ty, basicblock *); + static PyCodeObject *assemble(struct compiler *, int addNone); static PyObject *__doc__, *__annotations__; @@ -1550,6 +1552,11 @@ compiler_addop_j(struct compiler *c, int opcode, basicblock *b, int absolute) } \ } +#define CHECK(X) \ + if (!(X)) { \ + return 0; \ + } + /* These macros allows to check only for errors and not emmit bytecode * while visiting nodes. */ @@ -2751,180 +2758,179 @@ compiler_if(struct compiler *c, stmt_ty s) } static int -pattern_store_helper(struct compiler *c, expr_ty p) -{ +compiler_pattern_load(struct compiler *c, expr_ty p, basicblock *fail) +{ + assert(p->kind == Attribute_kind || p->kind == Constant_kind || p->kind == Name_kind); + assert(p->kind != Attribute_kind || p->v.Attribute.ctx == Load); + assert(p->kind != Name_kind || p->v.Name.ctx == Load); + VISIT(c, expr, p); + ADDOP_COMPARE(c, Eq); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, fail); + return 1; +} + +static int +compiler_pattern_store(struct compiler *c, expr_ty p) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); if (_PyUnicode_EqualToASCIIString(p->v.Name.id, "_")) { ADDOP(c, POP_TOP); + return 1; + } + VISIT(c, expr, p); + return 1; +} + +static int +compiler_pattern_name(struct compiler *c, expr_ty p, basicblock *fail) +{ + assert(p->kind == Name_kind); + assert(p->v.Name.ctx == Load || p->v.Name.ctx == Store); + if (p->v.Name.ctx == Load) { + return compiler_pattern_load(c, p, fail); + } + return compiler_pattern_store(c, p); +} + +static int +compiler_pattern_namedexpr(struct compiler *c, expr_ty p, basicblock *fail) +{ + assert(p->kind == NamedExpr_kind); + basicblock *block = compiler_new_block(c); + basicblock *end = compiler_new_block(c); + ADDOP(c, DUP_TOP); + CHECK(compiler_pattern(c, p->v.NamedExpr.value, block)); + CHECK(compiler_pattern_store(c, p->v.NamedExpr.target)); + ADDOP_JREL(c, JUMP_FORWARD, end); + compiler_use_next_block(c, block); + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, fail); + compiler_use_next_block(c, end); + return 1; +} + +static int +compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail) +{ + basicblock *block = compiler_new_block(c); + basicblock *end = compiler_new_block(c); + asdl_seq *keys = p->v.Dict.keys; + asdl_seq *values = p->v.Dict.values; + Py_ssize_t size = asdl_seq_LEN(values); + int star = size ? !asdl_seq_GET(keys, size - 1) : 0; + ADDOP_JREL(c, MATCH_MAP, fail); + for (Py_ssize_t i = 0; i < size - star; i++) { + expr_ty key = asdl_seq_GET(keys, i); + expr_ty value = asdl_seq_GET(values, i); + assert(key); + assert(p->kind == Attribute_kind || p->kind == Constant_kind || p->kind == Name_kind); + assert(p->kind != Attribute_kind || p->v.Attribute.ctx == Load); + assert(p->kind != Name_kind || p->v.Name.ctx == Load); + VISIT(c, expr, key); + ADDOP_JREL(c, MATCH_KEY, block); + CHECK(compiler_pattern(c, value, block)); + } + if (!star) { + ADDOP(c, POP_TOP); } else { - VISIT(c, expr, p); + CHECK(compiler_pattern_store(c, asdl_seq_GET(values, size - 1))); + } + ADDOP_JREL(c, JUMP_FORWARD, end); + compiler_use_next_block(c, block); + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, fail); + compiler_use_next_block(c, end); + return 1; +} + +static int +compiler_pattern_or(struct compiler *c, expr_ty p, basicblock *fail) +{ + assert(p->kind == BinOp_kind); + assert(p->v.BinOp.op== BitOr); + basicblock *block = compiler_new_block(c); + basicblock *end = compiler_new_block(c); + ADDOP(c, DUP_TOP); + CHECK(compiler_pattern(c, p->v.BinOp.left, block)); + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, end); + compiler_use_next_block(c, block); + CHECK(compiler_pattern(c, p->v.BinOp.right, fail)); + compiler_use_next_block(c, end); + return 1; +} + +static int +compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail) +{ + assert(p->kind == List_kind || p->kind == Tuple_kind); + asdl_seq *values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; + Py_ssize_t size = asdl_seq_LEN(values); + Py_ssize_t star = -1; + for (Py_ssize_t i = 0; i < size; i++) { + expr_ty value = asdl_seq_GET(values, i); + if (value->kind != Starred_kind) { + continue; + } + if (star >= 0) { + return compiler_error(c, "multiple starred names in pattern"); + } + // TODO: Test this math: + if ((size - i - 1) << 8 >= INT_MAX) { + return compiler_error(c, "too many sub-patterns follow starred name"); + } + star = i; + } + basicblock *block = compiler_new_block(c); + basicblock *end = compiler_new_block(c); + ADDOP_JREL(c, MATCH_SEQ, fail); + for (Py_ssize_t i = 0; i < size; i++) { + expr_ty value = asdl_seq_GET(values, i); + if (i == star) { + assert(value->kind == Starred_kind); + ADDOP_I(c, UNPACK_EX, (size - i - 1) << 8); + CHECK(compiler_pattern_store(c, value->v.Starred.value)); + if (size - i - 1) { + ADDOP_I(c, BUILD_TUPLE, size - i - 1); + ADDOP_JREL(c, MATCH_SEQ, fail); + } + else { + ADDOP_JREL(c, JUMP_FORWARD, end); + } + } + else { + ADDOP_JREL(c, FOR_ITER, fail); + CHECK(compiler_pattern(c, value, block)); + } } + ADDOP_JREL(c, FOR_ITER, end); + ADDOP(c, POP_TOP); + compiler_use_next_block(c, block); + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, fail); + compiler_use_next_block(c, end); return 1; } static int compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) { - basicblock *end, *block; - Py_ssize_t i, size, star; - asdl_seq *keys, *values; - expr_ty key, value; switch (p->kind) { - // Atomic patterns: - case Name_kind: - if (p->v.Name.ctx == Store) { - return pattern_store_helper(c, p); - } - assert(p->v.Name.ctx == Load); - // Fall... case Attribute_kind: - assert(p->kind != Attribute_kind || p->v.Attribute.ctx == Load); - // Fall.... case Constant_kind: - VISIT(c, expr, p); - ADDOP_COMPARE(c, Eq); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, fail); - return 1; - // Nested patterns: + return compiler_pattern_load(c, p, fail); case BinOp_kind: - assert(p->v.BinOp.op == BitOr); - end = compiler_new_block(c); - block = compiler_new_block(c); - ADDOP(c, DUP_TOP); - if (!compiler_pattern(c, p->v.BinOp.left, block)) { - return 0; - } - ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, end); - compiler_use_next_block(c, block); - if (!compiler_pattern(c, p->v.BinOp.right, fail)) { - return 0; - } - compiler_use_next_block(c, end); - return 1; + return compiler_pattern_or(c, p, fail); case Dict_kind: - keys = p->v.Dict.keys; - values = p->v.Dict.values; - size = asdl_seq_LEN(values); - star = 0; - // TODO: Rely on parser/validation for this? - for (i = 0; i < size; i++) { - if (asdl_seq_GET(keys, i)) { - continue; - } - value = asdl_seq_GET(values, i); - if (value->kind != Name_kind || value->v.Name.ctx != Store) { - return compiler_error(c, - "starred sub-patterns must be names"); - } - if (i != size - 1) { - return compiler_error(c, - "sub-patterns cannot follow starred name"); - } - star = 1; - } - end = compiler_new_block(c); - block = compiler_new_block(c); - ADDOP_JREL(c, MATCH_MAP, fail); - for (i = 0; i < size - star; i++) { - key = asdl_seq_GET(keys, i); - value = asdl_seq_GET(values, i); - assert(key); - assert(key->kind == Name_kind && key->v.Name.ctx == Load - || key->kind == Constant_kind); - VISIT(c, expr, key); - ADDOP_JREL(c, MATCH_KEY, block); - if (!compiler_pattern(c, value, block)) { - return 0; - } - } - if (!star) { - ADDOP(c, POP_TOP); - } - else if (!pattern_store_helper(c, asdl_seq_GET(values, size - 1))) { - return 0; - } - ADDOP_JREL(c, JUMP_FORWARD, end); - compiler_use_next_block(c, block); - ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, fail); - compiler_use_next_block(c, end); - return 1; + return compiler_pattern_mapping(c, p, fail); case List_kind: - case Tuple_kind: // TODO: Undecided yet if tuple syntax is legal. - values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; - size = asdl_seq_LEN(values); - star = -1; - for (i = 0; i < size; i++) { - value = asdl_seq_GET(values, i); - if (value->kind != Starred_kind) { - continue; - } - // TODO: Rely on parser/validation for this? - if (value->kind != Name_kind || value->v.Name.ctx != Store) { - return compiler_error(c, - "starred sub-patterns must be names"); - } - if (star >= 0) { - return compiler_error(c, - "multiple starred names in pattern"); - } - // TODO: Test this math: - if ((size - i - 1) << 8 >= INT_MAX) { - return compiler_error(c, - "too many sub-patterns follow starred name"); - } - star = i; - } - end = compiler_new_block(c); - block = compiler_new_block(c); - ADDOP_JREL(c, MATCH_SEQ, fail); - for (i = 0; i < size; i++) { - value = asdl_seq_GET(values, i); - if (i == star) { - assert(value->kind == Starred_kind); - ADDOP_I(c, UNPACK_EX, (size - i - 1) << 8); - if (!pattern_store_helper(c, value->v.Starred.value)) { - return 0; - } - if (size - i - 1) { - ADDOP_I(c, BUILD_TUPLE, size - i - 1); - ADDOP_JREL(c, MATCH_SEQ, fail); - } - else { - ADDOP_JREL(c, JUMP_FORWARD, end); - } - } - else { - ADDOP_JREL(c, FOR_ITER, fail); - if (!compiler_pattern(c, value, block)) { - return 0; - } - } - } - ADDOP_JREL(c, FOR_ITER, end); - ADDOP(c, POP_TOP); - compiler_use_next_block(c, block); - ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, fail); - compiler_use_next_block(c, end); - return 1; + case Tuple_kind: + return compiler_pattern_sequence(c, p, fail); + case Name_kind: + return compiler_pattern_name(c, p, fail); case NamedExpr_kind: - end = compiler_new_block(c); - block = compiler_new_block(c); - ADDOP(c, DUP_TOP); - if (!compiler_pattern(c, p->v.NamedExpr.value, block)) { - return 0; - } - VISIT(c, expr, p->v.NamedExpr.target); - ADDOP_JREL(c, JUMP_FORWARD, end); - compiler_use_next_block(c, block); - ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, fail); - compiler_use_next_block(c, end); - return 1; + return compiler_pattern_namedexpr(c, p, fail); default: Py_UNREACHABLE(); } @@ -2934,16 +2940,15 @@ static int compiler_match(struct compiler *c, stmt_ty s) { VISIT(c, expr, s->v.Match.target); - match_case_ty m; - basicblock *next, *end = compiler_new_block(c); + basicblock *end = compiler_new_block(c); Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); for (Py_ssize_t i = 0; i < cases; i++) { - m = asdl_seq_GET(s->v.Match.cases, i); - next = compiler_new_block(c); + match_case_ty m = asdl_seq_GET(s->v.Match.cases, i); + basicblock *next = compiler_new_block(c); ADDOP(c, DUP_TOP); compiler_pattern(c, m->pattern, next); - if (m->guard && !compiler_jump_if(c, m->guard, next, 0)) { - return 0; + if (m->guard) { + CHECK(compiler_jump_if(c, m->guard, next, 0)); } ADDOP(c, POP_TOP); VISIT_SEQ(c, stmt, m->body); From 09e8fdcc111e48da4f2d771d18d4d98d7f3965ed Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 29 May 2020 08:28:02 -0700 Subject: [PATCH 035/189] Handle errors when creating new blocks --- Python/compile.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 8048301f27f3e4..cafaf56b666f0a 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2796,8 +2796,9 @@ static int compiler_pattern_namedexpr(struct compiler *c, expr_ty p, basicblock *fail) { assert(p->kind == NamedExpr_kind); - basicblock *block = compiler_new_block(c); - basicblock *end = compiler_new_block(c); + basicblock *block, *end; + CHECK(block = compiler_new_block(c)); + CHECK(end = compiler_new_block(c)); ADDOP(c, DUP_TOP); CHECK(compiler_pattern(c, p->v.NamedExpr.value, block)); CHECK(compiler_pattern_store(c, p->v.NamedExpr.target)); @@ -2812,8 +2813,9 @@ compiler_pattern_namedexpr(struct compiler *c, expr_ty p, basicblock *fail) static int compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail) { - basicblock *block = compiler_new_block(c); - basicblock *end = compiler_new_block(c); + basicblock *block, *end; + CHECK(block = compiler_new_block(c)); + CHECK(end = compiler_new_block(c)); asdl_seq *keys = p->v.Dict.keys; asdl_seq *values = p->v.Dict.values; Py_ssize_t size = asdl_seq_LEN(values); @@ -2849,8 +2851,9 @@ compiler_pattern_or(struct compiler *c, expr_ty p, basicblock *fail) { assert(p->kind == BinOp_kind); assert(p->v.BinOp.op== BitOr); - basicblock *block = compiler_new_block(c); - basicblock *end = compiler_new_block(c); + basicblock *block, *end; + CHECK(block = compiler_new_block(c)); + CHECK(end = compiler_new_block(c)); ADDOP(c, DUP_TOP); CHECK(compiler_pattern(c, p->v.BinOp.left, block)); ADDOP(c, POP_TOP); @@ -2882,8 +2885,9 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail) } star = i; } - basicblock *block = compiler_new_block(c); - basicblock *end = compiler_new_block(c); + basicblock *block, *end; + CHECK(block = compiler_new_block(c)); + CHECK(end = compiler_new_block(c)); ADDOP_JREL(c, MATCH_SEQ, fail); for (Py_ssize_t i = 0; i < size; i++) { expr_ty value = asdl_seq_GET(values, i); @@ -2940,11 +2944,12 @@ static int compiler_match(struct compiler *c, stmt_ty s) { VISIT(c, expr, s->v.Match.target); - basicblock *end = compiler_new_block(c); + basicblock *next, *end; + CHECK(end = compiler_new_block(c)); Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); for (Py_ssize_t i = 0; i < cases; i++) { match_case_ty m = asdl_seq_GET(s->v.Match.cases, i); - basicblock *next = compiler_new_block(c); + CHECK(next = compiler_new_block(c)); ADDOP(c, DUP_TOP); compiler_pattern(c, m->pattern, next); if (m->guard) { From f612a2740c8e6e7f43b8d60f240ef226469115d3 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 29 May 2020 08:32:40 -0700 Subject: [PATCH 036/189] Break out _collections_abc stuff in ceval --- Python/ceval.c | 104 +++++++++++++++++++++++++++++++------------------ 1 file changed, 67 insertions(+), 37 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 7ecb7d5756e064..0a8e87dfe558b5 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -848,6 +848,56 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) return 0; } +// Need these for pattern matching: + +static int +match_map_type(PyObject *target) +{ + PyInterpreterState *interp = PyInterpreterState_Get(); + if (!interp) { + return -1; + } + if (!interp->map_abc) { + PyObject *abc = PyImport_ImportModule("_collections_abc"); + if (!abc) { + return -1; + } + interp->map_abc = PyObject_GetAttrString(abc, "Mapping"); + Py_DECREF(abc); + if (!interp->map_abc) { + return -1; + } + } + return PyObject_IsInstance(target, interp->map_abc); +} + +static int +match_seq_type(PyObject *target) +{ + PyInterpreterState *interp = PyInterpreterState_Get(); + if (!interp) { + return -1; + } + if (!interp->seq_abc) { + PyObject *abc = PyImport_ImportModule("_collections_abc"); + if (!abc) { + return -1; + } + interp->seq_abc = PyObject_GetAttrString(abc, "Sequence"); + Py_DECREF(abc); + if (!interp->seq_abc) { + return -1; + } + } + return ( + PyObject_IsInstance(target, interp->seq_abc) + && !PyIter_Check(target) + && !PyObject_TypeCheck(target, &PyUnicode_Type) + && !PyObject_TypeCheck(target, &PyBytes_Type) + && !PyObject_TypeCheck(target, &PyByteArray_Type) + ); +} + static int do_raise(PyThreadState *tstate, PyObject *exc, PyObject *cause); static int unpack_iterable(PyThreadState *, PyObject *, int, int, PyObject **); @@ -3309,23 +3359,12 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_MAP): { - PyInterpreterState *interp = PyInterpreterState_Get(); - if (!interp) { + PyObject *target = TOP(); + int match = match_map_type(target); + if (match < 0) { goto error; } - if (!interp->map_abc) { - PyObject *abc = PyImport_ImportModule("_collections_abc"); - if (!abc) { - goto error; - } - interp->map_abc = PyObject_GetAttrString(abc, "Mapping"); - Py_DECREF(abc); - if (!interp->map_abc) { - goto error; - } - } - PyObject *target = TOP(); - if (!PyObject_IsInstance(target, interp->map_abc)) { + if (!match) { STACK_SHRINK(1); Py_DECREF(target); JUMPBY(oparg); @@ -3351,35 +3390,26 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_SEQ): { - PyInterpreterState *interp = PyInterpreterState_Get(); - if (!interp) { + PyObject *target = TOP(); + int match = match_seq_type(target); + if (match < 0) { goto error; } - if (!interp->seq_abc) { - PyObject *abc = PyImport_ImportModule("_collections_abc"); - if (!abc) { - goto error; - } - interp->seq_abc = PyObject_GetAttrString(abc, "Sequence"); - Py_DECREF(abc); - if (!interp->seq_abc) { - goto error; - } - } - PyObject *target = TOP(); - if ( - !PyObject_IsInstance(target, interp->seq_abc) - || PyIter_Check(target) - || PyObject_TypeCheck(target, &PyUnicode_Type) - || PyObject_TypeCheck(target, &PyBytes_Type) - || PyObject_TypeCheck(target, &PyByteArray_Type) - ) { + if (!match) { STACK_SHRINK(1); Py_DECREF(target); JUMPBY(oparg); DISPATCH(); } - } // Fall... + PyObject *iter = PyObject_GetIter(target); + if (!iter) { + goto error; + } + Py_DECREF(target); + SET_TOP(iter); + DISPATCH(); + } + case TARGET(GET_ITER): { /* before: [obj]; after [getiter(obj)] */ PyObject *iterable = TOP(); From 21ac8790df5380e1e9b4340924a3e997aca7d70f Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 29 May 2020 08:35:31 -0700 Subject: [PATCH 037/189] Clean up new opcode docs --- Doc/library/dis.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index fbd71e24ee5da9..c64ea76c4ad7fd 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -992,29 +992,29 @@ All of the following opcodes use their arguments. .. opcode:: MATCH_SEQ (delta) - Used to implement pattern matching. Pop TOS. If it is an instance of - :class:`collections.abc.Sequence`, is not an :term:`iterator`, and is not an - instance of :class:`str`/:class:`bytes`/:class:`bytearray`, get an iterator - from it and push that onto the stack. Otherwise, increment the bytecode - counter by ``delta``. + Pop TOS. If it is an instance of :class:`collections.abc.Sequence`, is not + an :term:`iterator`, and is not an instance of + :class:`str`/:class:`bytes`/:class:`bytearray`, get an iterator from it and + push that onto the stack. Otherwise, increment the bytecode counter by + ``delta``. .. versionadded:: 3.10 .. opcode:: MATCH_MAP (delta) - Used to implement pattern matching. Pop TOS. If it is an instance of - :class:`collections.abc.Mapping`, copy it into a :class:`dict` and push that - onto the stack. Otherwise, increment the bytecode counter by *delta*. + Pop TOS. If it is an instance of :class:`collections.abc.Mapping`, copy it + into a :class:`dict` and push that onto the stack. Otherwise, increment the + bytecode counter by ``delta``. .. versionadded:: 3.10 .. opcode:: MATCH_KEY (delta) - Used to implement pattern matching. Pop TOS. If it is a key in the dict at - TOS1, remove it and push the associated value onto the stack. Otherwise, - increment the bytecode counter by *delta*. + Pop TOS. If it is a key in the :class:`dict` at TOS1, remove it and push the + associated value onto the stack. Otherwise, increment the bytecode counter + by ``delta``. .. versionadded:: 3.10 From c103ab4dddf946f13dc707863fa440c54d51832c Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 29 May 2020 08:45:56 -0700 Subject: [PATCH 038/189] Simplify string checks --- Python/ceval.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 0a8e87dfe558b5..a386b3b3671eb3 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -892,9 +892,9 @@ match_seq_type(PyObject *target) return ( PyObject_IsInstance(target, interp->seq_abc) && !PyIter_Check(target) - && !PyObject_TypeCheck(target, &PyUnicode_Type) - && !PyObject_TypeCheck(target, &PyBytes_Type) - && !PyObject_TypeCheck(target, &PyByteArray_Type) + && !PyUnicode_Check(target) + && !PyBytes_Check(target) + && !PyByteArray_Check(target) ); } From 14409e062c3e2233f21c5f5e06e23173ed1c15b4 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 29 May 2020 09:20:01 -0700 Subject: [PATCH 039/189] Add basic AST optimization --- Python/ast_opt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Python/ast_opt.c b/Python/ast_opt.c index ff786d6f8d63ef..87e6995ebcb379 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -395,6 +395,8 @@ static int astfold_keyword(keyword_ty node_, PyArena *ctx_, _PyASTOptimizeState static int astfold_arg(arg_ty node_, PyArena *ctx_, _PyASTOptimizeState *state); static int astfold_withitem(withitem_ty node_, PyArena *ctx_, _PyASTOptimizeState *state); static int astfold_excepthandler(excepthandler_ty node_, PyArena *ctx_, _PyASTOptimizeState *state); +static int astfold_match_case(match_case_ty node_, PyArena *ctx_, _PyASTOptimizeState *state); + #define CALL(FUNC, TYPE, ARG) \ if (!FUNC((ARG), ctx_, state)) \ return 0; @@ -710,6 +712,10 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) case Expr_kind: CALL(astfold_expr, expr_ty, node_->v.Expr.value); break; + case Match_kind: + CALL(astfold_expr, expr_ty, node_->v.Match.target); + CALL_SEQ(astfold_match_case, match_case_ty, node_->v.Match.cases); + break; default: break; } @@ -738,6 +744,16 @@ astfold_withitem(withitem_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) return 1; } +static int +astfold_match_case(match_case_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) +{ + CALL_OPT(astfold_expr, expr_ty, node_->guard); + // TODO: Create pattern optimizer. + // Don't blindly optimize the pattern as an expr; it plays by its own rules! + CALL_SEQ(astfold_stmt, stmt_ty, node_->body); + return 1; +} + #undef CALL #undef CALL_OPT #undef CALL_SEQ From e91c4004f3e2873a9e5f57d90c04423c43d89226 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 29 May 2020 11:02:39 -0700 Subject: [PATCH 040/189] Fix asserts --- Python/compile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index cafaf56b666f0a..45d0e32d6954e7 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2825,9 +2825,9 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail) expr_ty key = asdl_seq_GET(keys, i); expr_ty value = asdl_seq_GET(values, i); assert(key); - assert(p->kind == Attribute_kind || p->kind == Constant_kind || p->kind == Name_kind); - assert(p->kind != Attribute_kind || p->v.Attribute.ctx == Load); - assert(p->kind != Name_kind || p->v.Name.ctx == Load); + assert(key->kind == Attribute_kind || key->kind == Constant_kind || key->kind == Name_kind); + assert(key->kind != Attribute_kind || key->v.Attribute.ctx == Load); + assert(key->kind != Name_kind || key->v.Name.ctx == Load); VISIT(c, expr, key); ADDOP_JREL(c, MATCH_KEY, block); CHECK(compiler_pattern(c, value, block)); From 7fb4d11a9d59db463ed037318bc1ff6f407688d7 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 29 May 2020 17:35:20 -0700 Subject: [PATCH 041/189] Implement default object.__match__ --- Objects/clinic/typeobject.c.h | 11 ++++++++++- Objects/typeobject.c | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Objects/clinic/typeobject.c.h b/Objects/clinic/typeobject.c.h index 8c70d76d916db3..afaec9c809e5fb 100644 --- a/Objects/clinic/typeobject.c.h +++ b/Objects/clinic/typeobject.c.h @@ -243,4 +243,13 @@ object___dir__(PyObject *self, PyObject *Py_UNUSED(ignored)) { return object___dir___impl(self); } -/*[clinic end generated code: output=b4fb62939b08baf9 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(object___match____doc__, +"__match__($type, target, /)\n" +"--\n" +"\n" +"Match all instances of this type, returning them for further destructuring."); + +#define OBJECT___MATCH___METHODDEF \ + {"__match__", (PyCFunction)object___match__, METH_O|METH_CLASS, object___match____doc__}, +/*[clinic end generated code: output=9fc91a27a50d735d input=a9049054013a1b77]*/ diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 0e055d677f139e..fb95f6f8282f55 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4986,6 +4986,31 @@ object___dir___impl(PyObject *self) return result; } +/*[clinic input] +@classmethod +object.__match__ + + target: object + / + +Match all instances of this type, returning them for further destructuring. +[clinic start generated code]*/ + +static PyObject * +object___match__(PyTypeObject *type, PyObject *target) +/*[clinic end generated code: output=bcea50777819dfeb input=493f4963453b0072]*/ +{ + int match = PyObject_IsInstance(target, (PyObject *)type); + if (match < 0) { + return NULL; + } + if (match) { + Py_INCREF(target); + return target; + } + Py_RETURN_NONE; +} + static PyMethodDef object_methods[] = { OBJECT___REDUCE_EX___METHODDEF OBJECT___REDUCE___METHODDEF @@ -4996,6 +5021,7 @@ static PyMethodDef object_methods[] = { OBJECT___FORMAT___METHODDEF OBJECT___SIZEOF___METHODDEF OBJECT___DIR___METHODDEF + OBJECT___MATCH___METHODDEF {0} }; From 17356fb1ca49dddaea6dc36e2cbce38c0069f243 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sat, 30 May 2020 17:58:33 -0700 Subject: [PATCH 042/189] Fix sequence matching bug --- Python/compile.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 45d0e32d6954e7..4075451d5bdc5c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -982,8 +982,6 @@ stack_effect(int opcode, int oparg, int jump) case FOR_ITER: /* -1 at end of iterator, 1 if continue iterating. */ return jump > 0 ? -1 : 1; - case MATCH_SEQ: - case MATCH_MAP: case MATCH_KEY: return -(jump > 0); @@ -2849,17 +2847,21 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail) static int compiler_pattern_or(struct compiler *c, expr_ty p, basicblock *fail) { - assert(p->kind == BinOp_kind); - assert(p->v.BinOp.op== BitOr); + assert(p->kind == BoolOp_kind); + assert(p->v.BoolOp.op== Or); basicblock *block, *end; - CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); - ADDOP(c, DUP_TOP); - CHECK(compiler_pattern(c, p->v.BinOp.left, block)); + Py_ssize_t size = asdl_seq_LEN(p->v.BoolOp.values); + for (Py_ssize_t i = 0; i < size; i++) { + CHECK(block = compiler_new_block(c)); + ADDOP(c, DUP_TOP); + CHECK(compiler_pattern(c, asdl_seq_GET(p->v.BoolOp.values, i), block)); + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, end); + compiler_use_next_block(c, block); + } ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, end); - compiler_use_next_block(c, block); - CHECK(compiler_pattern(c, p->v.BinOp.right, fail)); + ADDOP_JREL(c, JUMP_FORWARD, fail); compiler_use_next_block(c, end); return 1; } @@ -2896,6 +2898,8 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail) ADDOP_I(c, UNPACK_EX, (size - i - 1) << 8); CHECK(compiler_pattern_store(c, value->v.Starred.value)); if (size - i - 1) { + ADDOP_I(c, BUILD_TUPLE, size - i - 1); + ADDOP_I(c, UNPACK_SEQUENCE, size - i - 1); ADDOP_I(c, BUILD_TUPLE, size - i - 1); ADDOP_JREL(c, MATCH_SEQ, fail); } @@ -2924,7 +2928,7 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) case Attribute_kind: case Constant_kind: return compiler_pattern_load(c, p, fail); - case BinOp_kind: + case BoolOp_kind: return compiler_pattern_or(c, p, fail); case Dict_kind: return compiler_pattern_mapping(c, p, fail); From 9d7bd070aaf4009d2d9199b20e72479c06128f34 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sat, 30 May 2020 18:09:47 -0700 Subject: [PATCH 043/189] BinOp -> BoolOp --- Grammar/python.gram | 94 +- Lib/test/test_patma.py | 101 +- Parser/pegen/parse.c | 5055 ++++++++++++++++++++-------------------- Python/ast.c | 21 +- Python/compile.c | 2 + 5 files changed, 2681 insertions(+), 2592 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index dba18e16fc36f6..ef69ad240bdddd 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -193,17 +193,24 @@ except_block[excepthandler_ty]: finally_block[asdl_seq*]: 'finally' ':' a=block { a } match_stmt[stmt_ty]: - | "match" target=expression ':' NEWLINE INDENT cases=case_block+ DEDENT {_Py_Match(target, cases, EXTRA) } + | "match" target=expression ':' NEWLINE INDENT cases=case_block+ DEDENT { + _Py_Match(target, cases, EXTRA) } case_block: - | "case" pattern=pattern guard=['if' a=named_expression { a }] ':' body=block { - _Py_match_case(pattern, guard, body, p->arena) } + | "case" pattern=pattern guard=[guard] ':' body=block { + _Py_match_case(pattern, guard, body, p->arena) } pattern: - | a=NAME ':=' b=or_pattern { _Py_NamedExpr(CHECK(_PyPegen_set_expr_context(p, a, Store)), b, EXTRA) } + | target=NAME ':=' value=or_pattern { + _Py_NamedExpr(CHECK(_PyPegen_set_expr_context(p, target, Store)), value, EXTRA) } | or_pattern +guard: + | 'if' guard=named_expression { + guard } or_pattern: - | '|'.closed_pattern+ + | value=closed_pattern '|' values='|'.closed_pattern+ { + _Py_BoolOp(Or, CHECK(_PyPegen_seq_insert_in_front(p, value, values)), EXTRA) } + | closed_pattern closed_pattern: | name_pattern @@ -215,32 +222,67 @@ closed_pattern: | class_pattern name_pattern: - | a=NAME !('.' | '(') { a } + | a=NAME !('.' | '(') { + _PyPegen_set_expr_context(p, a, Store) } literal_pattern: | NUMBER | strings - | 'None' - | 'True' - | 'False' + | 'None' { + _Py_Constant(Py_None, NULL, EXTRA) } + | 'True' { + _Py_Constant(Py_True, NULL, EXTRA) } + | 'False' { + _Py_Constant(Py_False, NULL, EXTRA) } constant_pattern: - | '.' NAME - | a='.'.NAME+ !'(' { a } + | '.' name=NAME { + name } + | value=name_or_attr '.' attr=NAME !'(' { + _Py_Attribute(value, attr->v.Name.id, Load, EXTRA) } group_pattern: - | '(' a=pattern ')' { a } + | '(' pattern=pattern ')' { + pattern } sequence_pattern: - | '[' a=[','.pattern+] ']' { _Py_List(a, Load, EXTRA) } - | '(' a=[','.pattern+] ')' { _Py_Tuple(a, Load, EXTRA) } + | '[' values=values_pattern ']' { + _Py_List(values, Load, EXTRA) } mapping_pattern: - | '{' ','.(key_pattern ':' closed_pattern)+ '}' { NULL } -key_pattern: - | a=literal_pattern &':' { a } - | a='|'.literal_pattern+ { NULL } + | '{' items=items_pattern '}' { + _Py_Dict(CHECK(_PyPegen_get_keys(p, items)), CHECK(_PyPegen_get_values(p, items)), EXTRA) } class_pattern: - | '.'.NAME+ '(' pattern_args ')' -pattern_args: - | ','.pattern+ ',' ','.(NAME '=' or_pattern)+ { NULL } - | ','.(NAME '=' or_pattern)+ { NULL } - | a=','.pattern+ { a } + | func=name_or_attr '(' ')' { + _Py_Call(func, NULL, NULL, EXTRA) } + | func=name_or_attr '(' args=','.pattern+ [','] ')' { + _Py_Call(func, args, NULL, EXTRA) } + | func=name_or_attr '(' keywords=','.keyword_pattern+ [','] ')' { + _Py_Call(func, NULL, keywords, EXTRA) } + | func=name_or_attr '(' args=','.pattern+ ',' keywords=','.keyword_pattern+ [','] ')' { + _Py_Call(func, args, keywords, EXTRA) } + +name_or_attr: + | value=name_or_attr '.' attr=NAME { + _Py_Attribute(value, attr->v.Name.id, Load, EXTRA) } + | NAME +values_pattern: + | values=','.value_pattern+ [','] { + values } +items_pattern: + | items=','.key_value_pattern+ [','] { + items } +keyword_pattern: + | arg=NAME '=' value=or_pattern { + _Py_keyword(arg->v.Name.id, value, EXTRA) } + +value_pattern: + | '*' value=name_pattern { + _Py_Starred(value, Store, EXTRA) } + | pattern +key_value_pattern: + | key=literal_pattern ':' value=closed_pattern { + _PyPegen_key_value_pair(p, key, value) } + | key=constant_pattern ':' value=closed_pattern { + _PyPegen_key_value_pair(p, key, value) } + | '**' value=name_pattern { + _PyPegen_key_value_pair(p, NULL, value) } + return_stmt[stmt_ty]: | 'return' a=[star_expressions] { _Py_Return(a, EXTRA) } @@ -702,12 +744,12 @@ invalid_assignment: _PyPegen_get_invalid_target(a), "cannot assign to %s", _PyPegen_get_expr_name(_PyPegen_get_invalid_target(a))) } | a=star_expressions augassign (yield_expr | star_expressions) { - RAISE_SYNTAX_ERROR_KNOWN_LOCATION( - a, + RAISE_SYNTAX_ERROR_KNOWN_LOCATION( + a, "'%s' is an illegal expression for augmented assignment", _PyPegen_get_expr_name(a) )} - + invalid_block: | NEWLINE !INDENT { RAISE_INDENTATION_ERROR("expected an indented block") } invalid_comprehension: diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 3fcb430f48f513..2c1c6fa879379e 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -18,6 +18,9 @@ class TestAST(unittest.TestCase): No tests for name loads/stores, since these need a patma parser to disambiguate. + + Note that we use "or" for "|" here, since the parser gives us a BoolOp-Or, + not a BinOp-BitOr. """ @staticmethod @@ -206,32 +209,32 @@ def test_walrus_05(self) -> None: self.assertEqual(namespace.get("z"), 0) def test_pipe_00(self) -> None: - match_cases = [MatchCase("0 | 1 | 2", "y = 0")] + match_cases = [MatchCase("0 or 1 or 2", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) def test_pipe_01(self) -> None: - match_cases = [MatchCase("0 | 1 | 2", "y = 0")] + match_cases = [MatchCase("0 or 1 or 2", "y = 0")] namespace = self.execute_match("x = 1", "x", match_cases, "") self.assertEqual(namespace.get("x"), 1) self.assertEqual(namespace.get("y"), 0) def test_pipe_02(self) -> None: - match_cases = [MatchCase("0 | 1 | 2", "y = 0")] + match_cases = [MatchCase("0 or 1 or 2", "y = 0")] namespace = self.execute_match("x = 2", "x", match_cases, "") self.assertEqual(namespace.get("x"), 2) self.assertEqual(namespace.get("y"), 0) def test_pipe_03(self) -> None: - match_cases = [MatchCase("0 | 1 | 2", "y = 0")] + match_cases = [MatchCase("0 or 1 or 2", "y = 0")] namespace = self.execute_match("x = 3", "x", match_cases, "") self.assertEqual(namespace.get("x"), 3) self.assertNotIn("y", namespace) def test_pipe_04(self) -> None: match_cases = [ - MatchCase("(z := 0) | (z := 1) | (z := 2)", "y = 0", "z == x % 2") + MatchCase("(z := 0) or (z := 1) or (z := 2)", "y = 0", "z == x % 2") ] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) @@ -240,7 +243,7 @@ def test_pipe_04(self) -> None: def test_pipe_05(self) -> None: match_cases = [ - MatchCase("(z := 0) | (z := 1) | (z := 2)", "y = 0", "z == x % 2") + MatchCase("(z := 0) or (z := 1) or (z := 2)", "y = 0", "z == x % 2") ] namespace = self.execute_match("x = 1", "x", match_cases, "") self.assertEqual(namespace.get("x"), 1) @@ -249,7 +252,7 @@ def test_pipe_05(self) -> None: def test_pipe_06(self) -> None: match_cases = [ - MatchCase("(z := 0) | (z := 1) | (z := 2)", "y = 0", "z == x % 2") + MatchCase("(z := 0) or (z := 1) or (z := 2)", "y = 0", "z == x % 2") ] namespace = self.execute_match("x = 2", "x", match_cases, "") self.assertEqual(namespace.get("x"), 2) @@ -258,7 +261,7 @@ def test_pipe_06(self) -> None: def test_pipe_07(self) -> None: match_cases = [ - MatchCase("(z := 0) | (z := 1) | (z := 2)", "y = 0", "z == x % 2") + MatchCase("(z := 0) or (z := 1) or (z := 2)", "y = 0", "z == x % 2") ] namespace = self.execute_match("x = 3", "x", match_cases, "") self.assertEqual(namespace.get("x"), 3) @@ -290,19 +293,19 @@ def test_sequence_03(self) -> None: self.assertEqual(namespace.get("y"), 0) def test_sequence_04(self) -> None: - match_cases = [MatchCase("(0, 1) | (1, 0)", "y = 0")] + match_cases = [MatchCase("(0, 1) or (1, 0)", "y = 0")] namespace = self.execute_match("x = [0, 1]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [0, 1]) self.assertEqual(namespace.get("y"), 0) def test_sequence_05(self) -> None: - match_cases = [MatchCase("(0, 1) | (1, 0)", "y = 0")] + match_cases = [MatchCase("(0, 1) or (1, 0)", "y = 0")] namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [1, 0]) self.assertEqual(namespace.get("y"), 0) def test_sequence_06(self) -> None: - match_cases = [MatchCase("(0, 1) | (1, 0)", "y = 0")] + match_cases = [MatchCase("(0, 1) or (1, 0)", "y = 0")] namespace = self.execute_match("x = [0, 0]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [0, 0]) self.assertNotIn("y", namespace) @@ -310,7 +313,7 @@ def test_sequence_06(self) -> None: def test_sequence_07(self) -> None: match_cases = [ MatchCase("(w := 0,)", "y = 0"), - MatchCase("[] | (1, z := (0 | 1)) | []", "y = 1"), + MatchCase("[] or (1, z := (0 or 1)) or []", "y = 1"), ] namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") self.assertNotIn("w", namespace) @@ -430,28 +433,28 @@ def test_mapping_02(self) -> None: self.assertNotIn("y", namespace) def test_mapping_03(self) -> None: - match_cases = [MatchCase("{0: (z := (0 | 1 | 2))}", "y = 0")] + match_cases = [MatchCase("{0: (z := (0 or 1 or 2))}", "y = 0")] namespace = self.execute_match("x = {0: 0}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0: 0}) self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 0) def test_mapping_04(self) -> None: - match_cases = [MatchCase("{0: (z := (0 | 1 | 2))}", "y = 0")] + match_cases = [MatchCase("{0: (z := (0 or 1 or 2))}", "y = 0")] namespace = self.execute_match("x = {0: 1}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0: 1}) self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 1) def test_mapping_05(self) -> None: - match_cases = [MatchCase("{0: (z := (0 | 1 | 2))}", "y = 0")] + match_cases = [MatchCase("{0: (z := (0 or 1 or 2))}", "y = 0")] namespace = self.execute_match("x = {0: 2}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0: 2}) self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 2) def test_mapping_06(self) -> None: - match_cases = [MatchCase("{0: (z := (0 | 1 | 2))}", "y = 0")] + match_cases = [MatchCase("{0: (z := (0 or 1 or 2))}", "y = 0")] namespace = self.execute_match("x = {0: 3}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0: 3}) self.assertNotIn("y", namespace) @@ -517,7 +520,7 @@ def test_mapping_12(self) -> None: match_cases = [ MatchCase("{0: [1, 2, {}]}", "y = 0"), MatchCase( - "{0: [1, 2, {}] | False} | {1: [()]} | {0: [1, 2, {}]} | [] | 'X' | {}", + "{0: [1, 2, {}] or False} or {1: [()]} or {0: [1, 2, {}]} or [] or 'X' or {}", "y = 1", ), MatchCase("()", "y = 2"), @@ -530,7 +533,7 @@ def test_mapping_13(self) -> None: match_cases = [ MatchCase("{0: [1, 2, {}]}", "y = 0"), MatchCase( - "{0: [1, 2, {}] | True} | {1: [()]} | {0: [1, 2, {}]} | [] | 'X' | {}", + "{0: [1, 2, {}] or True} or {1: [()]} or {0: [1, 2, {}]} or [] or 'X' or {}", "y = 1", ), MatchCase("()", "y = 2"), @@ -540,10 +543,70 @@ def test_mapping_13(self) -> None: self.assertEqual(namespace.get("y"), 1) +class TestMatch(unittest.TestCase): + + def test_grammar_00(self) -> None: + match 0: + case 0: + x = True + self.assertEqual(x, True) + + def test_grammar_01(self) -> None: + match 0: + case 0 if False: + x = False + case 0 if True: + x = True + self.assertEqual(x, True) + + def test_grammar_02(self) -> None: + match 0: + case 0: + x = True + case 0: + x = False + self.assertEqual(x, True) + + def test_grammar_03(self) -> None: + x = False + match 0: + case 0 | 1 | 2 | 3: + x = True + self.assertEqual(x, True) + + def test_grammar_04(self) -> None: + x = False + match 1: + case 0 | 1 | 2 | 3: + x = True + self.assertEqual(x, True) + + def test_grammar_05(self) -> None: + x = False + match 2: + case 0 | 1 | 2 | 3: + x = True + self.assertEqual(x, True) + + def test_grammar_06(self) -> None: + x = False + match 3: + case 0 | 1 | 2 | 3: + x = True + self.assertEqual(x, True) + + def test_grammar_07(self) -> None: + x = False + match 4: + case 0 | 1 | 2 | 3: + x = True + self.assertEqual(x, False) + + if __name__ == "__main__": # XXX: For quick test debugging... import dis match_cases = [ - MatchCase("([0, 1]) | {'XXX': (1 | (z := 2))} | (0, q, [[[{}]]])", "pass") + MatchCase("([0, 1]) or {'XXX': (1 or (z := 2))} or (0, q, [[[{}]]])", "pass") ] dis.dis(TestAST.compile_match("", "x", match_cases, "")) diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index f4d59b89f04281..5cdfc10302903d 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -116,311 +116,304 @@ static KeywordToken *reserved_keywords[] = { #define match_stmt_type 1038 #define case_block_type 1039 #define pattern_type 1040 -#define or_pattern_type 1041 -#define closed_pattern_type 1042 -#define name_pattern_type 1043 -#define literal_pattern_type 1044 -#define constant_pattern_type 1045 -#define group_pattern_type 1046 -#define sequence_pattern_type 1047 -#define mapping_pattern_type 1048 -#define key_pattern_type 1049 +#define guard_type 1041 +#define or_pattern_type 1042 +#define closed_pattern_type 1043 +#define name_pattern_type 1044 +#define literal_pattern_type 1045 +#define constant_pattern_type 1046 +#define group_pattern_type 1047 +#define sequence_pattern_type 1048 +#define mapping_pattern_type 1049 #define class_pattern_type 1050 -#define pattern_args_type 1051 -#define return_stmt_type 1052 -#define raise_stmt_type 1053 -#define function_def_type 1054 -#define function_def_raw_type 1055 -#define func_type_comment_type 1056 -#define params_type 1057 -#define parameters_type 1058 -#define slash_no_default_type 1059 -#define slash_with_default_type 1060 -#define star_etc_type 1061 -#define kwds_type 1062 -#define param_no_default_type 1063 -#define param_with_default_type 1064 -#define param_maybe_default_type 1065 -#define param_type 1066 -#define annotation_type 1067 -#define default_type 1068 -#define decorators_type 1069 -#define class_def_type 1070 -#define class_def_raw_type 1071 -#define block_type 1072 -#define expressions_list_type 1073 -#define star_expressions_type 1074 -#define star_expression_type 1075 -#define star_named_expressions_type 1076 -#define star_named_expression_type 1077 -#define named_expression_type 1078 -#define annotated_rhs_type 1079 -#define expressions_type 1080 -#define expression_type 1081 -#define lambdef_type 1082 -#define lambda_parameters_type 1083 -#define lambda_slash_no_default_type 1084 -#define lambda_slash_with_default_type 1085 -#define lambda_star_etc_type 1086 -#define lambda_kwds_type 1087 -#define lambda_param_no_default_type 1088 -#define lambda_param_with_default_type 1089 -#define lambda_param_maybe_default_type 1090 -#define lambda_param_type 1091 -#define disjunction_type 1092 -#define conjunction_type 1093 -#define inversion_type 1094 -#define comparison_type 1095 -#define compare_op_bitwise_or_pair_type 1096 -#define eq_bitwise_or_type 1097 -#define noteq_bitwise_or_type 1098 -#define lte_bitwise_or_type 1099 -#define lt_bitwise_or_type 1100 -#define gte_bitwise_or_type 1101 -#define gt_bitwise_or_type 1102 -#define notin_bitwise_or_type 1103 -#define in_bitwise_or_type 1104 -#define isnot_bitwise_or_type 1105 -#define is_bitwise_or_type 1106 -#define bitwise_or_type 1107 // Left-recursive -#define bitwise_xor_type 1108 // Left-recursive -#define bitwise_and_type 1109 // Left-recursive -#define shift_expr_type 1110 // Left-recursive -#define sum_type 1111 // Left-recursive -#define term_type 1112 // Left-recursive -#define factor_type 1113 -#define power_type 1114 -#define await_primary_type 1115 -#define primary_type 1116 // Left-recursive -#define slices_type 1117 -#define slice_type 1118 -#define atom_type 1119 -#define strings_type 1120 -#define list_type 1121 -#define listcomp_type 1122 -#define tuple_type 1123 -#define group_type 1124 -#define genexp_type 1125 -#define set_type 1126 -#define setcomp_type 1127 -#define dict_type 1128 -#define dictcomp_type 1129 -#define double_starred_kvpairs_type 1130 -#define double_starred_kvpair_type 1131 -#define kvpair_type 1132 -#define for_if_clauses_type 1133 -#define for_if_clause_type 1134 -#define yield_expr_type 1135 -#define arguments_type 1136 -#define args_type 1137 -#define kwargs_type 1138 -#define starred_expression_type 1139 -#define kwarg_or_starred_type 1140 -#define kwarg_or_double_starred_type 1141 -#define star_targets_type 1142 -#define star_targets_seq_type 1143 -#define star_target_type 1144 -#define star_atom_type 1145 -#define single_target_type 1146 -#define single_subscript_attribute_target_type 1147 -#define del_targets_type 1148 -#define del_target_type 1149 -#define del_t_atom_type 1150 -#define del_target_end_type 1151 -#define targets_type 1152 -#define target_type 1153 -#define t_primary_type 1154 // Left-recursive -#define t_lookahead_type 1155 -#define t_atom_type 1156 -#define incorrect_arguments_type 1157 -#define invalid_kwarg_type 1158 -#define invalid_named_expression_type 1159 -#define invalid_assignment_type 1160 -#define invalid_block_type 1161 -#define invalid_comprehension_type 1162 -#define invalid_dict_comprehension_type 1163 -#define invalid_parameters_type 1164 -#define invalid_star_etc_type 1165 -#define invalid_lambda_star_etc_type 1166 -#define invalid_double_type_comments_type 1167 -#define invalid_del_target_type 1168 -#define invalid_import_from_targets_type 1169 -#define _loop0_1_type 1170 -#define _loop0_2_type 1171 -#define _loop0_4_type 1172 -#define _gather_3_type 1173 -#define _loop0_6_type 1174 -#define _gather_5_type 1175 -#define _loop0_8_type 1176 -#define _gather_7_type 1177 -#define _loop0_10_type 1178 -#define _gather_9_type 1179 -#define _loop1_11_type 1180 -#define _loop0_13_type 1181 -#define _gather_12_type 1182 -#define _tmp_14_type 1183 -#define _tmp_15_type 1184 -#define _tmp_16_type 1185 -#define _tmp_17_type 1186 -#define _tmp_18_type 1187 -#define _tmp_19_type 1188 -#define _tmp_20_type 1189 -#define _tmp_21_type 1190 -#define _loop1_22_type 1191 -#define _tmp_23_type 1192 -#define _tmp_24_type 1193 -#define _loop0_26_type 1194 -#define _gather_25_type 1195 -#define _loop0_28_type 1196 -#define _gather_27_type 1197 -#define _tmp_29_type 1198 -#define _loop0_30_type 1199 -#define _loop1_31_type 1200 -#define _loop0_33_type 1201 -#define _gather_32_type 1202 -#define _tmp_34_type 1203 -#define _loop0_36_type 1204 -#define _gather_35_type 1205 -#define _tmp_37_type 1206 -#define _loop0_39_type 1207 -#define _gather_38_type 1208 -#define _loop0_41_type 1209 -#define _gather_40_type 1210 -#define _loop0_43_type 1211 -#define _gather_42_type 1212 -#define _loop0_45_type 1213 -#define _gather_44_type 1214 -#define _tmp_46_type 1215 -#define _loop1_47_type 1216 -#define _tmp_48_type 1217 -#define _loop1_49_type 1218 -#define _tmp_50_type 1219 -#define _loop0_52_type 1220 -#define _gather_51_type 1221 -#define _tmp_53_type 1222 -#define _loop0_55_type 1223 -#define _gather_54_type 1224 -#define _loop0_57_type 1225 -#define _gather_56_type 1226 -#define _loop0_59_type 1227 -#define _gather_58_type 1228 -#define _loop0_61_type 1229 -#define _gather_60_type 1230 -#define _loop0_63_type 1231 -#define _gather_62_type 1232 -#define _loop0_65_type 1233 -#define _gather_64_type 1234 -#define _loop0_67_type 1235 -#define _gather_66_type 1236 -#define _loop0_69_type 1237 -#define _gather_68_type 1238 -#define _loop0_71_type 1239 -#define _gather_70_type 1240 -#define _loop0_73_type 1241 -#define _gather_72_type 1242 -#define _tmp_74_type 1243 -#define _tmp_75_type 1244 -#define _tmp_76_type 1245 -#define _tmp_77_type 1246 -#define _loop0_78_type 1247 -#define _loop0_79_type 1248 -#define _loop0_80_type 1249 -#define _loop1_81_type 1250 -#define _loop0_82_type 1251 -#define _loop1_83_type 1252 -#define _loop1_84_type 1253 -#define _loop1_85_type 1254 -#define _loop0_86_type 1255 -#define _loop1_87_type 1256 -#define _loop0_88_type 1257 -#define _loop1_89_type 1258 -#define _loop0_90_type 1259 -#define _loop1_91_type 1260 -#define _loop1_92_type 1261 -#define _tmp_93_type 1262 -#define _loop0_95_type 1263 -#define _gather_94_type 1264 -#define _loop1_96_type 1265 -#define _loop0_98_type 1266 -#define _gather_97_type 1267 -#define _loop1_99_type 1268 -#define _loop0_100_type 1269 -#define _loop0_101_type 1270 -#define _loop0_102_type 1271 -#define _loop1_103_type 1272 -#define _loop0_104_type 1273 -#define _loop1_105_type 1274 -#define _loop1_106_type 1275 -#define _loop1_107_type 1276 -#define _loop0_108_type 1277 -#define _loop1_109_type 1278 -#define _loop0_110_type 1279 -#define _loop1_111_type 1280 -#define _loop0_112_type 1281 -#define _loop1_113_type 1282 -#define _loop1_114_type 1283 -#define _loop1_115_type 1284 -#define _loop1_116_type 1285 -#define _tmp_117_type 1286 -#define _loop0_119_type 1287 -#define _gather_118_type 1288 -#define _tmp_120_type 1289 -#define _tmp_121_type 1290 -#define _tmp_122_type 1291 -#define _tmp_123_type 1292 -#define _loop1_124_type 1293 -#define _tmp_125_type 1294 -#define _tmp_126_type 1295 -#define _loop0_128_type 1296 -#define _gather_127_type 1297 -#define _loop1_129_type 1298 -#define _loop0_130_type 1299 -#define _loop0_131_type 1300 -#define _tmp_132_type 1301 -#define _tmp_133_type 1302 -#define _loop0_135_type 1303 -#define _gather_134_type 1304 -#define _loop0_137_type 1305 -#define _gather_136_type 1306 -#define _loop0_139_type 1307 -#define _gather_138_type 1308 -#define _loop0_141_type 1309 -#define _gather_140_type 1310 -#define _loop0_142_type 1311 -#define _loop0_144_type 1312 -#define _gather_143_type 1313 -#define _tmp_145_type 1314 -#define _loop0_147_type 1315 -#define _gather_146_type 1316 -#define _loop0_149_type 1317 -#define _gather_148_type 1318 -#define _tmp_150_type 1319 -#define _loop0_151_type 1320 -#define _tmp_152_type 1321 -#define _tmp_153_type 1322 -#define _tmp_154_type 1323 -#define _tmp_155_type 1324 -#define _loop0_156_type 1325 -#define _tmp_157_type 1326 -#define _tmp_158_type 1327 -#define _tmp_159_type 1328 -#define _tmp_160_type 1329 -#define _tmp_161_type 1330 -#define _tmp_162_type 1331 -#define _tmp_163_type 1332 -#define _tmp_164_type 1333 -#define _tmp_165_type 1334 -#define _tmp_166_type 1335 -#define _tmp_167_type 1336 -#define _tmp_168_type 1337 -#define _tmp_169_type 1338 -#define _tmp_170_type 1339 -#define _tmp_171_type 1340 -#define _tmp_172_type 1341 -#define _tmp_173_type 1342 -#define _loop1_174_type 1343 -#define _tmp_175_type 1344 -#define _tmp_176_type 1345 +#define name_or_attr_type 1051 // Left-recursive +#define values_pattern_type 1052 +#define items_pattern_type 1053 +#define keyword_pattern_type 1054 +#define value_pattern_type 1055 +#define key_value_pattern_type 1056 +#define return_stmt_type 1057 +#define raise_stmt_type 1058 +#define function_def_type 1059 +#define function_def_raw_type 1060 +#define func_type_comment_type 1061 +#define params_type 1062 +#define parameters_type 1063 +#define slash_no_default_type 1064 +#define slash_with_default_type 1065 +#define star_etc_type 1066 +#define kwds_type 1067 +#define param_no_default_type 1068 +#define param_with_default_type 1069 +#define param_maybe_default_type 1070 +#define param_type 1071 +#define annotation_type 1072 +#define default_type 1073 +#define decorators_type 1074 +#define class_def_type 1075 +#define class_def_raw_type 1076 +#define block_type 1077 +#define expressions_list_type 1078 +#define star_expressions_type 1079 +#define star_expression_type 1080 +#define star_named_expressions_type 1081 +#define star_named_expression_type 1082 +#define named_expression_type 1083 +#define annotated_rhs_type 1084 +#define expressions_type 1085 +#define expression_type 1086 +#define lambdef_type 1087 +#define lambda_parameters_type 1088 +#define lambda_slash_no_default_type 1089 +#define lambda_slash_with_default_type 1090 +#define lambda_star_etc_type 1091 +#define lambda_kwds_type 1092 +#define lambda_param_no_default_type 1093 +#define lambda_param_with_default_type 1094 +#define lambda_param_maybe_default_type 1095 +#define lambda_param_type 1096 +#define disjunction_type 1097 +#define conjunction_type 1098 +#define inversion_type 1099 +#define comparison_type 1100 +#define compare_op_bitwise_or_pair_type 1101 +#define eq_bitwise_or_type 1102 +#define noteq_bitwise_or_type 1103 +#define lte_bitwise_or_type 1104 +#define lt_bitwise_or_type 1105 +#define gte_bitwise_or_type 1106 +#define gt_bitwise_or_type 1107 +#define notin_bitwise_or_type 1108 +#define in_bitwise_or_type 1109 +#define isnot_bitwise_or_type 1110 +#define is_bitwise_or_type 1111 +#define bitwise_or_type 1112 // Left-recursive +#define bitwise_xor_type 1113 // Left-recursive +#define bitwise_and_type 1114 // Left-recursive +#define shift_expr_type 1115 // Left-recursive +#define sum_type 1116 // Left-recursive +#define term_type 1117 // Left-recursive +#define factor_type 1118 +#define power_type 1119 +#define await_primary_type 1120 +#define primary_type 1121 // Left-recursive +#define slices_type 1122 +#define slice_type 1123 +#define atom_type 1124 +#define strings_type 1125 +#define list_type 1126 +#define listcomp_type 1127 +#define tuple_type 1128 +#define group_type 1129 +#define genexp_type 1130 +#define set_type 1131 +#define setcomp_type 1132 +#define dict_type 1133 +#define dictcomp_type 1134 +#define double_starred_kvpairs_type 1135 +#define double_starred_kvpair_type 1136 +#define kvpair_type 1137 +#define for_if_clauses_type 1138 +#define for_if_clause_type 1139 +#define yield_expr_type 1140 +#define arguments_type 1141 +#define args_type 1142 +#define kwargs_type 1143 +#define starred_expression_type 1144 +#define kwarg_or_starred_type 1145 +#define kwarg_or_double_starred_type 1146 +#define star_targets_type 1147 +#define star_targets_seq_type 1148 +#define star_target_type 1149 +#define star_atom_type 1150 +#define single_target_type 1151 +#define single_subscript_attribute_target_type 1152 +#define del_targets_type 1153 +#define del_target_type 1154 +#define del_t_atom_type 1155 +#define del_target_end_type 1156 +#define targets_type 1157 +#define target_type 1158 +#define t_primary_type 1159 // Left-recursive +#define t_lookahead_type 1160 +#define t_atom_type 1161 +#define incorrect_arguments_type 1162 +#define invalid_kwarg_type 1163 +#define invalid_named_expression_type 1164 +#define invalid_assignment_type 1165 +#define invalid_block_type 1166 +#define invalid_comprehension_type 1167 +#define invalid_dict_comprehension_type 1168 +#define invalid_parameters_type 1169 +#define invalid_star_etc_type 1170 +#define invalid_lambda_star_etc_type 1171 +#define invalid_double_type_comments_type 1172 +#define invalid_del_target_type 1173 +#define invalid_import_from_targets_type 1174 +#define _loop0_1_type 1175 +#define _loop0_2_type 1176 +#define _loop0_4_type 1177 +#define _gather_3_type 1178 +#define _loop0_6_type 1179 +#define _gather_5_type 1180 +#define _loop0_8_type 1181 +#define _gather_7_type 1182 +#define _loop0_10_type 1183 +#define _gather_9_type 1184 +#define _loop1_11_type 1185 +#define _loop0_13_type 1186 +#define _gather_12_type 1187 +#define _tmp_14_type 1188 +#define _tmp_15_type 1189 +#define _tmp_16_type 1190 +#define _tmp_17_type 1191 +#define _tmp_18_type 1192 +#define _tmp_19_type 1193 +#define _tmp_20_type 1194 +#define _tmp_21_type 1195 +#define _loop1_22_type 1196 +#define _tmp_23_type 1197 +#define _tmp_24_type 1198 +#define _loop0_26_type 1199 +#define _gather_25_type 1200 +#define _loop0_28_type 1201 +#define _gather_27_type 1202 +#define _tmp_29_type 1203 +#define _loop0_30_type 1204 +#define _loop1_31_type 1205 +#define _loop0_33_type 1206 +#define _gather_32_type 1207 +#define _tmp_34_type 1208 +#define _loop0_36_type 1209 +#define _gather_35_type 1210 +#define _tmp_37_type 1211 +#define _loop0_39_type 1212 +#define _gather_38_type 1213 +#define _loop0_41_type 1214 +#define _gather_40_type 1215 +#define _loop0_43_type 1216 +#define _gather_42_type 1217 +#define _loop0_45_type 1218 +#define _gather_44_type 1219 +#define _tmp_46_type 1220 +#define _loop1_47_type 1221 +#define _tmp_48_type 1222 +#define _loop1_49_type 1223 +#define _loop0_51_type 1224 +#define _gather_50_type 1225 +#define _tmp_52_type 1226 +#define _loop0_54_type 1227 +#define _gather_53_type 1228 +#define _loop0_56_type 1229 +#define _gather_55_type 1230 +#define _loop0_58_type 1231 +#define _gather_57_type 1232 +#define _loop0_60_type 1233 +#define _gather_59_type 1234 +#define _loop0_62_type 1235 +#define _gather_61_type 1236 +#define _loop0_64_type 1237 +#define _gather_63_type 1238 +#define _tmp_65_type 1239 +#define _tmp_66_type 1240 +#define _tmp_67_type 1241 +#define _tmp_68_type 1242 +#define _loop0_69_type 1243 +#define _loop0_70_type 1244 +#define _loop0_71_type 1245 +#define _loop1_72_type 1246 +#define _loop0_73_type 1247 +#define _loop1_74_type 1248 +#define _loop1_75_type 1249 +#define _loop1_76_type 1250 +#define _loop0_77_type 1251 +#define _loop1_78_type 1252 +#define _loop0_79_type 1253 +#define _loop1_80_type 1254 +#define _loop0_81_type 1255 +#define _loop1_82_type 1256 +#define _loop1_83_type 1257 +#define _tmp_84_type 1258 +#define _loop0_86_type 1259 +#define _gather_85_type 1260 +#define _loop1_87_type 1261 +#define _loop0_89_type 1262 +#define _gather_88_type 1263 +#define _loop1_90_type 1264 +#define _loop0_91_type 1265 +#define _loop0_92_type 1266 +#define _loop0_93_type 1267 +#define _loop1_94_type 1268 +#define _loop0_95_type 1269 +#define _loop1_96_type 1270 +#define _loop1_97_type 1271 +#define _loop1_98_type 1272 +#define _loop0_99_type 1273 +#define _loop1_100_type 1274 +#define _loop0_101_type 1275 +#define _loop1_102_type 1276 +#define _loop0_103_type 1277 +#define _loop1_104_type 1278 +#define _loop1_105_type 1279 +#define _loop1_106_type 1280 +#define _loop1_107_type 1281 +#define _tmp_108_type 1282 +#define _loop0_110_type 1283 +#define _gather_109_type 1284 +#define _tmp_111_type 1285 +#define _tmp_112_type 1286 +#define _tmp_113_type 1287 +#define _tmp_114_type 1288 +#define _loop1_115_type 1289 +#define _tmp_116_type 1290 +#define _tmp_117_type 1291 +#define _loop0_119_type 1292 +#define _gather_118_type 1293 +#define _loop1_120_type 1294 +#define _loop0_121_type 1295 +#define _loop0_122_type 1296 +#define _tmp_123_type 1297 +#define _tmp_124_type 1298 +#define _loop0_126_type 1299 +#define _gather_125_type 1300 +#define _loop0_128_type 1301 +#define _gather_127_type 1302 +#define _loop0_130_type 1303 +#define _gather_129_type 1304 +#define _loop0_132_type 1305 +#define _gather_131_type 1306 +#define _loop0_133_type 1307 +#define _loop0_135_type 1308 +#define _gather_134_type 1309 +#define _tmp_136_type 1310 +#define _loop0_138_type 1311 +#define _gather_137_type 1312 +#define _loop0_140_type 1313 +#define _gather_139_type 1314 +#define _tmp_141_type 1315 +#define _loop0_142_type 1316 +#define _tmp_143_type 1317 +#define _tmp_144_type 1318 +#define _tmp_145_type 1319 +#define _tmp_146_type 1320 +#define _loop0_147_type 1321 +#define _tmp_148_type 1322 +#define _tmp_149_type 1323 +#define _tmp_150_type 1324 +#define _tmp_151_type 1325 +#define _tmp_152_type 1326 +#define _tmp_153_type 1327 +#define _tmp_154_type 1328 +#define _tmp_155_type 1329 +#define _tmp_156_type 1330 +#define _tmp_157_type 1331 +#define _tmp_158_type 1332 +#define _tmp_159_type 1333 +#define _tmp_160_type 1334 +#define _tmp_161_type 1335 +#define _loop1_162_type 1336 +#define _tmp_163_type 1337 +#define _tmp_164_type 1338 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -463,6 +456,7 @@ static asdl_seq* finally_block_rule(Parser *p); static stmt_ty match_stmt_rule(Parser *p); static void *case_block_rule(Parser *p); static void *pattern_rule(Parser *p); +static void *guard_rule(Parser *p); static void *or_pattern_rule(Parser *p); static void *closed_pattern_rule(Parser *p); static void *name_pattern_rule(Parser *p); @@ -471,9 +465,13 @@ static void *constant_pattern_rule(Parser *p); static void *group_pattern_rule(Parser *p); static void *sequence_pattern_rule(Parser *p); static void *mapping_pattern_rule(Parser *p); -static void *key_pattern_rule(Parser *p); static void *class_pattern_rule(Parser *p); -static void *pattern_args_rule(Parser *p); +static void *name_or_attr_rule(Parser *p); +static void *values_pattern_rule(Parser *p); +static void *items_pattern_rule(Parser *p); +static void *keyword_pattern_rule(Parser *p); +static void *value_pattern_rule(Parser *p); +static void *key_value_pattern_rule(Parser *p); static stmt_ty return_stmt_rule(Parser *p); static stmt_ty raise_stmt_rule(Parser *p); static stmt_ty function_def_rule(Parser *p); @@ -641,133 +639,121 @@ static void *_tmp_46_rule(Parser *p); static asdl_seq *_loop1_47_rule(Parser *p); static void *_tmp_48_rule(Parser *p); static asdl_seq *_loop1_49_rule(Parser *p); -static void *_tmp_50_rule(Parser *p); -static asdl_seq *_loop0_52_rule(Parser *p); -static asdl_seq *_gather_51_rule(Parser *p); -static void *_tmp_53_rule(Parser *p); -static asdl_seq *_loop0_55_rule(Parser *p); -static asdl_seq *_gather_54_rule(Parser *p); -static asdl_seq *_loop0_57_rule(Parser *p); -static asdl_seq *_gather_56_rule(Parser *p); -static asdl_seq *_loop0_59_rule(Parser *p); -static asdl_seq *_gather_58_rule(Parser *p); -static asdl_seq *_loop0_61_rule(Parser *p); -static asdl_seq *_gather_60_rule(Parser *p); -static asdl_seq *_loop0_63_rule(Parser *p); -static asdl_seq *_gather_62_rule(Parser *p); -static asdl_seq *_loop0_65_rule(Parser *p); -static asdl_seq *_gather_64_rule(Parser *p); -static asdl_seq *_loop0_67_rule(Parser *p); -static asdl_seq *_gather_66_rule(Parser *p); +static asdl_seq *_loop0_51_rule(Parser *p); +static asdl_seq *_gather_50_rule(Parser *p); +static void *_tmp_52_rule(Parser *p); +static asdl_seq *_loop0_54_rule(Parser *p); +static asdl_seq *_gather_53_rule(Parser *p); +static asdl_seq *_loop0_56_rule(Parser *p); +static asdl_seq *_gather_55_rule(Parser *p); +static asdl_seq *_loop0_58_rule(Parser *p); +static asdl_seq *_gather_57_rule(Parser *p); +static asdl_seq *_loop0_60_rule(Parser *p); +static asdl_seq *_gather_59_rule(Parser *p); +static asdl_seq *_loop0_62_rule(Parser *p); +static asdl_seq *_gather_61_rule(Parser *p); +static asdl_seq *_loop0_64_rule(Parser *p); +static asdl_seq *_gather_63_rule(Parser *p); +static void *_tmp_65_rule(Parser *p); +static void *_tmp_66_rule(Parser *p); +static void *_tmp_67_rule(Parser *p); +static void *_tmp_68_rule(Parser *p); static asdl_seq *_loop0_69_rule(Parser *p); -static asdl_seq *_gather_68_rule(Parser *p); +static asdl_seq *_loop0_70_rule(Parser *p); static asdl_seq *_loop0_71_rule(Parser *p); -static asdl_seq *_gather_70_rule(Parser *p); +static asdl_seq *_loop1_72_rule(Parser *p); static asdl_seq *_loop0_73_rule(Parser *p); -static asdl_seq *_gather_72_rule(Parser *p); -static void *_tmp_74_rule(Parser *p); -static void *_tmp_75_rule(Parser *p); -static void *_tmp_76_rule(Parser *p); -static void *_tmp_77_rule(Parser *p); -static asdl_seq *_loop0_78_rule(Parser *p); +static asdl_seq *_loop1_74_rule(Parser *p); +static asdl_seq *_loop1_75_rule(Parser *p); +static asdl_seq *_loop1_76_rule(Parser *p); +static asdl_seq *_loop0_77_rule(Parser *p); +static asdl_seq *_loop1_78_rule(Parser *p); static asdl_seq *_loop0_79_rule(Parser *p); -static asdl_seq *_loop0_80_rule(Parser *p); -static asdl_seq *_loop1_81_rule(Parser *p); -static asdl_seq *_loop0_82_rule(Parser *p); +static asdl_seq *_loop1_80_rule(Parser *p); +static asdl_seq *_loop0_81_rule(Parser *p); +static asdl_seq *_loop1_82_rule(Parser *p); static asdl_seq *_loop1_83_rule(Parser *p); -static asdl_seq *_loop1_84_rule(Parser *p); -static asdl_seq *_loop1_85_rule(Parser *p); +static void *_tmp_84_rule(Parser *p); static asdl_seq *_loop0_86_rule(Parser *p); +static asdl_seq *_gather_85_rule(Parser *p); static asdl_seq *_loop1_87_rule(Parser *p); -static asdl_seq *_loop0_88_rule(Parser *p); -static asdl_seq *_loop1_89_rule(Parser *p); -static asdl_seq *_loop0_90_rule(Parser *p); -static asdl_seq *_loop1_91_rule(Parser *p); -static asdl_seq *_loop1_92_rule(Parser *p); -static void *_tmp_93_rule(Parser *p); +static asdl_seq *_loop0_89_rule(Parser *p); +static asdl_seq *_gather_88_rule(Parser *p); +static asdl_seq *_loop1_90_rule(Parser *p); +static asdl_seq *_loop0_91_rule(Parser *p); +static asdl_seq *_loop0_92_rule(Parser *p); +static asdl_seq *_loop0_93_rule(Parser *p); +static asdl_seq *_loop1_94_rule(Parser *p); static asdl_seq *_loop0_95_rule(Parser *p); -static asdl_seq *_gather_94_rule(Parser *p); static asdl_seq *_loop1_96_rule(Parser *p); -static asdl_seq *_loop0_98_rule(Parser *p); -static asdl_seq *_gather_97_rule(Parser *p); -static asdl_seq *_loop1_99_rule(Parser *p); -static asdl_seq *_loop0_100_rule(Parser *p); +static asdl_seq *_loop1_97_rule(Parser *p); +static asdl_seq *_loop1_98_rule(Parser *p); +static asdl_seq *_loop0_99_rule(Parser *p); +static asdl_seq *_loop1_100_rule(Parser *p); static asdl_seq *_loop0_101_rule(Parser *p); -static asdl_seq *_loop0_102_rule(Parser *p); -static asdl_seq *_loop1_103_rule(Parser *p); -static asdl_seq *_loop0_104_rule(Parser *p); +static asdl_seq *_loop1_102_rule(Parser *p); +static asdl_seq *_loop0_103_rule(Parser *p); +static asdl_seq *_loop1_104_rule(Parser *p); static asdl_seq *_loop1_105_rule(Parser *p); static asdl_seq *_loop1_106_rule(Parser *p); static asdl_seq *_loop1_107_rule(Parser *p); -static asdl_seq *_loop0_108_rule(Parser *p); -static asdl_seq *_loop1_109_rule(Parser *p); +static void *_tmp_108_rule(Parser *p); static asdl_seq *_loop0_110_rule(Parser *p); -static asdl_seq *_loop1_111_rule(Parser *p); -static asdl_seq *_loop0_112_rule(Parser *p); -static asdl_seq *_loop1_113_rule(Parser *p); -static asdl_seq *_loop1_114_rule(Parser *p); +static asdl_seq *_gather_109_rule(Parser *p); +static void *_tmp_111_rule(Parser *p); +static void *_tmp_112_rule(Parser *p); +static void *_tmp_113_rule(Parser *p); +static void *_tmp_114_rule(Parser *p); static asdl_seq *_loop1_115_rule(Parser *p); -static asdl_seq *_loop1_116_rule(Parser *p); +static void *_tmp_116_rule(Parser *p); static void *_tmp_117_rule(Parser *p); static asdl_seq *_loop0_119_rule(Parser *p); static asdl_seq *_gather_118_rule(Parser *p); -static void *_tmp_120_rule(Parser *p); -static void *_tmp_121_rule(Parser *p); -static void *_tmp_122_rule(Parser *p); +static asdl_seq *_loop1_120_rule(Parser *p); +static asdl_seq *_loop0_121_rule(Parser *p); +static asdl_seq *_loop0_122_rule(Parser *p); static void *_tmp_123_rule(Parser *p); -static asdl_seq *_loop1_124_rule(Parser *p); -static void *_tmp_125_rule(Parser *p); -static void *_tmp_126_rule(Parser *p); +static void *_tmp_124_rule(Parser *p); +static asdl_seq *_loop0_126_rule(Parser *p); +static asdl_seq *_gather_125_rule(Parser *p); static asdl_seq *_loop0_128_rule(Parser *p); static asdl_seq *_gather_127_rule(Parser *p); -static asdl_seq *_loop1_129_rule(Parser *p); static asdl_seq *_loop0_130_rule(Parser *p); -static asdl_seq *_loop0_131_rule(Parser *p); -static void *_tmp_132_rule(Parser *p); -static void *_tmp_133_rule(Parser *p); +static asdl_seq *_gather_129_rule(Parser *p); +static asdl_seq *_loop0_132_rule(Parser *p); +static asdl_seq *_gather_131_rule(Parser *p); +static asdl_seq *_loop0_133_rule(Parser *p); static asdl_seq *_loop0_135_rule(Parser *p); static asdl_seq *_gather_134_rule(Parser *p); -static asdl_seq *_loop0_137_rule(Parser *p); -static asdl_seq *_gather_136_rule(Parser *p); -static asdl_seq *_loop0_139_rule(Parser *p); -static asdl_seq *_gather_138_rule(Parser *p); -static asdl_seq *_loop0_141_rule(Parser *p); -static asdl_seq *_gather_140_rule(Parser *p); +static void *_tmp_136_rule(Parser *p); +static asdl_seq *_loop0_138_rule(Parser *p); +static asdl_seq *_gather_137_rule(Parser *p); +static asdl_seq *_loop0_140_rule(Parser *p); +static asdl_seq *_gather_139_rule(Parser *p); +static void *_tmp_141_rule(Parser *p); static asdl_seq *_loop0_142_rule(Parser *p); -static asdl_seq *_loop0_144_rule(Parser *p); -static asdl_seq *_gather_143_rule(Parser *p); +static void *_tmp_143_rule(Parser *p); +static void *_tmp_144_rule(Parser *p); static void *_tmp_145_rule(Parser *p); +static void *_tmp_146_rule(Parser *p); static asdl_seq *_loop0_147_rule(Parser *p); -static asdl_seq *_gather_146_rule(Parser *p); -static asdl_seq *_loop0_149_rule(Parser *p); -static asdl_seq *_gather_148_rule(Parser *p); +static void *_tmp_148_rule(Parser *p); +static void *_tmp_149_rule(Parser *p); static void *_tmp_150_rule(Parser *p); -static asdl_seq *_loop0_151_rule(Parser *p); +static void *_tmp_151_rule(Parser *p); static void *_tmp_152_rule(Parser *p); static void *_tmp_153_rule(Parser *p); static void *_tmp_154_rule(Parser *p); static void *_tmp_155_rule(Parser *p); -static asdl_seq *_loop0_156_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 void *_tmp_159_rule(Parser *p); static void *_tmp_160_rule(Parser *p); static void *_tmp_161_rule(Parser *p); -static void *_tmp_162_rule(Parser *p); +static asdl_seq *_loop1_162_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 void *_tmp_167_rule(Parser *p); -static void *_tmp_168_rule(Parser *p); -static void *_tmp_169_rule(Parser *p); -static void *_tmp_170_rule(Parser *p); -static void *_tmp_171_rule(Parser *p); -static void *_tmp_172_rule(Parser *p); -static void *_tmp_173_rule(Parser *p); -static asdl_seq *_loop1_174_rule(Parser *p); -static void *_tmp_175_rule(Parser *p); -static void *_tmp_176_rule(Parser *p); // file: statements? $ @@ -4699,7 +4685,7 @@ match_stmt_rule(Parser *p) return _res; } -// case_block: "case" pattern ['if' named_expression] ':' block +// case_block: "case" pattern guard? ':' block static void * case_block_rule(Parser *p) { @@ -4710,12 +4696,12 @@ case_block_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // "case" pattern ['if' named_expression] ':' block + { // "case" pattern guard? ':' block if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> case_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" pattern ['if' named_expression] ':' block")); + D(fprintf(stderr, "%*c> case_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" pattern guard? ':' block")); expr_ty _keyword; Token * _literal; asdl_seq* body; @@ -4726,14 +4712,14 @@ case_block_rule(Parser *p) && (pattern = pattern_rule(p)) // pattern && - (guard = _tmp_50_rule(p), 1) // ['if' named_expression] + (guard = guard_rule(p), 1) // guard? && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && (body = block_rule(p)) // block ) { - D(fprintf(stderr, "%*c+ case_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" pattern ['if' named_expression] ':' block")); + D(fprintf(stderr, "%*c+ case_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" pattern guard? ':' block")); _res = _Py_match_case ( pattern , guard , body , p -> arena ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -4744,7 +4730,7 @@ case_block_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s case_block[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" pattern ['if' named_expression] ':' block")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" pattern guard? ':' block")); } _res = NULL; done: @@ -4779,14 +4765,14 @@ pattern_rule(Parser *p) } D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':=' or_pattern")); Token * _literal; - expr_ty a; - void *b; + expr_ty target; + void *value; if ( - (a = _PyPegen_name_token(p)) // NAME + (target = _PyPegen_name_token(p)) // NAME && (_literal = _PyPegen_expect_token(p, 53)) // token=':=' && - (b = or_pattern_rule(p)) // or_pattern + (value = or_pattern_rule(p)) // or_pattern ) { D(fprintf(stderr, "%*c+ pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ':=' or_pattern")); @@ -4799,7 +4785,7 @@ pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA ); + _res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , target , Store ) ) , value , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -4836,7 +4822,51 @@ pattern_rule(Parser *p) return _res; } -// or_pattern: '|'.closed_pattern+ +// guard: 'if' named_expression +static void * +guard_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'if' named_expression + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> guard[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression")); + Token * _keyword; + expr_ty guard; + if ( + (_keyword = _PyPegen_expect_token(p, 510)) // token='if' + && + (guard = named_expression_rule(p)) // named_expression + ) + { + D(fprintf(stderr, "%*c+ guard[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression")); + _res = guard; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s guard[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// or_pattern: closed_pattern '|' '|'.closed_pattern+ | closed_pattern static void * or_pattern_rule(Parser *p) { @@ -4847,24 +4877,72 @@ or_pattern_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '|'.closed_pattern+ + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // closed_pattern '|' '|'.closed_pattern+ + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> or_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "closed_pattern '|' '|'.closed_pattern+")); + Token * _literal; + void *value; + asdl_seq * values; + if ( + (value = closed_pattern_rule(p)) // closed_pattern + && + (_literal = _PyPegen_expect_token(p, 18)) // token='|' + && + (values = _gather_50_rule(p)) // '|'.closed_pattern+ + ) + { + D(fprintf(stderr, "%*c+ or_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "closed_pattern '|' '|'.closed_pattern+")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , value , values ) ) , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s or_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "closed_pattern '|' '|'.closed_pattern+")); + } + { // closed_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> or_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|'.closed_pattern+")); - asdl_seq * _gather_51_var; + D(fprintf(stderr, "%*c> or_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "closed_pattern")); + void *closed_pattern_var; if ( - (_gather_51_var = _gather_51_rule(p)) // '|'.closed_pattern+ + (closed_pattern_var = closed_pattern_rule(p)) // closed_pattern ) { - D(fprintf(stderr, "%*c+ or_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'|'.closed_pattern+")); - _res = _gather_51_var; + D(fprintf(stderr, "%*c+ or_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "closed_pattern")); + _res = closed_pattern_var; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s or_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|'.closed_pattern+")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "closed_pattern")); } _res = NULL; done: @@ -5050,11 +5128,11 @@ name_pattern_rule(Parser *p) if ( (a = _PyPegen_name_token(p)) // NAME && - _PyPegen_lookahead(0, _tmp_53_rule, p) + _PyPegen_lookahead(0, _tmp_52_rule, p) ) { D(fprintf(stderr, "%*c+ name_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME !('.' | '(')")); - _res = a; + _res = _PyPegen_set_expr_context ( p , a , Store ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5083,6 +5161,15 @@ literal_pattern_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro { // NUMBER if (p->error_indicator) { D(p->level--); @@ -5133,7 +5220,21 @@ literal_pattern_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); - _res = _keyword; + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Constant ( Py_None , NULL , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; @@ -5152,7 +5253,21 @@ literal_pattern_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); - _res = _keyword; + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Constant ( Py_True , NULL , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; @@ -5171,7 +5286,21 @@ literal_pattern_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); - _res = _keyword; + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Constant ( Py_False , NULL , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; @@ -5184,7 +5313,7 @@ literal_pattern_rule(Parser *p) return _res; } -// constant_pattern: '.' NAME | '.'.NAME+ !'(' +// constant_pattern: '.' NAME | name_or_attr '.' NAME !'(' static void * constant_pattern_rule(Parser *p) { @@ -5195,6 +5324,15 @@ constant_pattern_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro { // '.' NAME if (p->error_indicator) { D(p->level--); @@ -5202,36 +5340,56 @@ constant_pattern_rule(Parser *p) } D(fprintf(stderr, "%*c> constant_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.' NAME")); Token * _literal; - expr_ty name_var; + expr_ty name; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' && - (name_var = _PyPegen_name_token(p)) // NAME + (name = _PyPegen_name_token(p)) // NAME ) { D(fprintf(stderr, "%*c+ constant_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.' NAME")); - _res = _PyPegen_dummy_name(p, _literal, name_var); + _res = name; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s constant_pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.' NAME")); } - { // '.'.NAME+ !'(' + { // name_or_attr '.' NAME !'(' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> constant_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'.NAME+ !'('")); - asdl_seq * a; + D(fprintf(stderr, "%*c> constant_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME !'('")); + Token * _literal; + expr_ty attr; + void *value; if ( - (a = _gather_54_rule(p)) // '.'.NAME+ + (value = name_or_attr_rule(p)) // name_or_attr + && + (_literal = _PyPegen_expect_token(p, 23)) // token='.' + && + (attr = _PyPegen_name_token(p)) // NAME && _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 7) // token='(' ) { - D(fprintf(stderr, "%*c+ constant_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'.NAME+ !'('")); - _res = a; + D(fprintf(stderr, "%*c+ constant_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME !'('")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Attribute ( value , attr -> v . Name . id , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5241,7 +5399,7 @@ constant_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s constant_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'.NAME+ !'('")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '.' NAME !'('")); } _res = NULL; done: @@ -5268,17 +5426,17 @@ group_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> group_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' pattern ')'")); Token * _literal; Token * _literal_1; - void *a; + void *pattern; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = pattern_rule(p)) // pattern + (pattern = pattern_rule(p)) // pattern && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { D(fprintf(stderr, "%*c+ group_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' pattern ')'")); - _res = a; + _res = pattern; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5296,7 +5454,7 @@ group_pattern_rule(Parser *p) return _res; } -// sequence_pattern: '[' ','.pattern+? ']' | '(' ','.pattern+? ')' +// sequence_pattern: '[' values_pattern ']' static void * sequence_pattern_rule(Parser *p) { @@ -5316,24 +5474,24 @@ sequence_pattern_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '[' ','.pattern+? ']' + { // '[' values_pattern ']' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' ','.pattern+? ']'")); + D(fprintf(stderr, "%*c> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' values_pattern ']'")); Token * _literal; Token * _literal_1; - void *a; + void *values; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' && - (a = _gather_56_rule(p), 1) // ','.pattern+? + (values = values_pattern_rule(p)) // values_pattern && (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' ) { - D(fprintf(stderr, "%*c+ sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' ','.pattern+? ']'")); + D(fprintf(stderr, "%*c+ sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' values_pattern ']'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5343,7 +5501,7 @@ sequence_pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_List ( a , Load , EXTRA ); + _res = _Py_List ( values , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5353,26 +5511,52 @@ sequence_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' ','.pattern+? ']'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' values_pattern ']'")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// mapping_pattern: '{' items_pattern '}' +static void * +mapping_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; } - { // '(' ','.pattern+? ')' + void * _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // '{' items_pattern '}' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' ','.pattern+? ')'")); + D(fprintf(stderr, "%*c> mapping_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' items_pattern '}'")); Token * _literal; Token * _literal_1; - void *a; + void *items; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' + (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (a = _gather_58_rule(p), 1) // ','.pattern+? + (items = items_pattern_rule(p)) // items_pattern && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' ) { - D(fprintf(stderr, "%*c+ sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' ','.pattern+? ')'")); + D(fprintf(stderr, "%*c+ mapping_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' items_pattern '}'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5382,7 +5566,7 @@ sequence_pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( a , Load , EXTRA ); + _res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , items ) ) , CHECK ( _PyPegen_get_values ( p , items ) ) , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5391,8 +5575,8 @@ sequence_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' ','.pattern+? ')'")); + D(fprintf(stderr, "%*c%s mapping_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' items_pattern '}'")); } _res = NULL; done: @@ -5400,9 +5584,13 @@ sequence_pattern_rule(Parser *p) return _res; } -// mapping_pattern: '{' ','.(key_pattern ':' closed_pattern)+ '}' +// class_pattern: +// | name_or_attr '(' ')' +// | name_or_attr '(' ','.pattern+ ','? ')' +// | name_or_attr '(' ','.keyword_pattern+ ','? ')' +// | name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')' static void * -mapping_pattern_rule(Parser *p) +class_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -5411,25 +5599,43 @@ mapping_pattern_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '{' ','.(key_pattern ':' closed_pattern)+ '}' + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // name_or_attr '(' ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> mapping_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' ','.(key_pattern ':' closed_pattern)+ '}'")); - asdl_seq * _gather_60_var; + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ')'")); Token * _literal; Token * _literal_1; + void *func; if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' + (func = name_or_attr_rule(p)) // name_or_attr && - (_gather_60_var = _gather_60_rule(p)) // ','.(key_pattern ':' closed_pattern)+ + (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ mapping_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' ','.(key_pattern ':' closed_pattern)+ '}'")); - _res = NULL; + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ')'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Call ( func , NULL , NULL , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5438,41 +5644,44 @@ mapping_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s mapping_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' ','.(key_pattern ':' closed_pattern)+ '}'")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// key_pattern: literal_pattern &':' | '|'.literal_pattern+ -static void * -key_pattern_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ')'")); } - void * _res = NULL; - int _mark = p->mark; - { // literal_pattern &':' + { // name_or_attr '(' ','.pattern+ ','? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> key_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern &':'")); - void *a; - if ( - (a = literal_pattern_rule(p)) // literal_pattern - && - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ','? ')'")); + Token * _literal; + Token * _literal_1; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_seq * args; + void *func; + if ( + (func = name_or_attr_rule(p)) // name_or_attr + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (args = _gather_53_rule(p)) // ','.pattern+ + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ key_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern &':'")); - _res = a; + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ','? ')'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Call ( func , args , NULL , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5481,22 +5690,44 @@ key_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s key_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern &':'")); + D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.pattern+ ','? ')'")); } - { // '|'.literal_pattern+ + { // name_or_attr '(' ','.keyword_pattern+ ','? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> key_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|'.literal_pattern+")); - asdl_seq * a; + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.keyword_pattern+ ','? ')'")); + Token * _literal; + Token * _literal_1; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *func; + asdl_seq * keywords; if ( - (a = _gather_62_rule(p)) // '|'.literal_pattern+ + (func = name_or_attr_rule(p)) // name_or_attr + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (keywords = _gather_55_rule(p)) // ','.keyword_pattern+ + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ key_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'|'.literal_pattern+")); - _res = NULL; + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.keyword_pattern+ ','? ')'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Call ( func , NULL , keywords , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5505,53 +5736,60 @@ key_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s key_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|'.literal_pattern+")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// class_pattern: '.'.NAME+ '(' pattern_args ')' -static void * -class_pattern_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.keyword_pattern+ ','? ')'")); } - void * _res = NULL; - int _mark = p->mark; - { // '.'.NAME+ '(' pattern_args ')' + { // name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'.NAME+ '(' pattern_args ')'")); - asdl_seq * _gather_64_var; + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'")); Token * _literal; Token * _literal_1; - void *pattern_args_var; + Token * _literal_2; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_seq * args; + void *func; + asdl_seq * keywords; if ( - (_gather_64_var = _gather_64_rule(p)) // '.'.NAME+ + (func = name_or_attr_rule(p)) // name_or_attr && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (pattern_args_var = pattern_args_rule(p)) // pattern_args + (args = _gather_57_rule(p)) // ','.pattern+ && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + && + (keywords = _gather_59_rule(p)) // ','.keyword_pattern+ + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + && + (_literal_2 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'.NAME+ '(' pattern_args ')'")); - _res = _PyPegen_dummy_name(p, _gather_64_var, _literal, pattern_args_var, _literal_1); + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Call ( func , args , keywords , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'.NAME+ '(' pattern_args ')'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'")); } _res = NULL; done: @@ -5559,12 +5797,39 @@ class_pattern_rule(Parser *p) return _res; } -// pattern_args: -// | ','.pattern+ ',' ','.(NAME '=' or_pattern)+ -// | ','.(NAME '=' or_pattern)+ -// | ','.pattern+ +// Left-recursive +// name_or_attr: name_or_attr '.' NAME | NAME +static void * name_or_attr_raw(Parser *); +static void * +name_or_attr_rule(Parser *p) +{ + D(p->level++); + void * _res = NULL; + if (_PyPegen_is_memoized(p, name_or_attr_type, &_res)) { + D(p->level--); + return _res; + } + int _mark = p->mark; + int _resmark = p->mark; + while (1) { + int tmpvar_1 = _PyPegen_update_memo(p, _mark, name_or_attr_type, _res); + if (tmpvar_1) { + D(p->level--); + return _res; + } + p->mark = _mark; + void *_raw = name_or_attr_raw(p); + if (_raw == NULL || p->mark <= _resmark) + break; + _resmark = p->mark; + _res = _raw; + } + p->mark = _resmark; + D(p->level--); + return _res; +} static void * -pattern_args_rule(Parser *p) +name_or_attr_raw(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -5573,25 +5838,43 @@ pattern_args_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ','.pattern+ ',' ','.(NAME '=' or_pattern)+ + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // name_or_attr '.' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> pattern_args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+ ',' ','.(NAME '=' or_pattern)+")); - asdl_seq * _gather_66_var; - asdl_seq * _gather_68_var; + D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME")); Token * _literal; + expr_ty attr; + void *value; if ( - (_gather_66_var = _gather_66_rule(p)) // ','.pattern+ + (value = name_or_attr_rule(p)) // name_or_attr && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (_literal = _PyPegen_expect_token(p, 23)) // token='.' && - (_gather_68_var = _gather_68_rule(p)) // ','.(NAME '=' or_pattern)+ + (attr = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ pattern_args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.pattern+ ',' ','.(NAME '=' or_pattern)+")); - _res = NULL; + D(fprintf(stderr, "%*c+ name_or_attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Attribute ( value , attr -> v . Name . id , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5600,22 +5883,62 @@ pattern_args_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s pattern_args[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.pattern+ ',' ','.(NAME '=' or_pattern)+")); + D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '.' NAME")); + } + { // NAME + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); + expr_ty name_var; + if ( + (name_var = _PyPegen_name_token(p)) // NAME + ) + { + D(fprintf(stderr, "%*c+ name_or_attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); + _res = name_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// values_pattern: ','.value_pattern+ ','? +static void * +values_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; } - { // ','.(NAME '=' or_pattern)+ + void * _res = NULL; + int _mark = p->mark; + { // ','.value_pattern+ ','? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> pattern_args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.(NAME '=' or_pattern)+")); - asdl_seq * _gather_70_var; + D(fprintf(stderr, "%*c> values_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.value_pattern+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_seq * values; if ( - (_gather_70_var = _gather_70_rule(p)) // ','.(NAME '=' or_pattern)+ + (values = _gather_61_rule(p)) // ','.value_pattern+ + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) { - D(fprintf(stderr, "%*c+ pattern_args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.(NAME '=' or_pattern)+")); - _res = NULL; + D(fprintf(stderr, "%*c+ values_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.value_pattern+ ','?")); + _res = values; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5624,22 +5947,43 @@ pattern_args_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s pattern_args[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.(NAME '=' or_pattern)+")); + D(fprintf(stderr, "%*c%s values_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.value_pattern+ ','?")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// items_pattern: ','.key_value_pattern+ ','? +static void * +items_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; } - { // ','.pattern+ + void * _res = NULL; + int _mark = p->mark; + { // ','.key_value_pattern+ ','? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> pattern_args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+")); - asdl_seq * a; + D(fprintf(stderr, "%*c> items_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.key_value_pattern+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_seq * items; if ( - (a = _gather_72_rule(p)) // ','.pattern+ + (items = _gather_63_rule(p)) // ','.key_value_pattern+ + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) { - D(fprintf(stderr, "%*c+ pattern_args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.pattern+")); - _res = a; + D(fprintf(stderr, "%*c+ items_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.key_value_pattern+ ','?")); + _res = items; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5648,8 +5992,8 @@ pattern_args_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s pattern_args[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.pattern+")); + D(fprintf(stderr, "%*c%s items_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.key_value_pattern+ ','?")); } _res = NULL; done: @@ -5657,16 +6001,16 @@ pattern_args_rule(Parser *p) return _res; } -// return_stmt: 'return' star_expressions? -static stmt_ty -return_stmt_rule(Parser *p) +// keyword_pattern: NAME '=' or_pattern +static void * +keyword_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - stmt_ty _res = NULL; + void * _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -5677,21 +6021,24 @@ return_stmt_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // 'return' star_expressions? + { // NAME '=' or_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> return_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?")); - Token * _keyword; - void *a; + D(fprintf(stderr, "%*c> keyword_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' or_pattern")); + Token * _literal; + expr_ty arg; + void *value; if ( - (_keyword = _PyPegen_expect_token(p, 500)) // token='return' + (arg = _PyPegen_name_token(p)) // NAME && - (a = star_expressions_rule(p), 1) // star_expressions? + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + && + (value = or_pattern_rule(p)) // or_pattern ) { - D(fprintf(stderr, "%*c+ return_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?")); + D(fprintf(stderr, "%*c+ keyword_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' or_pattern")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5701,7 +6048,7 @@ return_stmt_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Return ( a , EXTRA ); + _res = _Py_keyword ( arg -> v . Name . id , value , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5710,8 +6057,8 @@ return_stmt_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s return_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'return' star_expressions?")); + D(fprintf(stderr, "%*c%s keyword_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' or_pattern")); } _res = NULL; done: @@ -5719,16 +6066,16 @@ return_stmt_rule(Parser *p) return _res; } -// raise_stmt: 'raise' expression ['from' expression] | 'raise' -static stmt_ty -raise_stmt_rule(Parser *p) +// value_pattern: '*' name_pattern | pattern +static void * +value_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - stmt_ty _res = NULL; + void * _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -5739,24 +6086,21 @@ raise_stmt_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // 'raise' expression ['from' expression] + { // '*' name_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); - Token * _keyword; - expr_ty a; - void *b; + D(fprintf(stderr, "%*c> value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' name_pattern")); + Token * _literal; + void *value; if ( - (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' - && - (a = expression_rule(p)) // expression + (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (b = _tmp_74_rule(p), 1) // ['from' expression] + (value = name_pattern_rule(p)) // name_pattern ) { - D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); + D(fprintf(stderr, "%*c+ value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' name_pattern")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5766,7 +6110,7 @@ raise_stmt_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Raise ( a , b , EXTRA ); + _res = _Py_Starred ( value , Store , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5775,41 +6119,27 @@ raise_stmt_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise' expression ['from' expression]")); + D(fprintf(stderr, "%*c%s value_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' name_pattern")); } - { // 'raise' + { // pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise'")); - Token * _keyword; + D(fprintf(stderr, "%*c> value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); + void *pattern_var; if ( - (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' + (pattern_var = pattern_rule(p)) // pattern ) { - D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Raise ( NULL , NULL , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); + _res = pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise'")); + D(fprintf(stderr, "%*c%s value_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); } _res = NULL; done: @@ -5817,23 +6147,290 @@ raise_stmt_rule(Parser *p) return _res; } -// function_def: decorators function_def_raw | function_def_raw -static stmt_ty -function_def_rule(Parser *p) +// key_value_pattern: +// | literal_pattern ':' closed_pattern +// | constant_pattern ':' closed_pattern +// | '**' name_pattern +static void * +key_value_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - stmt_ty _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // decorators function_def_raw + { // literal_pattern ':' closed_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> function_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "decorators function_def_raw")); + D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern ':' closed_pattern")); + Token * _literal; + void *key; + void *value; + if ( + (key = literal_pattern_rule(p)) // literal_pattern + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (value = closed_pattern_rule(p)) // closed_pattern + ) + { + D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern ':' closed_pattern")); + _res = _PyPegen_key_value_pair ( p , key , 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 key_value_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern ':' closed_pattern")); + } + { // constant_pattern ':' closed_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern ':' closed_pattern")); + Token * _literal; + void *key; + void *value; + if ( + (key = constant_pattern_rule(p)) // constant_pattern + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (value = closed_pattern_rule(p)) // closed_pattern + ) + { + D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "constant_pattern ':' closed_pattern")); + _res = _PyPegen_key_value_pair ( p , key , 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 key_value_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "constant_pattern ':' closed_pattern")); + } + { // '**' name_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' name_pattern")); + Token * _literal; + void *value; + if ( + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + && + (value = name_pattern_rule(p)) // name_pattern + ) + { + D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' name_pattern")); + _res = _PyPegen_key_value_pair ( p , NULL , 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 key_value_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' name_pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// return_stmt: 'return' star_expressions? +static stmt_ty +return_stmt_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + stmt_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // 'return' star_expressions? + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> return_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?")); + Token * _keyword; + void *a; + if ( + (_keyword = _PyPegen_expect_token(p, 500)) // token='return' + && + (a = star_expressions_rule(p), 1) // star_expressions? + ) + { + D(fprintf(stderr, "%*c+ return_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Return ( a , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s return_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'return' star_expressions?")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// raise_stmt: 'raise' expression ['from' expression] | 'raise' +static stmt_ty +raise_stmt_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + stmt_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // 'raise' expression ['from' expression] + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); + Token * _keyword; + expr_ty a; + void *b; + if ( + (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' + && + (a = expression_rule(p)) // expression + && + (b = _tmp_65_rule(p), 1) // ['from' expression] + ) + { + D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Raise ( a , b , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise' expression ['from' expression]")); + } + { // 'raise' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise'")); + Token * _keyword; + if ( + (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' + ) + { + D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Raise ( NULL , NULL , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise'")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// function_def: decorators function_def_raw | function_def_raw +static stmt_ty +function_def_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + stmt_ty _res = NULL; + int _mark = p->mark; + { // decorators function_def_raw + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> function_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "decorators function_def_raw")); asdl_seq* d; stmt_ty f; if ( @@ -5928,7 +6525,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_75_rule(p), 1) // ['->' expression] + (a = _tmp_66_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -5988,7 +6585,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_76_rule(p), 1) // ['->' expression] + (a = _tmp_67_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -6052,7 +6649,7 @@ func_type_comment_rule(Parser *p) && (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' && - _PyPegen_lookahead(1, _tmp_77_rule, p) + _PyPegen_lookahead(1, _tmp_68_rule, p) ) { D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); @@ -6196,9 +6793,9 @@ parameters_rule(Parser *p) if ( (a = slash_no_default_rule(p)) // slash_no_default && - (b = _loop0_78_rule(p)) // param_no_default* + (b = _loop0_69_rule(p)) // param_no_default* && - (c = _loop0_79_rule(p)) // param_with_default* + (c = _loop0_70_rule(p)) // param_with_default* && (d = star_etc_rule(p), 1) // star_etc? ) @@ -6228,7 +6825,7 @@ parameters_rule(Parser *p) if ( (a = slash_with_default_rule(p)) // slash_with_default && - (b = _loop0_80_rule(p)) // param_with_default* + (b = _loop0_71_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -6256,9 +6853,9 @@ parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = _loop1_81_rule(p)) // param_no_default+ + (a = _loop1_72_rule(p)) // param_no_default+ && - (b = _loop0_82_rule(p)) // param_with_default* + (b = _loop0_73_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -6285,7 +6882,7 @@ parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_83_rule(p)) // param_with_default+ + (a = _loop1_74_rule(p)) // param_with_default+ && (b = star_etc_rule(p), 1) // star_etc? ) @@ -6354,7 +6951,7 @@ slash_no_default_rule(Parser *p) Token * _literal_1; asdl_seq * a; if ( - (a = _loop1_84_rule(p)) // param_no_default+ + (a = _loop1_75_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -6383,7 +6980,7 @@ slash_no_default_rule(Parser *p) Token * _literal; asdl_seq * a; if ( - (a = _loop1_85_rule(p)) // param_no_default+ + (a = _loop1_76_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -6433,9 +7030,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_86_rule(p)) // param_no_default* + (a = _loop0_77_rule(p)) // param_no_default* && - (b = _loop1_87_rule(p)) // param_with_default+ + (b = _loop1_78_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -6465,9 +7062,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_88_rule(p)) // param_no_default* + (a = _loop0_79_rule(p)) // param_no_default* && - (b = _loop1_89_rule(p)) // param_with_default+ + (b = _loop1_80_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -6523,7 +7120,7 @@ star_etc_rule(Parser *p) && (a = param_no_default_rule(p)) // param_no_default && - (b = _loop0_90_rule(p)) // param_maybe_default* + (b = _loop0_81_rule(p)) // param_maybe_default* && (c = kwds_rule(p), 1) // kwds? ) @@ -6556,7 +7153,7 @@ star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_91_rule(p)) // param_maybe_default+ + (b = _loop1_82_rule(p)) // param_maybe_default+ && (c = kwds_rule(p), 1) // kwds? ) @@ -7078,7 +7675,7 @@ decorators_rule(Parser *p) D(fprintf(stderr, "%*c> decorators[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); asdl_seq * a; if ( - (a = _loop1_92_rule(p)) // (('@' named_expression NEWLINE))+ + (a = _loop1_83_rule(p)) // (('@' named_expression NEWLINE))+ ) { D(fprintf(stderr, "%*c+ decorators[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); @@ -7199,7 +7796,7 @@ class_def_raw_rule(Parser *p) && (a = _PyPegen_name_token(p)) // NAME && - (b = _tmp_93_rule(p), 1) // ['(' arguments? ')'] + (b = _tmp_84_rule(p), 1) // ['(' arguments? ')'] && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -7348,7 +7945,7 @@ expressions_list_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_94_rule(p)) // ','.star_expression+ + (a = _gather_85_rule(p)) // ','.star_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -7408,7 +8005,7 @@ star_expressions_rule(Parser *p) if ( (a = star_expression_rule(p)) // star_expression && - (b = _loop1_96_rule(p)) // ((',' star_expression))+ + (b = _loop1_87_rule(p)) // ((',' star_expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -7603,7 +8200,7 @@ star_named_expressions_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_97_rule(p)) // ','.star_named_expression+ + (a = _gather_88_rule(p)) // ','.star_named_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -7901,7 +8498,7 @@ expressions_rule(Parser *p) if ( (a = expression_rule(p)) // expression && - (b = _loop1_99_rule(p)) // ((',' expression))+ + (b = _loop1_90_rule(p)) // ((',' expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8200,9 +8797,9 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default && - (b = _loop0_100_rule(p)) // lambda_param_no_default* + (b = _loop0_91_rule(p)) // lambda_param_no_default* && - (c = _loop0_101_rule(p)) // lambda_param_with_default* + (c = _loop0_92_rule(p)) // lambda_param_with_default* && (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -8232,7 +8829,7 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default && - (b = _loop0_102_rule(p)) // lambda_param_with_default* + (b = _loop0_93_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -8260,9 +8857,9 @@ lambda_parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = _loop1_103_rule(p)) // lambda_param_no_default+ + (a = _loop1_94_rule(p)) // lambda_param_no_default+ && - (b = _loop0_104_rule(p)) // lambda_param_with_default* + (b = _loop0_95_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -8289,7 +8886,7 @@ lambda_parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_105_rule(p)) // lambda_param_with_default+ + (a = _loop1_96_rule(p)) // lambda_param_with_default+ && (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -8360,7 +8957,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal_1; asdl_seq * a; if ( - (a = _loop1_106_rule(p)) // lambda_param_no_default+ + (a = _loop1_97_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -8389,7 +8986,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal; asdl_seq * a; if ( - (a = _loop1_107_rule(p)) // lambda_param_no_default+ + (a = _loop1_98_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -8439,9 +9036,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_108_rule(p)) // lambda_param_no_default* + (a = _loop0_99_rule(p)) // lambda_param_no_default* && - (b = _loop1_109_rule(p)) // lambda_param_with_default+ + (b = _loop1_100_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -8471,9 +9068,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_110_rule(p)) // lambda_param_no_default* + (a = _loop0_101_rule(p)) // lambda_param_no_default* && - (b = _loop1_111_rule(p)) // lambda_param_with_default+ + (b = _loop1_102_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -8529,7 +9126,7 @@ lambda_star_etc_rule(Parser *p) && (a = lambda_param_no_default_rule(p)) // lambda_param_no_default && - (b = _loop0_112_rule(p)) // lambda_param_maybe_default* + (b = _loop0_103_rule(p)) // lambda_param_maybe_default* && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -8562,7 +9159,7 @@ lambda_star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_113_rule(p)) // lambda_param_maybe_default+ + (b = _loop1_104_rule(p)) // lambda_param_maybe_default+ && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -8989,7 +9586,7 @@ disjunction_rule(Parser *p) if ( (a = conjunction_rule(p)) // conjunction && - (b = _loop1_114_rule(p)) // (('or' conjunction))+ + (b = _loop1_105_rule(p)) // (('or' conjunction))+ ) { D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); @@ -9075,7 +9672,7 @@ conjunction_rule(Parser *p) if ( (a = inversion_rule(p)) // inversion && - (b = _loop1_115_rule(p)) // (('and' inversion))+ + (b = _loop1_106_rule(p)) // (('and' inversion))+ ) { D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); @@ -9243,7 +9840,7 @@ comparison_rule(Parser *p) if ( (a = bitwise_or_rule(p)) // bitwise_or && - (b = _loop1_116_rule(p)) // compare_op_bitwise_or_pair+ + (b = _loop1_107_rule(p)) // compare_op_bitwise_or_pair+ ) { D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); @@ -9571,10 +10168,10 @@ noteq_bitwise_or_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); - void *_tmp_117_var; + void *_tmp_108_var; expr_ty a; if ( - (_tmp_117_var = _tmp_117_rule(p)) // '!=' + (_tmp_108_var = _tmp_108_rule(p)) // '!=' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -9971,8 +10568,8 @@ bitwise_or_rule(Parser *p) int _mark = p->mark; int _resmark = p->mark; while (1) { - int tmpvar_1 = _PyPegen_update_memo(p, _mark, bitwise_or_type, _res); - if (tmpvar_1) { + int tmpvar_2 = _PyPegen_update_memo(p, _mark, bitwise_or_type, _res); + if (tmpvar_2) { D(p->level--); return _res; } @@ -10085,8 +10682,8 @@ bitwise_xor_rule(Parser *p) int _mark = p->mark; int _resmark = p->mark; while (1) { - int tmpvar_2 = _PyPegen_update_memo(p, _mark, bitwise_xor_type, _res); - if (tmpvar_2) { + int tmpvar_3 = _PyPegen_update_memo(p, _mark, bitwise_xor_type, _res); + if (tmpvar_3) { D(p->level--); return _res; } @@ -10199,8 +10796,8 @@ bitwise_and_rule(Parser *p) int _mark = p->mark; int _resmark = p->mark; while (1) { - int tmpvar_3 = _PyPegen_update_memo(p, _mark, bitwise_and_type, _res); - if (tmpvar_3) { + int tmpvar_4 = _PyPegen_update_memo(p, _mark, bitwise_and_type, _res); + if (tmpvar_4) { D(p->level--); return _res; } @@ -10313,8 +10910,8 @@ shift_expr_rule(Parser *p) int _mark = p->mark; int _resmark = p->mark; while (1) { - int tmpvar_4 = _PyPegen_update_memo(p, _mark, shift_expr_type, _res); - if (tmpvar_4) { + int tmpvar_5 = _PyPegen_update_memo(p, _mark, shift_expr_type, _res); + if (tmpvar_5) { D(p->level--); return _res; } @@ -10466,8 +11063,8 @@ sum_rule(Parser *p) int _mark = p->mark; int _resmark = p->mark; while (1) { - int tmpvar_5 = _PyPegen_update_memo(p, _mark, sum_type, _res); - if (tmpvar_5) { + int tmpvar_6 = _PyPegen_update_memo(p, _mark, sum_type, _res); + if (tmpvar_6) { D(p->level--); return _res; } @@ -10625,8 +11222,8 @@ term_rule(Parser *p) int _mark = p->mark; int _resmark = p->mark; while (1) { - int tmpvar_6 = _PyPegen_update_memo(p, _mark, term_type, _res); - if (tmpvar_6) { + int tmpvar_7 = _PyPegen_update_memo(p, _mark, term_type, _res); + if (tmpvar_7) { D(p->level--); return _res; } @@ -11228,8 +11825,8 @@ primary_rule(Parser *p) int _mark = p->mark; int _resmark = p->mark; while (1) { - int tmpvar_7 = _PyPegen_update_memo(p, _mark, primary_type, _res); - if (tmpvar_7) { + int tmpvar_8 = _PyPegen_update_memo(p, _mark, primary_type, _res); + if (tmpvar_8) { D(p->level--); return _res; } @@ -11503,7 +12100,7 @@ slices_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_118_rule(p)) // ','.slice+ + (a = _gather_109_rule(p)) // ','.slice+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -11573,7 +12170,7 @@ slice_rule(Parser *p) && (b = expression_rule(p), 1) // expression? && - (c = _tmp_120_rule(p), 1) // [':' expression?] + (c = _tmp_111_rule(p), 1) // [':' expression?] ) { D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); @@ -11847,15 +12444,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - void *_tmp_121_var; + void *_tmp_112_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' && - (_tmp_121_var = _tmp_121_rule(p)) // tuple | group | genexp + (_tmp_112_var = _tmp_112_rule(p)) // tuple | group | genexp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - _res = _tmp_121_var; + _res = _tmp_112_var; goto done; } p->mark = _mark; @@ -11868,15 +12465,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - void *_tmp_122_var; + void *_tmp_113_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' && - (_tmp_122_var = _tmp_122_rule(p)) // list | listcomp + (_tmp_113_var = _tmp_113_rule(p)) // list | listcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - _res = _tmp_122_var; + _res = _tmp_113_var; goto done; } p->mark = _mark; @@ -11889,15 +12486,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - void *_tmp_123_var; + void *_tmp_114_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' && - (_tmp_123_var = _tmp_123_rule(p)) // dict | set | dictcomp | setcomp + (_tmp_114_var = _tmp_114_rule(p)) // dict | set | dictcomp | setcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - _res = _tmp_123_var; + _res = _tmp_114_var; goto done; } p->mark = _mark; @@ -11966,7 +12563,7 @@ strings_rule(Parser *p) D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+")); asdl_seq * a; if ( - (a = _loop1_124_rule(p)) // STRING+ + (a = _loop1_115_rule(p)) // STRING+ ) { D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+")); @@ -12173,7 +12770,7 @@ tuple_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_125_rule(p), 1) // [star_named_expression ',' star_named_expressions?] + (a = _tmp_116_rule(p), 1) // [star_named_expression ',' star_named_expressions?] && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -12229,7 +12826,7 @@ group_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_126_rule(p)) // yield_expr | named_expression + (a = _tmp_117_rule(p)) // yield_expr | named_expression && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -12665,7 +13262,7 @@ double_starred_kvpairs_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_127_rule(p)) // ','.double_starred_kvpair+ + (a = _gather_118_rule(p)) // ','.double_starred_kvpair+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -12816,13 +13413,13 @@ for_if_clauses_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); - asdl_seq * _loop1_129_var; + asdl_seq * _loop1_120_var; if ( - (_loop1_129_var = _loop1_129_rule(p)) // for_if_clause+ + (_loop1_120_var = _loop1_120_rule(p)) // for_if_clause+ ) { D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); - _res = _loop1_129_var; + _res = _loop1_120_var; goto done; } p->mark = _mark; @@ -12871,7 +13468,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = _loop0_130_rule(p)) // (('if' disjunction))* + (c = _loop0_121_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*")); @@ -12907,7 +13504,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = _loop0_131_rule(p)) // (('if' disjunction))* + (c = _loop0_122_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*")); @@ -13132,7 +13729,7 @@ args_rule(Parser *p) if ( (a = starred_expression_rule(p)) // starred_expression && - (b = _tmp_132_rule(p), 1) // [',' args] + (b = _tmp_123_rule(p), 1) // [',' args] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]")); @@ -13201,7 +13798,7 @@ args_rule(Parser *p) if ( (a = named_expression_rule(p)) // named_expression && - (b = _tmp_133_rule(p), 1) // [',' args] + (b = _tmp_124_rule(p), 1) // [',' args] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]")); @@ -13256,11 +13853,11 @@ kwargs_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _gather_134_rule(p)) // ','.kwarg_or_starred+ + (a = _gather_125_rule(p)) // ','.kwarg_or_starred+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _gather_136_rule(p)) // ','.kwarg_or_double_starred+ + (b = _gather_127_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); @@ -13282,13 +13879,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - asdl_seq * _gather_138_var; + asdl_seq * _gather_129_var; if ( - (_gather_138_var = _gather_138_rule(p)) // ','.kwarg_or_starred+ + (_gather_129_var = _gather_129_rule(p)) // ','.kwarg_or_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - _res = _gather_138_var; + _res = _gather_129_var; goto done; } p->mark = _mark; @@ -13301,13 +13898,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - asdl_seq * _gather_140_var; + asdl_seq * _gather_131_var; if ( - (_gather_140_var = _gather_140_rule(p)) // ','.kwarg_or_double_starred+ + (_gather_131_var = _gather_131_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - _res = _gather_140_var; + _res = _gather_131_var; goto done; } p->mark = _mark; @@ -13669,7 +14266,7 @@ star_targets_rule(Parser *p) if ( (a = star_target_rule(p)) // star_target && - (b = _loop0_142_rule(p)) // ((',' star_target))* + (b = _loop0_133_rule(p)) // ((',' star_target))* && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -13723,7 +14320,7 @@ star_targets_seq_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_143_rule(p)) // ','.star_target+ + (a = _gather_134_rule(p)) // ','.star_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -13786,7 +14383,7 @@ star_target_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (a = _tmp_145_rule(p)) // !'*' star_target + (a = _tmp_136_rule(p)) // !'*' star_target ) { D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); @@ -14308,7 +14905,7 @@ del_targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_146_rule(p)) // ','.del_target+ + (a = _gather_137_rule(p)) // ','.del_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -14787,7 +15384,7 @@ targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_148_rule(p)) // ','.target+ + (a = _gather_139_rule(p)) // ','.target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -14969,8 +15566,8 @@ t_primary_rule(Parser *p) int _mark = p->mark; int _resmark = p->mark; while (1) { - int tmpvar_8 = _PyPegen_update_memo(p, _mark, t_primary_type, _res); - if (tmpvar_8) { + int tmpvar_9 = _PyPegen_update_memo(p, _mark, t_primary_type, _res); + if (tmpvar_9) { D(p->level--); return _res; } @@ -15499,7 +16096,7 @@ incorrect_arguments_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_opt_var = _tmp_150_rule(p), 1) // [args | expression for_if_clauses] + (_opt_var = _tmp_141_rule(p), 1) // [args | expression for_if_clauses] ) { D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); @@ -15781,14 +16378,14 @@ invalid_assignment_rule(Parser *p) D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'")); Token * _literal; Token * _literal_1; - asdl_seq * _loop0_151_var; + asdl_seq * _loop0_142_var; expr_ty a; if ( (a = star_named_expression_rule(p)) // star_named_expression && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_loop0_151_var = _loop0_151_rule(p)) // star_named_expressions* + (_loop0_142_var = _loop0_142_rule(p)) // star_named_expressions* && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' ) @@ -15824,7 +16421,7 @@ invalid_assignment_rule(Parser *p) && (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_152_rule(p), 1) // ['=' annotated_rhs] + (_opt_var = _tmp_143_rule(p), 1) // ['=' annotated_rhs] ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]")); @@ -15847,14 +16444,14 @@ invalid_assignment_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); Token * _literal; - void *_tmp_153_var; + void *_tmp_144_var; expr_ty a; if ( (a = star_expressions_rule(p)) // star_expressions && (_literal = _PyPegen_expect_token(p, 22)) // token='=' && - (_tmp_153_var = _tmp_153_rule(p)) // yield_expr | star_expressions + (_tmp_144_var = _tmp_144_rule(p)) // yield_expr | star_expressions ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); @@ -15876,7 +16473,7 @@ invalid_assignment_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); - void *_tmp_154_var; + void *_tmp_145_var; expr_ty a; AugOperator* augassign_var; if ( @@ -15884,7 +16481,7 @@ invalid_assignment_rule(Parser *p) && (augassign_var = augassign_rule(p)) // augassign && - (_tmp_154_var = _tmp_154_rule(p)) // yield_expr | star_expressions + (_tmp_145_var = _tmp_145_rule(p)) // yield_expr | star_expressions ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); @@ -15966,11 +16563,11 @@ invalid_comprehension_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); - void *_tmp_155_var; + void *_tmp_146_var; expr_ty a; asdl_seq* for_if_clauses_var; if ( - (_tmp_155_var = _tmp_155_rule(p)) // '[' | '(' | '{' + (_tmp_146_var = _tmp_146_rule(p)) // '[' | '(' | '{' && (a = starred_expression_rule(p)) // starred_expression && @@ -16067,13 +16664,13 @@ invalid_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); - asdl_seq * _loop0_156_var; - void *_tmp_157_var; + asdl_seq * _loop0_147_var; + void *_tmp_148_var; arg_ty param_no_default_var; if ( - (_loop0_156_var = _loop0_156_rule(p)) // param_no_default* + (_loop0_147_var = _loop0_147_rule(p)) // param_no_default* && - (_tmp_157_var = _tmp_157_rule(p)) // slash_with_default | param_with_default+ + (_tmp_148_var = _tmp_148_rule(p)) // slash_with_default | param_with_default+ && (param_no_default_var = param_no_default_rule(p)) // param_no_default ) @@ -16115,11 +16712,11 @@ invalid_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); Token * _literal; - void *_tmp_158_var; + void *_tmp_149_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_158_var = _tmp_158_rule(p)) // ')' | ',' (')' | '**') + (_tmp_149_var = _tmp_149_rule(p)) // ')' | ',' (')' | '**') ) { D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); @@ -16189,11 +16786,11 @@ invalid_lambda_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); Token * _literal; - void *_tmp_159_var; + void *_tmp_150_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_159_var = _tmp_159_rule(p)) // ':' | ',' (':' | '**') + (_tmp_150_var = _tmp_150_rule(p)) // ':' | ',' (':' | '**') ) { D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); @@ -17603,12 +18200,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_160_var; + void *_tmp_151_var; while ( - (_tmp_160_var = _tmp_160_rule(p)) // star_targets '=' + (_tmp_151_var = _tmp_151_rule(p)) // star_targets '=' ) { - _res = _tmp_160_var; + _res = _tmp_151_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -17736,439 +18333,30 @@ _tmp_24_rule(Parser *p) if (p->error_indicator) { D(p->level--); return NULL; - } - D(fprintf(stderr, "%*c> _tmp_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); - expr_ty star_expressions_var; - if ( - (star_expressions_var = star_expressions_rule(p)) // star_expressions - ) - { - D(fprintf(stderr, "%*c+ _tmp_24[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); - _res = star_expressions_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_24[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _loop0_26: ',' NAME -static asdl_seq * -_loop0_26_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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ',' NAME - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_26[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME")); - Token * _literal; - expr_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = _PyPegen_name_token(p)) // NAME - ) - { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - 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_26[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME")); - } - asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); - PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_26_type, _seq); - D(p->level--); - return _seq; -} - -// _gather_25: NAME _loop0_26 -static asdl_seq * -_gather_25_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // NAME _loop0_26 - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _gather_25[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = _PyPegen_name_token(p)) // NAME - && - (seq = _loop0_26_rule(p)) // _loop0_26 - ) - { - D(fprintf(stderr, "%*c+ _gather_25[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_25[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_26")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _loop0_28: ',' NAME -static asdl_seq * -_loop0_28_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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ',' NAME - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_28[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME")); - Token * _literal; - expr_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = _PyPegen_name_token(p)) // NAME - ) - { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - 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_28[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME")); - } - asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); - PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_28_type, _seq); - D(p->level--); - return _seq; -} - -// _gather_27: NAME _loop0_28 -static asdl_seq * -_gather_27_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // NAME _loop0_28 - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _gather_27[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = _PyPegen_name_token(p)) // NAME - && - (seq = _loop0_28_rule(p)) // _loop0_28 - ) - { - D(fprintf(stderr, "%*c+ _gather_27[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_27[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_28")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_29: ',' expression -static void * -_tmp_29_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> _tmp_29[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); - Token * _literal; - expr_ty z; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (z = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ _tmp_29[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); - _res = z; - 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_29[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _loop0_30: ('.' | '...') -static asdl_seq * -_loop0_30_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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ('.' | '...') - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_161_var; - while ( - (_tmp_161_var = _tmp_161_rule(p)) // '.' | '...' - ) - { - _res = _tmp_161_var; - 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_30[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); - } - asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); - PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_30_type, _seq); - D(p->level--); - return _seq; -} - -// _loop1_31: ('.' | '...') -static asdl_seq * -_loop1_31_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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ('.' | '...') - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_162_var; - while ( - (_tmp_162_var = _tmp_162_rule(p)) // '.' | '...' + } + D(fprintf(stderr, "%*c> _tmp_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + expr_ty star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - _res = _tmp_162_var; - 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; + D(fprintf(stderr, "%*c+ _tmp_24[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + _res = star_expressions_var; + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_31[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - D(p->level--); - return NULL; - } - asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s _tmp_24[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } - for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); - PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_31_type, _seq); + _res = NULL; + done: D(p->level--); - return _seq; + return _res; } -// _loop0_33: ',' import_from_as_name +// _loop0_26: ',' NAME static asdl_seq * -_loop0_33_rule(Parser *p) +_loop0_26_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18187,18 +18375,18 @@ _loop0_33_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' import_from_as_name + { // ',' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_33[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' import_from_as_name")); + D(fprintf(stderr, "%*c> _loop0_26[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME")); Token * _literal; - alias_ty elem; + expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = import_from_as_name_rule(p)) // import_from_as_name + (elem = _PyPegen_name_token(p)) // NAME ) { _res = elem; @@ -18223,8 +18411,8 @@ _loop0_33_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_33[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' import_from_as_name")); + D(fprintf(stderr, "%*c%s _loop0_26[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -18236,14 +18424,14 @@ _loop0_33_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_33_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_26_type, _seq); D(p->level--); return _seq; } -// _gather_32: import_from_as_name _loop0_33 +// _gather_25: NAME _loop0_26 static asdl_seq * -_gather_32_rule(Parser *p) +_gather_25_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18252,71 +18440,27 @@ _gather_32_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // import_from_as_name _loop0_33 + { // NAME _loop0_26 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_32[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_33")); - alias_ty elem; + D(fprintf(stderr, "%*c> _gather_25[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26")); + expr_ty elem; asdl_seq * seq; if ( - (elem = import_from_as_name_rule(p)) // import_from_as_name + (elem = _PyPegen_name_token(p)) // NAME && - (seq = _loop0_33_rule(p)) // _loop0_33 + (seq = _loop0_26_rule(p)) // _loop0_26 ) { - D(fprintf(stderr, "%*c+ _gather_32[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_33")); + D(fprintf(stderr, "%*c+ _gather_25[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_32[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_name _loop0_33")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_34: 'as' NAME -static void * -_tmp_34_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'as' NAME - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_34[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - Token * _keyword; - expr_ty z; - if ( - (_keyword = _PyPegen_expect_token(p, 531)) // token='as' - && - (z = _PyPegen_name_token(p)) // NAME - ) - { - D(fprintf(stderr, "%*c+ _tmp_34[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - _res = z; - 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_34[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c%s _gather_25[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_26")); } _res = NULL; done: @@ -18324,9 +18468,9 @@ _tmp_34_rule(Parser *p) return _res; } -// _loop0_36: ',' dotted_as_name +// _loop0_28: ',' NAME static asdl_seq * -_loop0_36_rule(Parser *p) +_loop0_28_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18345,18 +18489,18 @@ _loop0_36_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' dotted_as_name + { // ',' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_36[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' dotted_as_name")); + D(fprintf(stderr, "%*c> _loop0_28[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME")); Token * _literal; - alias_ty elem; + expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = dotted_as_name_rule(p)) // dotted_as_name + (elem = _PyPegen_name_token(p)) // NAME ) { _res = elem; @@ -18381,8 +18525,8 @@ _loop0_36_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_36[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' dotted_as_name")); + D(fprintf(stderr, "%*c%s _loop0_28[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -18394,14 +18538,14 @@ _loop0_36_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_36_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_28_type, _seq); D(p->level--); return _seq; } -// _gather_35: dotted_as_name _loop0_36 +// _gather_27: NAME _loop0_28 static asdl_seq * -_gather_35_rule(Parser *p) +_gather_27_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18410,27 +18554,27 @@ _gather_35_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // dotted_as_name _loop0_36 + { // NAME _loop0_28 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_35[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_36")); - alias_ty elem; + D(fprintf(stderr, "%*c> _gather_27[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28")); + expr_ty elem; asdl_seq * seq; if ( - (elem = dotted_as_name_rule(p)) // dotted_as_name + (elem = _PyPegen_name_token(p)) // NAME && - (seq = _loop0_36_rule(p)) // _loop0_36 + (seq = _loop0_28_rule(p)) // _loop0_28 ) { - D(fprintf(stderr, "%*c+ _gather_35[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_36")); + D(fprintf(stderr, "%*c+ _gather_27[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_35[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_as_name _loop0_36")); + D(fprintf(stderr, "%*c%s _gather_27[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_28")); } _res = NULL; done: @@ -18438,9 +18582,9 @@ _gather_35_rule(Parser *p) return _res; } -// _tmp_37: 'as' NAME +// _tmp_29: ',' expression static void * -_tmp_37_rule(Parser *p) +_tmp_29_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18449,21 +18593,21 @@ _tmp_37_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // 'as' NAME + { // ',' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_37[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - Token * _keyword; + D(fprintf(stderr, "%*c> _tmp_29[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + Token * _literal; expr_ty z; if ( - (_keyword = _PyPegen_expect_token(p, 531)) // token='as' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (z = _PyPegen_name_token(p)) // NAME + (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_37[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c+ _tmp_29[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -18473,8 +18617,8 @@ _tmp_37_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_37[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c%s _tmp_29[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } _res = NULL; done: @@ -18482,9 +18626,9 @@ _tmp_37_rule(Parser *p) return _res; } -// _loop0_39: ',' with_item +// _loop0_30: ('.' | '...') static asdl_seq * -_loop0_39_rule(Parser *p) +_loop0_30_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18503,27 +18647,18 @@ _loop0_39_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' with_item + { // ('.' | '...') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_39[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); - Token * _literal; - withitem_ty elem; + D(fprintf(stderr, "%*c> _loop0_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); + void *_tmp_152_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = with_item_rule(p)) // with_item + (_tmp_152_var = _tmp_152_rule(p)) // '.' | '...' ) { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - D(p->level--); - return NULL; - } + _res = _tmp_152_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -18539,66 +18674,27 @@ _loop0_39_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_39[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); - } - asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); - PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_39_type, _seq); - D(p->level--); - return _seq; -} - -// _gather_38: with_item _loop0_39 -static asdl_seq * -_gather_38_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s _loop0_30[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // with_item _loop0_39 - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _gather_38[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_39")); - withitem_ty elem; - asdl_seq * seq; - if ( - (elem = with_item_rule(p)) // with_item - && - (seq = _loop0_39_rule(p)) // _loop0_39 - ) - { - D(fprintf(stderr, "%*c+ _gather_38[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_39")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_38[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_39")); + asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); + if (!_seq) { + PyMem_Free(_children); + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; } - _res = NULL; - done: + for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_30_type, _seq); D(p->level--); - return _res; + return _seq; } -// _loop0_41: ',' with_item +// _loop1_31: ('.' | '...') static asdl_seq * -_loop0_41_rule(Parser *p) +_loop1_31_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18617,27 +18713,18 @@ _loop0_41_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' with_item + { // ('.' | '...') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_41[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); - Token * _literal; - withitem_ty elem; + D(fprintf(stderr, "%*c> _loop1_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); + void *_tmp_153_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = with_item_rule(p)) // with_item + (_tmp_153_var = _tmp_153_rule(p)) // '.' | '...' ) { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - D(p->level--); - return NULL; - } + _res = _tmp_153_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -18653,8 +18740,13 @@ _loop0_41_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_41[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); + D(fprintf(stderr, "%*c%s _loop1_31[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -18666,53 +18758,14 @@ _loop0_41_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_41_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_31_type, _seq); D(p->level--); return _seq; } -// _gather_40: with_item _loop0_41 -static asdl_seq * -_gather_40_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // with_item _loop0_41 - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _gather_40[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_41")); - withitem_ty elem; - asdl_seq * seq; - if ( - (elem = with_item_rule(p)) // with_item - && - (seq = _loop0_41_rule(p)) // _loop0_41 - ) - { - D(fprintf(stderr, "%*c+ _gather_40[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_41")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_40[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_41")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _loop0_43: ',' with_item +// _loop0_33: ',' import_from_as_name static asdl_seq * -_loop0_43_rule(Parser *p) +_loop0_33_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18731,18 +18784,18 @@ _loop0_43_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' with_item + { // ',' import_from_as_name if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_43[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); + D(fprintf(stderr, "%*c> _loop0_33[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' import_from_as_name")); Token * _literal; - withitem_ty elem; + alias_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = with_item_rule(p)) // with_item + (elem = import_from_as_name_rule(p)) // import_from_as_name ) { _res = elem; @@ -18767,8 +18820,8 @@ _loop0_43_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_43[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); + D(fprintf(stderr, "%*c%s _loop0_33[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' import_from_as_name")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -18780,14 +18833,14 @@ _loop0_43_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_43_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_33_type, _seq); D(p->level--); return _seq; } -// _gather_42: with_item _loop0_43 +// _gather_32: import_from_as_name _loop0_33 static asdl_seq * -_gather_42_rule(Parser *p) +_gather_32_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18796,27 +18849,27 @@ _gather_42_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // with_item _loop0_43 + { // import_from_as_name _loop0_33 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_42[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_43")); - withitem_ty elem; + D(fprintf(stderr, "%*c> _gather_32[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_33")); + alias_ty elem; asdl_seq * seq; if ( - (elem = with_item_rule(p)) // with_item + (elem = import_from_as_name_rule(p)) // import_from_as_name && - (seq = _loop0_43_rule(p)) // _loop0_43 + (seq = _loop0_33_rule(p)) // _loop0_33 ) { - D(fprintf(stderr, "%*c+ _gather_42[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_43")); + D(fprintf(stderr, "%*c+ _gather_32[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_33")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_42[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_43")); + D(fprintf(stderr, "%*c%s _gather_32[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_name _loop0_33")); } _res = NULL; done: @@ -18824,9 +18877,53 @@ _gather_42_rule(Parser *p) return _res; } -// _loop0_45: ',' with_item +// _tmp_34: 'as' NAME +static void * +_tmp_34_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'as' NAME + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_34[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + Token * _keyword; + expr_ty z; + if ( + (_keyword = _PyPegen_expect_token(p, 531)) // token='as' + && + (z = _PyPegen_name_token(p)) // NAME + ) + { + D(fprintf(stderr, "%*c+ _tmp_34[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + _res = z; + 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_34[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_36: ',' dotted_as_name static asdl_seq * -_loop0_45_rule(Parser *p) +_loop0_36_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18845,18 +18942,18 @@ _loop0_45_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' with_item + { // ',' dotted_as_name if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_45[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); + D(fprintf(stderr, "%*c> _loop0_36[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' dotted_as_name")); Token * _literal; - withitem_ty elem; + alias_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = with_item_rule(p)) // with_item + (elem = dotted_as_name_rule(p)) // dotted_as_name ) { _res = elem; @@ -18881,8 +18978,8 @@ _loop0_45_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_45[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); + D(fprintf(stderr, "%*c%s _loop0_36[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' dotted_as_name")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -18894,14 +18991,14 @@ _loop0_45_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_45_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_36_type, _seq); D(p->level--); return _seq; } -// _gather_44: with_item _loop0_45 +// _gather_35: dotted_as_name _loop0_36 static asdl_seq * -_gather_44_rule(Parser *p) +_gather_35_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18910,27 +19007,27 @@ _gather_44_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // with_item _loop0_45 + { // dotted_as_name _loop0_36 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_44[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_45")); - withitem_ty elem; + D(fprintf(stderr, "%*c> _gather_35[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_36")); + alias_ty elem; asdl_seq * seq; if ( - (elem = with_item_rule(p)) // with_item + (elem = dotted_as_name_rule(p)) // dotted_as_name && - (seq = _loop0_45_rule(p)) // _loop0_45 + (seq = _loop0_36_rule(p)) // _loop0_36 ) { - D(fprintf(stderr, "%*c+ _gather_44[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_45")); + D(fprintf(stderr, "%*c+ _gather_35[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_36")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_44[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_45")); + D(fprintf(stderr, "%*c%s _gather_35[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_as_name _loop0_36")); } _res = NULL; done: @@ -18938,9 +19035,9 @@ _gather_44_rule(Parser *p) return _res; } -// _tmp_46: 'as' target +// _tmp_37: 'as' NAME static void * -_tmp_46_rule(Parser *p) +_tmp_37_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18949,22 +19046,22 @@ _tmp_46_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // 'as' target + { // 'as' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_46[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' target")); + D(fprintf(stderr, "%*c> _tmp_37[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; - expr_ty t; + expr_ty z; if ( (_keyword = _PyPegen_expect_token(p, 531)) // token='as' && - (t = target_rule(p)) // target + (z = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_46[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' target")); - _res = t; + D(fprintf(stderr, "%*c+ _tmp_37[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -18973,8 +19070,8 @@ _tmp_46_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_46[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' target")); + D(fprintf(stderr, "%*c%s _tmp_37[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; done: @@ -18982,9 +19079,9 @@ _tmp_46_rule(Parser *p) return _res; } -// _loop1_47: except_block +// _loop0_39: ',' with_item static asdl_seq * -_loop1_47_rule(Parser *p) +_loop0_39_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19003,18 +19100,27 @@ _loop1_47_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // except_block + { // ',' with_item if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_47[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block")); - excepthandler_ty except_block_var; + D(fprintf(stderr, "%*c> _loop0_39[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); + Token * _literal; + withitem_ty elem; while ( - (except_block_var = except_block_rule(p)) // except_block + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = with_item_rule(p)) // with_item ) { - _res = except_block_var; + _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 *)); @@ -19029,14 +19135,9 @@ _loop1_47_rule(Parser *p) _children[_n++] = _res; _mark = p->mark; } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_47[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_block")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - D(p->level--); - return NULL; + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_39[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -19048,48 +19149,43 @@ _loop1_47_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_47_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_39_type, _seq); D(p->level--); return _seq; } -// _tmp_48: 'as' NAME -static void * -_tmp_48_rule(Parser *p) +// _gather_38: with_item _loop0_39 +static asdl_seq * +_gather_38_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // 'as' NAME + { // with_item _loop0_39 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_48[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - Token * _keyword; - expr_ty z; + D(fprintf(stderr, "%*c> _gather_38[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_39")); + withitem_ty elem; + asdl_seq * seq; if ( - (_keyword = _PyPegen_expect_token(p, 531)) // token='as' + (elem = with_item_rule(p)) // with_item && - (z = _PyPegen_name_token(p)) // NAME + (seq = _loop0_39_rule(p)) // _loop0_39 ) { - D(fprintf(stderr, "%*c+ _tmp_48[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - _res = z; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _gather_38[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_39")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_48[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c%s _gather_38[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_39")); } _res = NULL; done: @@ -19097,9 +19193,9 @@ _tmp_48_rule(Parser *p) return _res; } -// _loop1_49: case_block +// _loop0_41: ',' with_item static asdl_seq * -_loop1_49_rule(Parser *p) +_loop0_41_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19118,18 +19214,27 @@ _loop1_49_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // case_block + { // ',' with_item if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_49[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "case_block")); - void *case_block_var; + D(fprintf(stderr, "%*c> _loop0_41[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); + Token * _literal; + withitem_ty elem; while ( - (case_block_var = case_block_rule(p)) // case_block + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = with_item_rule(p)) // with_item ) { - _res = case_block_var; + _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 *)); @@ -19145,13 +19250,8 @@ _loop1_49_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_49[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "case_block")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s _loop0_41[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -19163,48 +19263,43 @@ _loop1_49_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_49_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_41_type, _seq); D(p->level--); return _seq; } -// _tmp_50: 'if' named_expression -static void * -_tmp_50_rule(Parser *p) +// _gather_40: with_item _loop0_41 +static asdl_seq * +_gather_40_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // 'if' named_expression + { // with_item _loop0_41 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_50[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression")); - Token * _keyword; - expr_ty a; + D(fprintf(stderr, "%*c> _gather_40[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_41")); + withitem_ty elem; + asdl_seq * seq; if ( - (_keyword = _PyPegen_expect_token(p, 510)) // token='if' + (elem = with_item_rule(p)) // with_item && - (a = named_expression_rule(p)) // named_expression + (seq = _loop0_41_rule(p)) // _loop0_41 ) { - D(fprintf(stderr, "%*c+ _tmp_50[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression")); - _res = a; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _gather_40[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_41")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_50[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression")); + D(fprintf(stderr, "%*c%s _gather_40[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_41")); } _res = NULL; done: @@ -19212,9 +19307,9 @@ _tmp_50_rule(Parser *p) return _res; } -// _loop0_52: '|' closed_pattern +// _loop0_43: ',' with_item static asdl_seq * -_loop0_52_rule(Parser *p) +_loop0_43_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19233,18 +19328,18 @@ _loop0_52_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // '|' closed_pattern + { // ',' with_item if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_52[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|' closed_pattern")); + D(fprintf(stderr, "%*c> _loop0_43[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); Token * _literal; - void *elem; + withitem_ty elem; while ( - (_literal = _PyPegen_expect_token(p, 18)) // token='|' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = closed_pattern_rule(p)) // closed_pattern + (elem = with_item_rule(p)) // with_item ) { _res = elem; @@ -19269,8 +19364,8 @@ _loop0_52_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_52[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|' closed_pattern")); + D(fprintf(stderr, "%*c%s _loop0_43[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -19282,14 +19377,14 @@ _loop0_52_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_52_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_43_type, _seq); D(p->level--); return _seq; } -// _gather_51: closed_pattern _loop0_52 +// _gather_42: with_item _loop0_43 static asdl_seq * -_gather_51_rule(Parser *p) +_gather_42_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19298,82 +19393,27 @@ _gather_51_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // closed_pattern _loop0_52 + { // with_item _loop0_43 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_51[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "closed_pattern _loop0_52")); - void *elem; + D(fprintf(stderr, "%*c> _gather_42[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_43")); + withitem_ty elem; asdl_seq * seq; if ( - (elem = closed_pattern_rule(p)) // closed_pattern + (elem = with_item_rule(p)) // with_item && - (seq = _loop0_52_rule(p)) // _loop0_52 + (seq = _loop0_43_rule(p)) // _loop0_43 ) { - D(fprintf(stderr, "%*c+ _gather_51[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "closed_pattern _loop0_52")); + D(fprintf(stderr, "%*c+ _gather_42[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_43")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_51[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "closed_pattern _loop0_52")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_53: '.' | '(' -static void * -_tmp_53_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_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 23)) // token='.' - ) - { - D(fprintf(stderr, "%*c+ _tmp_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_53[%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_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - ) - { - D(fprintf(stderr, "%*c+ _tmp_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_53[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c%s _gather_42[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_43")); } _res = NULL; done: @@ -19381,9 +19421,9 @@ _tmp_53_rule(Parser *p) return _res; } -// _loop0_55: '.' NAME +// _loop0_45: ',' with_item static asdl_seq * -_loop0_55_rule(Parser *p) +_loop0_45_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19402,18 +19442,18 @@ _loop0_55_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // '.' NAME + { // ',' with_item if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.' NAME")); + D(fprintf(stderr, "%*c> _loop0_45[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); Token * _literal; - expr_ty elem; + withitem_ty elem; while ( - (_literal = _PyPegen_expect_token(p, 23)) // token='.' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _PyPegen_name_token(p)) // NAME + (elem = with_item_rule(p)) // with_item ) { _res = elem; @@ -19438,8 +19478,8 @@ _loop0_55_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_55[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.' NAME")); + D(fprintf(stderr, "%*c%s _loop0_45[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -19451,14 +19491,14 @@ _loop0_55_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_55_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_45_type, _seq); D(p->level--); return _seq; } -// _gather_54: NAME _loop0_55 +// _gather_44: with_item _loop0_45 static asdl_seq * -_gather_54_rule(Parser *p) +_gather_44_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19467,27 +19507,71 @@ _gather_54_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // NAME _loop0_55 + { // with_item _loop0_45 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_55")); - expr_ty elem; + D(fprintf(stderr, "%*c> _gather_44[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_45")); + withitem_ty elem; asdl_seq * seq; if ( - (elem = _PyPegen_name_token(p)) // NAME + (elem = with_item_rule(p)) // with_item && - (seq = _loop0_55_rule(p)) // _loop0_55 + (seq = _loop0_45_rule(p)) // _loop0_45 ) { - D(fprintf(stderr, "%*c+ _gather_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_55")); + D(fprintf(stderr, "%*c+ _gather_44[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_45")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_54[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_55")); + D(fprintf(stderr, "%*c%s _gather_44[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_45")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_46: 'as' target +static void * +_tmp_46_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'as' target + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_46[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' target")); + Token * _keyword; + expr_ty t; + if ( + (_keyword = _PyPegen_expect_token(p, 531)) // token='as' + && + (t = target_rule(p)) // target + ) + { + D(fprintf(stderr, "%*c+ _tmp_46[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' target")); + _res = t; + 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_46[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' target")); } _res = NULL; done: @@ -19495,9 +19579,9 @@ _gather_54_rule(Parser *p) return _res; } -// _loop0_57: ',' pattern +// _loop1_47: except_block static asdl_seq * -_loop0_57_rule(Parser *p) +_loop1_47_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19516,27 +19600,18 @@ _loop0_57_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' pattern + { // except_block if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); - Token * _literal; - void *elem; + D(fprintf(stderr, "%*c> _loop1_47[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block")); + excepthandler_ty except_block_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = pattern_rule(p)) // pattern + (except_block_var = except_block_rule(p)) // except_block ) { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - D(p->level--); - return NULL; - } + _res = except_block_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -19552,8 +19627,13 @@ _loop0_57_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_57[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c%s _loop1_47[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_block")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -19565,43 +19645,48 @@ _loop0_57_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_57_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_47_type, _seq); D(p->level--); return _seq; } -// _gather_56: pattern _loop0_57 -static asdl_seq * -_gather_56_rule(Parser *p) +// _tmp_48: 'as' NAME +static void * +_tmp_48_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - asdl_seq * _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // pattern _loop0_57 + { // 'as' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_57")); - void *elem; - asdl_seq * seq; + D(fprintf(stderr, "%*c> _tmp_48[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + Token * _keyword; + expr_ty z; if ( - (elem = pattern_rule(p)) // pattern + (_keyword = _PyPegen_expect_token(p, 531)) // token='as' && - (seq = _loop0_57_rule(p)) // _loop0_57 + (z = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _gather_56[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_57")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); + D(fprintf(stderr, "%*c+ _tmp_48[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_56[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_57")); + D(fprintf(stderr, "%*c%s _tmp_48[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; done: @@ -19609,9 +19694,9 @@ _gather_56_rule(Parser *p) return _res; } -// _loop0_59: ',' pattern +// _loop1_49: case_block static asdl_seq * -_loop0_59_rule(Parser *p) +_loop1_49_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19630,27 +19715,18 @@ _loop0_59_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' pattern + { // case_block if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); - Token * _literal; - void *elem; + D(fprintf(stderr, "%*c> _loop1_49[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "case_block")); + void *case_block_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = pattern_rule(p)) // pattern + (case_block_var = case_block_rule(p)) // case_block ) { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - D(p->level--); - return NULL; - } + _res = case_block_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -19666,8 +19742,13 @@ _loop0_59_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_59[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c%s _loop1_49[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "case_block")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -19679,53 +19760,14 @@ _loop0_59_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_59_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_49_type, _seq); D(p->level--); return _seq; } -// _gather_58: pattern _loop0_59 -static asdl_seq * -_gather_58_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // pattern _loop0_59 - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _gather_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_59")); - void *elem; - asdl_seq * seq; - if ( - (elem = pattern_rule(p)) // pattern - && - (seq = _loop0_59_rule(p)) // _loop0_59 - ) - { - D(fprintf(stderr, "%*c+ _gather_58[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_59")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_58[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_59")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _loop0_61: ',' (key_pattern ':' closed_pattern) +// _loop0_51: '|' closed_pattern static asdl_seq * -_loop0_61_rule(Parser *p) +_loop0_51_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19744,18 +19786,18 @@ _loop0_61_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' (key_pattern ':' closed_pattern) + { // '|' closed_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (key_pattern ':' closed_pattern)")); + D(fprintf(stderr, "%*c> _loop0_51[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|' closed_pattern")); Token * _literal; void *elem; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (_literal = _PyPegen_expect_token(p, 18)) // token='|' && - (elem = _tmp_163_rule(p)) // key_pattern ':' closed_pattern + (elem = closed_pattern_rule(p)) // closed_pattern ) { _res = elem; @@ -19780,8 +19822,8 @@ _loop0_61_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_61[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (key_pattern ':' closed_pattern)")); + D(fprintf(stderr, "%*c%s _loop0_51[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|' closed_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -19793,14 +19835,14 @@ _loop0_61_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_61_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_51_type, _seq); D(p->level--); return _seq; } -// _gather_60: (key_pattern ':' closed_pattern) _loop0_61 +// _gather_50: closed_pattern _loop0_51 static asdl_seq * -_gather_60_rule(Parser *p) +_gather_50_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19809,27 +19851,82 @@ _gather_60_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (key_pattern ':' closed_pattern) _loop0_61 + { // closed_pattern _loop0_51 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(key_pattern ':' closed_pattern) _loop0_61")); + D(fprintf(stderr, "%*c> _gather_50[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "closed_pattern _loop0_51")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_163_rule(p)) // key_pattern ':' closed_pattern + (elem = closed_pattern_rule(p)) // closed_pattern && - (seq = _loop0_61_rule(p)) // _loop0_61 + (seq = _loop0_51_rule(p)) // _loop0_51 ) { - D(fprintf(stderr, "%*c+ _gather_60[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(key_pattern ':' closed_pattern) _loop0_61")); + D(fprintf(stderr, "%*c+ _gather_50[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "closed_pattern _loop0_51")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_60[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(key_pattern ':' closed_pattern) _loop0_61")); + D(fprintf(stderr, "%*c%s _gather_50[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "closed_pattern _loop0_51")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_52: '.' | '(' +static void * +_tmp_52_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_52[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 23)) // token='.' + ) + { + D(fprintf(stderr, "%*c+ _tmp_52[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_52[%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_52[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + ) + { + D(fprintf(stderr, "%*c+ _tmp_52[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_52[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } _res = NULL; done: @@ -19837,9 +19934,9 @@ _gather_60_rule(Parser *p) return _res; } -// _loop0_63: '|' literal_pattern +// _loop0_54: ',' pattern static asdl_seq * -_loop0_63_rule(Parser *p) +_loop0_54_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19858,18 +19955,18 @@ _loop0_63_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // '|' literal_pattern + { // ',' pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|' literal_pattern")); + D(fprintf(stderr, "%*c> _loop0_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; void *elem; while ( - (_literal = _PyPegen_expect_token(p, 18)) // token='|' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = literal_pattern_rule(p)) // literal_pattern + (elem = pattern_rule(p)) // pattern ) { _res = elem; @@ -19894,8 +19991,8 @@ _loop0_63_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_63[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|' literal_pattern")); + D(fprintf(stderr, "%*c%s _loop0_54[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -19907,14 +20004,14 @@ _loop0_63_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_63_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_54_type, _seq); D(p->level--); return _seq; } -// _gather_62: literal_pattern _loop0_63 +// _gather_53: pattern _loop0_54 static asdl_seq * -_gather_62_rule(Parser *p) +_gather_53_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19923,27 +20020,27 @@ _gather_62_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // literal_pattern _loop0_63 + { // pattern _loop0_54 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern _loop0_63")); + D(fprintf(stderr, "%*c> _gather_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_54")); void *elem; asdl_seq * seq; if ( - (elem = literal_pattern_rule(p)) // literal_pattern + (elem = pattern_rule(p)) // pattern && - (seq = _loop0_63_rule(p)) // _loop0_63 + (seq = _loop0_54_rule(p)) // _loop0_54 ) { - D(fprintf(stderr, "%*c+ _gather_62[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern _loop0_63")); + D(fprintf(stderr, "%*c+ _gather_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_54")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_62[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern _loop0_63")); + D(fprintf(stderr, "%*c%s _gather_53[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_54")); } _res = NULL; done: @@ -19951,9 +20048,9 @@ _gather_62_rule(Parser *p) return _res; } -// _loop0_65: '.' NAME +// _loop0_56: ',' keyword_pattern static asdl_seq * -_loop0_65_rule(Parser *p) +_loop0_56_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19972,18 +20069,18 @@ _loop0_65_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // '.' NAME + { // ',' keyword_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.' NAME")); + D(fprintf(stderr, "%*c> _loop0_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; - expr_ty elem; + void *elem; while ( - (_literal = _PyPegen_expect_token(p, 23)) // token='.' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _PyPegen_name_token(p)) // NAME + (elem = keyword_pattern_rule(p)) // keyword_pattern ) { _res = elem; @@ -20008,8 +20105,8 @@ _loop0_65_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_65[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.' NAME")); + D(fprintf(stderr, "%*c%s _loop0_56[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -20021,14 +20118,14 @@ _loop0_65_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_65_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_56_type, _seq); D(p->level--); return _seq; } -// _gather_64: NAME _loop0_65 +// _gather_55: keyword_pattern _loop0_56 static asdl_seq * -_gather_64_rule(Parser *p) +_gather_55_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20037,27 +20134,27 @@ _gather_64_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // NAME _loop0_65 + { // keyword_pattern _loop0_56 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_65")); - expr_ty elem; + D(fprintf(stderr, "%*c> _gather_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_56")); + void *elem; asdl_seq * seq; if ( - (elem = _PyPegen_name_token(p)) // NAME + (elem = keyword_pattern_rule(p)) // keyword_pattern && - (seq = _loop0_65_rule(p)) // _loop0_65 + (seq = _loop0_56_rule(p)) // _loop0_56 ) { - D(fprintf(stderr, "%*c+ _gather_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_65")); + D(fprintf(stderr, "%*c+ _gather_55[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_56")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_64[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_65")); + D(fprintf(stderr, "%*c%s _gather_55[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_56")); } _res = NULL; done: @@ -20065,9 +20162,9 @@ _gather_64_rule(Parser *p) return _res; } -// _loop0_67: ',' pattern +// _loop0_58: ',' pattern static asdl_seq * -_loop0_67_rule(Parser *p) +_loop0_58_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20091,7 +20188,7 @@ _loop0_67_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _loop0_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; void *elem; while ( @@ -20122,7 +20219,7 @@ _loop0_67_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_67[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_58[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20135,14 +20232,14 @@ _loop0_67_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_67_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_58_type, _seq); D(p->level--); return _seq; } -// _gather_66: pattern _loop0_67 +// _gather_57: pattern _loop0_58 static asdl_seq * -_gather_66_rule(Parser *p) +_gather_57_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20151,27 +20248,27 @@ _gather_66_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // pattern _loop0_67 + { // pattern _loop0_58 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_67")); + D(fprintf(stderr, "%*c> _gather_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_58")); void *elem; asdl_seq * seq; if ( (elem = pattern_rule(p)) // pattern && - (seq = _loop0_67_rule(p)) // _loop0_67 + (seq = _loop0_58_rule(p)) // _loop0_58 ) { - D(fprintf(stderr, "%*c+ _gather_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_67")); + D(fprintf(stderr, "%*c+ _gather_57[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_58")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_66[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_67")); + D(fprintf(stderr, "%*c%s _gather_57[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_58")); } _res = NULL; done: @@ -20179,9 +20276,9 @@ _gather_66_rule(Parser *p) return _res; } -// _loop0_69: ',' (NAME '=' or_pattern) +// _loop0_60: ',' keyword_pattern static asdl_seq * -_loop0_69_rule(Parser *p) +_loop0_60_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20200,18 +20297,18 @@ _loop0_69_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' (NAME '=' or_pattern) + { // ',' keyword_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (NAME '=' or_pattern)")); + D(fprintf(stderr, "%*c> _loop0_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_164_rule(p)) // NAME '=' or_pattern + (elem = keyword_pattern_rule(p)) // keyword_pattern ) { _res = elem; @@ -20236,8 +20333,8 @@ _loop0_69_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_69[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (NAME '=' or_pattern)")); + D(fprintf(stderr, "%*c%s _loop0_60[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -20249,14 +20346,14 @@ _loop0_69_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_69_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_60_type, _seq); D(p->level--); return _seq; } -// _gather_68: (NAME '=' or_pattern) _loop0_69 +// _gather_59: keyword_pattern _loop0_60 static asdl_seq * -_gather_68_rule(Parser *p) +_gather_59_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20265,27 +20362,27 @@ _gather_68_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (NAME '=' or_pattern) _loop0_69 + { // keyword_pattern _loop0_60 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(NAME '=' or_pattern) _loop0_69")); + D(fprintf(stderr, "%*c> _gather_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_60")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_164_rule(p)) // NAME '=' or_pattern + (elem = keyword_pattern_rule(p)) // keyword_pattern && - (seq = _loop0_69_rule(p)) // _loop0_69 + (seq = _loop0_60_rule(p)) // _loop0_60 ) { - D(fprintf(stderr, "%*c+ _gather_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(NAME '=' or_pattern) _loop0_69")); + D(fprintf(stderr, "%*c+ _gather_59[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_60")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_68[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(NAME '=' or_pattern) _loop0_69")); + D(fprintf(stderr, "%*c%s _gather_59[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_60")); } _res = NULL; done: @@ -20293,9 +20390,9 @@ _gather_68_rule(Parser *p) return _res; } -// _loop0_71: ',' (NAME '=' or_pattern) +// _loop0_62: ',' value_pattern static asdl_seq * -_loop0_71_rule(Parser *p) +_loop0_62_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20314,18 +20411,18 @@ _loop0_71_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' (NAME '=' or_pattern) + { // ',' value_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (NAME '=' or_pattern)")); + D(fprintf(stderr, "%*c> _loop0_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' value_pattern")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_165_rule(p)) // NAME '=' or_pattern + (elem = value_pattern_rule(p)) // value_pattern ) { _res = elem; @@ -20350,8 +20447,8 @@ _loop0_71_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_71[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (NAME '=' or_pattern)")); + D(fprintf(stderr, "%*c%s _loop0_62[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' value_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -20363,14 +20460,14 @@ _loop0_71_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_71_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_62_type, _seq); D(p->level--); return _seq; } -// _gather_70: (NAME '=' or_pattern) _loop0_71 +// _gather_61: value_pattern _loop0_62 static asdl_seq * -_gather_70_rule(Parser *p) +_gather_61_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20379,27 +20476,27 @@ _gather_70_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (NAME '=' or_pattern) _loop0_71 + { // value_pattern _loop0_62 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(NAME '=' or_pattern) _loop0_71")); + D(fprintf(stderr, "%*c> _gather_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_62")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_165_rule(p)) // NAME '=' or_pattern + (elem = value_pattern_rule(p)) // value_pattern && - (seq = _loop0_71_rule(p)) // _loop0_71 + (seq = _loop0_62_rule(p)) // _loop0_62 ) { - D(fprintf(stderr, "%*c+ _gather_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(NAME '=' or_pattern) _loop0_71")); + D(fprintf(stderr, "%*c+ _gather_61[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_62")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_70[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(NAME '=' or_pattern) _loop0_71")); + D(fprintf(stderr, "%*c%s _gather_61[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern _loop0_62")); } _res = NULL; done: @@ -20407,9 +20504,9 @@ _gather_70_rule(Parser *p) return _res; } -// _loop0_73: ',' pattern +// _loop0_64: ',' key_value_pattern static asdl_seq * -_loop0_73_rule(Parser *p) +_loop0_64_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20428,18 +20525,18 @@ _loop0_73_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' pattern + { // ',' key_value_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _loop0_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = pattern_rule(p)) // pattern + (elem = key_value_pattern_rule(p)) // key_value_pattern ) { _res = elem; @@ -20464,8 +20561,8 @@ _loop0_73_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_73[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c%s _loop0_64[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' key_value_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -20477,14 +20574,14 @@ _loop0_73_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_73_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_64_type, _seq); D(p->level--); return _seq; } -// _gather_72: pattern _loop0_73 +// _gather_63: key_value_pattern _loop0_64 static asdl_seq * -_gather_72_rule(Parser *p) +_gather_63_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20493,27 +20590,27 @@ _gather_72_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // pattern _loop0_73 + { // key_value_pattern _loop0_64 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_73")); + D(fprintf(stderr, "%*c> _gather_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_64")); void *elem; asdl_seq * seq; if ( - (elem = pattern_rule(p)) // pattern + (elem = key_value_pattern_rule(p)) // key_value_pattern && - (seq = _loop0_73_rule(p)) // _loop0_73 + (seq = _loop0_64_rule(p)) // _loop0_64 ) { - D(fprintf(stderr, "%*c+ _gather_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_73")); + D(fprintf(stderr, "%*c+ _gather_63[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_64")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_72[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_73")); + D(fprintf(stderr, "%*c%s _gather_63[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_64")); } _res = NULL; done: @@ -20521,9 +20618,9 @@ _gather_72_rule(Parser *p) return _res; } -// _tmp_74: 'from' expression +// _tmp_65: 'from' expression static void * -_tmp_74_rule(Parser *p) +_tmp_65_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20537,7 +20634,7 @@ _tmp_74_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); + D(fprintf(stderr, "%*c> _tmp_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); Token * _keyword; expr_ty z; if ( @@ -20546,7 +20643,7 @@ _tmp_74_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_74[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); + D(fprintf(stderr, "%*c+ _tmp_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -20556,7 +20653,7 @@ _tmp_74_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_74[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_65[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression")); } _res = NULL; @@ -20565,9 +20662,9 @@ _tmp_74_rule(Parser *p) return _res; } -// _tmp_75: '->' expression +// _tmp_66: '->' expression static void * -_tmp_75_rule(Parser *p) +_tmp_66_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20581,7 +20678,7 @@ _tmp_75_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -20590,7 +20687,7 @@ _tmp_75_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_75[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -20600,7 +20697,7 @@ _tmp_75_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_75[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_66[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -20609,9 +20706,9 @@ _tmp_75_rule(Parser *p) return _res; } -// _tmp_76: '->' expression +// _tmp_67: '->' expression static void * -_tmp_76_rule(Parser *p) +_tmp_67_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20625,7 +20722,7 @@ _tmp_76_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -20634,7 +20731,7 @@ _tmp_76_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_76[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -20644,7 +20741,7 @@ _tmp_76_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_76[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_67[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -20653,9 +20750,9 @@ _tmp_76_rule(Parser *p) return _res; } -// _tmp_77: NEWLINE INDENT +// _tmp_68: NEWLINE INDENT static void * -_tmp_77_rule(Parser *p) +_tmp_68_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20669,7 +20766,7 @@ _tmp_77_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); Token * indent_var; Token * newline_var; if ( @@ -20678,12 +20775,12 @@ _tmp_77_rule(Parser *p) (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' ) { - D(fprintf(stderr, "%*c+ _tmp_77[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); _res = _PyPegen_dummy_name(p, newline_var, indent_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_77[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); } _res = NULL; @@ -20692,9 +20789,9 @@ _tmp_77_rule(Parser *p) return _res; } -// _loop0_78: param_no_default +// _loop0_69: param_no_default static asdl_seq * -_loop0_78_rule(Parser *p) +_loop0_69_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20718,7 +20815,7 @@ _loop0_78_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_69[%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 @@ -20740,7 +20837,7 @@ _loop0_78_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_78[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_69[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20753,14 +20850,14 @@ _loop0_78_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_78_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_69_type, _seq); D(p->level--); return _seq; } -// _loop0_79: param_with_default +// _loop0_70: param_with_default static asdl_seq * -_loop0_79_rule(Parser *p) +_loop0_70_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20784,7 +20881,7 @@ _loop0_79_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -20806,7 +20903,7 @@ _loop0_79_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_79[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_70[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20819,14 +20916,14 @@ _loop0_79_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_70_type, _seq); D(p->level--); return _seq; } -// _loop0_80: param_with_default +// _loop0_71: param_with_default static asdl_seq * -_loop0_80_rule(Parser *p) +_loop0_71_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20850,7 +20947,7 @@ _loop0_80_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -20872,7 +20969,7 @@ _loop0_80_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_80[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_71[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20885,14 +20982,14 @@ _loop0_80_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_80_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_71_type, _seq); D(p->level--); return _seq; } -// _loop1_81: param_no_default +// _loop1_72: param_no_default static asdl_seq * -_loop1_81_rule(Parser *p) +_loop1_72_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20916,7 +21013,7 @@ _loop1_81_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_72[%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 @@ -20938,7 +21035,7 @@ _loop1_81_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_72[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -20956,14 +21053,14 @@ _loop1_81_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_72_type, _seq); D(p->level--); return _seq; } -// _loop0_82: param_with_default +// _loop0_73: param_with_default static asdl_seq * -_loop0_82_rule(Parser *p) +_loop0_73_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20987,7 +21084,7 @@ _loop0_82_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21009,7 +21106,7 @@ _loop0_82_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_82[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_73[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21022,14 +21119,14 @@ _loop0_82_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_82_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_73_type, _seq); D(p->level--); return _seq; } -// _loop1_83: param_with_default +// _loop1_74: param_with_default static asdl_seq * -_loop1_83_rule(Parser *p) +_loop1_74_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21053,7 +21150,7 @@ _loop1_83_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21075,7 +21172,7 @@ _loop1_83_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_74[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -21093,14 +21190,14 @@ _loop1_83_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_74_type, _seq); D(p->level--); return _seq; } -// _loop1_84: param_no_default +// _loop1_75: param_no_default static asdl_seq * -_loop1_84_rule(Parser *p) +_loop1_75_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21124,7 +21221,7 @@ _loop1_84_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_75[%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 @@ -21146,7 +21243,7 @@ _loop1_84_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_75[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -21164,14 +21261,14 @@ _loop1_84_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_75_type, _seq); D(p->level--); return _seq; } -// _loop1_85: param_no_default +// _loop1_76: param_no_default static asdl_seq * -_loop1_85_rule(Parser *p) +_loop1_76_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21195,7 +21292,7 @@ _loop1_85_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_76[%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 @@ -21217,7 +21314,7 @@ _loop1_85_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_85[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_76[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -21235,14 +21332,14 @@ _loop1_85_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_85_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_76_type, _seq); D(p->level--); return _seq; } -// _loop0_86: param_no_default +// _loop0_77: param_no_default static asdl_seq * -_loop0_86_rule(Parser *p) +_loop0_77_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21266,7 +21363,7 @@ _loop0_86_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_77[%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 @@ -21288,7 +21385,7 @@ _loop0_86_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_86[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_77[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21301,14 +21398,14 @@ _loop0_86_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_86_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_77_type, _seq); D(p->level--); return _seq; } -// _loop1_87: param_with_default +// _loop1_78: param_with_default static asdl_seq * -_loop1_87_rule(Parser *p) +_loop1_78_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21332,7 +21429,7 @@ _loop1_87_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21354,7 +21451,7 @@ _loop1_87_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_78[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -21372,14 +21469,14 @@ _loop1_87_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_87_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_78_type, _seq); D(p->level--); return _seq; } -// _loop0_88: param_no_default +// _loop0_79: param_no_default static asdl_seq * -_loop0_88_rule(Parser *p) +_loop0_79_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21403,7 +21500,7 @@ _loop0_88_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_79[%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 @@ -21425,7 +21522,7 @@ _loop0_88_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_88[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_79[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21438,14 +21535,14 @@ _loop0_88_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_88_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq); D(p->level--); return _seq; } -// _loop1_89: param_with_default +// _loop1_80: param_with_default static asdl_seq * -_loop1_89_rule(Parser *p) +_loop1_80_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21469,7 +21566,7 @@ _loop1_89_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21491,7 +21588,7 @@ _loop1_89_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_80[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -21509,14 +21606,14 @@ _loop1_89_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_80_type, _seq); D(p->level--); return _seq; } -// _loop0_90: param_maybe_default +// _loop0_81: param_maybe_default static asdl_seq * -_loop0_90_rule(Parser *p) +_loop0_81_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21540,7 +21637,7 @@ _loop0_90_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -21562,7 +21659,7 @@ _loop0_90_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_90[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_81[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21575,14 +21672,14 @@ _loop0_90_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_90_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_81_type, _seq); D(p->level--); return _seq; } -// _loop1_91: param_maybe_default +// _loop1_82: param_maybe_default static asdl_seq * -_loop1_91_rule(Parser *p) +_loop1_82_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21606,7 +21703,7 @@ _loop1_91_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -21628,7 +21725,7 @@ _loop1_91_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_82[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -21646,14 +21743,14 @@ _loop1_91_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_82_type, _seq); D(p->level--); return _seq; } -// _loop1_92: ('@' named_expression NEWLINE) +// _loop1_83: ('@' named_expression NEWLINE) static asdl_seq * -_loop1_92_rule(Parser *p) +_loop1_83_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21677,13 +21774,13 @@ _loop1_92_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); - void *_tmp_166_var; + D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); + void *_tmp_154_var; while ( - (_tmp_166_var = _tmp_166_rule(p)) // '@' named_expression NEWLINE + (_tmp_154_var = _tmp_154_rule(p)) // '@' named_expression NEWLINE ) { - _res = _tmp_166_var; + _res = _tmp_154_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -21699,7 +21796,7 @@ _loop1_92_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_92[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)")); } if (_n == 0 || p->error_indicator) { @@ -21717,14 +21814,14 @@ _loop1_92_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_92_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); D(p->level--); return _seq; } -// _tmp_93: '(' arguments? ')' +// _tmp_84: '(' arguments? ')' static void * -_tmp_93_rule(Parser *p) +_tmp_84_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21738,7 +21835,7 @@ _tmp_93_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c> _tmp_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); Token * _literal; Token * _literal_1; void *z; @@ -21750,7 +21847,7 @@ _tmp_93_rule(Parser *p) (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c+ _tmp_84[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21760,7 +21857,7 @@ _tmp_93_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_84[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); } _res = NULL; @@ -21769,9 +21866,9 @@ _tmp_93_rule(Parser *p) return _res; } -// _loop0_95: ',' star_expression +// _loop0_86: ',' star_expression static asdl_seq * -_loop0_95_rule(Parser *p) +_loop0_86_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21795,7 +21892,7 @@ _loop0_95_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _loop0_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty elem; while ( @@ -21826,7 +21923,7 @@ _loop0_95_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_95[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_86[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21839,14 +21936,14 @@ _loop0_95_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_95_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_86_type, _seq); D(p->level--); return _seq; } -// _gather_94: star_expression _loop0_95 +// _gather_85: star_expression _loop0_86 static asdl_seq * -_gather_94_rule(Parser *p) +_gather_85_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21855,27 +21952,27 @@ _gather_94_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_expression _loop0_95 + { // star_expression _loop0_86 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_95")); + D(fprintf(stderr, "%*c> _gather_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_86")); expr_ty elem; asdl_seq * seq; if ( (elem = star_expression_rule(p)) // star_expression && - (seq = _loop0_95_rule(p)) // _loop0_95 + (seq = _loop0_86_rule(p)) // _loop0_86 ) { - D(fprintf(stderr, "%*c+ _gather_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_95")); + D(fprintf(stderr, "%*c+ _gather_85[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_86")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_94[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_95")); + D(fprintf(stderr, "%*c%s _gather_85[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_86")); } _res = NULL; done: @@ -21883,9 +21980,9 @@ _gather_94_rule(Parser *p) return _res; } -// _loop1_96: (',' star_expression) +// _loop1_87: (',' star_expression) static asdl_seq * -_loop1_96_rule(Parser *p) +_loop1_87_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21909,13 +22006,13 @@ _loop1_96_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); - void *_tmp_167_var; + D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); + void *_tmp_155_var; while ( - (_tmp_167_var = _tmp_167_rule(p)) // ',' star_expression + (_tmp_155_var = _tmp_155_rule(p)) // ',' star_expression ) { - _res = _tmp_167_var; + _res = _tmp_155_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -21931,7 +22028,7 @@ _loop1_96_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_96[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); } if (_n == 0 || p->error_indicator) { @@ -21949,14 +22046,14 @@ _loop1_96_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_96_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_87_type, _seq); D(p->level--); return _seq; } -// _loop0_98: ',' star_named_expression +// _loop0_89: ',' star_named_expression static asdl_seq * -_loop0_98_rule(Parser *p) +_loop0_89_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21980,7 +22077,7 @@ _loop0_98_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); + D(fprintf(stderr, "%*c> _loop0_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); Token * _literal; expr_ty elem; while ( @@ -22011,7 +22108,7 @@ _loop0_98_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_98[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_89[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22024,14 +22121,14 @@ _loop0_98_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_98_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_89_type, _seq); D(p->level--); return _seq; } -// _gather_97: star_named_expression _loop0_98 +// _gather_88: star_named_expression _loop0_89 static asdl_seq * -_gather_97_rule(Parser *p) +_gather_88_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22040,27 +22137,27 @@ _gather_97_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_named_expression _loop0_98 + { // star_named_expression _loop0_89 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_98")); + D(fprintf(stderr, "%*c> _gather_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_89")); expr_ty elem; asdl_seq * seq; if ( (elem = star_named_expression_rule(p)) // star_named_expression && - (seq = _loop0_98_rule(p)) // _loop0_98 + (seq = _loop0_89_rule(p)) // _loop0_89 ) { - D(fprintf(stderr, "%*c+ _gather_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_98")); + D(fprintf(stderr, "%*c+ _gather_88[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_89")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_97[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_98")); + D(fprintf(stderr, "%*c%s _gather_88[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_89")); } _res = NULL; done: @@ -22068,9 +22165,9 @@ _gather_97_rule(Parser *p) return _res; } -// _loop1_99: (',' expression) +// _loop1_90: (',' expression) static asdl_seq * -_loop1_99_rule(Parser *p) +_loop1_90_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22094,13 +22191,13 @@ _loop1_99_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); - void *_tmp_168_var; + D(fprintf(stderr, "%*c> _loop1_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); + void *_tmp_156_var; while ( - (_tmp_168_var = _tmp_168_rule(p)) // ',' expression + (_tmp_156_var = _tmp_156_rule(p)) // ',' expression ) { - _res = _tmp_168_var; + _res = _tmp_156_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22116,7 +22213,7 @@ _loop1_99_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_99[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_90[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); } if (_n == 0 || p->error_indicator) { @@ -22134,14 +22231,14 @@ _loop1_99_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_90_type, _seq); D(p->level--); return _seq; } -// _loop0_100: lambda_param_no_default +// _loop0_91: lambda_param_no_default static asdl_seq * -_loop0_100_rule(Parser *p) +_loop0_91_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22165,7 +22262,7 @@ _loop0_100_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_91[%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 @@ -22187,7 +22284,7 @@ _loop0_100_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_100[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_91[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22200,14 +22297,14 @@ _loop0_100_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_100_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_91_type, _seq); D(p->level--); return _seq; } -// _loop0_101: lambda_param_with_default +// _loop0_92: lambda_param_with_default static asdl_seq * -_loop0_101_rule(Parser *p) +_loop0_92_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22231,7 +22328,7 @@ _loop0_101_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22253,7 +22350,7 @@ _loop0_101_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_101[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_92[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22266,14 +22363,14 @@ _loop0_101_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_101_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_92_type, _seq); D(p->level--); return _seq; } -// _loop0_102: lambda_param_with_default +// _loop0_93: lambda_param_with_default static asdl_seq * -_loop0_102_rule(Parser *p) +_loop0_93_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22297,7 +22394,7 @@ _loop0_102_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22319,7 +22416,7 @@ _loop0_102_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_102[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_93[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22332,14 +22429,14 @@ _loop0_102_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_102_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_93_type, _seq); D(p->level--); return _seq; } -// _loop1_103: lambda_param_no_default +// _loop1_94: lambda_param_no_default static asdl_seq * -_loop1_103_rule(Parser *p) +_loop1_94_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22363,7 +22460,7 @@ _loop1_103_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_94[%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 @@ -22385,7 +22482,7 @@ _loop1_103_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_103[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_94[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -22403,14 +22500,14 @@ _loop1_103_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_103_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_94_type, _seq); D(p->level--); return _seq; } -// _loop0_104: lambda_param_with_default +// _loop0_95: lambda_param_with_default static asdl_seq * -_loop0_104_rule(Parser *p) +_loop0_95_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22434,7 +22531,7 @@ _loop0_104_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22456,7 +22553,7 @@ _loop0_104_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_104[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22469,14 +22566,14 @@ _loop0_104_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_104_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_95_type, _seq); D(p->level--); return _seq; } -// _loop1_105: lambda_param_with_default +// _loop1_96: lambda_param_with_default static asdl_seq * -_loop1_105_rule(Parser *p) +_loop1_96_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22500,7 +22597,7 @@ _loop1_105_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22522,7 +22619,7 @@ _loop1_105_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_96[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -22540,14 +22637,14 @@ _loop1_105_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_96_type, _seq); D(p->level--); return _seq; } -// _loop1_106: lambda_param_no_default +// _loop1_97: lambda_param_no_default static asdl_seq * -_loop1_106_rule(Parser *p) +_loop1_97_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22571,7 +22668,7 @@ _loop1_106_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_97[%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 @@ -22593,7 +22690,7 @@ _loop1_106_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_97[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -22611,14 +22708,14 @@ _loop1_106_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_106_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_97_type, _seq); D(p->level--); return _seq; } -// _loop1_107: lambda_param_no_default +// _loop1_98: lambda_param_no_default static asdl_seq * -_loop1_107_rule(Parser *p) +_loop1_98_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22642,7 +22739,7 @@ _loop1_107_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_98[%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 @@ -22664,7 +22761,7 @@ _loop1_107_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_107[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_98[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -22682,14 +22779,14 @@ _loop1_107_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_107_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_98_type, _seq); D(p->level--); return _seq; } -// _loop0_108: lambda_param_no_default +// _loop0_99: lambda_param_no_default static asdl_seq * -_loop0_108_rule(Parser *p) +_loop0_99_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22713,7 +22810,7 @@ _loop0_108_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_99[%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 @@ -22735,7 +22832,7 @@ _loop0_108_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_108[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_99[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22748,14 +22845,14 @@ _loop0_108_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_108_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_99_type, _seq); D(p->level--); return _seq; } -// _loop1_109: lambda_param_with_default +// _loop1_100: lambda_param_with_default static asdl_seq * -_loop1_109_rule(Parser *p) +_loop1_100_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22779,7 +22876,7 @@ _loop1_109_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22801,7 +22898,7 @@ _loop1_109_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_109[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_100[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -22819,14 +22916,14 @@ _loop1_109_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_109_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_100_type, _seq); D(p->level--); return _seq; } -// _loop0_110: lambda_param_no_default +// _loop0_101: lambda_param_no_default static asdl_seq * -_loop0_110_rule(Parser *p) +_loop0_101_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22850,7 +22947,7 @@ _loop0_110_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_101[%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 @@ -22872,7 +22969,7 @@ _loop0_110_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_110[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_101[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22885,14 +22982,14 @@ _loop0_110_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_101_type, _seq); D(p->level--); return _seq; } -// _loop1_111: lambda_param_with_default +// _loop1_102: lambda_param_with_default static asdl_seq * -_loop1_111_rule(Parser *p) +_loop1_102_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22916,7 +23013,7 @@ _loop1_111_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22938,7 +23035,7 @@ _loop1_111_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_111[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_102[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -22956,14 +23053,14 @@ _loop1_111_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_111_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_102_type, _seq); D(p->level--); return _seq; } -// _loop0_112: lambda_param_maybe_default +// _loop0_103: lambda_param_maybe_default static asdl_seq * -_loop0_112_rule(Parser *p) +_loop0_103_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22987,7 +23084,7 @@ _loop0_112_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -23009,7 +23106,7 @@ _loop0_112_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23022,14 +23119,14 @@ _loop0_112_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_103_type, _seq); D(p->level--); return _seq; } -// _loop1_113: lambda_param_maybe_default +// _loop1_104: lambda_param_maybe_default static asdl_seq * -_loop1_113_rule(Parser *p) +_loop1_104_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23053,7 +23150,7 @@ _loop1_113_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -23075,7 +23172,7 @@ _loop1_113_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_113[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_104[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -23093,14 +23190,14 @@ _loop1_113_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_113_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_104_type, _seq); D(p->level--); return _seq; } -// _loop1_114: ('or' conjunction) +// _loop1_105: ('or' conjunction) static asdl_seq * -_loop1_114_rule(Parser *p) +_loop1_105_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23124,13 +23221,13 @@ _loop1_114_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); - void *_tmp_169_var; + D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); + void *_tmp_157_var; while ( - (_tmp_169_var = _tmp_169_rule(p)) // 'or' conjunction + (_tmp_157_var = _tmp_157_rule(p)) // 'or' conjunction ) { - _res = _tmp_169_var; + _res = _tmp_157_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23146,7 +23243,7 @@ _loop1_114_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_114[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); } if (_n == 0 || p->error_indicator) { @@ -23164,14 +23261,14 @@ _loop1_114_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_114_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq); D(p->level--); return _seq; } -// _loop1_115: ('and' inversion) +// _loop1_106: ('and' inversion) static asdl_seq * -_loop1_115_rule(Parser *p) +_loop1_106_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23195,13 +23292,13 @@ _loop1_115_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); - void *_tmp_170_var; + D(fprintf(stderr, "%*c> _loop1_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); + void *_tmp_158_var; while ( - (_tmp_170_var = _tmp_170_rule(p)) // 'and' inversion + (_tmp_158_var = _tmp_158_rule(p)) // 'and' inversion ) { - _res = _tmp_170_var; + _res = _tmp_158_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23217,7 +23314,7 @@ _loop1_115_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); } if (_n == 0 || p->error_indicator) { @@ -23235,14 +23332,14 @@ _loop1_115_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_115_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_106_type, _seq); D(p->level--); return _seq; } -// _loop1_116: compare_op_bitwise_or_pair +// _loop1_107: compare_op_bitwise_or_pair static asdl_seq * -_loop1_116_rule(Parser *p) +_loop1_107_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23266,7 +23363,7 @@ _loop1_116_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); + D(fprintf(stderr, "%*c> _loop1_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); CmpopExprPair* compare_op_bitwise_or_pair_var; while ( (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair @@ -23288,7 +23385,7 @@ _loop1_116_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_116[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_107[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); } if (_n == 0 || p->error_indicator) { @@ -23306,14 +23403,14 @@ _loop1_116_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_116_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_107_type, _seq); D(p->level--); return _seq; } -// _tmp_117: '!=' +// _tmp_108: '!=' static void * -_tmp_117_rule(Parser *p) +_tmp_108_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23327,13 +23424,13 @@ _tmp_117_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c> _tmp_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); Token * tok; if ( (tok = _PyPegen_expect_token(p, 28)) // token='!=' ) { - D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c+ _tmp_108[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23343,7 +23440,7 @@ _tmp_117_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_108[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); } _res = NULL; @@ -23352,9 +23449,9 @@ _tmp_117_rule(Parser *p) return _res; } -// _loop0_119: ',' slice +// _loop0_110: ',' slice static asdl_seq * -_loop0_119_rule(Parser *p) +_loop0_110_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23378,7 +23475,7 @@ _loop0_119_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); + D(fprintf(stderr, "%*c> _loop0_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); Token * _literal; expr_ty elem; while ( @@ -23409,7 +23506,7 @@ _loop0_119_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_119[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_110[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' slice")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23422,14 +23519,14 @@ _loop0_119_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq); D(p->level--); return _seq; } -// _gather_118: slice _loop0_119 +// _gather_109: slice _loop0_110 static asdl_seq * -_gather_118_rule(Parser *p) +_gather_109_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23438,27 +23535,27 @@ _gather_118_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // slice _loop0_119 + { // slice _loop0_110 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_119")); + D(fprintf(stderr, "%*c> _gather_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_110")); expr_ty elem; asdl_seq * seq; if ( (elem = slice_rule(p)) // slice && - (seq = _loop0_119_rule(p)) // _loop0_119 + (seq = _loop0_110_rule(p)) // _loop0_110 ) { - D(fprintf(stderr, "%*c+ _gather_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_119")); + D(fprintf(stderr, "%*c+ _gather_109[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_110")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_118[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_119")); + D(fprintf(stderr, "%*c%s _gather_109[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_110")); } _res = NULL; done: @@ -23466,9 +23563,9 @@ _gather_118_rule(Parser *p) return _res; } -// _tmp_120: ':' expression? +// _tmp_111: ':' expression? static void * -_tmp_120_rule(Parser *p) +_tmp_111_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23482,7 +23579,7 @@ _tmp_120_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c> _tmp_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); Token * _literal; void *d; if ( @@ -23491,7 +23588,7 @@ _tmp_120_rule(Parser *p) (d = expression_rule(p), 1) // expression? ) { - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c+ _tmp_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); _res = d; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23501,7 +23598,7 @@ _tmp_120_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_111[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); } _res = NULL; @@ -23510,9 +23607,9 @@ _tmp_120_rule(Parser *p) return _res; } -// _tmp_121: tuple | group | genexp +// _tmp_112: tuple | group | genexp static void * -_tmp_121_rule(Parser *p) +_tmp_112_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23526,18 +23623,18 @@ _tmp_121_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c> _tmp_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); expr_ty tuple_var; if ( (tuple_var = tuple_rule(p)) // tuple ) { - D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c+ _tmp_112[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); _res = tuple_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_112[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); } { // group @@ -23545,18 +23642,18 @@ _tmp_121_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c> _tmp_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); expr_ty group_var; if ( (group_var = group_rule(p)) // group ) { - D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c+ _tmp_112[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); _res = group_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_112[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group")); } { // genexp @@ -23564,18 +23661,18 @@ _tmp_121_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c> _tmp_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); expr_ty genexp_var; if ( (genexp_var = genexp_rule(p)) // genexp ) { - D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c+ _tmp_112[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); _res = genexp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_112[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); } _res = NULL; @@ -23584,9 +23681,9 @@ _tmp_121_rule(Parser *p) return _res; } -// _tmp_122: list | listcomp +// _tmp_113: list | listcomp static void * -_tmp_122_rule(Parser *p) +_tmp_113_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23600,18 +23697,18 @@ _tmp_122_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); expr_ty list_var; if ( (list_var = list_rule(p)) // list ) { - D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); _res = list_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); } { // listcomp @@ -23619,18 +23716,18 @@ _tmp_122_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); expr_ty listcomp_var; if ( (listcomp_var = listcomp_rule(p)) // listcomp ) { - D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); _res = listcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp")); } _res = NULL; @@ -23639,9 +23736,9 @@ _tmp_122_rule(Parser *p) return _res; } -// _tmp_123: dict | set | dictcomp | setcomp +// _tmp_114: dict | set | dictcomp | setcomp static void * -_tmp_123_rule(Parser *p) +_tmp_114_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23655,18 +23752,18 @@ _tmp_123_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c> _tmp_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); expr_ty dict_var; if ( (dict_var = dict_rule(p)) // dict ) { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c+ _tmp_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); _res = dict_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_114[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict")); } { // set @@ -23674,18 +23771,18 @@ _tmp_123_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c> _tmp_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); expr_ty set_var; if ( (set_var = set_rule(p)) // set ) { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c+ _tmp_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); _res = set_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_114[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set")); } { // dictcomp @@ -23693,18 +23790,18 @@ _tmp_123_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c> _tmp_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); expr_ty dictcomp_var; if ( (dictcomp_var = dictcomp_rule(p)) // dictcomp ) { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c+ _tmp_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); _res = dictcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_114[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp")); } { // setcomp @@ -23712,18 +23809,18 @@ _tmp_123_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c> _tmp_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); expr_ty setcomp_var; if ( (setcomp_var = setcomp_rule(p)) // setcomp ) { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c+ _tmp_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); _res = setcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_114[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp")); } _res = NULL; @@ -23732,9 +23829,9 @@ _tmp_123_rule(Parser *p) return _res; } -// _loop1_124: STRING +// _loop1_115: STRING static asdl_seq * -_loop1_124_rule(Parser *p) +_loop1_115_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23758,7 +23855,7 @@ _loop1_124_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); + D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); expr_ty string_var; while ( (string_var = _PyPegen_string_token(p)) // STRING @@ -23780,7 +23877,7 @@ _loop1_124_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_124[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); } if (_n == 0 || p->error_indicator) { @@ -23798,14 +23895,14 @@ _loop1_124_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_124_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_115_type, _seq); D(p->level--); return _seq; } -// _tmp_125: star_named_expression ',' star_named_expressions? +// _tmp_116: star_named_expression ',' star_named_expressions? static void * -_tmp_125_rule(Parser *p) +_tmp_116_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23819,7 +23916,7 @@ _tmp_125_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); Token * _literal; expr_ty y; void *z; @@ -23831,7 +23928,7 @@ _tmp_125_rule(Parser *p) (z = star_named_expressions_rule(p), 1) // star_named_expressions? ) { - D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); _res = _PyPegen_seq_insert_in_front ( p , y , z ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23841,7 +23938,7 @@ _tmp_125_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); } _res = NULL; @@ -23850,9 +23947,9 @@ _tmp_125_rule(Parser *p) return _res; } -// _tmp_126: yield_expr | named_expression +// _tmp_117: yield_expr | named_expression static void * -_tmp_126_rule(Parser *p) +_tmp_117_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23866,18 +23963,18 @@ _tmp_126_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // named_expression @@ -23885,18 +23982,18 @@ _tmp_126_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); expr_ty named_expression_var; if ( (named_expression_var = named_expression_rule(p)) // named_expression ) { - D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); _res = named_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); } _res = NULL; @@ -23905,9 +24002,9 @@ _tmp_126_rule(Parser *p) return _res; } -// _loop0_128: ',' double_starred_kvpair +// _loop0_119: ',' double_starred_kvpair static asdl_seq * -_loop0_128_rule(Parser *p) +_loop0_119_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23931,7 +24028,7 @@ _loop0_128_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); + D(fprintf(stderr, "%*c> _loop0_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); Token * _literal; KeyValuePair* elem; while ( @@ -23962,7 +24059,7 @@ _loop0_128_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_128[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_119[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23975,14 +24072,14 @@ _loop0_128_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_128_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq); D(p->level--); return _seq; } -// _gather_127: double_starred_kvpair _loop0_128 +// _gather_118: double_starred_kvpair _loop0_119 static asdl_seq * -_gather_127_rule(Parser *p) +_gather_118_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23991,27 +24088,27 @@ _gather_127_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // double_starred_kvpair _loop0_128 + { // double_starred_kvpair _loop0_119 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_128")); + D(fprintf(stderr, "%*c> _gather_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_119")); KeyValuePair* elem; asdl_seq * seq; if ( (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair && - (seq = _loop0_128_rule(p)) // _loop0_128 + (seq = _loop0_119_rule(p)) // _loop0_119 ) { - D(fprintf(stderr, "%*c+ _gather_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_128")); + D(fprintf(stderr, "%*c+ _gather_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_119")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_127[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_128")); + D(fprintf(stderr, "%*c%s _gather_118[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_119")); } _res = NULL; done: @@ -24019,9 +24116,9 @@ _gather_127_rule(Parser *p) return _res; } -// _loop1_129: for_if_clause +// _loop1_120: for_if_clause static asdl_seq * -_loop1_129_rule(Parser *p) +_loop1_120_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24045,7 +24142,7 @@ _loop1_129_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); + D(fprintf(stderr, "%*c> _loop1_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); comprehension_ty for_if_clause_var; while ( (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause @@ -24067,7 +24164,7 @@ _loop1_129_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_129[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_120[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); } if (_n == 0 || p->error_indicator) { @@ -24085,14 +24182,14 @@ _loop1_129_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_129_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_120_type, _seq); D(p->level--); return _seq; } -// _loop0_130: ('if' disjunction) +// _loop0_121: ('if' disjunction) static asdl_seq * -_loop0_130_rule(Parser *p) +_loop0_121_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24116,13 +24213,13 @@ _loop0_130_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_171_var; + D(fprintf(stderr, "%*c> _loop0_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_159_var; while ( - (_tmp_171_var = _tmp_171_rule(p)) // 'if' disjunction + (_tmp_159_var = _tmp_159_rule(p)) // 'if' disjunction ) { - _res = _tmp_171_var; + _res = _tmp_159_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24138,7 +24235,7 @@ _loop0_130_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_121[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24151,14 +24248,14 @@ _loop0_130_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_121_type, _seq); D(p->level--); return _seq; } -// _loop0_131: ('if' disjunction) +// _loop0_122: ('if' disjunction) static asdl_seq * -_loop0_131_rule(Parser *p) +_loop0_122_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24182,13 +24279,13 @@ _loop0_131_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_172_var; + D(fprintf(stderr, "%*c> _loop0_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_160_var; while ( - (_tmp_172_var = _tmp_172_rule(p)) // 'if' disjunction + (_tmp_160_var = _tmp_160_rule(p)) // 'if' disjunction ) { - _res = _tmp_172_var; + _res = _tmp_160_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24204,7 +24301,7 @@ _loop0_131_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_131[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24217,14 +24314,14 @@ _loop0_131_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_131_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_122_type, _seq); D(p->level--); return _seq; } -// _tmp_132: ',' args +// _tmp_123: ',' args static void * -_tmp_132_rule(Parser *p) +_tmp_123_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24238,7 +24335,7 @@ _tmp_132_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); Token * _literal; expr_ty c; if ( @@ -24247,7 +24344,7 @@ _tmp_132_rule(Parser *p) (c = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -24257,7 +24354,7 @@ _tmp_132_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_132[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); } _res = NULL; @@ -24266,9 +24363,9 @@ _tmp_132_rule(Parser *p) return _res; } -// _tmp_133: ',' args +// _tmp_124: ',' args static void * -_tmp_133_rule(Parser *p) +_tmp_124_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24282,7 +24379,7 @@ _tmp_133_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); Token * _literal; expr_ty c; if ( @@ -24291,7 +24388,7 @@ _tmp_133_rule(Parser *p) (c = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -24301,7 +24398,7 @@ _tmp_133_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); } _res = NULL; @@ -24310,9 +24407,9 @@ _tmp_133_rule(Parser *p) return _res; } -// _loop0_135: ',' kwarg_or_starred +// _loop0_126: ',' kwarg_or_starred static asdl_seq * -_loop0_135_rule(Parser *p) +_loop0_126_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24336,7 +24433,7 @@ _loop0_135_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -24367,7 +24464,7 @@ _loop0_135_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_135[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_126[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24380,14 +24477,14 @@ _loop0_135_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_135_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_126_type, _seq); D(p->level--); return _seq; } -// _gather_134: kwarg_or_starred _loop0_135 +// _gather_125: kwarg_or_starred _loop0_126 static asdl_seq * -_gather_134_rule(Parser *p) +_gather_125_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24396,27 +24493,27 @@ _gather_134_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_135 + { // kwarg_or_starred _loop0_126 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_135")); + D(fprintf(stderr, "%*c> _gather_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_126")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_135_rule(p)) // _loop0_135 + (seq = _loop0_126_rule(p)) // _loop0_126 ) { - D(fprintf(stderr, "%*c+ _gather_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_135")); + D(fprintf(stderr, "%*c+ _gather_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_126")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_134[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_135")); + D(fprintf(stderr, "%*c%s _gather_125[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_126")); } _res = NULL; done: @@ -24424,9 +24521,9 @@ _gather_134_rule(Parser *p) return _res; } -// _loop0_137: ',' kwarg_or_double_starred +// _loop0_128: ',' kwarg_or_double_starred static asdl_seq * -_loop0_137_rule(Parser *p) +_loop0_128_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24450,7 +24547,7 @@ _loop0_137_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -24481,7 +24578,7 @@ _loop0_137_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_137[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_128[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24494,14 +24591,14 @@ _loop0_137_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_137_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_128_type, _seq); D(p->level--); return _seq; } -// _gather_136: kwarg_or_double_starred _loop0_137 +// _gather_127: kwarg_or_double_starred _loop0_128 static asdl_seq * -_gather_136_rule(Parser *p) +_gather_127_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24510,27 +24607,27 @@ _gather_136_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_137 + { // kwarg_or_double_starred _loop0_128 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_137")); + D(fprintf(stderr, "%*c> _gather_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_128")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_137_rule(p)) // _loop0_137 + (seq = _loop0_128_rule(p)) // _loop0_128 ) { - D(fprintf(stderr, "%*c+ _gather_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_137")); + D(fprintf(stderr, "%*c+ _gather_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_128")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_136[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_137")); + D(fprintf(stderr, "%*c%s _gather_127[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_128")); } _res = NULL; done: @@ -24538,9 +24635,9 @@ _gather_136_rule(Parser *p) return _res; } -// _loop0_139: ',' kwarg_or_starred +// _loop0_130: ',' kwarg_or_starred static asdl_seq * -_loop0_139_rule(Parser *p) +_loop0_130_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24564,7 +24661,7 @@ _loop0_139_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -24595,7 +24692,7 @@ _loop0_139_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_139[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24608,14 +24705,14 @@ _loop0_139_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_139_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq); D(p->level--); return _seq; } -// _gather_138: kwarg_or_starred _loop0_139 +// _gather_129: kwarg_or_starred _loop0_130 static asdl_seq * -_gather_138_rule(Parser *p) +_gather_129_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24624,27 +24721,27 @@ _gather_138_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_139 + { // kwarg_or_starred _loop0_130 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_139")); + D(fprintf(stderr, "%*c> _gather_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_130")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_139_rule(p)) // _loop0_139 + (seq = _loop0_130_rule(p)) // _loop0_130 ) { - D(fprintf(stderr, "%*c+ _gather_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_139")); + D(fprintf(stderr, "%*c+ _gather_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_130")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_138[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_139")); + D(fprintf(stderr, "%*c%s _gather_129[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_130")); } _res = NULL; done: @@ -24652,9 +24749,9 @@ _gather_138_rule(Parser *p) return _res; } -// _loop0_141: ',' kwarg_or_double_starred +// _loop0_132: ',' kwarg_or_double_starred static asdl_seq * -_loop0_141_rule(Parser *p) +_loop0_132_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24678,7 +24775,7 @@ _loop0_141_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -24709,7 +24806,7 @@ _loop0_141_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_141[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_132[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24722,14 +24819,14 @@ _loop0_141_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_141_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_132_type, _seq); D(p->level--); return _seq; } -// _gather_140: kwarg_or_double_starred _loop0_141 +// _gather_131: kwarg_or_double_starred _loop0_132 static asdl_seq * -_gather_140_rule(Parser *p) +_gather_131_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24738,27 +24835,27 @@ _gather_140_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_141 + { // kwarg_or_double_starred _loop0_132 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_141")); + D(fprintf(stderr, "%*c> _gather_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_132")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_141_rule(p)) // _loop0_141 + (seq = _loop0_132_rule(p)) // _loop0_132 ) { - D(fprintf(stderr, "%*c+ _gather_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_141")); + D(fprintf(stderr, "%*c+ _gather_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_132")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_140[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_141")); + D(fprintf(stderr, "%*c%s _gather_131[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_132")); } _res = NULL; done: @@ -24766,9 +24863,9 @@ _gather_140_rule(Parser *p) return _res; } -// _loop0_142: (',' star_target) +// _loop0_133: (',' star_target) static asdl_seq * -_loop0_142_rule(Parser *p) +_loop0_133_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24792,13 +24889,13 @@ _loop0_142_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_173_var; + D(fprintf(stderr, "%*c> _loop0_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_161_var; while ( - (_tmp_173_var = _tmp_173_rule(p)) // ',' star_target + (_tmp_161_var = _tmp_161_rule(p)) // ',' star_target ) { - _res = _tmp_173_var; + _res = _tmp_161_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24814,7 +24911,7 @@ _loop0_142_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_142[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_133[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24827,14 +24924,14 @@ _loop0_142_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_142_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_133_type, _seq); D(p->level--); return _seq; } -// _loop0_144: ',' star_target +// _loop0_135: ',' star_target static asdl_seq * -_loop0_144_rule(Parser *p) +_loop0_135_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24858,7 +24955,7 @@ _loop0_144_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _loop0_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty elem; while ( @@ -24889,7 +24986,7 @@ _loop0_144_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_144[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_135[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24902,14 +24999,14 @@ _loop0_144_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_144_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_135_type, _seq); D(p->level--); return _seq; } -// _gather_143: star_target _loop0_144 +// _gather_134: star_target _loop0_135 static asdl_seq * -_gather_143_rule(Parser *p) +_gather_134_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24918,27 +25015,27 @@ _gather_143_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_target _loop0_144 + { // star_target _loop0_135 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_144")); + D(fprintf(stderr, "%*c> _gather_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_135")); expr_ty elem; asdl_seq * seq; if ( (elem = star_target_rule(p)) // star_target && - (seq = _loop0_144_rule(p)) // _loop0_144 + (seq = _loop0_135_rule(p)) // _loop0_135 ) { - D(fprintf(stderr, "%*c+ _gather_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_144")); + D(fprintf(stderr, "%*c+ _gather_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_135")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_143[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_144")); + D(fprintf(stderr, "%*c%s _gather_134[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_135")); } _res = NULL; done: @@ -24946,9 +25043,9 @@ _gather_143_rule(Parser *p) return _res; } -// _tmp_145: !'*' star_target +// _tmp_136: !'*' star_target static void * -_tmp_145_rule(Parser *p) +_tmp_136_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24962,7 +25059,7 @@ _tmp_145_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); expr_ty star_target_var; if ( _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' @@ -24970,12 +25067,12 @@ _tmp_145_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); _res = star_target_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); } _res = NULL; @@ -24984,9 +25081,9 @@ _tmp_145_rule(Parser *p) return _res; } -// _loop0_147: ',' del_target +// _loop0_138: ',' del_target static asdl_seq * -_loop0_147_rule(Parser *p) +_loop0_138_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25010,7 +25107,7 @@ _loop0_147_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); + D(fprintf(stderr, "%*c> _loop0_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); Token * _literal; expr_ty elem; while ( @@ -25041,7 +25138,7 @@ _loop0_147_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_147[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_138[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25054,14 +25151,14 @@ _loop0_147_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_147_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_138_type, _seq); D(p->level--); return _seq; } -// _gather_146: del_target _loop0_147 +// _gather_137: del_target _loop0_138 static asdl_seq * -_gather_146_rule(Parser *p) +_gather_137_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25070,27 +25167,27 @@ _gather_146_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // del_target _loop0_147 + { // del_target _loop0_138 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_147")); + D(fprintf(stderr, "%*c> _gather_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_138")); expr_ty elem; asdl_seq * seq; if ( (elem = del_target_rule(p)) // del_target && - (seq = _loop0_147_rule(p)) // _loop0_147 + (seq = _loop0_138_rule(p)) // _loop0_138 ) { - D(fprintf(stderr, "%*c+ _gather_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_147")); + D(fprintf(stderr, "%*c+ _gather_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_138")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_146[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_147")); + D(fprintf(stderr, "%*c%s _gather_137[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_138")); } _res = NULL; done: @@ -25098,9 +25195,9 @@ _gather_146_rule(Parser *p) return _res; } -// _loop0_149: ',' target +// _loop0_140: ',' target static asdl_seq * -_loop0_149_rule(Parser *p) +_loop0_140_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25124,7 +25221,7 @@ _loop0_149_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); + D(fprintf(stderr, "%*c> _loop0_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); Token * _literal; expr_ty elem; while ( @@ -25155,7 +25252,7 @@ _loop0_149_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_149[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_140[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25168,14 +25265,14 @@ _loop0_149_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_149_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_140_type, _seq); D(p->level--); return _seq; } -// _gather_148: target _loop0_149 +// _gather_139: target _loop0_140 static asdl_seq * -_gather_148_rule(Parser *p) +_gather_139_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25184,27 +25281,27 @@ _gather_148_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // target _loop0_149 + { // target _loop0_140 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_149")); + D(fprintf(stderr, "%*c> _gather_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_140")); expr_ty elem; asdl_seq * seq; if ( (elem = target_rule(p)) // target && - (seq = _loop0_149_rule(p)) // _loop0_149 + (seq = _loop0_140_rule(p)) // _loop0_140 ) { - D(fprintf(stderr, "%*c+ _gather_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_149")); + D(fprintf(stderr, "%*c+ _gather_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_140")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_148[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_149")); + D(fprintf(stderr, "%*c%s _gather_139[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_140")); } _res = NULL; done: @@ -25212,9 +25309,9 @@ _gather_148_rule(Parser *p) return _res; } -// _tmp_150: args | expression for_if_clauses +// _tmp_141: args | expression for_if_clauses static void * -_tmp_150_rule(Parser *p) +_tmp_141_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25228,18 +25325,18 @@ _tmp_150_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); expr_ty args_var; if ( (args_var = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); _res = args_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_141[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); } { // expression for_if_clauses @@ -25247,7 +25344,7 @@ _tmp_150_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); expr_ty expression_var; asdl_seq* for_if_clauses_var; if ( @@ -25256,12 +25353,12 @@ _tmp_150_rule(Parser *p) (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses ) { - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_141[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); } _res = NULL; @@ -25270,9 +25367,9 @@ _tmp_150_rule(Parser *p) return _res; } -// _loop0_151: star_named_expressions +// _loop0_142: star_named_expressions static asdl_seq * -_loop0_151_rule(Parser *p) +_loop0_142_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25296,7 +25393,7 @@ _loop0_151_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); + D(fprintf(stderr, "%*c> _loop0_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); asdl_seq* star_named_expressions_var; while ( (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions @@ -25318,7 +25415,7 @@ _loop0_151_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_151[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_142[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25331,14 +25428,14 @@ _loop0_151_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_151_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_142_type, _seq); D(p->level--); return _seq; } -// _tmp_152: '=' annotated_rhs +// _tmp_143: '=' annotated_rhs static void * -_tmp_152_rule(Parser *p) +_tmp_143_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25352,7 +25449,7 @@ _tmp_152_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); Token * _literal; expr_ty annotated_rhs_var; if ( @@ -25361,12 +25458,12 @@ _tmp_152_rule(Parser *p) (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs ) { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); } _res = NULL; @@ -25375,9 +25472,9 @@ _tmp_152_rule(Parser *p) return _res; } -// _tmp_153: yield_expr | star_expressions +// _tmp_144: yield_expr | star_expressions static void * -_tmp_153_rule(Parser *p) +_tmp_144_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25391,18 +25488,18 @@ _tmp_153_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -25410,18 +25507,18 @@ _tmp_153_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -25430,9 +25527,9 @@ _tmp_153_rule(Parser *p) return _res; } -// _tmp_154: yield_expr | star_expressions +// _tmp_145: yield_expr | star_expressions static void * -_tmp_154_rule(Parser *p) +_tmp_145_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25446,18 +25543,18 @@ _tmp_154_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -25465,18 +25562,18 @@ _tmp_154_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -25485,9 +25582,9 @@ _tmp_154_rule(Parser *p) return _res; } -// _tmp_155: '[' | '(' | '{' +// _tmp_146: '[' | '(' | '{' static void * -_tmp_155_rule(Parser *p) +_tmp_146_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25501,18 +25598,18 @@ _tmp_155_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); } { // '(' @@ -25520,18 +25617,18 @@ _tmp_155_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' ) { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } { // '{' @@ -25539,18 +25636,18 @@ _tmp_155_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' ) { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); } _res = NULL; @@ -25559,9 +25656,9 @@ _tmp_155_rule(Parser *p) return _res; } -// _loop0_156: param_no_default +// _loop0_147: param_no_default static asdl_seq * -_loop0_156_rule(Parser *p) +_loop0_147_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25585,7 +25682,7 @@ _loop0_156_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_147[%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 @@ -25607,7 +25704,7 @@ _loop0_156_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_156[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_147[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25620,14 +25717,14 @@ _loop0_156_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_156_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_147_type, _seq); D(p->level--); return _seq; } -// _tmp_157: slash_with_default | param_with_default+ +// _tmp_148: slash_with_default | param_with_default+ static void * -_tmp_157_rule(Parser *p) +_tmp_148_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25641,18 +25738,18 @@ _tmp_157_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c> _tmp_148[%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_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c+ _tmp_148[%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_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); } { // param_with_default+ @@ -25660,18 +25757,18 @@ _tmp_157_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - asdl_seq * _loop1_174_var; + D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + asdl_seq * _loop1_162_var; if ( - (_loop1_174_var = _loop1_174_rule(p)) // param_with_default+ + (_loop1_162_var = _loop1_162_rule(p)) // param_with_default+ ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - _res = _loop1_174_var; + D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + _res = _loop1_162_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+")); } _res = NULL; @@ -25680,9 +25777,9 @@ _tmp_157_rule(Parser *p) return _res; } -// _tmp_158: ')' | ',' (')' | '**') +// _tmp_149: ')' | ',' (')' | '**') static void * -_tmp_158_rule(Parser *p) +_tmp_149_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25696,18 +25793,18 @@ _tmp_158_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // ',' (')' | '**') @@ -25715,21 +25812,21 @@ _tmp_158_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); Token * _literal; - void *_tmp_175_var; + void *_tmp_163_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_175_var = _tmp_175_rule(p)) // ')' | '**' + (_tmp_163_var = _tmp_163_rule(p)) // ')' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_175_var); + D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_163_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); } _res = NULL; @@ -25738,9 +25835,9 @@ _tmp_158_rule(Parser *p) return _res; } -// _tmp_159: ':' | ',' (':' | '**') +// _tmp_150: ':' | ',' (':' | '**') static void * -_tmp_159_rule(Parser *p) +_tmp_150_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25754,18 +25851,18 @@ _tmp_159_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // ',' (':' | '**') @@ -25773,21 +25870,21 @@ _tmp_159_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); Token * _literal; - void *_tmp_176_var; + void *_tmp_164_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_176_var = _tmp_176_rule(p)) // ':' | '**' + (_tmp_164_var = _tmp_164_rule(p)) // ':' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_176_var); + D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_164_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); } _res = NULL; @@ -25796,9 +25893,9 @@ _tmp_159_rule(Parser *p) return _res; } -// _tmp_160: star_targets '=' +// _tmp_151: star_targets '=' static void * -_tmp_160_rule(Parser *p) +_tmp_151_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25812,7 +25909,7 @@ _tmp_160_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty z; if ( @@ -25821,7 +25918,7 @@ _tmp_160_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25831,7 +25928,7 @@ _tmp_160_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -25840,9 +25937,9 @@ _tmp_160_rule(Parser *p) return _res; } -// _tmp_161: '.' | '...' +// _tmp_152: '.' | '...' static void * -_tmp_161_rule(Parser *p) +_tmp_152_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25856,18 +25953,18 @@ _tmp_161_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -25875,18 +25972,18 @@ _tmp_161_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -25895,9 +25992,9 @@ _tmp_161_rule(Parser *p) return _res; } -// _tmp_162: '.' | '...' +// _tmp_153: '.' | '...' static void * -_tmp_162_rule(Parser *p) +_tmp_153_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25911,18 +26008,18 @@ _tmp_162_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -25930,18 +26027,18 @@ _tmp_162_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -25950,135 +26047,9 @@ _tmp_162_rule(Parser *p) return _res; } -// _tmp_163: key_pattern ':' closed_pattern +// _tmp_154: '@' named_expression NEWLINE static void * -_tmp_163_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // key_pattern ':' closed_pattern - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_pattern ':' closed_pattern")); - Token * _literal; - void *closed_pattern_var; - void *key_pattern_var; - if ( - (key_pattern_var = key_pattern_rule(p)) // key_pattern - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (closed_pattern_var = closed_pattern_rule(p)) // closed_pattern - ) - { - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_pattern ':' closed_pattern")); - _res = _PyPegen_dummy_name(p, key_pattern_var, _literal, closed_pattern_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_pattern ':' closed_pattern")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_164: NAME '=' or_pattern -static void * -_tmp_164_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // NAME '=' or_pattern - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' or_pattern")); - Token * _literal; - expr_ty name_var; - void *or_pattern_var; - if ( - (name_var = _PyPegen_name_token(p)) // NAME - && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - && - (or_pattern_var = or_pattern_rule(p)) // or_pattern - ) - { - D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' or_pattern")); - _res = _PyPegen_dummy_name(p, name_var, _literal, or_pattern_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' or_pattern")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_165: NAME '=' or_pattern -static void * -_tmp_165_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // NAME '=' or_pattern - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' or_pattern")); - Token * _literal; - expr_ty name_var; - void *or_pattern_var; - if ( - (name_var = _PyPegen_name_token(p)) // NAME - && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - && - (or_pattern_var = or_pattern_rule(p)) // or_pattern - ) - { - D(fprintf(stderr, "%*c+ _tmp_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' or_pattern")); - _res = _PyPegen_dummy_name(p, name_var, _literal, or_pattern_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_165[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' or_pattern")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_166: '@' named_expression NEWLINE -static void * -_tmp_166_rule(Parser *p) +_tmp_154_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26092,7 +26063,7 @@ _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, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); Token * _literal; expr_ty f; Token * newline_var; @@ -26104,7 +26075,7 @@ _tmp_166_rule(Parser *p) (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); _res = f; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26114,7 +26085,7 @@ _tmp_166_rule(Parser *p) 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_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); } _res = NULL; @@ -26123,9 +26094,9 @@ _tmp_166_rule(Parser *p) return _res; } -// _tmp_167: ',' star_expression +// _tmp_155: ',' star_expression static void * -_tmp_167_rule(Parser *p) +_tmp_155_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26139,7 +26110,7 @@ _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, "',' star_expression")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty c; if ( @@ -26148,7 +26119,7 @@ _tmp_167_rule(Parser *p) (c = star_expression_rule(p)) // star_expression ) { - D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26158,7 +26129,7 @@ _tmp_167_rule(Parser *p) 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_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } _res = NULL; @@ -26167,9 +26138,9 @@ _tmp_167_rule(Parser *p) return _res; } -// _tmp_168: ',' expression +// _tmp_156: ',' expression static void * -_tmp_168_rule(Parser *p) +_tmp_156_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26183,7 +26154,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, "',' expression")); + D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty c; if ( @@ -26192,7 +26163,7 @@ _tmp_168_rule(Parser *p) (c = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26202,7 +26173,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_156[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } _res = NULL; @@ -26211,9 +26182,9 @@ _tmp_168_rule(Parser *p) return _res; } -// _tmp_169: 'or' conjunction +// _tmp_157: 'or' conjunction static void * -_tmp_169_rule(Parser *p) +_tmp_157_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26227,7 +26198,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, "'or' conjunction")); + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); Token * _keyword; expr_ty c; if ( @@ -26236,7 +26207,7 @@ _tmp_169_rule(Parser *p) (c = conjunction_rule(p)) // conjunction ) { - D(fprintf(stderr, "%*c+ _tmp_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26246,7 +26217,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_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); } _res = NULL; @@ -26255,9 +26226,9 @@ _tmp_169_rule(Parser *p) return _res; } -// _tmp_170: 'and' inversion +// _tmp_158: 'and' inversion static void * -_tmp_170_rule(Parser *p) +_tmp_158_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26271,7 +26242,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, "'and' inversion")); + D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); Token * _keyword; expr_ty c; if ( @@ -26280,7 +26251,7 @@ _tmp_170_rule(Parser *p) (c = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26290,7 +26261,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_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); } _res = NULL; @@ -26299,9 +26270,9 @@ _tmp_170_rule(Parser *p) return _res; } -// _tmp_171: 'if' disjunction +// _tmp_159: 'if' disjunction static void * -_tmp_171_rule(Parser *p) +_tmp_159_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26315,7 +26286,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, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -26324,7 +26295,7 @@ _tmp_171_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26334,7 +26305,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_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -26343,9 +26314,9 @@ _tmp_171_rule(Parser *p) return _res; } -// _tmp_172: 'if' disjunction +// _tmp_160: 'if' disjunction static void * -_tmp_172_rule(Parser *p) +_tmp_160_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26359,7 +26330,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, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -26368,7 +26339,7 @@ _tmp_172_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26378,7 +26349,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_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -26387,9 +26358,9 @@ _tmp_172_rule(Parser *p) return _res; } -// _tmp_173: ',' star_target +// _tmp_161: ',' star_target static void * -_tmp_173_rule(Parser *p) +_tmp_161_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26403,7 +26374,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, "',' star_target")); + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty c; if ( @@ -26412,7 +26383,7 @@ _tmp_173_rule(Parser *p) (c = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26422,7 +26393,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_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } _res = NULL; @@ -26431,9 +26402,9 @@ _tmp_173_rule(Parser *p) return _res; } -// _loop1_174: param_with_default +// _loop1_162: param_with_default static asdl_seq * -_loop1_174_rule(Parser *p) +_loop1_162_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26457,7 +26428,7 @@ _loop1_174_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -26479,7 +26450,7 @@ _loop1_174_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_174[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_162[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -26497,14 +26468,14 @@ _loop1_174_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_174_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_162_type, _seq); D(p->level--); return _seq; } -// _tmp_175: ')' | '**' +// _tmp_163: ')' | '**' static void * -_tmp_175_rule(Parser *p) +_tmp_163_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26518,18 +26489,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, "')'")); + D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; 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_163[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // '**' @@ -26537,18 +26508,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, "'**'")); + D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; 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_163[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -26557,9 +26528,9 @@ _tmp_175_rule(Parser *p) return _res; } -// _tmp_176: ':' | '**' +// _tmp_164: ':' | '**' static void * -_tmp_176_rule(Parser *p) +_tmp_164_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26573,18 +26544,18 @@ _tmp_176_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // '**' @@ -26592,18 +26563,18 @@ _tmp_176_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; diff --git a/Python/ast.c b/Python/ast.c index 7d06aeed048c9d..c50ee38f21fda7 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -311,14 +311,25 @@ validate_pattern(expr_ty p) switch (p->kind) { case Attribute_kind: return validate_expr(p, Load); - case BinOp_kind: - if (p->v.BinOp.op != BitOr) { + case BoolOp_kind: + if (p->v.BoolOp.op != Or) { + PyErr_SetString(PyExc_ValueError, + "BoolOp op in pattern must be Or"); + return 0; + } + values = p->v.BoolOp.values; + size = asdl_seq_LEN(values); + if (size < 2) { PyErr_SetString(PyExc_ValueError, - "BinOp op in pattern must be BitOr"); + "BoolOp must have at least two values"); return 0; } - return (validate_pattern(p->v.BinOp.left) - && validate_pattern(p->v.BinOp.right)); + for (i = 0; i < size; i++) { + if (!validate_pattern(asdl_seq_GET(values, i))) { + return 0; + } + } + return 1; case Constant_kind: return validate_expr(p, Load); case Dict_kind: diff --git a/Python/compile.c b/Python/compile.c index 4075451d5bdc5c..dfb9ff91174644 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -983,6 +983,8 @@ stack_effect(int opcode, int oparg, int jump) /* -1 at end of iterator, 1 if continue iterating. */ return jump > 0 ? -1 : 1; case MATCH_KEY: + case MATCH_MAP: + case MATCH_SEQ: return -(jump > 0); case STORE_ATTR: From 77fc89dcf4aa73bda80e919e50764213af63d230 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 31 May 2020 00:16:45 -0700 Subject: [PATCH 044/189] Fix failing tests --- Lib/ast.py | 34 ++++++++++++++++++++++++++++++++++ Lib/test/test_descrtut.py | 1 + Lib/test/test_pydoc.py | 4 +++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Lib/ast.py b/Lib/ast.py index 6a5b39e270b9b5..53bc9449d15c3b 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -659,6 +659,7 @@ def __init__(self): self._precedences = {} self._type_ignores = {} self._indent = 0 + self._pattern = False def interleave(self, inter, f, seq): """Call f on each item in seq, calling inter() in between.""" @@ -720,6 +721,17 @@ def block(self, *, extra = None): yield self._indent -= 1 + @contextmanager + def pattern(self): + assert not self._pattern + self._pattern = True + yield + assert self._pattern + self._pattern = False + + def in_pattern(self): + return self._pattern + @contextmanager def delimit(self, start, end): """A context manager for preparing the source for expressions. It adds @@ -1320,6 +1332,11 @@ def visit_Compare(self, node): boolop_precedence = {"and": _Precedence.AND, "or": _Precedence.OR} def visit_BoolOp(self, node): + + if self.in_pattern(): + self.interleave(lambda: self.write(" | "), self.traverse, node.values) + return + operator = self.boolops[node.op.__class__.__name__] operator_precedence = self.boolop_precedence[operator] @@ -1399,6 +1416,13 @@ def visit_Slice(self, node): self.write(":") self.traverse(node.step) + def visit_Match(self, node): + self.fill("match ") + self.traverse(node.target) + with self.block(): + for case in node.cases: + self.traverse(case) + def visit_arg(self, node): self.write(node.arg) if node.annotation: @@ -1483,6 +1507,16 @@ def visit_withitem(self, node): self.write(" as ") self.traverse(node.optional_vars) + def visit_match_case(self, node): + self.fill("case ") + with self.pattern(): + self.traverse(node.pattern) + if node.guard: + self.write(" if ") + self.traverse(node.guard) + with self.block(): + self.traverse(node.body) + def unparse(ast_obj): unparser = _Unparser() return unparser.visit(ast_obj) diff --git a/Lib/test/test_descrtut.py b/Lib/test/test_descrtut.py index 8e25f58d7aa20e..f4567880955315 100644 --- a/Lib/test/test_descrtut.py +++ b/Lib/test/test_descrtut.py @@ -188,6 +188,7 @@ def merge(self, other): '__le__', '__len__', '__lt__', + '__match__', '__mul__', '__ne__', '__new__', diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index ffabb7f1b94072..8c8537f2d536ca 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -772,9 +772,11 @@ def method_returning_true(self): del expected['__doc__'] del expected['__class__'] # inspect resolves descriptors on type into methods, but vars doesn't, - # so we need to update __subclasshook__ and __init_subclass__. + # so we need to update __subclasshook__, __init_subclass__ and + # __match__. expected['__subclasshook__'] = TestClass.__subclasshook__ expected['__init_subclass__'] = TestClass.__init_subclass__ + expected['__match__'] = TestClass.__match__ methods = pydoc.allmethods(TestClass) self.assertDictEqual(methods, expected) From bad2fe2ef4a426cd81159abd92684d7cc7f953e7 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 31 May 2020 12:14:30 -0700 Subject: [PATCH 045/189] Add MATCH_TYPE opcode --- Doc/library/dis.rst | 29 ++++++++++++++------- Include/opcode.h | 5 ++-- Lib/importlib/_bootstrap_external.py | 4 +-- Lib/opcode.py | 5 ++-- Python/ceval.c | 39 ++++++++++++++++++++++++++++ Python/compile.c | 6 ++++- Python/importlib_external.h | 2 +- Python/opcode_targets.h | 6 ++--- 8 files changed, 75 insertions(+), 21 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index c64ea76c4ad7fd..ce12b7a2fdb2d1 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -990,13 +990,11 @@ All of the following opcodes use their arguments. code counter is incremented by *delta*. -.. opcode:: MATCH_SEQ (delta) +.. opcode:: MATCH_KEY (delta) - Pop TOS. If it is an instance of :class:`collections.abc.Sequence`, is not - an :term:`iterator`, and is not an instance of - :class:`str`/:class:`bytes`/:class:`bytearray`, get an iterator from it and - push that onto the stack. Otherwise, increment the bytecode counter by - ``delta``. + Pop TOS. If it is a key in the :class:`dict` at TOS1, remove it and push the + associated value onto the stack. Otherwise, increment the bytecode counter + by ``delta``. .. versionadded:: 3.10 @@ -1010,11 +1008,22 @@ All of the following opcodes use their arguments. .. versionadded:: 3.10 -.. opcode:: MATCH_KEY (delta) +.. opcode:: MATCH_SEQ (delta) - Pop TOS. If it is a key in the :class:`dict` at TOS1, remove it and push the - associated value onto the stack. Otherwise, increment the bytecode counter - by ``delta``. + Pop TOS. If it is an instance of :class:`collections.abc.Sequence`, is not + an :term:`iterator`, and is not an instance of + :class:`str`/:class:`bytes`/:class:`bytearray`, get an iterator from it and + push that onto the stack. Otherwise, increment the bytecode counter by + ``delta``. + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_TYPE (delta) + + Pop TOS and TOS1. If TOS is an instance of :class:`type` and has a + ``__match__`` method, call it on TOS1 and push the result onto the stack if + it is not ``None``. Otherwise, increment the bytecode counter by ``delta``. .. versionadded:: 3.10 diff --git a/Include/opcode.h b/Include/opcode.h index 6cff79517cccb7..00e68040f2ae4e 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -127,9 +127,10 @@ extern "C" { #define SET_UPDATE 163 #define DICT_MERGE 164 #define DICT_UPDATE 165 -#define MATCH_SEQ 166 +#define MATCH_KEY 166 #define MATCH_MAP 167 -#define MATCH_KEY 168 +#define MATCH_SEQ 168 +#define MATCH_TYPE 169 /* EXCEPT_HANDLER is a special, implicit block type which is created when entering an except handler. It is not an opcode but we define it here diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index eb3100b41dae4d..635e62ddaeb01b 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3438 (add MATCH_KEY, MATCH_MAP, MATCH_SEQ) +# Python 3.10a0 3439 (add MATCH_KEY, MATCH_MAP, MATCH_SEQ, MATCH_TYPE) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3438).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3439).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index 67f0e3149aaf18..37a6ed4be6776b 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -213,8 +213,9 @@ def jabs_op(name, op): def_op('SET_UPDATE', 163) def_op('DICT_MERGE', 164) def_op('DICT_UPDATE', 165) -jrel_op('MATCH_SEQ', 166) +jrel_op('MATCH_KEY', 166) jrel_op('MATCH_MAP', 167) -jrel_op('MATCH_KEY', 168) +jrel_op('MATCH_SEQ', 168) +jrel_op('MATCH_TYPE', 169) del def_op, name_op, jrel_op, jabs_op diff --git a/Python/ceval.c b/Python/ceval.c index a386b3b3671eb3..0fdd68e2422cd8 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3410,6 +3410,45 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } + case TARGET(MATCH_TYPE): { + PyObject *type = TOP(); + PyObject *target = SECOND(); + if (!PyType_Check(type)) { + _PyErr_Format(tstate, PyExc_TypeError, + "called match pattern must be a type; " + "did you mean '%s'?", Py_TYPE(type)->tp_name); + goto error; + } + PyObject *method = PyObject_GetAttrString(type, "__match__"); + if (method == Py_None) { + Py_DECREF(method); + _PyErr_Format(tstate, PyExc_TypeError, + "type '%s' cannot be matched", + Py_TYPE(type)->tp_name); + goto error; + } + PyObject *match = PyObject_CallOneArg(method, target); + Py_DECREF(method); + if (!match) { + goto error; + } + if (match == Py_None) { + Py_DECREF(match); + STACK_SHRINK(2); + Py_DECREF(type); + Py_DECREF(target); + JUMPBY(oparg); + DISPATCH(); + } + STACK_SHRINK(1); + Py_DECREF(type); + Py_DECREF(target); + SET_TOP(match); + DISPATCH(); + } + + + case TARGET(GET_ITER): { /* before: [obj]; after [getiter(obj)] */ PyObject *iterable = TOP(); diff --git a/Python/compile.c b/Python/compile.c index dfb9ff91174644..b9061f81e07446 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -985,7 +985,9 @@ stack_effect(int opcode, int oparg, int jump) case MATCH_KEY: case MATCH_MAP: case MATCH_SEQ: - return -(jump > 0); + return jump > 0 ? -1 : 0; + case MATCH_TYPE: + return jump > 0 ? -2 : 0; case STORE_ATTR: return -2; @@ -2901,6 +2903,8 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail) CHECK(compiler_pattern_store(c, value->v.Starred.value)); if (size - i - 1) { ADDOP_I(c, BUILD_TUPLE, size - i - 1); + // Argh, our tuple is backwards! Unpacking and rebuilding is the + // simplest way to reverse it: ADDOP_I(c, UNPACK_SEQUENCE, size - i - 1); ADDOP_I(c, BUILD_TUPLE, size - i - 1); ADDOP_JREL(c, MATCH_SEQ, fail); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index ea266c93abde41..120adff2d1d04e 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,110,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,111,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 955fa3bf1668c7..785515709378b6 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -165,10 +165,10 @@ static void *opcode_targets[256] = { &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, - &&TARGET_MATCH_SEQ, - &&TARGET_MATCH_MAP, &&TARGET_MATCH_KEY, - &&_unknown_opcode, + &&TARGET_MATCH_MAP, + &&TARGET_MATCH_SEQ, + &&TARGET_MATCH_TYPE, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From 2924d2f5f47063977a8e2e55e43f2d9bc44b6990 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 31 May 2020 15:17:05 -0700 Subject: [PATCH 046/189] Fix parsing/unparsing of name contexts --- Grammar/python.gram | 2 +- Lib/ast.py | 9 +++++++-- Lib/test/test_patma.py | 25 +++++++++++++++++++++++++ Parser/pegen/parse.c | 40 ++++++++++++++++++++-------------------- 4 files changed, 53 insertions(+), 23 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index ef69ad240bdddd..3150129479ad10 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -258,9 +258,9 @@ class_pattern: _Py_Call(func, args, keywords, EXTRA) } name_or_attr: + | NAME | value=name_or_attr '.' attr=NAME { _Py_Attribute(value, attr->v.Name.id, Load, EXTRA) } - | NAME values_pattern: | values=','.value_pattern+ [','] { values } diff --git a/Lib/ast.py b/Lib/ast.py index 53bc9449d15c3b..658323bf194483 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -1106,6 +1106,8 @@ def _fstring_FormattedValue(self, node, write): write("}") def visit_Name(self, node): + if self.in_pattern() and isinstance(node.ctx, Load): + self.write(".") self.write(node.id) def _write_docstring(self, node): @@ -1351,8 +1353,11 @@ def increasing_level_traverse(node): self.interleave(lambda: self.write(s), increasing_level_traverse, node.values) def visit_Attribute(self, node): - self.set_precedence(_Precedence.ATOM, node.value) - self.traverse(node.value) + if self.in_pattern() and isinstance(node.value, Name): + self.write(node.value.id) + else: + self.set_precedence(_Precedence.ATOM, node.value) + self.traverse(node.value) # Special case: 3.__abs__() is a syntax error, so if node.value # is an integer literal then we need to either parenthesize # it or add an extra space to get 3 .__abs__(). diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 2c1c6fa879379e..e22d37a12fb7fd 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -602,6 +602,31 @@ def test_grammar_07(self) -> None: x = True self.assertEqual(x, False) + def test_name_context_00(self) -> None: + x = 0 + y = 1 + match x: + case z := .y: + pass + self.assertEqual(x, 0) + self.assertEqual(y, 1) + with self.assertRaises(NameError): + z + + def test_name_context_01(self) -> None: + class A: + B = 0 + match 0: + case x if x: + z = 0 + case y := .x if y: + z = 1 + case A.B: + z = 2 + self.assertEqual(A.B, 0) + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertEqual(z, 2) if __name__ == "__main__": # XXX: For quick test debugging... import dis diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index 5cdfc10302903d..5cdb7e135dc885 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -5798,7 +5798,7 @@ class_pattern_rule(Parser *p) } // Left-recursive -// name_or_attr: name_or_attr '.' NAME | NAME +// name_or_attr: NAME | name_or_attr '.' NAME static void * name_or_attr_raw(Parser *); static void * name_or_attr_rule(Parser *p) @@ -5847,6 +5847,25 @@ name_or_attr_raw(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro + { // NAME + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); + expr_ty name_var; + if ( + (name_var = _PyPegen_name_token(p)) // NAME + ) + { + D(fprintf(stderr, "%*c+ name_or_attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); + _res = name_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); + } { // name_or_attr '.' NAME if (p->error_indicator) { D(p->level--); @@ -5886,25 +5905,6 @@ name_or_attr_raw(Parser *p) D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '.' NAME")); } - { // NAME - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); - expr_ty name_var; - if ( - (name_var = _PyPegen_name_token(p)) // NAME - ) - { - D(fprintf(stderr, "%*c+ name_or_attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); - _res = name_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); - } _res = NULL; done: D(p->level--); From 66852e9566b854d71d5c00d33461d1ba05871d0b Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 31 May 2020 17:15:04 -0700 Subject: [PATCH 047/189] Clean up grammar --- Grammar/python.gram | 14 ++--- Lib/test/test_patma.py | 138 +++++++++++++++++++++++++++++++++-------- Parser/pegen/parse.c | 12 ++-- Python/ast.c | 3 +- Python/compile.c | 5 +- 5 files changed, 127 insertions(+), 45 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 3150129479ad10..f5601bf30478f8 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -196,7 +196,7 @@ match_stmt[stmt_ty]: | "match" target=expression ':' NEWLINE INDENT cases=case_block+ DEDENT { _Py_Match(target, cases, EXTRA) } case_block: - | "case" pattern=pattern guard=[guard] ':' body=block { + | "case" pattern=pattern guard=guard? ':' body=block { _Py_match_case(pattern, guard, body, p->arena) } pattern: @@ -242,7 +242,7 @@ group_pattern: | '(' pattern=pattern ')' { pattern } sequence_pattern: - | '[' values=values_pattern ']' { + | '[' values=values_pattern? ']' { _Py_List(values, Load, EXTRA) } mapping_pattern: | '{' items=items_pattern '}' { @@ -250,11 +250,11 @@ mapping_pattern: class_pattern: | func=name_or_attr '(' ')' { _Py_Call(func, NULL, NULL, EXTRA) } - | func=name_or_attr '(' args=','.pattern+ [','] ')' { + | func=name_or_attr '(' args=','.pattern+ ','? ')' { _Py_Call(func, args, NULL, EXTRA) } - | func=name_or_attr '(' keywords=','.keyword_pattern+ [','] ')' { + | func=name_or_attr '(' keywords=','.keyword_pattern+ ','? ')' { _Py_Call(func, NULL, keywords, EXTRA) } - | func=name_or_attr '(' args=','.pattern+ ',' keywords=','.keyword_pattern+ [','] ')' { + | func=name_or_attr '(' args=','.pattern+ ',' keywords=','.keyword_pattern+ ','? ')' { _Py_Call(func, args, keywords, EXTRA) } name_or_attr: @@ -262,10 +262,10 @@ name_or_attr: | value=name_or_attr '.' attr=NAME { _Py_Attribute(value, attr->v.Name.id, Load, EXTRA) } values_pattern: - | values=','.value_pattern+ [','] { + | values=','.value_pattern+ ','? { values } items_pattern: - | items=','.key_value_pattern+ [','] { + | items=','.key_value_pattern+ ','? { items } keyword_pattern: | arg=NAME '=' value=or_pattern { diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index e22d37a12fb7fd..806a19abb50445 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -269,7 +269,7 @@ def test_pipe_07(self) -> None: self.assertNotIn("z", namespace) def test_sequence_00(self) -> None: - match_cases = [MatchCase("()", "y = 0")] + match_cases = [MatchCase("[]", "y = 0")] namespace = self.execute_match("x = ()", "x", match_cases, "") self.assertEqual(namespace.get("x"), ()) self.assertEqual(namespace.get("y"), 0) @@ -293,27 +293,27 @@ def test_sequence_03(self) -> None: self.assertEqual(namespace.get("y"), 0) def test_sequence_04(self) -> None: - match_cases = [MatchCase("(0, 1) or (1, 0)", "y = 0")] + match_cases = [MatchCase("[0, 1] or [1, 0]", "y = 0")] namespace = self.execute_match("x = [0, 1]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [0, 1]) self.assertEqual(namespace.get("y"), 0) def test_sequence_05(self) -> None: - match_cases = [MatchCase("(0, 1) or (1, 0)", "y = 0")] + match_cases = [MatchCase("[0, 1] or [1, 0]", "y = 0")] namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [1, 0]) self.assertEqual(namespace.get("y"), 0) def test_sequence_06(self) -> None: - match_cases = [MatchCase("(0, 1) or (1, 0)", "y = 0")] + match_cases = [MatchCase("[0, 1] or [1, 0]", "y = 0")] namespace = self.execute_match("x = [0, 0]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [0, 0]) self.assertNotIn("y", namespace) def test_sequence_07(self) -> None: match_cases = [ - MatchCase("(w := 0,)", "y = 0"), - MatchCase("[] or (1, z := (0 or 1)) or []", "y = 1"), + MatchCase("[w := 0,]", "y = 0"), + MatchCase("[] or [1, z := (0 or 1)] or []", "y = 1"), ] namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") self.assertNotIn("w", namespace) @@ -323,9 +323,9 @@ def test_sequence_07(self) -> None: def test_sequence_08(self) -> None: match_cases = [ - MatchCase("(0,)", "y = 0"), - MatchCase("(1, 0)", "y = 1", "(x := x[:0])"), - MatchCase("(1, 0)", "y = 2"), + MatchCase("[0,]", "y = 0"), + MatchCase("[1, 0]", "y = 1", "(x := x[:0])"), + MatchCase("[1, 0]", "y = 2"), ] namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") self.assertEqual(namespace.get("x"), []) @@ -338,7 +338,7 @@ def test_sequence_09(self) -> None: self.assertNotIn("y", namespace) def test_sequence_10(self) -> None: - match_cases = [MatchCase("()", "y = 0")] + match_cases = [MatchCase("[]", "y = 0")] namespace = self.execute_match("x = set()", "x", match_cases, "") self.assertEqual(namespace.get("x"), set()) self.assertNotIn("y", namespace) @@ -356,7 +356,7 @@ def test_sequence_12(self) -> None: self.assertNotIn("y", namespace) def test_sequence_13(self) -> None: - match_cases = [MatchCase("(0, 1)", "y = 0")] + match_cases = [MatchCase("[0, 1]", "y = 0")] namespace = self.execute_match("x = {0: False, 1: True}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0: False, 1: True}) self.assertNotIn("y", namespace) @@ -463,8 +463,8 @@ def test_mapping_06(self) -> None: def test_mapping_07(self) -> None: match_cases = [ MatchCase("{0: [1, 2, {}]}", "y = 0"), - MatchCase("{0: [1, 2, {}], 1: [()]}", "y = 1"), - MatchCase("()", "y = 2"), + MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), + MatchCase("[]", "y = 2"), ] namespace = self.execute_match("x = {}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {}) @@ -473,8 +473,8 @@ def test_mapping_07(self) -> None: def test_mapping_08(self) -> None: match_cases = [ MatchCase("{0: [1, 2, {}]}", "y = 0"), - MatchCase("{0: [1, 2, {}], 1: [()]}", "y = 1"), - MatchCase("()", "y = 2"), + MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), + MatchCase("[]", "y = 2"), ] namespace = self.execute_match( "x = {False: (True, 2.0, {})}", "x", match_cases, "" @@ -485,8 +485,8 @@ def test_mapping_08(self) -> None: def test_mapping_09(self) -> None: match_cases = [ MatchCase("{0: [1, 2, {}]}", "y = 0"), - MatchCase("{0: [1, 2, {}], 1: [()]}", "y = 1"), - MatchCase("()", "y = 2"), + MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), + MatchCase("[]", "y = 2"), ] namespace = self.execute_match( "x = {False: (True, 2.0, {}), 1: [[]], 2: 0}", "x", match_cases, "" @@ -497,8 +497,8 @@ def test_mapping_09(self) -> None: def test_mapping_10(self) -> None: match_cases = [ MatchCase("{0: [1, 2]}", "y = 0"), - MatchCase("{0: [1, 2, {}], 1: [()]}", "y = 1"), - MatchCase("()", "y = 2"), + MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), + MatchCase("[]", "y = 2"), ] namespace = self.execute_match( "x = {False: (True, 2.0, {}), 1: [[]], 2: 0}", "x", match_cases, "" @@ -509,8 +509,8 @@ def test_mapping_10(self) -> None: def test_mapping_11(self) -> None: match_cases = [ MatchCase("{0: [1, 2, {}]}", "y = 0"), - MatchCase("{0: [1, 2, {}], 1: [()]}", "y = 1"), - MatchCase("()", "y = 2"), + MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), + MatchCase("[]", "y = 2"), ] namespace = self.execute_match("x = []", "x", match_cases, "") self.assertEqual(namespace.get("x"), []) @@ -520,10 +520,10 @@ def test_mapping_12(self) -> None: match_cases = [ MatchCase("{0: [1, 2, {}]}", "y = 0"), MatchCase( - "{0: [1, 2, {}] or False} or {1: [()]} or {0: [1, 2, {}]} or [] or 'X' or {}", + "{0: [1, 2, {}] or False} or {1: [[]]} or {0: [1, 2, {}]} or [] or 'X' or {}", "y = 1", ), - MatchCase("()", "y = 2"), + MatchCase("[]", "y = 2"), ] namespace = self.execute_match("x = {0: 0}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0: 0}) @@ -533,10 +533,10 @@ def test_mapping_13(self) -> None: match_cases = [ MatchCase("{0: [1, 2, {}]}", "y = 0"), MatchCase( - "{0: [1, 2, {}] or True} or {1: [()]} or {0: [1, 2, {}]} or [] or 'X' or {}", + "{0: [1, 2, {}] or True} or {1: [[]]} or {0: [1, 2, {}]} or [] or 'X' or {}", "y = 1", ), - MatchCase("()", "y = 2"), + MatchCase("[]", "y = 2"), ] namespace = self.execute_match("x = {0: 0}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0: 0}) @@ -602,7 +602,7 @@ def test_grammar_07(self) -> None: x = True self.assertEqual(x, False) - def test_name_context_00(self) -> None: + def test_grammar_08(self) -> None: x = 0 y = 1 match x: @@ -613,7 +613,7 @@ def test_name_context_00(self) -> None: with self.assertRaises(NameError): z - def test_name_context_01(self) -> None: + def test_grammar_09(self) -> None: class A: B = 0 match 0: @@ -628,6 +628,90 @@ class A: self.assertEqual(y, 0) self.assertEqual(z, 2) + def test_grammar_10(self) -> None: + match (): + case []: + x = 0 + self.assertEqual(x, 0) + + def test_grammar_11(self) -> None: + match (0, 1, 2): + case [*x]: + y = 0 + self.assertEqual(x, [0, 1, 2]) + self.assertEqual(y, 0) + + def test_grammar_12(self) -> None: + match (0, 1, 2): + case [0, *x]: + y = 0 + self.assertEqual(x, [1, 2]) + self.assertEqual(y, 0) + + def test_grammar_13(self) -> None: + match (0, 1, 2): + case [0, 1, *x,]: + y = 0 + self.assertEqual(x, [2]) + self.assertEqual(y, 0) + + def test_grammar_14(self) -> None: + match (0, 1, 2): + case [0, 1, 2, *x]: + y = 0 + self.assertEqual(x, []) + self.assertEqual(y, 0) + + def test_grammar_15(self) -> None: + match (0, 1, 2): + case [*x, 2,]: + y = 0 + self.assertEqual(x, [0, 1]) + self.assertEqual(y, 0) + + def test_grammar_16(self) -> None: + match (0, 1, 2): + case [*x, 1, 2]: + y = 0 + self.assertEqual(x, [0]) + self.assertEqual(y, 0) + + def test_grammar_17(self) -> None: + match (0, 1, 2): + case [*x, 0, 1, 2,]: + y = 0 + self.assertEqual(x, []) + self.assertEqual(y, 0) + + def test_grammar_18(self) -> None: + match (0, 1, 2): + case [0, *x, 2]: + y = 0 + self.assertEqual(x, [1]) + self.assertEqual(y, 0) + + def test_grammar_19(self) -> None: + match (0, 1, 2): + case [0, 1, *x, 2,]: + y = 0 + self.assertEqual(x, []) + self.assertEqual(y, 0) + + def test_grammar_20(self) -> None: + match (0, 1, 2): + case [0, *x, 1, 2]: + y = 0 + self.assertEqual(x, []) + self.assertEqual(y, 0) + + def test_grammar_21(self) -> None: + match (0, 1, 2): + case [*x,]: + y = 0 + self.assertEqual(x, [0, 1, 2]) + self.assertEqual(y, 0) + + if __name__ == "__main__": # XXX: For quick test debugging... import dis diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index 5cdb7e135dc885..844715d7e439d6 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -5454,7 +5454,7 @@ group_pattern_rule(Parser *p) return _res; } -// sequence_pattern: '[' values_pattern ']' +// sequence_pattern: '[' values_pattern? ']' static void * sequence_pattern_rule(Parser *p) { @@ -5474,24 +5474,24 @@ sequence_pattern_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '[' values_pattern ']' + { // '[' values_pattern? ']' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' values_pattern ']'")); + D(fprintf(stderr, "%*c> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' values_pattern? ']'")); Token * _literal; Token * _literal_1; void *values; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' && - (values = values_pattern_rule(p)) // values_pattern + (values = values_pattern_rule(p), 1) // values_pattern? && (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' ) { - D(fprintf(stderr, "%*c+ sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' values_pattern ']'")); + D(fprintf(stderr, "%*c+ sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' values_pattern? ']'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5511,7 +5511,7 @@ sequence_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' values_pattern ']'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' values_pattern? ']'")); } _res = NULL; done: diff --git a/Python/ast.c b/Python/ast.c index c50ee38f21fda7..d498acb9eae74e 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -364,8 +364,7 @@ validate_pattern(expr_ty p) } return 1; case List_kind: - case Tuple_kind: // TODO: Undecided yet if tuple syntax is legal. - values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; + values = p->v.List.elts; size = asdl_seq_LEN(values); for (i = 0; i < size; i++) { value = asdl_seq_GET(values, i); diff --git a/Python/compile.c b/Python/compile.c index b9061f81e07446..044ff18de067a0 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2873,8 +2873,8 @@ compiler_pattern_or(struct compiler *c, expr_ty p, basicblock *fail) static int compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail) { - assert(p->kind == List_kind || p->kind == Tuple_kind); - asdl_seq *values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; + assert(p->kind == List_kind); + asdl_seq *values = p->v.List.elts; Py_ssize_t size = asdl_seq_LEN(values); Py_ssize_t star = -1; for (Py_ssize_t i = 0; i < size; i++) { @@ -2939,7 +2939,6 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) case Dict_kind: return compiler_pattern_mapping(c, p, fail); case List_kind: - case Tuple_kind: return compiler_pattern_sequence(c, p, fail); case Name_kind: return compiler_pattern_name(c, p, fail); From f1a1eb942260591b7caa4cf49de0dfdeb844f65c Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 1 Jun 2020 08:47:11 -0700 Subject: [PATCH 048/189] Fix calls and error messages --- Grammar/python.gram | 21 +- Parser/pegen/parse.c | 3087 +++++++++++++++++++++++++----------------- Python/ast_opt.c | 1 + Python/compile.c | 36 +- 4 files changed, 1912 insertions(+), 1233 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index f5601bf30478f8..820a7bb8252c44 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -192,7 +192,7 @@ except_block[excepthandler_ty]: | 'except' ':' b=block { _Py_ExceptHandler(NULL, NULL, b, EXTRA) } finally_block[asdl_seq*]: 'finally' ':' a=block { a } -match_stmt[stmt_ty]: +match_stmt: | "match" target=expression ':' NEWLINE INDENT cases=case_block+ DEDENT { _Py_Match(target, cases, EXTRA) } case_block: @@ -245,17 +245,19 @@ sequence_pattern: | '[' values=values_pattern? ']' { _Py_List(values, Load, EXTRA) } mapping_pattern: - | '{' items=items_pattern '}' { + | '{' items=items_pattern? '}' { _Py_Dict(CHECK(_PyPegen_get_keys(p, items)), CHECK(_PyPegen_get_values(p, items)), EXTRA) } class_pattern: | func=name_or_attr '(' ')' { _Py_Call(func, NULL, NULL, EXTRA) } - | func=name_or_attr '(' args=','.pattern+ ','? ')' { + | func=name_or_attr '(' args=','.arg_pattern+ ','? ')' { _Py_Call(func, args, NULL, EXTRA) } | func=name_or_attr '(' keywords=','.keyword_pattern+ ','? ')' { _Py_Call(func, NULL, keywords, EXTRA) } - | func=name_or_attr '(' args=','.pattern+ ',' keywords=','.keyword_pattern+ ','? ')' { + | func=name_or_attr '(' args=','.arg_pattern+ ',' keywords=','.keyword_pattern+ ','? ')' { _Py_Call(func, args, keywords, EXTRA) } + | func=name_or_attr '(' [','.arg_pattern+ ','] ','.keyword_pattern+ ',' error=arg_pattern [',' ','.(arg_pattern | keyword_pattern)+] ','? ')' { + RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "positional pattern follows keyword pattern") } name_or_attr: | NAME @@ -267,23 +269,26 @@ values_pattern: items_pattern: | items=','.key_value_pattern+ ','? { items } +arg_pattern[expr_ty]: + | pattern !'=' + | error='*' NAME { + RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "can't use starred pattern here") } keyword_pattern: | arg=NAME '=' value=or_pattern { _Py_keyword(arg->v.Name.id, value, EXTRA) } + | error='**' NAME { + RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "can't use starred pattern here") } value_pattern: | '*' value=name_pattern { _Py_Starred(value, Store, EXTRA) } | pattern key_value_pattern: - | key=literal_pattern ':' value=closed_pattern { - _PyPegen_key_value_pair(p, key, value) } - | key=constant_pattern ':' value=closed_pattern { + | key=(literal_pattern | constant_pattern) ':' value=closed_pattern { _PyPegen_key_value_pair(p, key, value) } | '**' value=name_pattern { _PyPegen_key_value_pair(p, NULL, value) } - return_stmt[stmt_ty]: | 'return' a=[star_expressions] { _Py_Return(a, EXTRA) } diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index 844715d7e439d6..e9c2cdd3973500 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -129,291 +129,302 @@ static KeywordToken *reserved_keywords[] = { #define name_or_attr_type 1051 // Left-recursive #define values_pattern_type 1052 #define items_pattern_type 1053 -#define keyword_pattern_type 1054 -#define value_pattern_type 1055 -#define key_value_pattern_type 1056 -#define return_stmt_type 1057 -#define raise_stmt_type 1058 -#define function_def_type 1059 -#define function_def_raw_type 1060 -#define func_type_comment_type 1061 -#define params_type 1062 -#define parameters_type 1063 -#define slash_no_default_type 1064 -#define slash_with_default_type 1065 -#define star_etc_type 1066 -#define kwds_type 1067 -#define param_no_default_type 1068 -#define param_with_default_type 1069 -#define param_maybe_default_type 1070 -#define param_type 1071 -#define annotation_type 1072 -#define default_type 1073 -#define decorators_type 1074 -#define class_def_type 1075 -#define class_def_raw_type 1076 -#define block_type 1077 -#define expressions_list_type 1078 -#define star_expressions_type 1079 -#define star_expression_type 1080 -#define star_named_expressions_type 1081 -#define star_named_expression_type 1082 -#define named_expression_type 1083 -#define annotated_rhs_type 1084 -#define expressions_type 1085 -#define expression_type 1086 -#define lambdef_type 1087 -#define lambda_parameters_type 1088 -#define lambda_slash_no_default_type 1089 -#define lambda_slash_with_default_type 1090 -#define lambda_star_etc_type 1091 -#define lambda_kwds_type 1092 -#define lambda_param_no_default_type 1093 -#define lambda_param_with_default_type 1094 -#define lambda_param_maybe_default_type 1095 -#define lambda_param_type 1096 -#define disjunction_type 1097 -#define conjunction_type 1098 -#define inversion_type 1099 -#define comparison_type 1100 -#define compare_op_bitwise_or_pair_type 1101 -#define eq_bitwise_or_type 1102 -#define noteq_bitwise_or_type 1103 -#define lte_bitwise_or_type 1104 -#define lt_bitwise_or_type 1105 -#define gte_bitwise_or_type 1106 -#define gt_bitwise_or_type 1107 -#define notin_bitwise_or_type 1108 -#define in_bitwise_or_type 1109 -#define isnot_bitwise_or_type 1110 -#define is_bitwise_or_type 1111 -#define bitwise_or_type 1112 // Left-recursive -#define bitwise_xor_type 1113 // Left-recursive -#define bitwise_and_type 1114 // Left-recursive -#define shift_expr_type 1115 // Left-recursive -#define sum_type 1116 // Left-recursive -#define term_type 1117 // Left-recursive -#define factor_type 1118 -#define power_type 1119 -#define await_primary_type 1120 -#define primary_type 1121 // Left-recursive -#define slices_type 1122 -#define slice_type 1123 -#define atom_type 1124 -#define strings_type 1125 -#define list_type 1126 -#define listcomp_type 1127 -#define tuple_type 1128 -#define group_type 1129 -#define genexp_type 1130 -#define set_type 1131 -#define setcomp_type 1132 -#define dict_type 1133 -#define dictcomp_type 1134 -#define double_starred_kvpairs_type 1135 -#define double_starred_kvpair_type 1136 -#define kvpair_type 1137 -#define for_if_clauses_type 1138 -#define for_if_clause_type 1139 -#define yield_expr_type 1140 -#define arguments_type 1141 -#define args_type 1142 -#define kwargs_type 1143 -#define starred_expression_type 1144 -#define kwarg_or_starred_type 1145 -#define kwarg_or_double_starred_type 1146 -#define star_targets_type 1147 -#define star_targets_seq_type 1148 -#define star_target_type 1149 -#define star_atom_type 1150 -#define single_target_type 1151 -#define single_subscript_attribute_target_type 1152 -#define del_targets_type 1153 -#define del_target_type 1154 -#define del_t_atom_type 1155 -#define del_target_end_type 1156 -#define targets_type 1157 -#define target_type 1158 -#define t_primary_type 1159 // Left-recursive -#define t_lookahead_type 1160 -#define t_atom_type 1161 -#define incorrect_arguments_type 1162 -#define invalid_kwarg_type 1163 -#define invalid_named_expression_type 1164 -#define invalid_assignment_type 1165 -#define invalid_block_type 1166 -#define invalid_comprehension_type 1167 -#define invalid_dict_comprehension_type 1168 -#define invalid_parameters_type 1169 -#define invalid_star_etc_type 1170 -#define invalid_lambda_star_etc_type 1171 -#define invalid_double_type_comments_type 1172 -#define invalid_del_target_type 1173 -#define invalid_import_from_targets_type 1174 -#define _loop0_1_type 1175 -#define _loop0_2_type 1176 -#define _loop0_4_type 1177 -#define _gather_3_type 1178 -#define _loop0_6_type 1179 -#define _gather_5_type 1180 -#define _loop0_8_type 1181 -#define _gather_7_type 1182 -#define _loop0_10_type 1183 -#define _gather_9_type 1184 -#define _loop1_11_type 1185 -#define _loop0_13_type 1186 -#define _gather_12_type 1187 -#define _tmp_14_type 1188 -#define _tmp_15_type 1189 -#define _tmp_16_type 1190 -#define _tmp_17_type 1191 -#define _tmp_18_type 1192 -#define _tmp_19_type 1193 -#define _tmp_20_type 1194 -#define _tmp_21_type 1195 -#define _loop1_22_type 1196 -#define _tmp_23_type 1197 -#define _tmp_24_type 1198 -#define _loop0_26_type 1199 -#define _gather_25_type 1200 -#define _loop0_28_type 1201 -#define _gather_27_type 1202 -#define _tmp_29_type 1203 -#define _loop0_30_type 1204 -#define _loop1_31_type 1205 -#define _loop0_33_type 1206 -#define _gather_32_type 1207 -#define _tmp_34_type 1208 -#define _loop0_36_type 1209 -#define _gather_35_type 1210 -#define _tmp_37_type 1211 -#define _loop0_39_type 1212 -#define _gather_38_type 1213 -#define _loop0_41_type 1214 -#define _gather_40_type 1215 -#define _loop0_43_type 1216 -#define _gather_42_type 1217 -#define _loop0_45_type 1218 -#define _gather_44_type 1219 -#define _tmp_46_type 1220 -#define _loop1_47_type 1221 -#define _tmp_48_type 1222 -#define _loop1_49_type 1223 -#define _loop0_51_type 1224 -#define _gather_50_type 1225 -#define _tmp_52_type 1226 -#define _loop0_54_type 1227 -#define _gather_53_type 1228 -#define _loop0_56_type 1229 -#define _gather_55_type 1230 -#define _loop0_58_type 1231 -#define _gather_57_type 1232 -#define _loop0_60_type 1233 -#define _gather_59_type 1234 -#define _loop0_62_type 1235 -#define _gather_61_type 1236 -#define _loop0_64_type 1237 -#define _gather_63_type 1238 -#define _tmp_65_type 1239 -#define _tmp_66_type 1240 -#define _tmp_67_type 1241 -#define _tmp_68_type 1242 -#define _loop0_69_type 1243 -#define _loop0_70_type 1244 -#define _loop0_71_type 1245 -#define _loop1_72_type 1246 -#define _loop0_73_type 1247 -#define _loop1_74_type 1248 -#define _loop1_75_type 1249 -#define _loop1_76_type 1250 -#define _loop0_77_type 1251 -#define _loop1_78_type 1252 -#define _loop0_79_type 1253 -#define _loop1_80_type 1254 -#define _loop0_81_type 1255 -#define _loop1_82_type 1256 -#define _loop1_83_type 1257 -#define _tmp_84_type 1258 -#define _loop0_86_type 1259 -#define _gather_85_type 1260 -#define _loop1_87_type 1261 -#define _loop0_89_type 1262 -#define _gather_88_type 1263 -#define _loop1_90_type 1264 +#define arg_pattern_type 1054 +#define keyword_pattern_type 1055 +#define value_pattern_type 1056 +#define key_value_pattern_type 1057 +#define return_stmt_type 1058 +#define raise_stmt_type 1059 +#define function_def_type 1060 +#define function_def_raw_type 1061 +#define func_type_comment_type 1062 +#define params_type 1063 +#define parameters_type 1064 +#define slash_no_default_type 1065 +#define slash_with_default_type 1066 +#define star_etc_type 1067 +#define kwds_type 1068 +#define param_no_default_type 1069 +#define param_with_default_type 1070 +#define param_maybe_default_type 1071 +#define param_type 1072 +#define annotation_type 1073 +#define default_type 1074 +#define decorators_type 1075 +#define class_def_type 1076 +#define class_def_raw_type 1077 +#define block_type 1078 +#define expressions_list_type 1079 +#define star_expressions_type 1080 +#define star_expression_type 1081 +#define star_named_expressions_type 1082 +#define star_named_expression_type 1083 +#define named_expression_type 1084 +#define annotated_rhs_type 1085 +#define expressions_type 1086 +#define expression_type 1087 +#define lambdef_type 1088 +#define lambda_parameters_type 1089 +#define lambda_slash_no_default_type 1090 +#define lambda_slash_with_default_type 1091 +#define lambda_star_etc_type 1092 +#define lambda_kwds_type 1093 +#define lambda_param_no_default_type 1094 +#define lambda_param_with_default_type 1095 +#define lambda_param_maybe_default_type 1096 +#define lambda_param_type 1097 +#define disjunction_type 1098 +#define conjunction_type 1099 +#define inversion_type 1100 +#define comparison_type 1101 +#define compare_op_bitwise_or_pair_type 1102 +#define eq_bitwise_or_type 1103 +#define noteq_bitwise_or_type 1104 +#define lte_bitwise_or_type 1105 +#define lt_bitwise_or_type 1106 +#define gte_bitwise_or_type 1107 +#define gt_bitwise_or_type 1108 +#define notin_bitwise_or_type 1109 +#define in_bitwise_or_type 1110 +#define isnot_bitwise_or_type 1111 +#define is_bitwise_or_type 1112 +#define bitwise_or_type 1113 // Left-recursive +#define bitwise_xor_type 1114 // Left-recursive +#define bitwise_and_type 1115 // Left-recursive +#define shift_expr_type 1116 // Left-recursive +#define sum_type 1117 // Left-recursive +#define term_type 1118 // Left-recursive +#define factor_type 1119 +#define power_type 1120 +#define await_primary_type 1121 +#define primary_type 1122 // Left-recursive +#define slices_type 1123 +#define slice_type 1124 +#define atom_type 1125 +#define strings_type 1126 +#define list_type 1127 +#define listcomp_type 1128 +#define tuple_type 1129 +#define group_type 1130 +#define genexp_type 1131 +#define set_type 1132 +#define setcomp_type 1133 +#define dict_type 1134 +#define dictcomp_type 1135 +#define double_starred_kvpairs_type 1136 +#define double_starred_kvpair_type 1137 +#define kvpair_type 1138 +#define for_if_clauses_type 1139 +#define for_if_clause_type 1140 +#define yield_expr_type 1141 +#define arguments_type 1142 +#define args_type 1143 +#define kwargs_type 1144 +#define starred_expression_type 1145 +#define kwarg_or_starred_type 1146 +#define kwarg_or_double_starred_type 1147 +#define star_targets_type 1148 +#define star_targets_seq_type 1149 +#define star_target_type 1150 +#define star_atom_type 1151 +#define single_target_type 1152 +#define single_subscript_attribute_target_type 1153 +#define del_targets_type 1154 +#define del_target_type 1155 +#define del_t_atom_type 1156 +#define del_target_end_type 1157 +#define targets_type 1158 +#define target_type 1159 +#define t_primary_type 1160 // Left-recursive +#define t_lookahead_type 1161 +#define t_atom_type 1162 +#define incorrect_arguments_type 1163 +#define invalid_kwarg_type 1164 +#define invalid_named_expression_type 1165 +#define invalid_assignment_type 1166 +#define invalid_block_type 1167 +#define invalid_comprehension_type 1168 +#define invalid_dict_comprehension_type 1169 +#define invalid_parameters_type 1170 +#define invalid_star_etc_type 1171 +#define invalid_lambda_star_etc_type 1172 +#define invalid_double_type_comments_type 1173 +#define invalid_del_target_type 1174 +#define invalid_import_from_targets_type 1175 +#define _loop0_1_type 1176 +#define _loop0_2_type 1177 +#define _loop0_4_type 1178 +#define _gather_3_type 1179 +#define _loop0_6_type 1180 +#define _gather_5_type 1181 +#define _loop0_8_type 1182 +#define _gather_7_type 1183 +#define _loop0_10_type 1184 +#define _gather_9_type 1185 +#define _loop1_11_type 1186 +#define _loop0_13_type 1187 +#define _gather_12_type 1188 +#define _tmp_14_type 1189 +#define _tmp_15_type 1190 +#define _tmp_16_type 1191 +#define _tmp_17_type 1192 +#define _tmp_18_type 1193 +#define _tmp_19_type 1194 +#define _tmp_20_type 1195 +#define _tmp_21_type 1196 +#define _loop1_22_type 1197 +#define _tmp_23_type 1198 +#define _tmp_24_type 1199 +#define _loop0_26_type 1200 +#define _gather_25_type 1201 +#define _loop0_28_type 1202 +#define _gather_27_type 1203 +#define _tmp_29_type 1204 +#define _loop0_30_type 1205 +#define _loop1_31_type 1206 +#define _loop0_33_type 1207 +#define _gather_32_type 1208 +#define _tmp_34_type 1209 +#define _loop0_36_type 1210 +#define _gather_35_type 1211 +#define _tmp_37_type 1212 +#define _loop0_39_type 1213 +#define _gather_38_type 1214 +#define _loop0_41_type 1215 +#define _gather_40_type 1216 +#define _loop0_43_type 1217 +#define _gather_42_type 1218 +#define _loop0_45_type 1219 +#define _gather_44_type 1220 +#define _tmp_46_type 1221 +#define _loop1_47_type 1222 +#define _tmp_48_type 1223 +#define _loop1_49_type 1224 +#define _loop0_51_type 1225 +#define _gather_50_type 1226 +#define _tmp_52_type 1227 +#define _loop0_54_type 1228 +#define _gather_53_type 1229 +#define _loop0_56_type 1230 +#define _gather_55_type 1231 +#define _loop0_58_type 1232 +#define _gather_57_type 1233 +#define _loop0_60_type 1234 +#define _gather_59_type 1235 +#define _tmp_61_type 1236 +#define _loop0_63_type 1237 +#define _gather_62_type 1238 +#define _tmp_64_type 1239 +#define _loop0_66_type 1240 +#define _gather_65_type 1241 +#define _loop0_68_type 1242 +#define _gather_67_type 1243 +#define _tmp_69_type 1244 +#define _tmp_70_type 1245 +#define _tmp_71_type 1246 +#define _tmp_72_type 1247 +#define _tmp_73_type 1248 +#define _loop0_74_type 1249 +#define _loop0_75_type 1250 +#define _loop0_76_type 1251 +#define _loop1_77_type 1252 +#define _loop0_78_type 1253 +#define _loop1_79_type 1254 +#define _loop1_80_type 1255 +#define _loop1_81_type 1256 +#define _loop0_82_type 1257 +#define _loop1_83_type 1258 +#define _loop0_84_type 1259 +#define _loop1_85_type 1260 +#define _loop0_86_type 1261 +#define _loop1_87_type 1262 +#define _loop1_88_type 1263 +#define _tmp_89_type 1264 #define _loop0_91_type 1265 -#define _loop0_92_type 1266 -#define _loop0_93_type 1267 -#define _loop1_94_type 1268 -#define _loop0_95_type 1269 -#define _loop1_96_type 1270 -#define _loop1_97_type 1271 -#define _loop1_98_type 1272 -#define _loop0_99_type 1273 -#define _loop1_100_type 1274 -#define _loop0_101_type 1275 -#define _loop1_102_type 1276 -#define _loop0_103_type 1277 -#define _loop1_104_type 1278 -#define _loop1_105_type 1279 -#define _loop1_106_type 1280 -#define _loop1_107_type 1281 -#define _tmp_108_type 1282 -#define _loop0_110_type 1283 -#define _gather_109_type 1284 -#define _tmp_111_type 1285 -#define _tmp_112_type 1286 -#define _tmp_113_type 1287 -#define _tmp_114_type 1288 -#define _loop1_115_type 1289 -#define _tmp_116_type 1290 -#define _tmp_117_type 1291 -#define _loop0_119_type 1292 -#define _gather_118_type 1293 -#define _loop1_120_type 1294 -#define _loop0_121_type 1295 -#define _loop0_122_type 1296 -#define _tmp_123_type 1297 -#define _tmp_124_type 1298 -#define _loop0_126_type 1299 -#define _gather_125_type 1300 -#define _loop0_128_type 1301 -#define _gather_127_type 1302 -#define _loop0_130_type 1303 -#define _gather_129_type 1304 -#define _loop0_132_type 1305 -#define _gather_131_type 1306 +#define _gather_90_type 1266 +#define _loop1_92_type 1267 +#define _loop0_94_type 1268 +#define _gather_93_type 1269 +#define _loop1_95_type 1270 +#define _loop0_96_type 1271 +#define _loop0_97_type 1272 +#define _loop0_98_type 1273 +#define _loop1_99_type 1274 +#define _loop0_100_type 1275 +#define _loop1_101_type 1276 +#define _loop1_102_type 1277 +#define _loop1_103_type 1278 +#define _loop0_104_type 1279 +#define _loop1_105_type 1280 +#define _loop0_106_type 1281 +#define _loop1_107_type 1282 +#define _loop0_108_type 1283 +#define _loop1_109_type 1284 +#define _loop1_110_type 1285 +#define _loop1_111_type 1286 +#define _loop1_112_type 1287 +#define _tmp_113_type 1288 +#define _loop0_115_type 1289 +#define _gather_114_type 1290 +#define _tmp_116_type 1291 +#define _tmp_117_type 1292 +#define _tmp_118_type 1293 +#define _tmp_119_type 1294 +#define _loop1_120_type 1295 +#define _tmp_121_type 1296 +#define _tmp_122_type 1297 +#define _loop0_124_type 1298 +#define _gather_123_type 1299 +#define _loop1_125_type 1300 +#define _loop0_126_type 1301 +#define _loop0_127_type 1302 +#define _tmp_128_type 1303 +#define _tmp_129_type 1304 +#define _loop0_131_type 1305 +#define _gather_130_type 1306 #define _loop0_133_type 1307 -#define _loop0_135_type 1308 -#define _gather_134_type 1309 -#define _tmp_136_type 1310 -#define _loop0_138_type 1311 -#define _gather_137_type 1312 -#define _loop0_140_type 1313 -#define _gather_139_type 1314 -#define _tmp_141_type 1315 -#define _loop0_142_type 1316 -#define _tmp_143_type 1317 -#define _tmp_144_type 1318 -#define _tmp_145_type 1319 -#define _tmp_146_type 1320 -#define _loop0_147_type 1321 -#define _tmp_148_type 1322 -#define _tmp_149_type 1323 -#define _tmp_150_type 1324 -#define _tmp_151_type 1325 -#define _tmp_152_type 1326 -#define _tmp_153_type 1327 -#define _tmp_154_type 1328 -#define _tmp_155_type 1329 -#define _tmp_156_type 1330 -#define _tmp_157_type 1331 -#define _tmp_158_type 1332 -#define _tmp_159_type 1333 -#define _tmp_160_type 1334 -#define _tmp_161_type 1335 -#define _loop1_162_type 1336 -#define _tmp_163_type 1337 -#define _tmp_164_type 1338 +#define _gather_132_type 1308 +#define _loop0_135_type 1309 +#define _gather_134_type 1310 +#define _loop0_137_type 1311 +#define _gather_136_type 1312 +#define _loop0_138_type 1313 +#define _loop0_140_type 1314 +#define _gather_139_type 1315 +#define _tmp_141_type 1316 +#define _loop0_143_type 1317 +#define _gather_142_type 1318 +#define _loop0_145_type 1319 +#define _gather_144_type 1320 +#define _tmp_146_type 1321 +#define _loop0_147_type 1322 +#define _tmp_148_type 1323 +#define _tmp_149_type 1324 +#define _tmp_150_type 1325 +#define _tmp_151_type 1326 +#define _loop0_152_type 1327 +#define _tmp_153_type 1328 +#define _tmp_154_type 1329 +#define _tmp_155_type 1330 +#define _tmp_156_type 1331 +#define _tmp_157_type 1332 +#define _tmp_158_type 1333 +#define _loop0_160_type 1334 +#define _gather_159_type 1335 +#define _loop0_162_type 1336 +#define _gather_161_type 1337 +#define _tmp_163_type 1338 +#define _tmp_164_type 1339 +#define _tmp_165_type 1340 +#define _tmp_166_type 1341 +#define _tmp_167_type 1342 +#define _tmp_168_type 1343 +#define _tmp_169_type 1344 +#define _tmp_170_type 1345 +#define _loop1_171_type 1346 +#define _tmp_172_type 1347 +#define _tmp_173_type 1348 +#define _tmp_174_type 1349 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -453,7 +464,7 @@ static withitem_ty with_item_rule(Parser *p); static stmt_ty try_stmt_rule(Parser *p); static excepthandler_ty except_block_rule(Parser *p); static asdl_seq* finally_block_rule(Parser *p); -static stmt_ty match_stmt_rule(Parser *p); +static void *match_stmt_rule(Parser *p); static void *case_block_rule(Parser *p); static void *pattern_rule(Parser *p); static void *guard_rule(Parser *p); @@ -469,6 +480,7 @@ static void *class_pattern_rule(Parser *p); static void *name_or_attr_rule(Parser *p); static void *values_pattern_rule(Parser *p); static void *items_pattern_rule(Parser *p); +static expr_ty arg_pattern_rule(Parser *p); static void *keyword_pattern_rule(Parser *p); static void *value_pattern_rule(Parser *p); static void *key_value_pattern_rule(Parser *p); @@ -650,110 +662,120 @@ static asdl_seq *_loop0_58_rule(Parser *p); static asdl_seq *_gather_57_rule(Parser *p); static asdl_seq *_loop0_60_rule(Parser *p); static asdl_seq *_gather_59_rule(Parser *p); -static asdl_seq *_loop0_62_rule(Parser *p); -static asdl_seq *_gather_61_rule(Parser *p); -static asdl_seq *_loop0_64_rule(Parser *p); -static asdl_seq *_gather_63_rule(Parser *p); -static void *_tmp_65_rule(Parser *p); -static void *_tmp_66_rule(Parser *p); -static void *_tmp_67_rule(Parser *p); -static void *_tmp_68_rule(Parser *p); -static asdl_seq *_loop0_69_rule(Parser *p); -static asdl_seq *_loop0_70_rule(Parser *p); -static asdl_seq *_loop0_71_rule(Parser *p); -static asdl_seq *_loop1_72_rule(Parser *p); -static asdl_seq *_loop0_73_rule(Parser *p); -static asdl_seq *_loop1_74_rule(Parser *p); -static asdl_seq *_loop1_75_rule(Parser *p); -static asdl_seq *_loop1_76_rule(Parser *p); -static asdl_seq *_loop0_77_rule(Parser *p); -static asdl_seq *_loop1_78_rule(Parser *p); -static asdl_seq *_loop0_79_rule(Parser *p); +static void *_tmp_61_rule(Parser *p); +static asdl_seq *_loop0_63_rule(Parser *p); +static asdl_seq *_gather_62_rule(Parser *p); +static void *_tmp_64_rule(Parser *p); +static asdl_seq *_loop0_66_rule(Parser *p); +static asdl_seq *_gather_65_rule(Parser *p); +static asdl_seq *_loop0_68_rule(Parser *p); +static asdl_seq *_gather_67_rule(Parser *p); +static void *_tmp_69_rule(Parser *p); +static void *_tmp_70_rule(Parser *p); +static void *_tmp_71_rule(Parser *p); +static void *_tmp_72_rule(Parser *p); +static void *_tmp_73_rule(Parser *p); +static asdl_seq *_loop0_74_rule(Parser *p); +static asdl_seq *_loop0_75_rule(Parser *p); +static asdl_seq *_loop0_76_rule(Parser *p); +static asdl_seq *_loop1_77_rule(Parser *p); +static asdl_seq *_loop0_78_rule(Parser *p); +static asdl_seq *_loop1_79_rule(Parser *p); static asdl_seq *_loop1_80_rule(Parser *p); -static asdl_seq *_loop0_81_rule(Parser *p); -static asdl_seq *_loop1_82_rule(Parser *p); +static asdl_seq *_loop1_81_rule(Parser *p); +static asdl_seq *_loop0_82_rule(Parser *p); static asdl_seq *_loop1_83_rule(Parser *p); -static void *_tmp_84_rule(Parser *p); +static asdl_seq *_loop0_84_rule(Parser *p); +static asdl_seq *_loop1_85_rule(Parser *p); static asdl_seq *_loop0_86_rule(Parser *p); -static asdl_seq *_gather_85_rule(Parser *p); static asdl_seq *_loop1_87_rule(Parser *p); -static asdl_seq *_loop0_89_rule(Parser *p); -static asdl_seq *_gather_88_rule(Parser *p); -static asdl_seq *_loop1_90_rule(Parser *p); +static asdl_seq *_loop1_88_rule(Parser *p); +static void *_tmp_89_rule(Parser *p); static asdl_seq *_loop0_91_rule(Parser *p); -static asdl_seq *_loop0_92_rule(Parser *p); -static asdl_seq *_loop0_93_rule(Parser *p); -static asdl_seq *_loop1_94_rule(Parser *p); -static asdl_seq *_loop0_95_rule(Parser *p); -static asdl_seq *_loop1_96_rule(Parser *p); -static asdl_seq *_loop1_97_rule(Parser *p); -static asdl_seq *_loop1_98_rule(Parser *p); -static asdl_seq *_loop0_99_rule(Parser *p); -static asdl_seq *_loop1_100_rule(Parser *p); -static asdl_seq *_loop0_101_rule(Parser *p); +static asdl_seq *_gather_90_rule(Parser *p); +static asdl_seq *_loop1_92_rule(Parser *p); +static asdl_seq *_loop0_94_rule(Parser *p); +static asdl_seq *_gather_93_rule(Parser *p); +static asdl_seq *_loop1_95_rule(Parser *p); +static asdl_seq *_loop0_96_rule(Parser *p); +static asdl_seq *_loop0_97_rule(Parser *p); +static asdl_seq *_loop0_98_rule(Parser *p); +static asdl_seq *_loop1_99_rule(Parser *p); +static asdl_seq *_loop0_100_rule(Parser *p); +static asdl_seq *_loop1_101_rule(Parser *p); static asdl_seq *_loop1_102_rule(Parser *p); -static asdl_seq *_loop0_103_rule(Parser *p); -static asdl_seq *_loop1_104_rule(Parser *p); +static asdl_seq *_loop1_103_rule(Parser *p); +static asdl_seq *_loop0_104_rule(Parser *p); static asdl_seq *_loop1_105_rule(Parser *p); -static asdl_seq *_loop1_106_rule(Parser *p); +static asdl_seq *_loop0_106_rule(Parser *p); static asdl_seq *_loop1_107_rule(Parser *p); -static void *_tmp_108_rule(Parser *p); -static asdl_seq *_loop0_110_rule(Parser *p); -static asdl_seq *_gather_109_rule(Parser *p); -static void *_tmp_111_rule(Parser *p); -static void *_tmp_112_rule(Parser *p); +static asdl_seq *_loop0_108_rule(Parser *p); +static asdl_seq *_loop1_109_rule(Parser *p); +static asdl_seq *_loop1_110_rule(Parser *p); +static asdl_seq *_loop1_111_rule(Parser *p); +static asdl_seq *_loop1_112_rule(Parser *p); static void *_tmp_113_rule(Parser *p); -static void *_tmp_114_rule(Parser *p); -static asdl_seq *_loop1_115_rule(Parser *p); +static asdl_seq *_loop0_115_rule(Parser *p); +static asdl_seq *_gather_114_rule(Parser *p); static void *_tmp_116_rule(Parser *p); static void *_tmp_117_rule(Parser *p); -static asdl_seq *_loop0_119_rule(Parser *p); -static asdl_seq *_gather_118_rule(Parser *p); +static void *_tmp_118_rule(Parser *p); +static void *_tmp_119_rule(Parser *p); static asdl_seq *_loop1_120_rule(Parser *p); -static asdl_seq *_loop0_121_rule(Parser *p); -static asdl_seq *_loop0_122_rule(Parser *p); -static void *_tmp_123_rule(Parser *p); -static void *_tmp_124_rule(Parser *p); +static void *_tmp_121_rule(Parser *p); +static void *_tmp_122_rule(Parser *p); +static asdl_seq *_loop0_124_rule(Parser *p); +static asdl_seq *_gather_123_rule(Parser *p); +static asdl_seq *_loop1_125_rule(Parser *p); static asdl_seq *_loop0_126_rule(Parser *p); -static asdl_seq *_gather_125_rule(Parser *p); -static asdl_seq *_loop0_128_rule(Parser *p); -static asdl_seq *_gather_127_rule(Parser *p); -static asdl_seq *_loop0_130_rule(Parser *p); -static asdl_seq *_gather_129_rule(Parser *p); -static asdl_seq *_loop0_132_rule(Parser *p); -static asdl_seq *_gather_131_rule(Parser *p); +static asdl_seq *_loop0_127_rule(Parser *p); +static void *_tmp_128_rule(Parser *p); +static void *_tmp_129_rule(Parser *p); +static asdl_seq *_loop0_131_rule(Parser *p); +static asdl_seq *_gather_130_rule(Parser *p); static asdl_seq *_loop0_133_rule(Parser *p); +static asdl_seq *_gather_132_rule(Parser *p); static asdl_seq *_loop0_135_rule(Parser *p); static asdl_seq *_gather_134_rule(Parser *p); -static void *_tmp_136_rule(Parser *p); +static asdl_seq *_loop0_137_rule(Parser *p); +static asdl_seq *_gather_136_rule(Parser *p); static asdl_seq *_loop0_138_rule(Parser *p); -static asdl_seq *_gather_137_rule(Parser *p); static asdl_seq *_loop0_140_rule(Parser *p); static asdl_seq *_gather_139_rule(Parser *p); static void *_tmp_141_rule(Parser *p); -static asdl_seq *_loop0_142_rule(Parser *p); -static void *_tmp_143_rule(Parser *p); -static void *_tmp_144_rule(Parser *p); -static void *_tmp_145_rule(Parser *p); +static asdl_seq *_loop0_143_rule(Parser *p); +static asdl_seq *_gather_142_rule(Parser *p); +static asdl_seq *_loop0_145_rule(Parser *p); +static asdl_seq *_gather_144_rule(Parser *p); static void *_tmp_146_rule(Parser *p); static asdl_seq *_loop0_147_rule(Parser *p); static void *_tmp_148_rule(Parser *p); static void *_tmp_149_rule(Parser *p); static void *_tmp_150_rule(Parser *p); static void *_tmp_151_rule(Parser *p); -static void *_tmp_152_rule(Parser *p); +static asdl_seq *_loop0_152_rule(Parser *p); static void *_tmp_153_rule(Parser *p); static void *_tmp_154_rule(Parser *p); 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 void *_tmp_159_rule(Parser *p); -static void *_tmp_160_rule(Parser *p); -static void *_tmp_161_rule(Parser *p); -static asdl_seq *_loop1_162_rule(Parser *p); +static asdl_seq *_loop0_160_rule(Parser *p); +static asdl_seq *_gather_159_rule(Parser *p); +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 void *_tmp_167_rule(Parser *p); +static void *_tmp_168_rule(Parser *p); +static void *_tmp_169_rule(Parser *p); +static void *_tmp_170_rule(Parser *p); +static asdl_seq *_loop1_171_rule(Parser *p); +static void *_tmp_172_rule(Parser *p); +static void *_tmp_173_rule(Parser *p); +static void *_tmp_174_rule(Parser *p); // file: statements? $ @@ -2066,7 +2088,7 @@ compound_stmt_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "match_stmt")); - stmt_ty match_stmt_var; + void *match_stmt_var; if ( (match_stmt_var = match_stmt_rule(p)) // match_stmt ) @@ -4609,7 +4631,7 @@ finally_block_rule(Parser *p) } // match_stmt: "match" expression ':' NEWLINE INDENT case_block+ DEDENT -static stmt_ty +static void * match_stmt_rule(Parser *p) { D(p->level++); @@ -4617,7 +4639,7 @@ match_stmt_rule(Parser *p) D(p->level--); return NULL; } - stmt_ty _res = NULL; + void * _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -5519,7 +5541,7 @@ sequence_pattern_rule(Parser *p) return _res; } -// mapping_pattern: '{' items_pattern '}' +// mapping_pattern: '{' items_pattern? '}' static void * mapping_pattern_rule(Parser *p) { @@ -5539,24 +5561,24 @@ mapping_pattern_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '{' items_pattern '}' + { // '{' items_pattern? '}' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> mapping_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' items_pattern '}'")); + D(fprintf(stderr, "%*c> mapping_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' items_pattern? '}'")); Token * _literal; Token * _literal_1; void *items; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (items = items_pattern_rule(p)) // items_pattern + (items = items_pattern_rule(p), 1) // items_pattern? && (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' ) { - D(fprintf(stderr, "%*c+ mapping_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' items_pattern '}'")); + D(fprintf(stderr, "%*c+ mapping_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' items_pattern? '}'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5576,7 +5598,7 @@ mapping_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s mapping_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' items_pattern '}'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' items_pattern? '}'")); } _res = NULL; done: @@ -5586,9 +5608,10 @@ mapping_pattern_rule(Parser *p) // class_pattern: // | name_or_attr '(' ')' -// | name_or_attr '(' ','.pattern+ ','? ')' +// | name_or_attr '(' ','.arg_pattern+ ','? ')' // | name_or_attr '(' ','.keyword_pattern+ ','? ')' -// | name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')' +// | name_or_attr '(' ','.arg_pattern+ ',' ','.keyword_pattern+ ','? ')' +// | name_or_attr '(' [','.arg_pattern+ ','] ','.keyword_pattern+ ',' arg_pattern [',' ','.(arg_pattern | keyword_pattern)+] ','? ')' static void * class_pattern_rule(Parser *p) { @@ -5647,12 +5670,12 @@ class_pattern_rule(Parser *p) D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ')'")); } - { // name_or_attr '(' ','.pattern+ ','? ')' + { // name_or_attr '(' ','.arg_pattern+ ','? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ','? ')'")); + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.arg_pattern+ ','? ')'")); Token * _literal; Token * _literal_1; void *_opt_var; @@ -5664,14 +5687,14 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (args = _gather_53_rule(p)) // ','.pattern+ + (args = _gather_53_rule(p)) // ','.arg_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ','? ')'")); + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.arg_pattern+ ','? ')'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5691,7 +5714,7 @@ class_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.pattern+ ','? ')'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.arg_pattern+ ','? ')'")); } { // name_or_attr '(' ','.keyword_pattern+ ','? ')' if (p->error_indicator) { @@ -5739,12 +5762,12 @@ class_pattern_rule(Parser *p) D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.keyword_pattern+ ','? ')'")); } - { // name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')' + { // name_or_attr '(' ','.arg_pattern+ ',' ','.keyword_pattern+ ','? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'")); + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.arg_pattern+ ',' ','.keyword_pattern+ ','? ')'")); Token * _literal; Token * _literal_1; Token * _literal_2; @@ -5758,7 +5781,7 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (args = _gather_57_rule(p)) // ','.pattern+ + (args = _gather_57_rule(p)) // ','.arg_pattern+ && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && @@ -5769,7 +5792,7 @@ class_pattern_rule(Parser *p) (_literal_2 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'")); + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.arg_pattern+ ',' ','.keyword_pattern+ ','? ')'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5789,7 +5812,58 @@ class_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.arg_pattern+ ',' ','.keyword_pattern+ ','? ')'")); + } + { // name_or_attr '(' [','.arg_pattern+ ','] ','.keyword_pattern+ ',' arg_pattern [',' ','.(arg_pattern | keyword_pattern)+] ','? ')' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.arg_pattern+ ','] ','.keyword_pattern+ ',' arg_pattern [',' ','.(arg_pattern | keyword_pattern)+] ','? ')'")); + asdl_seq * _gather_62_var; + Token * _literal; + Token * _literal_1; + Token * _literal_2; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + void *_opt_var_2; + UNUSED(_opt_var_2); // Silence compiler warnings + expr_ty error; + void *func; + if ( + (func = name_or_attr_rule(p)) // name_or_attr + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (_opt_var = _tmp_61_rule(p), 1) // [','.arg_pattern+ ','] + && + (_gather_62_var = _gather_62_rule(p)) // ','.keyword_pattern+ + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + && + (error = arg_pattern_rule(p)) // arg_pattern + && + (_opt_var_1 = _tmp_64_rule(p), 1) // [',' ','.(arg_pattern | keyword_pattern)+] + && + (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? + && + (_literal_2 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.arg_pattern+ ','] ','.keyword_pattern+ ',' arg_pattern [',' ','.(arg_pattern | keyword_pattern)+] ','? ')'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "positional pattern follows keyword pattern" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' [','.arg_pattern+ ','] ','.keyword_pattern+ ',' arg_pattern [',' ','.(arg_pattern | keyword_pattern)+] ','? ')'")); } _res = NULL; done: @@ -5932,7 +6006,7 @@ values_pattern_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * values; if ( - (values = _gather_61_rule(p)) // ','.value_pattern+ + (values = _gather_65_rule(p)) // ','.value_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -5977,7 +6051,7 @@ items_pattern_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * items; if ( - (items = _gather_63_rule(p)) // ','.key_value_pattern+ + (items = _gather_67_rule(p)) // ','.key_value_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -6001,7 +6075,72 @@ items_pattern_rule(Parser *p) return _res; } -// keyword_pattern: NAME '=' or_pattern +// arg_pattern: pattern !'=' | '*' NAME +static expr_ty +arg_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + { // pattern !'=' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> arg_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern !'='")); + void *pattern_var; + if ( + (pattern_var = pattern_rule(p)) // pattern + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' + ) + { + D(fprintf(stderr, "%*c+ arg_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern !'='")); + _res = pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s arg_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern !'='")); + } + { // '*' NAME + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> arg_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' NAME")); + Token * error; + expr_ty name_var; + if ( + (error = _PyPegen_expect_token(p, 16)) // token='*' + && + (name_var = _PyPegen_name_token(p)) // NAME + ) + { + D(fprintf(stderr, "%*c+ arg_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' NAME")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "can't use starred pattern here" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s arg_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' NAME")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// keyword_pattern: NAME '=' or_pattern | '**' NAME static void * keyword_pattern_rule(Parser *p) { @@ -6060,6 +6199,33 @@ keyword_pattern_rule(Parser *p) D(fprintf(stderr, "%*c%s keyword_pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' or_pattern")); } + { // '**' NAME + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> keyword_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' NAME")); + Token * error; + expr_ty name_var; + if ( + (error = _PyPegen_expect_token(p, 35)) // token='**' + && + (name_var = _PyPegen_name_token(p)) // NAME + ) + { + D(fprintf(stderr, "%*c+ keyword_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' NAME")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "can't use starred pattern here" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s keyword_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' NAME")); + } _res = NULL; done: D(p->level--); @@ -6148,8 +6314,7 @@ value_pattern_rule(Parser *p) } // key_value_pattern: -// | literal_pattern ':' closed_pattern -// | constant_pattern ':' closed_pattern +// | (literal_pattern | constant_pattern) ':' closed_pattern // | '**' name_pattern static void * key_value_pattern_rule(Parser *p) @@ -6161,54 +6326,24 @@ key_value_pattern_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // literal_pattern ':' closed_pattern - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern ':' closed_pattern")); - Token * _literal; - void *key; - void *value; - if ( - (key = literal_pattern_rule(p)) // literal_pattern - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (value = closed_pattern_rule(p)) // closed_pattern - ) - { - D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern ':' closed_pattern")); - _res = _PyPegen_key_value_pair ( p , key , 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 key_value_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern ':' closed_pattern")); - } - { // constant_pattern ':' closed_pattern + { // (literal_pattern | constant_pattern) ':' closed_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern ':' closed_pattern")); + D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(literal_pattern | constant_pattern) ':' closed_pattern")); Token * _literal; void *key; void *value; if ( - (key = constant_pattern_rule(p)) // constant_pattern + (key = _tmp_69_rule(p)) // literal_pattern | constant_pattern && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && (value = closed_pattern_rule(p)) // closed_pattern ) { - D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "constant_pattern ':' closed_pattern")); + D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(literal_pattern | constant_pattern) ':' closed_pattern")); _res = _PyPegen_key_value_pair ( p , key , value ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -6219,7 +6354,7 @@ key_value_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s key_value_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "constant_pattern ':' closed_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(literal_pattern | constant_pattern) ':' closed_pattern")); } { // '**' name_pattern if (p->error_indicator) { @@ -6350,7 +6485,7 @@ raise_stmt_rule(Parser *p) && (a = expression_rule(p)) // expression && - (b = _tmp_65_rule(p), 1) // ['from' expression] + (b = _tmp_70_rule(p), 1) // ['from' expression] ) { D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); @@ -6525,7 +6660,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_66_rule(p), 1) // ['->' expression] + (a = _tmp_71_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -6585,7 +6720,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_67_rule(p), 1) // ['->' expression] + (a = _tmp_72_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -6649,7 +6784,7 @@ func_type_comment_rule(Parser *p) && (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' && - _PyPegen_lookahead(1, _tmp_68_rule, p) + _PyPegen_lookahead(1, _tmp_73_rule, p) ) { D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); @@ -6793,9 +6928,9 @@ parameters_rule(Parser *p) if ( (a = slash_no_default_rule(p)) // slash_no_default && - (b = _loop0_69_rule(p)) // param_no_default* + (b = _loop0_74_rule(p)) // param_no_default* && - (c = _loop0_70_rule(p)) // param_with_default* + (c = _loop0_75_rule(p)) // param_with_default* && (d = star_etc_rule(p), 1) // star_etc? ) @@ -6825,7 +6960,7 @@ parameters_rule(Parser *p) if ( (a = slash_with_default_rule(p)) // slash_with_default && - (b = _loop0_71_rule(p)) // param_with_default* + (b = _loop0_76_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -6853,9 +6988,9 @@ parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = _loop1_72_rule(p)) // param_no_default+ + (a = _loop1_77_rule(p)) // param_no_default+ && - (b = _loop0_73_rule(p)) // param_with_default* + (b = _loop0_78_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -6882,7 +7017,7 @@ parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_74_rule(p)) // param_with_default+ + (a = _loop1_79_rule(p)) // param_with_default+ && (b = star_etc_rule(p), 1) // star_etc? ) @@ -6951,7 +7086,7 @@ slash_no_default_rule(Parser *p) Token * _literal_1; asdl_seq * a; if ( - (a = _loop1_75_rule(p)) // param_no_default+ + (a = _loop1_80_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -6980,7 +7115,7 @@ slash_no_default_rule(Parser *p) Token * _literal; asdl_seq * a; if ( - (a = _loop1_76_rule(p)) // param_no_default+ + (a = _loop1_81_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7030,9 +7165,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_77_rule(p)) // param_no_default* + (a = _loop0_82_rule(p)) // param_no_default* && - (b = _loop1_78_rule(p)) // param_with_default+ + (b = _loop1_83_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7062,9 +7197,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_79_rule(p)) // param_no_default* + (a = _loop0_84_rule(p)) // param_no_default* && - (b = _loop1_80_rule(p)) // param_with_default+ + (b = _loop1_85_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7120,7 +7255,7 @@ star_etc_rule(Parser *p) && (a = param_no_default_rule(p)) // param_no_default && - (b = _loop0_81_rule(p)) // param_maybe_default* + (b = _loop0_86_rule(p)) // param_maybe_default* && (c = kwds_rule(p), 1) // kwds? ) @@ -7153,7 +7288,7 @@ star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_82_rule(p)) // param_maybe_default+ + (b = _loop1_87_rule(p)) // param_maybe_default+ && (c = kwds_rule(p), 1) // kwds? ) @@ -7675,7 +7810,7 @@ decorators_rule(Parser *p) D(fprintf(stderr, "%*c> decorators[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); asdl_seq * a; if ( - (a = _loop1_83_rule(p)) // (('@' named_expression NEWLINE))+ + (a = _loop1_88_rule(p)) // (('@' named_expression NEWLINE))+ ) { D(fprintf(stderr, "%*c+ decorators[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); @@ -7796,7 +7931,7 @@ class_def_raw_rule(Parser *p) && (a = _PyPegen_name_token(p)) // NAME && - (b = _tmp_84_rule(p), 1) // ['(' arguments? ')'] + (b = _tmp_89_rule(p), 1) // ['(' arguments? ')'] && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -7945,7 +8080,7 @@ expressions_list_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_85_rule(p)) // ','.star_expression+ + (a = _gather_90_rule(p)) // ','.star_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8005,7 +8140,7 @@ star_expressions_rule(Parser *p) if ( (a = star_expression_rule(p)) // star_expression && - (b = _loop1_87_rule(p)) // ((',' star_expression))+ + (b = _loop1_92_rule(p)) // ((',' star_expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8200,7 +8335,7 @@ star_named_expressions_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_88_rule(p)) // ','.star_named_expression+ + (a = _gather_93_rule(p)) // ','.star_named_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8498,7 +8633,7 @@ expressions_rule(Parser *p) if ( (a = expression_rule(p)) // expression && - (b = _loop1_90_rule(p)) // ((',' expression))+ + (b = _loop1_95_rule(p)) // ((',' expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8797,9 +8932,9 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default && - (b = _loop0_91_rule(p)) // lambda_param_no_default* + (b = _loop0_96_rule(p)) // lambda_param_no_default* && - (c = _loop0_92_rule(p)) // lambda_param_with_default* + (c = _loop0_97_rule(p)) // lambda_param_with_default* && (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -8829,7 +8964,7 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default && - (b = _loop0_93_rule(p)) // lambda_param_with_default* + (b = _loop0_98_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -8857,9 +8992,9 @@ lambda_parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = _loop1_94_rule(p)) // lambda_param_no_default+ + (a = _loop1_99_rule(p)) // lambda_param_no_default+ && - (b = _loop0_95_rule(p)) // lambda_param_with_default* + (b = _loop0_100_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -8886,7 +9021,7 @@ lambda_parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_96_rule(p)) // lambda_param_with_default+ + (a = _loop1_101_rule(p)) // lambda_param_with_default+ && (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -8957,7 +9092,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal_1; asdl_seq * a; if ( - (a = _loop1_97_rule(p)) // lambda_param_no_default+ + (a = _loop1_102_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -8986,7 +9121,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal; asdl_seq * a; if ( - (a = _loop1_98_rule(p)) // lambda_param_no_default+ + (a = _loop1_103_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9036,9 +9171,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_99_rule(p)) // lambda_param_no_default* + (a = _loop0_104_rule(p)) // lambda_param_no_default* && - (b = _loop1_100_rule(p)) // lambda_param_with_default+ + (b = _loop1_105_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9068,9 +9203,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_101_rule(p)) // lambda_param_no_default* + (a = _loop0_106_rule(p)) // lambda_param_no_default* && - (b = _loop1_102_rule(p)) // lambda_param_with_default+ + (b = _loop1_107_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9126,7 +9261,7 @@ lambda_star_etc_rule(Parser *p) && (a = lambda_param_no_default_rule(p)) // lambda_param_no_default && - (b = _loop0_103_rule(p)) // lambda_param_maybe_default* + (b = _loop0_108_rule(p)) // lambda_param_maybe_default* && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -9159,7 +9294,7 @@ lambda_star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_104_rule(p)) // lambda_param_maybe_default+ + (b = _loop1_109_rule(p)) // lambda_param_maybe_default+ && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -9586,7 +9721,7 @@ disjunction_rule(Parser *p) if ( (a = conjunction_rule(p)) // conjunction && - (b = _loop1_105_rule(p)) // (('or' conjunction))+ + (b = _loop1_110_rule(p)) // (('or' conjunction))+ ) { D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); @@ -9672,7 +9807,7 @@ conjunction_rule(Parser *p) if ( (a = inversion_rule(p)) // inversion && - (b = _loop1_106_rule(p)) // (('and' inversion))+ + (b = _loop1_111_rule(p)) // (('and' inversion))+ ) { D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); @@ -9840,7 +9975,7 @@ comparison_rule(Parser *p) if ( (a = bitwise_or_rule(p)) // bitwise_or && - (b = _loop1_107_rule(p)) // compare_op_bitwise_or_pair+ + (b = _loop1_112_rule(p)) // compare_op_bitwise_or_pair+ ) { D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); @@ -10168,10 +10303,10 @@ noteq_bitwise_or_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); - void *_tmp_108_var; + void *_tmp_113_var; expr_ty a; if ( - (_tmp_108_var = _tmp_108_rule(p)) // '!=' + (_tmp_113_var = _tmp_113_rule(p)) // '!=' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -12100,7 +12235,7 @@ slices_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_109_rule(p)) // ','.slice+ + (a = _gather_114_rule(p)) // ','.slice+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -12170,7 +12305,7 @@ slice_rule(Parser *p) && (b = expression_rule(p), 1) // expression? && - (c = _tmp_111_rule(p), 1) // [':' expression?] + (c = _tmp_116_rule(p), 1) // [':' expression?] ) { D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); @@ -12444,15 +12579,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - void *_tmp_112_var; + void *_tmp_117_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' && - (_tmp_112_var = _tmp_112_rule(p)) // tuple | group | genexp + (_tmp_117_var = _tmp_117_rule(p)) // tuple | group | genexp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - _res = _tmp_112_var; + _res = _tmp_117_var; goto done; } p->mark = _mark; @@ -12465,15 +12600,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - void *_tmp_113_var; + void *_tmp_118_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' && - (_tmp_113_var = _tmp_113_rule(p)) // list | listcomp + (_tmp_118_var = _tmp_118_rule(p)) // list | listcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - _res = _tmp_113_var; + _res = _tmp_118_var; goto done; } p->mark = _mark; @@ -12486,15 +12621,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - void *_tmp_114_var; + void *_tmp_119_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' && - (_tmp_114_var = _tmp_114_rule(p)) // dict | set | dictcomp | setcomp + (_tmp_119_var = _tmp_119_rule(p)) // dict | set | dictcomp | setcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - _res = _tmp_114_var; + _res = _tmp_119_var; goto done; } p->mark = _mark; @@ -12563,7 +12698,7 @@ strings_rule(Parser *p) D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+")); asdl_seq * a; if ( - (a = _loop1_115_rule(p)) // STRING+ + (a = _loop1_120_rule(p)) // STRING+ ) { D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+")); @@ -12770,7 +12905,7 @@ tuple_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_116_rule(p), 1) // [star_named_expression ',' star_named_expressions?] + (a = _tmp_121_rule(p), 1) // [star_named_expression ',' star_named_expressions?] && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -12826,7 +12961,7 @@ group_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_117_rule(p)) // yield_expr | named_expression + (a = _tmp_122_rule(p)) // yield_expr | named_expression && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -13262,7 +13397,7 @@ double_starred_kvpairs_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_118_rule(p)) // ','.double_starred_kvpair+ + (a = _gather_123_rule(p)) // ','.double_starred_kvpair+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -13413,13 +13548,13 @@ for_if_clauses_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); - asdl_seq * _loop1_120_var; + asdl_seq * _loop1_125_var; if ( - (_loop1_120_var = _loop1_120_rule(p)) // for_if_clause+ + (_loop1_125_var = _loop1_125_rule(p)) // for_if_clause+ ) { D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); - _res = _loop1_120_var; + _res = _loop1_125_var; goto done; } p->mark = _mark; @@ -13468,7 +13603,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = _loop0_121_rule(p)) // (('if' disjunction))* + (c = _loop0_126_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*")); @@ -13504,7 +13639,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = _loop0_122_rule(p)) // (('if' disjunction))* + (c = _loop0_127_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*")); @@ -13729,7 +13864,7 @@ args_rule(Parser *p) if ( (a = starred_expression_rule(p)) // starred_expression && - (b = _tmp_123_rule(p), 1) // [',' args] + (b = _tmp_128_rule(p), 1) // [',' args] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]")); @@ -13798,7 +13933,7 @@ args_rule(Parser *p) if ( (a = named_expression_rule(p)) // named_expression && - (b = _tmp_124_rule(p), 1) // [',' args] + (b = _tmp_129_rule(p), 1) // [',' args] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]")); @@ -13853,11 +13988,11 @@ kwargs_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _gather_125_rule(p)) // ','.kwarg_or_starred+ + (a = _gather_130_rule(p)) // ','.kwarg_or_starred+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _gather_127_rule(p)) // ','.kwarg_or_double_starred+ + (b = _gather_132_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); @@ -13879,13 +14014,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - asdl_seq * _gather_129_var; + asdl_seq * _gather_134_var; if ( - (_gather_129_var = _gather_129_rule(p)) // ','.kwarg_or_starred+ + (_gather_134_var = _gather_134_rule(p)) // ','.kwarg_or_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - _res = _gather_129_var; + _res = _gather_134_var; goto done; } p->mark = _mark; @@ -13898,13 +14033,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - asdl_seq * _gather_131_var; + asdl_seq * _gather_136_var; if ( - (_gather_131_var = _gather_131_rule(p)) // ','.kwarg_or_double_starred+ + (_gather_136_var = _gather_136_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - _res = _gather_131_var; + _res = _gather_136_var; goto done; } p->mark = _mark; @@ -14266,7 +14401,7 @@ star_targets_rule(Parser *p) if ( (a = star_target_rule(p)) // star_target && - (b = _loop0_133_rule(p)) // ((',' star_target))* + (b = _loop0_138_rule(p)) // ((',' star_target))* && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -14320,7 +14455,7 @@ star_targets_seq_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_134_rule(p)) // ','.star_target+ + (a = _gather_139_rule(p)) // ','.star_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -14383,7 +14518,7 @@ star_target_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (a = _tmp_136_rule(p)) // !'*' star_target + (a = _tmp_141_rule(p)) // !'*' star_target ) { D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); @@ -14905,7 +15040,7 @@ del_targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_137_rule(p)) // ','.del_target+ + (a = _gather_142_rule(p)) // ','.del_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -15384,7 +15519,7 @@ targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_139_rule(p)) // ','.target+ + (a = _gather_144_rule(p)) // ','.target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -16096,7 +16231,7 @@ incorrect_arguments_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_opt_var = _tmp_141_rule(p), 1) // [args | expression for_if_clauses] + (_opt_var = _tmp_146_rule(p), 1) // [args | expression for_if_clauses] ) { D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); @@ -16378,14 +16513,14 @@ invalid_assignment_rule(Parser *p) D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'")); Token * _literal; Token * _literal_1; - asdl_seq * _loop0_142_var; + asdl_seq * _loop0_147_var; expr_ty a; if ( (a = star_named_expression_rule(p)) // star_named_expression && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_loop0_142_var = _loop0_142_rule(p)) // star_named_expressions* + (_loop0_147_var = _loop0_147_rule(p)) // star_named_expressions* && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' ) @@ -16421,7 +16556,7 @@ invalid_assignment_rule(Parser *p) && (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_143_rule(p), 1) // ['=' annotated_rhs] + (_opt_var = _tmp_148_rule(p), 1) // ['=' annotated_rhs] ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]")); @@ -16444,14 +16579,14 @@ invalid_assignment_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); Token * _literal; - void *_tmp_144_var; + void *_tmp_149_var; expr_ty a; if ( (a = star_expressions_rule(p)) // star_expressions && (_literal = _PyPegen_expect_token(p, 22)) // token='=' && - (_tmp_144_var = _tmp_144_rule(p)) // yield_expr | star_expressions + (_tmp_149_var = _tmp_149_rule(p)) // yield_expr | star_expressions ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); @@ -16473,7 +16608,7 @@ invalid_assignment_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); - void *_tmp_145_var; + void *_tmp_150_var; expr_ty a; AugOperator* augassign_var; if ( @@ -16481,7 +16616,7 @@ invalid_assignment_rule(Parser *p) && (augassign_var = augassign_rule(p)) // augassign && - (_tmp_145_var = _tmp_145_rule(p)) // yield_expr | star_expressions + (_tmp_150_var = _tmp_150_rule(p)) // yield_expr | star_expressions ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); @@ -16563,11 +16698,11 @@ invalid_comprehension_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); - void *_tmp_146_var; + void *_tmp_151_var; expr_ty a; asdl_seq* for_if_clauses_var; if ( - (_tmp_146_var = _tmp_146_rule(p)) // '[' | '(' | '{' + (_tmp_151_var = _tmp_151_rule(p)) // '[' | '(' | '{' && (a = starred_expression_rule(p)) // starred_expression && @@ -16664,13 +16799,13 @@ invalid_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); - asdl_seq * _loop0_147_var; - void *_tmp_148_var; + asdl_seq * _loop0_152_var; + void *_tmp_153_var; arg_ty param_no_default_var; if ( - (_loop0_147_var = _loop0_147_rule(p)) // param_no_default* + (_loop0_152_var = _loop0_152_rule(p)) // param_no_default* && - (_tmp_148_var = _tmp_148_rule(p)) // slash_with_default | param_with_default+ + (_tmp_153_var = _tmp_153_rule(p)) // slash_with_default | param_with_default+ && (param_no_default_var = param_no_default_rule(p)) // param_no_default ) @@ -16712,11 +16847,11 @@ invalid_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); Token * _literal; - void *_tmp_149_var; + void *_tmp_154_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_149_var = _tmp_149_rule(p)) // ')' | ',' (')' | '**') + (_tmp_154_var = _tmp_154_rule(p)) // ')' | ',' (')' | '**') ) { D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); @@ -16786,11 +16921,11 @@ invalid_lambda_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); Token * _literal; - void *_tmp_150_var; + void *_tmp_155_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_150_var = _tmp_150_rule(p)) // ':' | ',' (':' | '**') + (_tmp_155_var = _tmp_155_rule(p)) // ':' | ',' (':' | '**') ) { D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); @@ -18200,12 +18335,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_151_var; + void *_tmp_156_var; while ( - (_tmp_151_var = _tmp_151_rule(p)) // star_targets '=' + (_tmp_156_var = _tmp_156_rule(p)) // star_targets '=' ) { - _res = _tmp_151_var; + _res = _tmp_156_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -18653,12 +18788,12 @@ _loop0_30_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop0_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_152_var; + void *_tmp_157_var; while ( - (_tmp_152_var = _tmp_152_rule(p)) // '.' | '...' + (_tmp_157_var = _tmp_157_rule(p)) // '.' | '...' ) { - _res = _tmp_152_var; + _res = _tmp_157_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -18719,12 +18854,12 @@ _loop1_31_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_153_var; + void *_tmp_158_var; while ( - (_tmp_153_var = _tmp_153_rule(p)) // '.' | '...' + (_tmp_158_var = _tmp_158_rule(p)) // '.' | '...' ) { - _res = _tmp_153_var; + _res = _tmp_158_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -19934,7 +20069,7 @@ _tmp_52_rule(Parser *p) return _res; } -// _loop0_54: ',' pattern +// _loop0_54: ',' arg_pattern static asdl_seq * _loop0_54_rule(Parser *p) { @@ -19955,18 +20090,18 @@ _loop0_54_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' pattern + { // ',' arg_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _loop0_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' arg_pattern")); Token * _literal; - void *elem; + expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = pattern_rule(p)) // pattern + (elem = arg_pattern_rule(p)) // arg_pattern ) { _res = elem; @@ -19992,7 +20127,7 @@ _loop0_54_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s _loop0_54[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' arg_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -20009,7 +20144,7 @@ _loop0_54_rule(Parser *p) return _seq; } -// _gather_53: pattern _loop0_54 +// _gather_53: arg_pattern _loop0_54 static asdl_seq * _gather_53_rule(Parser *p) { @@ -20020,27 +20155,27 @@ _gather_53_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // pattern _loop0_54 + { // arg_pattern _loop0_54 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_54")); - void *elem; + D(fprintf(stderr, "%*c> _gather_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "arg_pattern _loop0_54")); + expr_ty elem; asdl_seq * seq; if ( - (elem = pattern_rule(p)) // pattern + (elem = arg_pattern_rule(p)) // arg_pattern && (seq = _loop0_54_rule(p)) // _loop0_54 ) { - D(fprintf(stderr, "%*c+ _gather_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_54")); + D(fprintf(stderr, "%*c+ _gather_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "arg_pattern _loop0_54")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _gather_53[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_54")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "arg_pattern _loop0_54")); } _res = NULL; done: @@ -20162,7 +20297,7 @@ _gather_55_rule(Parser *p) return _res; } -// _loop0_58: ',' pattern +// _loop0_58: ',' arg_pattern static asdl_seq * _loop0_58_rule(Parser *p) { @@ -20183,18 +20318,18 @@ _loop0_58_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' pattern + { // ',' arg_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _loop0_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' arg_pattern")); Token * _literal; - void *elem; + expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = pattern_rule(p)) // pattern + (elem = arg_pattern_rule(p)) // arg_pattern ) { _res = elem; @@ -20220,7 +20355,7 @@ _loop0_58_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s _loop0_58[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' arg_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -20237,7 +20372,7 @@ _loop0_58_rule(Parser *p) return _seq; } -// _gather_57: pattern _loop0_58 +// _gather_57: arg_pattern _loop0_58 static asdl_seq * _gather_57_rule(Parser *p) { @@ -20248,27 +20383,27 @@ _gather_57_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // pattern _loop0_58 + { // arg_pattern _loop0_58 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_58")); - void *elem; + D(fprintf(stderr, "%*c> _gather_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "arg_pattern _loop0_58")); + expr_ty elem; asdl_seq * seq; if ( - (elem = pattern_rule(p)) // pattern + (elem = arg_pattern_rule(p)) // arg_pattern && (seq = _loop0_58_rule(p)) // _loop0_58 ) { - D(fprintf(stderr, "%*c+ _gather_57[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_58")); + D(fprintf(stderr, "%*c+ _gather_57[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "arg_pattern _loop0_58")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _gather_57[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_58")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "arg_pattern _loop0_58")); } _res = NULL; done: @@ -20390,9 +20525,48 @@ _gather_59_rule(Parser *p) return _res; } -// _loop0_62: ',' value_pattern +// _tmp_61: ','.arg_pattern+ ',' +static void * +_tmp_61_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ','.arg_pattern+ ',' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.arg_pattern+ ','")); + asdl_seq * _gather_159_var; + Token * _literal; + if ( + (_gather_159_var = _gather_159_rule(p)) // ','.arg_pattern+ + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_61[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.arg_pattern+ ','")); + _res = _PyPegen_dummy_name(p, _gather_159_var, _literal); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_61[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.arg_pattern+ ','")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_63: ',' keyword_pattern static asdl_seq * -_loop0_62_rule(Parser *p) +_loop0_63_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20411,18 +20585,18 @@ _loop0_62_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' value_pattern + { // ',' keyword_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' value_pattern")); + D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = value_pattern_rule(p)) // value_pattern + (elem = keyword_pattern_rule(p)) // keyword_pattern ) { _res = elem; @@ -20447,8 +20621,8 @@ _loop0_62_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_62[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' value_pattern")); + D(fprintf(stderr, "%*c%s _loop0_63[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -20460,14 +20634,14 @@ _loop0_62_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_62_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_63_type, _seq); D(p->level--); return _seq; } -// _gather_61: value_pattern _loop0_62 +// _gather_62: keyword_pattern _loop0_63 static asdl_seq * -_gather_61_rule(Parser *p) +_gather_62_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20476,27 +20650,66 @@ _gather_61_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // value_pattern _loop0_62 + { // keyword_pattern _loop0_63 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_62")); + D(fprintf(stderr, "%*c> _gather_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_63")); void *elem; asdl_seq * seq; if ( - (elem = value_pattern_rule(p)) // value_pattern + (elem = keyword_pattern_rule(p)) // keyword_pattern && - (seq = _loop0_62_rule(p)) // _loop0_62 + (seq = _loop0_63_rule(p)) // _loop0_63 ) { - D(fprintf(stderr, "%*c+ _gather_61[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_62")); + D(fprintf(stderr, "%*c+ _gather_62[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_63")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_61[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern _loop0_62")); + D(fprintf(stderr, "%*c%s _gather_62[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_63")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_64: ',' ','.(arg_pattern | keyword_pattern)+ +static void * +_tmp_64_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ',' ','.(arg_pattern | keyword_pattern)+ + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(arg_pattern | keyword_pattern)+")); + asdl_seq * _gather_161_var; + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (_gather_161_var = _gather_161_rule(p)) // ','.(arg_pattern | keyword_pattern)+ + ) + { + D(fprintf(stderr, "%*c+ _tmp_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(arg_pattern | keyword_pattern)+")); + _res = _PyPegen_dummy_name(p, _literal, _gather_161_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_64[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.(arg_pattern | keyword_pattern)+")); } _res = NULL; done: @@ -20504,9 +20717,9 @@ _gather_61_rule(Parser *p) return _res; } -// _loop0_64: ',' key_value_pattern +// _loop0_66: ',' value_pattern static asdl_seq * -_loop0_64_rule(Parser *p) +_loop0_66_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20525,18 +20738,18 @@ _loop0_64_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' key_value_pattern + { // ',' value_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); + D(fprintf(stderr, "%*c> _loop0_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' value_pattern")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = key_value_pattern_rule(p)) // key_value_pattern + (elem = value_pattern_rule(p)) // value_pattern ) { _res = elem; @@ -20561,8 +20774,8 @@ _loop0_64_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_64[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' key_value_pattern")); + D(fprintf(stderr, "%*c%s _loop0_66[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' value_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -20574,14 +20787,14 @@ _loop0_64_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_64_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_66_type, _seq); D(p->level--); return _seq; } -// _gather_63: key_value_pattern _loop0_64 +// _gather_65: value_pattern _loop0_66 static asdl_seq * -_gather_63_rule(Parser *p) +_gather_65_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20590,27 +20803,27 @@ _gather_63_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // key_value_pattern _loop0_64 + { // value_pattern _loop0_66 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_64")); + D(fprintf(stderr, "%*c> _gather_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_66")); void *elem; asdl_seq * seq; if ( - (elem = key_value_pattern_rule(p)) // key_value_pattern + (elem = value_pattern_rule(p)) // value_pattern && - (seq = _loop0_64_rule(p)) // _loop0_64 + (seq = _loop0_66_rule(p)) // _loop0_66 ) { - D(fprintf(stderr, "%*c+ _gather_63[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_64")); + D(fprintf(stderr, "%*c+ _gather_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_66")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_63[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_64")); + D(fprintf(stderr, "%*c%s _gather_65[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern _loop0_66")); } _res = NULL; done: @@ -20618,32 +20831,201 @@ _gather_63_rule(Parser *p) return _res; } -// _tmp_65: 'from' expression -static void * -_tmp_65_rule(Parser *p) +// _loop0_68: ',' key_value_pattern +static asdl_seq * +_loop0_68_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // 'from' expression + int _start_mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' key_value_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); - Token * _keyword; - expr_ty z; - if ( - (_keyword = _PyPegen_expect_token(p, 514)) // token='from' - && + D(fprintf(stderr, "%*c> _loop0_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); + Token * _literal; + void *elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = key_value_pattern_rule(p)) // key_value_pattern + ) + { + _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_68[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' key_value_pattern")); + } + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_68_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_67: key_value_pattern _loop0_68 +static asdl_seq * +_gather_67_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // key_value_pattern _loop0_68 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _gather_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_68")); + void *elem; + asdl_seq * seq; + if ( + (elem = key_value_pattern_rule(p)) // key_value_pattern + && + (seq = _loop0_68_rule(p)) // _loop0_68 + ) + { + D(fprintf(stderr, "%*c+ _gather_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_68")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_67[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_68")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_69: literal_pattern | constant_pattern +static void * +_tmp_69_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // literal_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + void *literal_pattern_var; + if ( + (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern + ) + { + D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + _res = literal_pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_69[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern")); + } + { // constant_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern")); + void *constant_pattern_var; + if ( + (constant_pattern_var = constant_pattern_rule(p)) // constant_pattern + ) + { + D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "constant_pattern")); + _res = constant_pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_69[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "constant_pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_70: 'from' expression +static void * +_tmp_70_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'from' expression + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); + Token * _keyword; + expr_ty z; + if ( + (_keyword = _PyPegen_expect_token(p, 514)) // token='from' + && (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); + D(fprintf(stderr, "%*c+ _tmp_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -20653,7 +21035,7 @@ _tmp_65_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_65[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_70[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression")); } _res = NULL; @@ -20662,9 +21044,9 @@ _tmp_65_rule(Parser *p) return _res; } -// _tmp_66: '->' expression +// _tmp_71: '->' expression static void * -_tmp_66_rule(Parser *p) +_tmp_71_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20678,7 +21060,7 @@ _tmp_66_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -20687,7 +21069,7 @@ _tmp_66_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_71[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -20697,7 +21079,7 @@ _tmp_66_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_66[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_71[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -20706,9 +21088,9 @@ _tmp_66_rule(Parser *p) return _res; } -// _tmp_67: '->' expression +// _tmp_72: '->' expression static void * -_tmp_67_rule(Parser *p) +_tmp_72_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20722,7 +21104,7 @@ _tmp_67_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -20731,7 +21113,7 @@ _tmp_67_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -20741,7 +21123,7 @@ _tmp_67_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_67[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_72[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -20750,9 +21132,9 @@ _tmp_67_rule(Parser *p) return _res; } -// _tmp_68: NEWLINE INDENT +// _tmp_73: NEWLINE INDENT static void * -_tmp_68_rule(Parser *p) +_tmp_73_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20766,7 +21148,7 @@ _tmp_68_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c> _tmp_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); Token * indent_var; Token * newline_var; if ( @@ -20775,12 +21157,12 @@ _tmp_68_rule(Parser *p) (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' ) { - D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c+ _tmp_73[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); _res = _PyPegen_dummy_name(p, newline_var, indent_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_73[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); } _res = NULL; @@ -20789,9 +21171,9 @@ _tmp_68_rule(Parser *p) return _res; } -// _loop0_69: param_no_default +// _loop0_74: param_no_default static asdl_seq * -_loop0_69_rule(Parser *p) +_loop0_74_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20815,7 +21197,7 @@ _loop0_69_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_74[%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 @@ -20837,7 +21219,7 @@ _loop0_69_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_69[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_74[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20850,14 +21232,14 @@ _loop0_69_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_69_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_74_type, _seq); D(p->level--); return _seq; } -// _loop0_70: param_with_default +// _loop0_75: param_with_default static asdl_seq * -_loop0_70_rule(Parser *p) +_loop0_75_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20881,7 +21263,7 @@ _loop0_70_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -20903,7 +21285,7 @@ _loop0_70_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_70[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_75[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20916,14 +21298,14 @@ _loop0_70_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_70_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_75_type, _seq); D(p->level--); return _seq; } -// _loop0_71: param_with_default +// _loop0_76: param_with_default static asdl_seq * -_loop0_71_rule(Parser *p) +_loop0_76_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20947,7 +21329,7 @@ _loop0_71_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -20969,7 +21351,7 @@ _loop0_71_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_71[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_76[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20982,14 +21364,14 @@ _loop0_71_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_71_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_76_type, _seq); D(p->level--); return _seq; } -// _loop1_72: param_no_default +// _loop1_77: param_no_default static asdl_seq * -_loop1_72_rule(Parser *p) +_loop1_77_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21013,7 +21395,7 @@ _loop1_72_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_77[%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 @@ -21035,7 +21417,7 @@ _loop1_72_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_72[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_77[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -21053,14 +21435,14 @@ _loop1_72_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_72_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_77_type, _seq); D(p->level--); return _seq; } -// _loop0_73: param_with_default +// _loop0_78: param_with_default static asdl_seq * -_loop0_73_rule(Parser *p) +_loop0_78_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21084,7 +21466,7 @@ _loop0_73_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21106,7 +21488,7 @@ _loop0_73_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_73[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_78[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21119,14 +21501,14 @@ _loop0_73_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_73_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_78_type, _seq); D(p->level--); return _seq; } -// _loop1_74: param_with_default +// _loop1_79: param_with_default static asdl_seq * -_loop1_74_rule(Parser *p) +_loop1_79_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21150,7 +21532,7 @@ _loop1_74_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21172,7 +21554,7 @@ _loop1_74_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_74[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_79[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -21190,14 +21572,14 @@ _loop1_74_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_74_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_79_type, _seq); D(p->level--); return _seq; } -// _loop1_75: param_no_default +// _loop1_80: param_no_default static asdl_seq * -_loop1_75_rule(Parser *p) +_loop1_80_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21221,7 +21603,7 @@ _loop1_75_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_80[%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 @@ -21243,7 +21625,7 @@ _loop1_75_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_75[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_80[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -21261,14 +21643,14 @@ _loop1_75_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_75_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_80_type, _seq); D(p->level--); return _seq; } -// _loop1_76: param_no_default +// _loop1_81: param_no_default static asdl_seq * -_loop1_76_rule(Parser *p) +_loop1_81_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21292,7 +21674,7 @@ _loop1_76_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_81[%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 @@ -21314,7 +21696,7 @@ _loop1_76_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_76[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -21332,14 +21714,14 @@ _loop1_76_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_76_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq); D(p->level--); return _seq; } -// _loop0_77: param_no_default +// _loop0_82: param_no_default static asdl_seq * -_loop0_77_rule(Parser *p) +_loop0_82_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21363,7 +21745,7 @@ _loop0_77_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_82[%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 @@ -21385,7 +21767,7 @@ _loop0_77_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_77[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_82[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21398,14 +21780,14 @@ _loop0_77_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_77_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_82_type, _seq); D(p->level--); return _seq; } -// _loop1_78: param_with_default +// _loop1_83: param_with_default static asdl_seq * -_loop1_78_rule(Parser *p) +_loop1_83_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21429,7 +21811,7 @@ _loop1_78_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21451,7 +21833,7 @@ _loop1_78_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_78[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -21469,14 +21851,14 @@ _loop1_78_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_78_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); D(p->level--); return _seq; } -// _loop0_79: param_no_default +// _loop0_84: param_no_default static asdl_seq * -_loop0_79_rule(Parser *p) +_loop0_84_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21500,7 +21882,7 @@ _loop0_79_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_84[%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 @@ -21522,7 +21904,7 @@ _loop0_79_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_79[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_84[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21535,14 +21917,14 @@ _loop0_79_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_84_type, _seq); D(p->level--); return _seq; } -// _loop1_80: param_with_default +// _loop1_85: param_with_default static asdl_seq * -_loop1_80_rule(Parser *p) +_loop1_85_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21566,7 +21948,7 @@ _loop1_80_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21588,7 +21970,7 @@ _loop1_80_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_80[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_85[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -21606,14 +21988,14 @@ _loop1_80_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_80_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_85_type, _seq); D(p->level--); return _seq; } -// _loop0_81: param_maybe_default +// _loop0_86: param_maybe_default static asdl_seq * -_loop0_81_rule(Parser *p) +_loop0_86_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21637,7 +22019,7 @@ _loop0_81_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -21659,7 +22041,7 @@ _loop0_81_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_81[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_86[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21672,14 +22054,14 @@ _loop0_81_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_81_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_86_type, _seq); D(p->level--); return _seq; } -// _loop1_82: param_maybe_default +// _loop1_87: param_maybe_default static asdl_seq * -_loop1_82_rule(Parser *p) +_loop1_87_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21703,7 +22085,7 @@ _loop1_82_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -21725,7 +22107,7 @@ _loop1_82_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_82[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -21743,14 +22125,14 @@ _loop1_82_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_82_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_87_type, _seq); D(p->level--); return _seq; } -// _loop1_83: ('@' named_expression NEWLINE) +// _loop1_88: ('@' named_expression NEWLINE) static asdl_seq * -_loop1_83_rule(Parser *p) +_loop1_88_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21774,13 +22156,13 @@ _loop1_83_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); - void *_tmp_154_var; + D(fprintf(stderr, "%*c> _loop1_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); + void *_tmp_163_var; while ( - (_tmp_154_var = _tmp_154_rule(p)) // '@' named_expression NEWLINE + (_tmp_163_var = _tmp_163_rule(p)) // '@' named_expression NEWLINE ) { - _res = _tmp_154_var; + _res = _tmp_163_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -21796,7 +22178,7 @@ _loop1_83_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_88[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)")); } if (_n == 0 || p->error_indicator) { @@ -21814,14 +22196,14 @@ _loop1_83_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_88_type, _seq); D(p->level--); return _seq; } -// _tmp_84: '(' arguments? ')' +// _tmp_89: '(' arguments? ')' static void * -_tmp_84_rule(Parser *p) +_tmp_89_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21835,7 +22217,7 @@ _tmp_84_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c> _tmp_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); Token * _literal; Token * _literal_1; void *z; @@ -21847,7 +22229,7 @@ _tmp_84_rule(Parser *p) (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_84[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c+ _tmp_89[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21857,7 +22239,7 @@ _tmp_84_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_84[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_89[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); } _res = NULL; @@ -21866,9 +22248,9 @@ _tmp_84_rule(Parser *p) return _res; } -// _loop0_86: ',' star_expression +// _loop0_91: ',' star_expression static asdl_seq * -_loop0_86_rule(Parser *p) +_loop0_91_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21892,7 +22274,7 @@ _loop0_86_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _loop0_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty elem; while ( @@ -21923,7 +22305,7 @@ _loop0_86_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_86[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_91[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21936,14 +22318,14 @@ _loop0_86_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_86_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_91_type, _seq); D(p->level--); return _seq; } -// _gather_85: star_expression _loop0_86 +// _gather_90: star_expression _loop0_91 static asdl_seq * -_gather_85_rule(Parser *p) +_gather_90_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21952,27 +22334,27 @@ _gather_85_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_expression _loop0_86 + { // star_expression _loop0_91 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_86")); + D(fprintf(stderr, "%*c> _gather_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_91")); expr_ty elem; asdl_seq * seq; if ( (elem = star_expression_rule(p)) // star_expression && - (seq = _loop0_86_rule(p)) // _loop0_86 + (seq = _loop0_91_rule(p)) // _loop0_91 ) { - D(fprintf(stderr, "%*c+ _gather_85[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_86")); + D(fprintf(stderr, "%*c+ _gather_90[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_91")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_85[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_86")); + D(fprintf(stderr, "%*c%s _gather_90[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_91")); } _res = NULL; done: @@ -21980,9 +22362,9 @@ _gather_85_rule(Parser *p) return _res; } -// _loop1_87: (',' star_expression) +// _loop1_92: (',' star_expression) static asdl_seq * -_loop1_87_rule(Parser *p) +_loop1_92_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22006,13 +22388,13 @@ _loop1_87_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); - void *_tmp_155_var; + D(fprintf(stderr, "%*c> _loop1_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); + void *_tmp_164_var; while ( - (_tmp_155_var = _tmp_155_rule(p)) // ',' star_expression + (_tmp_164_var = _tmp_164_rule(p)) // ',' star_expression ) { - _res = _tmp_155_var; + _res = _tmp_164_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22028,7 +22410,7 @@ _loop1_87_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_92[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); } if (_n == 0 || p->error_indicator) { @@ -22046,14 +22428,14 @@ _loop1_87_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_87_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_92_type, _seq); D(p->level--); return _seq; } -// _loop0_89: ',' star_named_expression +// _loop0_94: ',' star_named_expression static asdl_seq * -_loop0_89_rule(Parser *p) +_loop0_94_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22077,7 +22459,7 @@ _loop0_89_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); + D(fprintf(stderr, "%*c> _loop0_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); Token * _literal; expr_ty elem; while ( @@ -22108,7 +22490,7 @@ _loop0_89_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_89[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_94[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22121,14 +22503,14 @@ _loop0_89_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_89_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_94_type, _seq); D(p->level--); return _seq; } -// _gather_88: star_named_expression _loop0_89 +// _gather_93: star_named_expression _loop0_94 static asdl_seq * -_gather_88_rule(Parser *p) +_gather_93_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22137,27 +22519,27 @@ _gather_88_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_named_expression _loop0_89 + { // star_named_expression _loop0_94 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_89")); + D(fprintf(stderr, "%*c> _gather_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_94")); expr_ty elem; asdl_seq * seq; if ( (elem = star_named_expression_rule(p)) // star_named_expression && - (seq = _loop0_89_rule(p)) // _loop0_89 + (seq = _loop0_94_rule(p)) // _loop0_94 ) { - D(fprintf(stderr, "%*c+ _gather_88[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_89")); + D(fprintf(stderr, "%*c+ _gather_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_94")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_88[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_89")); + D(fprintf(stderr, "%*c%s _gather_93[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_94")); } _res = NULL; done: @@ -22165,9 +22547,9 @@ _gather_88_rule(Parser *p) return _res; } -// _loop1_90: (',' expression) +// _loop1_95: (',' expression) static asdl_seq * -_loop1_90_rule(Parser *p) +_loop1_95_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22191,13 +22573,13 @@ _loop1_90_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); - void *_tmp_156_var; + D(fprintf(stderr, "%*c> _loop1_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); + void *_tmp_165_var; while ( - (_tmp_156_var = _tmp_156_rule(p)) // ',' expression + (_tmp_165_var = _tmp_165_rule(p)) // ',' expression ) { - _res = _tmp_156_var; + _res = _tmp_165_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22213,7 +22595,7 @@ _loop1_90_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_90[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); } if (_n == 0 || p->error_indicator) { @@ -22231,14 +22613,14 @@ _loop1_90_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_90_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_95_type, _seq); D(p->level--); return _seq; } -// _loop0_91: lambda_param_no_default +// _loop0_96: lambda_param_no_default static asdl_seq * -_loop0_91_rule(Parser *p) +_loop0_96_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22262,7 +22644,7 @@ _loop0_91_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_96[%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 @@ -22284,7 +22666,7 @@ _loop0_91_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_91[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_96[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22297,14 +22679,14 @@ _loop0_91_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_91_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_96_type, _seq); D(p->level--); return _seq; } -// _loop0_92: lambda_param_with_default +// _loop0_97: lambda_param_with_default static asdl_seq * -_loop0_92_rule(Parser *p) +_loop0_97_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22328,7 +22710,7 @@ _loop0_92_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22350,7 +22732,7 @@ _loop0_92_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_92[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_97[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22363,14 +22745,14 @@ _loop0_92_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_92_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_97_type, _seq); D(p->level--); return _seq; } -// _loop0_93: lambda_param_with_default +// _loop0_98: lambda_param_with_default static asdl_seq * -_loop0_93_rule(Parser *p) +_loop0_98_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22394,7 +22776,7 @@ _loop0_93_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22416,7 +22798,7 @@ _loop0_93_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_93[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_98[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22429,14 +22811,14 @@ _loop0_93_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_93_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_98_type, _seq); D(p->level--); return _seq; } -// _loop1_94: lambda_param_no_default +// _loop1_99: lambda_param_no_default static asdl_seq * -_loop1_94_rule(Parser *p) +_loop1_99_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22460,7 +22842,7 @@ _loop1_94_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_99[%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 @@ -22482,7 +22864,7 @@ _loop1_94_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_94[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_99[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -22500,14 +22882,14 @@ _loop1_94_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_94_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq); D(p->level--); return _seq; } -// _loop0_95: lambda_param_with_default +// _loop0_100: lambda_param_with_default static asdl_seq * -_loop0_95_rule(Parser *p) +_loop0_100_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22531,7 +22913,7 @@ _loop0_95_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22553,7 +22935,7 @@ _loop0_95_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_95[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_100[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22566,14 +22948,14 @@ _loop0_95_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_95_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_100_type, _seq); D(p->level--); return _seq; } -// _loop1_96: lambda_param_with_default +// _loop1_101: lambda_param_with_default static asdl_seq * -_loop1_96_rule(Parser *p) +_loop1_101_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22597,7 +22979,7 @@ _loop1_96_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22619,7 +23001,7 @@ _loop1_96_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_96[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_101[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -22637,14 +23019,14 @@ _loop1_96_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_96_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_101_type, _seq); D(p->level--); return _seq; } -// _loop1_97: lambda_param_no_default +// _loop1_102: lambda_param_no_default static asdl_seq * -_loop1_97_rule(Parser *p) +_loop1_102_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22668,7 +23050,7 @@ _loop1_97_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_102[%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 @@ -22690,7 +23072,7 @@ _loop1_97_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_97[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_102[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -22708,14 +23090,14 @@ _loop1_97_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_97_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_102_type, _seq); D(p->level--); return _seq; } -// _loop1_98: lambda_param_no_default +// _loop1_103: lambda_param_no_default static asdl_seq * -_loop1_98_rule(Parser *p) +_loop1_103_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22739,7 +23121,7 @@ _loop1_98_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_103[%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 @@ -22761,7 +23143,7 @@ _loop1_98_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_98[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_103[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -22779,14 +23161,14 @@ _loop1_98_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_98_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_103_type, _seq); D(p->level--); return _seq; } -// _loop0_99: lambda_param_no_default +// _loop0_104: lambda_param_no_default static asdl_seq * -_loop0_99_rule(Parser *p) +_loop0_104_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22810,7 +23192,7 @@ _loop0_99_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_104[%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 @@ -22832,7 +23214,7 @@ _loop0_99_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_99[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_104[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22845,14 +23227,14 @@ _loop0_99_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_99_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_104_type, _seq); D(p->level--); return _seq; } -// _loop1_100: lambda_param_with_default +// _loop1_105: lambda_param_with_default static asdl_seq * -_loop1_100_rule(Parser *p) +_loop1_105_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22876,7 +23258,7 @@ _loop1_100_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22898,7 +23280,7 @@ _loop1_100_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_100[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -22916,14 +23298,14 @@ _loop1_100_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_100_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq); D(p->level--); return _seq; } -// _loop0_101: lambda_param_no_default +// _loop0_106: lambda_param_no_default static asdl_seq * -_loop0_101_rule(Parser *p) +_loop0_106_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22947,7 +23329,7 @@ _loop0_101_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_106[%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 @@ -22969,7 +23351,7 @@ _loop0_101_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_101[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_106[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22982,14 +23364,14 @@ _loop0_101_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_101_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_106_type, _seq); D(p->level--); return _seq; } -// _loop1_102: lambda_param_with_default +// _loop1_107: lambda_param_with_default static asdl_seq * -_loop1_102_rule(Parser *p) +_loop1_107_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23013,7 +23395,7 @@ _loop1_102_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23035,7 +23417,7 @@ _loop1_102_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_102[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_107[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -23053,14 +23435,14 @@ _loop1_102_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_102_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_107_type, _seq); D(p->level--); return _seq; } -// _loop0_103: lambda_param_maybe_default +// _loop0_108: lambda_param_maybe_default static asdl_seq * -_loop0_103_rule(Parser *p) +_loop0_108_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23084,7 +23466,7 @@ _loop0_103_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -23106,7 +23488,7 @@ _loop0_103_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_108[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23119,14 +23501,14 @@ _loop0_103_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_103_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_108_type, _seq); D(p->level--); return _seq; } -// _loop1_104: lambda_param_maybe_default +// _loop1_109: lambda_param_maybe_default static asdl_seq * -_loop1_104_rule(Parser *p) +_loop1_109_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23150,7 +23532,7 @@ _loop1_104_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -23172,7 +23554,7 @@ _loop1_104_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_104[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_109[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -23190,14 +23572,14 @@ _loop1_104_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_104_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_109_type, _seq); D(p->level--); return _seq; } -// _loop1_105: ('or' conjunction) +// _loop1_110: ('or' conjunction) static asdl_seq * -_loop1_105_rule(Parser *p) +_loop1_110_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23221,13 +23603,13 @@ _loop1_105_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); - void *_tmp_157_var; + D(fprintf(stderr, "%*c> _loop1_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); + void *_tmp_166_var; while ( - (_tmp_157_var = _tmp_157_rule(p)) // 'or' conjunction + (_tmp_166_var = _tmp_166_rule(p)) // 'or' conjunction ) { - _res = _tmp_157_var; + _res = _tmp_166_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23243,7 +23625,7 @@ _loop1_105_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_110[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); } if (_n == 0 || p->error_indicator) { @@ -23261,14 +23643,14 @@ _loop1_105_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_110_type, _seq); D(p->level--); return _seq; } -// _loop1_106: ('and' inversion) +// _loop1_111: ('and' inversion) static asdl_seq * -_loop1_106_rule(Parser *p) +_loop1_111_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23292,13 +23674,13 @@ _loop1_106_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); - void *_tmp_158_var; + D(fprintf(stderr, "%*c> _loop1_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); + void *_tmp_167_var; while ( - (_tmp_158_var = _tmp_158_rule(p)) // 'and' inversion + (_tmp_167_var = _tmp_167_rule(p)) // 'and' inversion ) { - _res = _tmp_158_var; + _res = _tmp_167_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23314,7 +23696,7 @@ _loop1_106_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_111[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); } if (_n == 0 || p->error_indicator) { @@ -23332,14 +23714,14 @@ _loop1_106_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_106_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_111_type, _seq); D(p->level--); return _seq; } -// _loop1_107: compare_op_bitwise_or_pair +// _loop1_112: compare_op_bitwise_or_pair static asdl_seq * -_loop1_107_rule(Parser *p) +_loop1_112_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23363,7 +23745,7 @@ _loop1_107_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); + D(fprintf(stderr, "%*c> _loop1_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); CmpopExprPair* compare_op_bitwise_or_pair_var; while ( (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair @@ -23385,7 +23767,7 @@ _loop1_107_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_107[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_112[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); } if (_n == 0 || p->error_indicator) { @@ -23403,14 +23785,14 @@ _loop1_107_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_107_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_112_type, _seq); D(p->level--); return _seq; } -// _tmp_108: '!=' +// _tmp_113: '!=' static void * -_tmp_108_rule(Parser *p) +_tmp_113_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23424,13 +23806,13 @@ _tmp_108_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); Token * tok; if ( (tok = _PyPegen_expect_token(p, 28)) // token='!=' ) { - D(fprintf(stderr, "%*c+ _tmp_108[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23440,7 +23822,7 @@ _tmp_108_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_108[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); } _res = NULL; @@ -23449,9 +23831,9 @@ _tmp_108_rule(Parser *p) return _res; } -// _loop0_110: ',' slice +// _loop0_115: ',' slice static asdl_seq * -_loop0_110_rule(Parser *p) +_loop0_115_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23475,7 +23857,7 @@ _loop0_110_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); + D(fprintf(stderr, "%*c> _loop0_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); Token * _literal; expr_ty elem; while ( @@ -23506,7 +23888,7 @@ _loop0_110_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_110[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_115[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' slice")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23519,14 +23901,14 @@ _loop0_110_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_115_type, _seq); D(p->level--); return _seq; } -// _gather_109: slice _loop0_110 +// _gather_114: slice _loop0_115 static asdl_seq * -_gather_109_rule(Parser *p) +_gather_114_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23535,27 +23917,27 @@ _gather_109_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // slice _loop0_110 + { // slice _loop0_115 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_110")); + D(fprintf(stderr, "%*c> _gather_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_115")); expr_ty elem; asdl_seq * seq; if ( (elem = slice_rule(p)) // slice && - (seq = _loop0_110_rule(p)) // _loop0_110 + (seq = _loop0_115_rule(p)) // _loop0_115 ) { - D(fprintf(stderr, "%*c+ _gather_109[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_110")); + D(fprintf(stderr, "%*c+ _gather_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_115")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_109[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_110")); + D(fprintf(stderr, "%*c%s _gather_114[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_115")); } _res = NULL; done: @@ -23563,9 +23945,9 @@ _gather_109_rule(Parser *p) return _res; } -// _tmp_111: ':' expression? +// _tmp_116: ':' expression? static void * -_tmp_111_rule(Parser *p) +_tmp_116_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23579,7 +23961,7 @@ _tmp_111_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); Token * _literal; void *d; if ( @@ -23588,7 +23970,7 @@ _tmp_111_rule(Parser *p) (d = expression_rule(p), 1) // expression? ) { - D(fprintf(stderr, "%*c+ _tmp_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); _res = d; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23598,7 +23980,7 @@ _tmp_111_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_111[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); } _res = NULL; @@ -23607,9 +23989,9 @@ _tmp_111_rule(Parser *p) return _res; } -// _tmp_112: tuple | group | genexp +// _tmp_117: tuple | group | genexp static void * -_tmp_112_rule(Parser *p) +_tmp_117_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23623,18 +24005,18 @@ _tmp_112_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); expr_ty tuple_var; if ( (tuple_var = tuple_rule(p)) // tuple ) { - D(fprintf(stderr, "%*c+ _tmp_112[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); _res = tuple_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_112[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); } { // group @@ -23642,18 +24024,18 @@ _tmp_112_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); expr_ty group_var; if ( (group_var = group_rule(p)) // group ) { - D(fprintf(stderr, "%*c+ _tmp_112[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); _res = group_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_112[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group")); } { // genexp @@ -23661,18 +24043,18 @@ _tmp_112_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); expr_ty genexp_var; if ( (genexp_var = genexp_rule(p)) // genexp ) { - D(fprintf(stderr, "%*c+ _tmp_112[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); _res = genexp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_112[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); } _res = NULL; @@ -23681,9 +24063,9 @@ _tmp_112_rule(Parser *p) return _res; } -// _tmp_113: list | listcomp +// _tmp_118: list | listcomp static void * -_tmp_113_rule(Parser *p) +_tmp_118_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23697,18 +24079,18 @@ _tmp_113_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); expr_ty list_var; if ( (list_var = list_rule(p)) // list ) { - D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); _res = list_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); } { // listcomp @@ -23716,18 +24098,18 @@ _tmp_113_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); expr_ty listcomp_var; if ( (listcomp_var = listcomp_rule(p)) // listcomp ) { - D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); _res = listcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp")); } _res = NULL; @@ -23736,9 +24118,9 @@ _tmp_113_rule(Parser *p) return _res; } -// _tmp_114: dict | set | dictcomp | setcomp +// _tmp_119: dict | set | dictcomp | setcomp static void * -_tmp_114_rule(Parser *p) +_tmp_119_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23752,18 +24134,18 @@ _tmp_114_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); expr_ty dict_var; if ( (dict_var = dict_rule(p)) // dict ) { - D(fprintf(stderr, "%*c+ _tmp_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); _res = dict_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_114[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict")); } { // set @@ -23771,18 +24153,18 @@ _tmp_114_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); expr_ty set_var; if ( (set_var = set_rule(p)) // set ) { - D(fprintf(stderr, "%*c+ _tmp_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); _res = set_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_114[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set")); } { // dictcomp @@ -23790,18 +24172,18 @@ _tmp_114_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); expr_ty dictcomp_var; if ( (dictcomp_var = dictcomp_rule(p)) // dictcomp ) { - D(fprintf(stderr, "%*c+ _tmp_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); _res = dictcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_114[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp")); } { // setcomp @@ -23809,18 +24191,18 @@ _tmp_114_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); expr_ty setcomp_var; if ( (setcomp_var = setcomp_rule(p)) // setcomp ) { - D(fprintf(stderr, "%*c+ _tmp_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); _res = setcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_114[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp")); } _res = NULL; @@ -23829,9 +24211,9 @@ _tmp_114_rule(Parser *p) return _res; } -// _loop1_115: STRING +// _loop1_120: STRING static asdl_seq * -_loop1_115_rule(Parser *p) +_loop1_120_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23855,7 +24237,7 @@ _loop1_115_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); + D(fprintf(stderr, "%*c> _loop1_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); expr_ty string_var; while ( (string_var = _PyPegen_string_token(p)) // STRING @@ -23877,7 +24259,7 @@ _loop1_115_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_120[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); } if (_n == 0 || p->error_indicator) { @@ -23895,14 +24277,14 @@ _loop1_115_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_115_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_120_type, _seq); D(p->level--); return _seq; } -// _tmp_116: star_named_expression ',' star_named_expressions? +// _tmp_121: star_named_expression ',' star_named_expressions? static void * -_tmp_116_rule(Parser *p) +_tmp_121_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23916,7 +24298,7 @@ _tmp_116_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); Token * _literal; expr_ty y; void *z; @@ -23928,7 +24310,7 @@ _tmp_116_rule(Parser *p) (z = star_named_expressions_rule(p), 1) // star_named_expressions? ) { - D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); _res = _PyPegen_seq_insert_in_front ( p , y , z ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23938,7 +24320,7 @@ _tmp_116_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); } _res = NULL; @@ -23947,9 +24329,9 @@ _tmp_116_rule(Parser *p) return _res; } -// _tmp_117: yield_expr | named_expression +// _tmp_122: yield_expr | named_expression static void * -_tmp_117_rule(Parser *p) +_tmp_122_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23963,18 +24345,18 @@ _tmp_117_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // named_expression @@ -23982,18 +24364,18 @@ _tmp_117_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); expr_ty named_expression_var; if ( (named_expression_var = named_expression_rule(p)) // named_expression ) { - D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); _res = named_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); } _res = NULL; @@ -24002,9 +24384,9 @@ _tmp_117_rule(Parser *p) return _res; } -// _loop0_119: ',' double_starred_kvpair +// _loop0_124: ',' double_starred_kvpair static asdl_seq * -_loop0_119_rule(Parser *p) +_loop0_124_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24028,7 +24410,7 @@ _loop0_119_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); + D(fprintf(stderr, "%*c> _loop0_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); Token * _literal; KeyValuePair* elem; while ( @@ -24059,7 +24441,7 @@ _loop0_119_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_119[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_124[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24072,14 +24454,14 @@ _loop0_119_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_124_type, _seq); D(p->level--); return _seq; } -// _gather_118: double_starred_kvpair _loop0_119 +// _gather_123: double_starred_kvpair _loop0_124 static asdl_seq * -_gather_118_rule(Parser *p) +_gather_123_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24088,27 +24470,27 @@ _gather_118_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // double_starred_kvpair _loop0_119 + { // double_starred_kvpair _loop0_124 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_119")); + D(fprintf(stderr, "%*c> _gather_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_124")); KeyValuePair* elem; asdl_seq * seq; if ( (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair && - (seq = _loop0_119_rule(p)) // _loop0_119 + (seq = _loop0_124_rule(p)) // _loop0_124 ) { - D(fprintf(stderr, "%*c+ _gather_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_119")); + D(fprintf(stderr, "%*c+ _gather_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_124")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_118[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_119")); + D(fprintf(stderr, "%*c%s _gather_123[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_124")); } _res = NULL; done: @@ -24116,9 +24498,9 @@ _gather_118_rule(Parser *p) return _res; } -// _loop1_120: for_if_clause +// _loop1_125: for_if_clause static asdl_seq * -_loop1_120_rule(Parser *p) +_loop1_125_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24142,7 +24524,7 @@ _loop1_120_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); + D(fprintf(stderr, "%*c> _loop1_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); comprehension_ty for_if_clause_var; while ( (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause @@ -24164,7 +24546,7 @@ _loop1_120_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_120[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); } if (_n == 0 || p->error_indicator) { @@ -24182,14 +24564,14 @@ _loop1_120_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_120_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_125_type, _seq); D(p->level--); return _seq; } -// _loop0_121: ('if' disjunction) +// _loop0_126: ('if' disjunction) static asdl_seq * -_loop0_121_rule(Parser *p) +_loop0_126_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24213,13 +24595,13 @@ _loop0_121_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_159_var; + D(fprintf(stderr, "%*c> _loop0_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_168_var; while ( - (_tmp_159_var = _tmp_159_rule(p)) // 'if' disjunction + (_tmp_168_var = _tmp_168_rule(p)) // 'if' disjunction ) { - _res = _tmp_159_var; + _res = _tmp_168_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24235,7 +24617,7 @@ _loop0_121_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_121[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_126[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24248,14 +24630,14 @@ _loop0_121_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_121_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_126_type, _seq); D(p->level--); return _seq; } -// _loop0_122: ('if' disjunction) +// _loop0_127: ('if' disjunction) static asdl_seq * -_loop0_122_rule(Parser *p) +_loop0_127_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24279,13 +24661,13 @@ _loop0_122_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_160_var; + D(fprintf(stderr, "%*c> _loop0_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_169_var; while ( - (_tmp_160_var = _tmp_160_rule(p)) // 'if' disjunction + (_tmp_169_var = _tmp_169_rule(p)) // 'if' disjunction ) { - _res = _tmp_160_var; + _res = _tmp_169_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24301,7 +24683,7 @@ _loop0_122_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_122[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_127[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24314,14 +24696,14 @@ _loop0_122_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_122_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_127_type, _seq); D(p->level--); return _seq; } -// _tmp_123: ',' args +// _tmp_128: ',' args static void * -_tmp_123_rule(Parser *p) +_tmp_128_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24335,7 +24717,7 @@ _tmp_123_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); Token * _literal; expr_ty c; if ( @@ -24344,7 +24726,7 @@ _tmp_123_rule(Parser *p) (c = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -24354,7 +24736,7 @@ _tmp_123_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); } _res = NULL; @@ -24363,9 +24745,9 @@ _tmp_123_rule(Parser *p) return _res; } -// _tmp_124: ',' args +// _tmp_129: ',' args static void * -_tmp_124_rule(Parser *p) +_tmp_129_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24379,7 +24761,7 @@ _tmp_124_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c> _tmp_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); Token * _literal; expr_ty c; if ( @@ -24388,7 +24770,7 @@ _tmp_124_rule(Parser *p) (c = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c+ _tmp_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -24398,7 +24780,7 @@ _tmp_124_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_129[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); } _res = NULL; @@ -24407,9 +24789,9 @@ _tmp_124_rule(Parser *p) return _res; } -// _loop0_126: ',' kwarg_or_starred +// _loop0_131: ',' kwarg_or_starred static asdl_seq * -_loop0_126_rule(Parser *p) +_loop0_131_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24433,7 +24815,7 @@ _loop0_126_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -24464,7 +24846,7 @@ _loop0_126_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_126[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_131[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24477,14 +24859,14 @@ _loop0_126_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_126_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_131_type, _seq); D(p->level--); return _seq; } -// _gather_125: kwarg_or_starred _loop0_126 +// _gather_130: kwarg_or_starred _loop0_131 static asdl_seq * -_gather_125_rule(Parser *p) +_gather_130_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24493,27 +24875,27 @@ _gather_125_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_126 + { // kwarg_or_starred _loop0_131 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_126")); + D(fprintf(stderr, "%*c> _gather_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_131")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_126_rule(p)) // _loop0_126 + (seq = _loop0_131_rule(p)) // _loop0_131 ) { - D(fprintf(stderr, "%*c+ _gather_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_126")); + D(fprintf(stderr, "%*c+ _gather_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_131")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_125[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_126")); + D(fprintf(stderr, "%*c%s _gather_130[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_131")); } _res = NULL; done: @@ -24521,9 +24903,9 @@ _gather_125_rule(Parser *p) return _res; } -// _loop0_128: ',' kwarg_or_double_starred +// _loop0_133: ',' kwarg_or_double_starred static asdl_seq * -_loop0_128_rule(Parser *p) +_loop0_133_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24547,7 +24929,7 @@ _loop0_128_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -24578,7 +24960,7 @@ _loop0_128_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_128[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_133[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24591,14 +24973,14 @@ _loop0_128_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_128_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_133_type, _seq); D(p->level--); return _seq; } -// _gather_127: kwarg_or_double_starred _loop0_128 +// _gather_132: kwarg_or_double_starred _loop0_133 static asdl_seq * -_gather_127_rule(Parser *p) +_gather_132_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24607,27 +24989,27 @@ _gather_127_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_128 + { // kwarg_or_double_starred _loop0_133 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_128")); + D(fprintf(stderr, "%*c> _gather_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_133")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_128_rule(p)) // _loop0_128 + (seq = _loop0_133_rule(p)) // _loop0_133 ) { - D(fprintf(stderr, "%*c+ _gather_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_128")); + D(fprintf(stderr, "%*c+ _gather_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_133")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_127[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_128")); + D(fprintf(stderr, "%*c%s _gather_132[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_133")); } _res = NULL; done: @@ -24635,9 +25017,9 @@ _gather_127_rule(Parser *p) return _res; } -// _loop0_130: ',' kwarg_or_starred +// _loop0_135: ',' kwarg_or_starred static asdl_seq * -_loop0_130_rule(Parser *p) +_loop0_135_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24661,7 +25043,7 @@ _loop0_130_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -24692,7 +25074,7 @@ _loop0_130_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_135[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24705,14 +25087,14 @@ _loop0_130_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_135_type, _seq); D(p->level--); return _seq; } -// _gather_129: kwarg_or_starred _loop0_130 +// _gather_134: kwarg_or_starred _loop0_135 static asdl_seq * -_gather_129_rule(Parser *p) +_gather_134_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24721,27 +25103,27 @@ _gather_129_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_130 + { // kwarg_or_starred _loop0_135 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_130")); + D(fprintf(stderr, "%*c> _gather_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_135")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_130_rule(p)) // _loop0_130 + (seq = _loop0_135_rule(p)) // _loop0_135 ) { - D(fprintf(stderr, "%*c+ _gather_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_130")); + D(fprintf(stderr, "%*c+ _gather_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_135")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_129[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_130")); + D(fprintf(stderr, "%*c%s _gather_134[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_135")); } _res = NULL; done: @@ -24749,9 +25131,9 @@ _gather_129_rule(Parser *p) return _res; } -// _loop0_132: ',' kwarg_or_double_starred +// _loop0_137: ',' kwarg_or_double_starred static asdl_seq * -_loop0_132_rule(Parser *p) +_loop0_137_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24775,7 +25157,7 @@ _loop0_132_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -24806,7 +25188,7 @@ _loop0_132_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_132[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_137[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24819,14 +25201,14 @@ _loop0_132_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_132_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_137_type, _seq); D(p->level--); return _seq; } -// _gather_131: kwarg_or_double_starred _loop0_132 +// _gather_136: kwarg_or_double_starred _loop0_137 static asdl_seq * -_gather_131_rule(Parser *p) +_gather_136_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24835,27 +25217,27 @@ _gather_131_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_132 + { // kwarg_or_double_starred _loop0_137 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_132")); + D(fprintf(stderr, "%*c> _gather_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_137")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_132_rule(p)) // _loop0_132 + (seq = _loop0_137_rule(p)) // _loop0_137 ) { - D(fprintf(stderr, "%*c+ _gather_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_132")); + D(fprintf(stderr, "%*c+ _gather_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_137")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_131[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_132")); + D(fprintf(stderr, "%*c%s _gather_136[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_137")); } _res = NULL; done: @@ -24863,9 +25245,9 @@ _gather_131_rule(Parser *p) return _res; } -// _loop0_133: (',' star_target) +// _loop0_138: (',' star_target) static asdl_seq * -_loop0_133_rule(Parser *p) +_loop0_138_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24889,13 +25271,13 @@ _loop0_133_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_161_var; + D(fprintf(stderr, "%*c> _loop0_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_170_var; while ( - (_tmp_161_var = _tmp_161_rule(p)) // ',' star_target + (_tmp_170_var = _tmp_170_rule(p)) // ',' star_target ) { - _res = _tmp_161_var; + _res = _tmp_170_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24911,7 +25293,7 @@ _loop0_133_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_133[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_138[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24924,14 +25306,14 @@ _loop0_133_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_133_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_138_type, _seq); D(p->level--); return _seq; } -// _loop0_135: ',' star_target +// _loop0_140: ',' star_target static asdl_seq * -_loop0_135_rule(Parser *p) +_loop0_140_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24955,7 +25337,7 @@ _loop0_135_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _loop0_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty elem; while ( @@ -24986,7 +25368,7 @@ _loop0_135_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_135[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_140[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24999,14 +25381,14 @@ _loop0_135_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_135_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_140_type, _seq); D(p->level--); return _seq; } -// _gather_134: star_target _loop0_135 +// _gather_139: star_target _loop0_140 static asdl_seq * -_gather_134_rule(Parser *p) +_gather_139_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25015,27 +25397,27 @@ _gather_134_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_target _loop0_135 + { // star_target _loop0_140 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_135")); + D(fprintf(stderr, "%*c> _gather_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_140")); expr_ty elem; asdl_seq * seq; if ( (elem = star_target_rule(p)) // star_target && - (seq = _loop0_135_rule(p)) // _loop0_135 + (seq = _loop0_140_rule(p)) // _loop0_140 ) { - D(fprintf(stderr, "%*c+ _gather_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_135")); + D(fprintf(stderr, "%*c+ _gather_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_140")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_134[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_135")); + D(fprintf(stderr, "%*c%s _gather_139[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_140")); } _res = NULL; done: @@ -25043,9 +25425,9 @@ _gather_134_rule(Parser *p) return _res; } -// _tmp_136: !'*' star_target +// _tmp_141: !'*' star_target static void * -_tmp_136_rule(Parser *p) +_tmp_141_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25059,7 +25441,7 @@ _tmp_136_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); expr_ty star_target_var; if ( _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' @@ -25067,12 +25449,12 @@ _tmp_136_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); _res = star_target_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_141[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); } _res = NULL; @@ -25081,9 +25463,9 @@ _tmp_136_rule(Parser *p) return _res; } -// _loop0_138: ',' del_target +// _loop0_143: ',' del_target static asdl_seq * -_loop0_138_rule(Parser *p) +_loop0_143_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25107,7 +25489,7 @@ _loop0_138_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); + D(fprintf(stderr, "%*c> _loop0_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); Token * _literal; expr_ty elem; while ( @@ -25138,7 +25520,7 @@ _loop0_138_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_138[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_143[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25151,14 +25533,14 @@ _loop0_138_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_138_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_143_type, _seq); D(p->level--); return _seq; } -// _gather_137: del_target _loop0_138 +// _gather_142: del_target _loop0_143 static asdl_seq * -_gather_137_rule(Parser *p) +_gather_142_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25167,27 +25549,27 @@ _gather_137_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // del_target _loop0_138 + { // del_target _loop0_143 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_138")); + D(fprintf(stderr, "%*c> _gather_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_143")); expr_ty elem; asdl_seq * seq; if ( (elem = del_target_rule(p)) // del_target && - (seq = _loop0_138_rule(p)) // _loop0_138 + (seq = _loop0_143_rule(p)) // _loop0_143 ) { - D(fprintf(stderr, "%*c+ _gather_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_138")); + D(fprintf(stderr, "%*c+ _gather_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_143")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_137[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_138")); + D(fprintf(stderr, "%*c%s _gather_142[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_143")); } _res = NULL; done: @@ -25195,9 +25577,9 @@ _gather_137_rule(Parser *p) return _res; } -// _loop0_140: ',' target +// _loop0_145: ',' target static asdl_seq * -_loop0_140_rule(Parser *p) +_loop0_145_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25221,7 +25603,7 @@ _loop0_140_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); + D(fprintf(stderr, "%*c> _loop0_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); Token * _literal; expr_ty elem; while ( @@ -25252,7 +25634,7 @@ _loop0_140_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_140[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_145[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25265,14 +25647,14 @@ _loop0_140_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_140_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_145_type, _seq); D(p->level--); return _seq; } -// _gather_139: target _loop0_140 +// _gather_144: target _loop0_145 static asdl_seq * -_gather_139_rule(Parser *p) +_gather_144_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25281,27 +25663,27 @@ _gather_139_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // target _loop0_140 + { // target _loop0_145 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_140")); + D(fprintf(stderr, "%*c> _gather_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_145")); expr_ty elem; asdl_seq * seq; if ( (elem = target_rule(p)) // target && - (seq = _loop0_140_rule(p)) // _loop0_140 + (seq = _loop0_145_rule(p)) // _loop0_145 ) { - D(fprintf(stderr, "%*c+ _gather_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_140")); + D(fprintf(stderr, "%*c+ _gather_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_145")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_139[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_140")); + D(fprintf(stderr, "%*c%s _gather_144[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_145")); } _res = NULL; done: @@ -25309,9 +25691,9 @@ _gather_139_rule(Parser *p) return _res; } -// _tmp_141: args | expression for_if_clauses +// _tmp_146: args | expression for_if_clauses static void * -_tmp_141_rule(Parser *p) +_tmp_146_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25325,18 +25707,18 @@ _tmp_141_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); expr_ty args_var; if ( (args_var = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); _res = args_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_141[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); } { // expression for_if_clauses @@ -25344,7 +25726,7 @@ _tmp_141_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); expr_ty expression_var; asdl_seq* for_if_clauses_var; if ( @@ -25353,12 +25735,12 @@ _tmp_141_rule(Parser *p) (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses ) { - D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_141[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); } _res = NULL; @@ -25367,9 +25749,9 @@ _tmp_141_rule(Parser *p) return _res; } -// _loop0_142: star_named_expressions +// _loop0_147: star_named_expressions static asdl_seq * -_loop0_142_rule(Parser *p) +_loop0_147_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25393,7 +25775,7 @@ _loop0_142_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); + D(fprintf(stderr, "%*c> _loop0_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); asdl_seq* star_named_expressions_var; while ( (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions @@ -25415,7 +25797,7 @@ _loop0_142_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_142[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_147[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25428,14 +25810,14 @@ _loop0_142_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_142_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_147_type, _seq); D(p->level--); return _seq; } -// _tmp_143: '=' annotated_rhs +// _tmp_148: '=' annotated_rhs static void * -_tmp_143_rule(Parser *p) +_tmp_148_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25449,7 +25831,7 @@ _tmp_143_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); Token * _literal; expr_ty annotated_rhs_var; if ( @@ -25458,12 +25840,12 @@ _tmp_143_rule(Parser *p) (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs ) { - D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); } _res = NULL; @@ -25472,9 +25854,9 @@ _tmp_143_rule(Parser *p) return _res; } -// _tmp_144: yield_expr | star_expressions +// _tmp_149: yield_expr | star_expressions static void * -_tmp_144_rule(Parser *p) +_tmp_149_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25488,18 +25870,18 @@ _tmp_144_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -25507,18 +25889,18 @@ _tmp_144_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -25527,9 +25909,9 @@ _tmp_144_rule(Parser *p) return _res; } -// _tmp_145: yield_expr | star_expressions +// _tmp_150: yield_expr | star_expressions static void * -_tmp_145_rule(Parser *p) +_tmp_150_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25543,18 +25925,18 @@ _tmp_145_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -25562,18 +25944,18 @@ _tmp_145_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -25582,9 +25964,9 @@ _tmp_145_rule(Parser *p) return _res; } -// _tmp_146: '[' | '(' | '{' +// _tmp_151: '[' | '(' | '{' static void * -_tmp_146_rule(Parser *p) +_tmp_151_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25598,18 +25980,18 @@ _tmp_146_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); } { // '(' @@ -25617,18 +25999,18 @@ _tmp_146_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' ) { - D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } { // '{' @@ -25636,18 +26018,18 @@ _tmp_146_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' ) { - D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); } _res = NULL; @@ -25656,9 +26038,9 @@ _tmp_146_rule(Parser *p) return _res; } -// _loop0_147: param_no_default +// _loop0_152: param_no_default static asdl_seq * -_loop0_147_rule(Parser *p) +_loop0_152_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25682,7 +26064,7 @@ _loop0_147_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_152[%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 @@ -25704,7 +26086,7 @@ _loop0_147_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_147[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25717,14 +26099,14 @@ _loop0_147_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_147_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_152_type, _seq); D(p->level--); return _seq; } -// _tmp_148: slash_with_default | param_with_default+ +// _tmp_153: slash_with_default | param_with_default+ static void * -_tmp_148_rule(Parser *p) +_tmp_153_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25738,18 +26120,18 @@ _tmp_148_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c> _tmp_153[%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_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c+ _tmp_153[%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_148[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); } { // param_with_default+ @@ -25757,18 +26139,18 @@ _tmp_148_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - asdl_seq * _loop1_162_var; + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + asdl_seq * _loop1_171_var; if ( - (_loop1_162_var = _loop1_162_rule(p)) // param_with_default+ + (_loop1_171_var = _loop1_171_rule(p)) // param_with_default+ ) { - D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - _res = _loop1_162_var; + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + _res = _loop1_171_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+")); } _res = NULL; @@ -25777,9 +26159,9 @@ _tmp_148_rule(Parser *p) return _res; } -// _tmp_149: ')' | ',' (')' | '**') +// _tmp_154: ')' | ',' (')' | '**') static void * -_tmp_149_rule(Parser *p) +_tmp_154_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25793,18 +26175,18 @@ _tmp_149_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // ',' (')' | '**') @@ -25812,21 +26194,21 @@ _tmp_149_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); Token * _literal; - void *_tmp_163_var; + void *_tmp_172_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_163_var = _tmp_163_rule(p)) // ')' | '**' + (_tmp_172_var = _tmp_172_rule(p)) // ')' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_163_var); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_172_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); } _res = NULL; @@ -25835,9 +26217,9 @@ _tmp_149_rule(Parser *p) return _res; } -// _tmp_150: ':' | ',' (':' | '**') +// _tmp_155: ':' | ',' (':' | '**') static void * -_tmp_150_rule(Parser *p) +_tmp_155_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25851,18 +26233,18 @@ _tmp_150_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // ',' (':' | '**') @@ -25870,21 +26252,21 @@ _tmp_150_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); Token * _literal; - void *_tmp_164_var; + void *_tmp_173_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_164_var = _tmp_164_rule(p)) // ':' | '**' + (_tmp_173_var = _tmp_173_rule(p)) // ':' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_164_var); + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_173_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); } _res = NULL; @@ -25893,9 +26275,9 @@ _tmp_150_rule(Parser *p) return _res; } -// _tmp_151: star_targets '=' +// _tmp_156: star_targets '=' static void * -_tmp_151_rule(Parser *p) +_tmp_156_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25909,7 +26291,7 @@ _tmp_151_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty z; if ( @@ -25918,7 +26300,7 @@ _tmp_151_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25928,7 +26310,7 @@ _tmp_151_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -25937,9 +26319,9 @@ _tmp_151_rule(Parser *p) return _res; } -// _tmp_152: '.' | '...' +// _tmp_157: '.' | '...' static void * -_tmp_152_rule(Parser *p) +_tmp_157_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25953,18 +26335,18 @@ _tmp_152_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -25972,18 +26354,18 @@ _tmp_152_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -25992,9 +26374,9 @@ _tmp_152_rule(Parser *p) return _res; } -// _tmp_153: '.' | '...' +// _tmp_158: '.' | '...' static void * -_tmp_153_rule(Parser *p) +_tmp_158_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26008,18 +26390,18 @@ _tmp_153_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -26027,18 +26409,18 @@ _tmp_153_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -26047,9 +26429,237 @@ _tmp_153_rule(Parser *p) return _res; } -// _tmp_154: '@' named_expression NEWLINE +// _loop0_160: ',' arg_pattern +static asdl_seq * +_loop0_160_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' arg_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' arg_pattern")); + Token * _literal; + expr_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = arg_pattern_rule(p)) // arg_pattern + ) + { + _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_160[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' arg_pattern")); + } + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_160_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_159: arg_pattern _loop0_160 +static asdl_seq * +_gather_159_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // arg_pattern _loop0_160 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _gather_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "arg_pattern _loop0_160")); + expr_ty elem; + asdl_seq * seq; + if ( + (elem = arg_pattern_rule(p)) // arg_pattern + && + (seq = _loop0_160_rule(p)) // _loop0_160 + ) + { + D(fprintf(stderr, "%*c+ _gather_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "arg_pattern _loop0_160")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_159[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "arg_pattern _loop0_160")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_162: ',' (arg_pattern | keyword_pattern) +static asdl_seq * +_loop0_162_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' (arg_pattern | keyword_pattern) + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (arg_pattern | keyword_pattern)")); + Token * _literal; + void *elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = _tmp_174_rule(p)) // arg_pattern | keyword_pattern + ) + { + _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_162[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (arg_pattern | keyword_pattern)")); + } + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_162_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_161: (arg_pattern | keyword_pattern) _loop0_162 +static asdl_seq * +_gather_161_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // (arg_pattern | keyword_pattern) _loop0_162 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _gather_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(arg_pattern | keyword_pattern) _loop0_162")); + void *elem; + asdl_seq * seq; + if ( + (elem = _tmp_174_rule(p)) // arg_pattern | keyword_pattern + && + (seq = _loop0_162_rule(p)) // _loop0_162 + ) + { + D(fprintf(stderr, "%*c+ _gather_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(arg_pattern | keyword_pattern) _loop0_162")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_161[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(arg_pattern | keyword_pattern) _loop0_162")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_163: '@' named_expression NEWLINE static void * -_tmp_154_rule(Parser *p) +_tmp_163_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26063,7 +26673,7 @@ _tmp_154_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); Token * _literal; expr_ty f; Token * newline_var; @@ -26075,7 +26685,7 @@ _tmp_154_rule(Parser *p) (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); _res = f; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26085,7 +26695,7 @@ _tmp_154_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); } _res = NULL; @@ -26094,9 +26704,9 @@ _tmp_154_rule(Parser *p) return _res; } -// _tmp_155: ',' star_expression +// _tmp_164: ',' star_expression static void * -_tmp_155_rule(Parser *p) +_tmp_164_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26110,7 +26720,7 @@ _tmp_155_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty c; if ( @@ -26119,7 +26729,7 @@ _tmp_155_rule(Parser *p) (c = star_expression_rule(p)) // star_expression ) { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26129,7 +26739,7 @@ _tmp_155_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } _res = NULL; @@ -26138,9 +26748,9 @@ _tmp_155_rule(Parser *p) return _res; } -// _tmp_156: ',' expression +// _tmp_165: ',' expression static void * -_tmp_156_rule(Parser *p) +_tmp_165_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26154,7 +26764,7 @@ _tmp_156_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _tmp_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty c; if ( @@ -26163,7 +26773,7 @@ _tmp_156_rule(Parser *p) (c = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c+ _tmp_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26173,7 +26783,7 @@ _tmp_156_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_165[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } _res = NULL; @@ -26182,9 +26792,9 @@ _tmp_156_rule(Parser *p) return _res; } -// _tmp_157: 'or' conjunction +// _tmp_166: 'or' conjunction static void * -_tmp_157_rule(Parser *p) +_tmp_166_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26198,7 +26808,7 @@ _tmp_157_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); Token * _keyword; expr_ty c; if ( @@ -26207,7 +26817,7 @@ _tmp_157_rule(Parser *p) (c = conjunction_rule(p)) // conjunction ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26217,7 +26827,7 @@ _tmp_157_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); } _res = NULL; @@ -26226,9 +26836,9 @@ _tmp_157_rule(Parser *p) return _res; } -// _tmp_158: 'and' inversion +// _tmp_167: 'and' inversion static void * -_tmp_158_rule(Parser *p) +_tmp_167_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26242,7 +26852,7 @@ _tmp_158_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); Token * _keyword; expr_ty c; if ( @@ -26251,7 +26861,7 @@ _tmp_158_rule(Parser *p) (c = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26261,7 +26871,7 @@ _tmp_158_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); } _res = NULL; @@ -26270,9 +26880,9 @@ _tmp_158_rule(Parser *p) return _res; } -// _tmp_159: 'if' disjunction +// _tmp_168: 'if' disjunction static void * -_tmp_159_rule(Parser *p) +_tmp_168_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26286,7 +26896,7 @@ _tmp_159_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -26295,7 +26905,7 @@ _tmp_159_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26305,7 +26915,7 @@ _tmp_159_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_159[%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, "'if' disjunction")); } _res = NULL; @@ -26314,9 +26924,9 @@ _tmp_159_rule(Parser *p) return _res; } -// _tmp_160: 'if' disjunction +// _tmp_169: 'if' disjunction static void * -_tmp_160_rule(Parser *p) +_tmp_169_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26330,7 +26940,7 @@ _tmp_160_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -26339,7 +26949,7 @@ _tmp_160_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26349,7 +26959,7 @@ _tmp_160_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_160[%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, "'if' disjunction")); } _res = NULL; @@ -26358,9 +26968,9 @@ _tmp_160_rule(Parser *p) return _res; } -// _tmp_161: ',' star_target +// _tmp_170: ',' star_target static void * -_tmp_161_rule(Parser *p) +_tmp_170_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26374,7 +26984,7 @@ _tmp_161_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _tmp_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty c; if ( @@ -26383,7 +26993,7 @@ _tmp_161_rule(Parser *p) (c = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26393,7 +27003,7 @@ _tmp_161_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_161[%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, "',' star_target")); } _res = NULL; @@ -26402,9 +27012,9 @@ _tmp_161_rule(Parser *p) return _res; } -// _loop1_162: param_with_default +// _loop1_171: param_with_default static asdl_seq * -_loop1_162_rule(Parser *p) +_loop1_171_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26428,7 +27038,7 @@ _loop1_162_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -26450,7 +27060,7 @@ _loop1_162_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_162[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_171[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -26468,14 +27078,14 @@ _loop1_162_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_162_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_171_type, _seq); D(p->level--); return _seq; } -// _tmp_163: ')' | '**' +// _tmp_172: ')' | '**' static void * -_tmp_163_rule(Parser *p) +_tmp_172_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26489,18 +27099,18 @@ _tmp_163_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_163[%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, "')'")); } { // '**' @@ -26508,18 +27118,18 @@ _tmp_163_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_163[%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, "'**'")); } _res = NULL; @@ -26528,9 +27138,9 @@ _tmp_163_rule(Parser *p) return _res; } -// _tmp_164: ':' | '**' +// _tmp_173: ':' | '**' static void * -_tmp_164_rule(Parser *p) +_tmp_173_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26544,18 +27154,18 @@ _tmp_164_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_164[%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, "':'")); } { // '**' @@ -26563,18 +27173,18 @@ _tmp_164_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_164[%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, "'**'")); } _res = NULL; @@ -26583,6 +27193,61 @@ _tmp_164_rule(Parser *p) return _res; } +// _tmp_174: arg_pattern | keyword_pattern +static void * +_tmp_174_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // arg_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "arg_pattern")); + expr_ty arg_pattern_var; + if ( + (arg_pattern_var = arg_pattern_rule(p)) // arg_pattern + ) + { + D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "arg_pattern")); + _res = arg_pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_174[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "arg_pattern")); + } + { // keyword_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); + void *keyword_pattern_var; + if ( + (keyword_pattern_var = keyword_pattern_rule(p)) // keyword_pattern + ) + { + D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); + _res = keyword_pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_174[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + void * _PyPegen_parse(Parser *p) { diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 87e6995ebcb379..d44d9fa641c928 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -715,6 +715,7 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) case Match_kind: CALL(astfold_expr, expr_ty, node_->v.Match.target); CALL_SEQ(astfold_match_case, match_case_ty, node_->v.Match.cases); + // TODO: Mark unreachable cases for removal? Maybe pattern == NULL? break; default: break; diff --git a/Python/compile.c b/Python/compile.c index 044ff18de067a0..62debc301b894d 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2772,10 +2772,13 @@ compiler_pattern_load(struct compiler *c, expr_ty p, basicblock *fail) } static int -compiler_pattern_store(struct compiler *c, expr_ty p) { +compiler_pattern_store(struct compiler *c, expr_ty p, int anon_ok) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); if (_PyUnicode_EqualToASCIIString(p->v.Name.id, "_")) { + if (!anon_ok) { + return compiler_error(c, "can't assign to '_' here; consider removing?"); + } ADDOP(c, POP_TOP); return 1; } @@ -2791,7 +2794,7 @@ compiler_pattern_name(struct compiler *c, expr_ty p, basicblock *fail) if (p->v.Name.ctx == Load) { return compiler_pattern_load(c, p, fail); } - return compiler_pattern_store(c, p); + return compiler_pattern_store(c, p, 1); } static int @@ -2803,7 +2806,7 @@ compiler_pattern_namedexpr(struct compiler *c, expr_ty p, basicblock *fail) CHECK(end = compiler_new_block(c)); ADDOP(c, DUP_TOP); CHECK(compiler_pattern(c, p->v.NamedExpr.value, block)); - CHECK(compiler_pattern_store(c, p->v.NamedExpr.target)); + CHECK(compiler_pattern_store(c, p->v.NamedExpr.target, 0)); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); ADDOP(c, POP_TOP); @@ -2826,7 +2829,9 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail) for (Py_ssize_t i = 0; i < size - star; i++) { expr_ty key = asdl_seq_GET(keys, i); expr_ty value = asdl_seq_GET(values, i); - assert(key); + if (!key) { + return compiler_error(c, "can't use starred pattern here; consider moving to end?"); + } assert(key->kind == Attribute_kind || key->kind == Constant_kind || key->kind == Name_kind); assert(key->kind != Attribute_kind || key->v.Attribute.ctx == Load); assert(key->kind != Name_kind || key->v.Name.ctx == Load); @@ -2838,7 +2843,7 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail) ADDOP(c, POP_TOP); } else { - CHECK(compiler_pattern_store(c, asdl_seq_GET(values, size - 1))); + CHECK(compiler_pattern_store(c, asdl_seq_GET(values, size - 1), 0)); } ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); @@ -2899,15 +2904,18 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail) expr_ty value = asdl_seq_GET(values, i); if (i == star) { assert(value->kind == Starred_kind); - ADDOP_I(c, UNPACK_EX, (size - i - 1) << 8); - CHECK(compiler_pattern_store(c, value->v.Starred.value)); - if (size - i - 1) { - ADDOP_I(c, BUILD_TUPLE, size - i - 1); - // Argh, our tuple is backwards! Unpacking and rebuilding is the - // simplest way to reverse it: - ADDOP_I(c, UNPACK_SEQUENCE, size - i - 1); - ADDOP_I(c, BUILD_TUPLE, size - i - 1); - ADDOP_JREL(c, MATCH_SEQ, fail); + Py_ssize_t remaining = size - i - 1; + ADDOP_I(c, UNPACK_EX, remaining << 8); + CHECK(compiler_pattern_store(c, value->v.Starred.value, 1)); + if (remaining) { + ADDOP_I(c, BUILD_TUPLE, remaining); + if (remaining > 1) { + // Argh, our tuple is backwards! + // Unpacking and repacking is the easiest way to reverse it: + ADDOP_I(c, UNPACK_SEQUENCE, remaining); + ADDOP_I(c, BUILD_TUPLE, remaining); + } + ADDOP(c, GET_ITER); } else { ADDOP_JREL(c, JUMP_FORWARD, end); From de7c3f0799ff9950542313626eb06787de12d741 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 1 Jun 2020 09:14:40 -0700 Subject: [PATCH 049/189] Miscellaneous cleanup --- Grammar/python.gram | 24 +- Lib/test/test_pydoc.py | 2 +- Parser/pegen/parse.c | 2789 ++++++++++++++++++++++++---------------- 3 files changed, 1671 insertions(+), 1144 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 820a7bb8252c44..099fe6a324d635 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -199,7 +199,7 @@ case_block: | "case" pattern=pattern guard=guard? ':' body=block { _Py_match_case(pattern, guard, body, p->arena) } -pattern: +pattern[expr_ty]: | target=NAME ':=' value=or_pattern { _Py_NamedExpr(CHECK(_PyPegen_set_expr_context(p, target, Store)), value, EXTRA) } | or_pattern @@ -222,7 +222,7 @@ closed_pattern: | class_pattern name_pattern: - | a=NAME !('.' | '(') { + | a=NAME !('.' | '(' | '=') { _PyPegen_set_expr_context(p, a, Store) } literal_pattern: | NUMBER @@ -250,14 +250,16 @@ mapping_pattern: class_pattern: | func=name_or_attr '(' ')' { _Py_Call(func, NULL, NULL, EXTRA) } - | func=name_or_attr '(' args=','.arg_pattern+ ','? ')' { + | func=name_or_attr '(' args=','.pattern+ ','? ')' { _Py_Call(func, args, NULL, EXTRA) } | func=name_or_attr '(' keywords=','.keyword_pattern+ ','? ')' { _Py_Call(func, NULL, keywords, EXTRA) } - | func=name_or_attr '(' args=','.arg_pattern+ ',' keywords=','.keyword_pattern+ ','? ')' { + | func=name_or_attr '(' args=','.pattern+ ',' keywords=','.keyword_pattern+ ','? ')' { _Py_Call(func, args, keywords, EXTRA) } - | func=name_or_attr '(' [','.arg_pattern+ ','] ','.keyword_pattern+ ',' error=arg_pattern [',' ','.(arg_pattern | keyword_pattern)+] ','? ')' { + | func=name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' error=pattern [',' ','.argument_pattern+] ','? ')' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "positional pattern follows keyword pattern") } + | func=name_or_attr '(' [','.argument_pattern+ ','] error=error_star [',' ','.(argument_pattern | error_star)+] ','? ')' { + RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "can't use starred pattern here") } name_or_attr: | NAME @@ -269,15 +271,15 @@ values_pattern: items_pattern: | items=','.key_value_pattern+ ','? { items } -arg_pattern[expr_ty]: - | pattern !'=' - | error='*' NAME { - RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "can't use starred pattern here") } keyword_pattern: | arg=NAME '=' value=or_pattern { _Py_keyword(arg->v.Name.id, value, EXTRA) } - | error='**' NAME { - RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "can't use starred pattern here") } +argument_pattern: + | pattern + | keyword_pattern +error_star[expr_ty]: + | ('*' | '**') error=NAME { + error } value_pattern: | '*' value=name_pattern { diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index 8c8537f2d536ca..5fe39779b12845 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -772,7 +772,7 @@ def method_returning_true(self): del expected['__doc__'] del expected['__class__'] # inspect resolves descriptors on type into methods, but vars doesn't, - # so we need to update __subclasshook__, __init_subclass__ and + # so we need to update __subclasshook__, __init_subclass__, and # __match__. expected['__subclasshook__'] = TestClass.__subclasshook__ expected['__init_subclass__'] = TestClass.__init_subclass__ diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index e9c2cdd3973500..697fe1fdfe79a5 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -129,8 +129,8 @@ static KeywordToken *reserved_keywords[] = { #define name_or_attr_type 1051 // Left-recursive #define values_pattern_type 1052 #define items_pattern_type 1053 -#define arg_pattern_type 1054 -#define keyword_pattern_type 1055 +#define keyword_pattern_type 1054 +#define error_star_type 1055 #define value_pattern_type 1056 #define key_value_pattern_type 1057 #define return_stmt_type 1058 @@ -315,116 +315,125 @@ static KeywordToken *reserved_keywords[] = { #define _loop0_63_type 1237 #define _gather_62_type 1238 #define _tmp_64_type 1239 -#define _loop0_66_type 1240 -#define _gather_65_type 1241 +#define _tmp_65_type 1240 +#define _tmp_66_type 1241 #define _loop0_68_type 1242 #define _gather_67_type 1243 -#define _tmp_69_type 1244 -#define _tmp_70_type 1245 +#define _loop0_70_type 1244 +#define _gather_69_type 1245 #define _tmp_71_type 1246 #define _tmp_72_type 1247 #define _tmp_73_type 1248 -#define _loop0_74_type 1249 -#define _loop0_75_type 1250 -#define _loop0_76_type 1251 -#define _loop1_77_type 1252 +#define _tmp_74_type 1249 +#define _tmp_75_type 1250 +#define _tmp_76_type 1251 +#define _loop0_77_type 1252 #define _loop0_78_type 1253 -#define _loop1_79_type 1254 +#define _loop0_79_type 1254 #define _loop1_80_type 1255 -#define _loop1_81_type 1256 -#define _loop0_82_type 1257 +#define _loop0_81_type 1256 +#define _loop1_82_type 1257 #define _loop1_83_type 1258 -#define _loop0_84_type 1259 -#define _loop1_85_type 1260 -#define _loop0_86_type 1261 -#define _loop1_87_type 1262 +#define _loop1_84_type 1259 +#define _loop0_85_type 1260 +#define _loop1_86_type 1261 +#define _loop0_87_type 1262 #define _loop1_88_type 1263 -#define _tmp_89_type 1264 -#define _loop0_91_type 1265 -#define _gather_90_type 1266 -#define _loop1_92_type 1267 +#define _loop0_89_type 1264 +#define _loop1_90_type 1265 +#define _loop1_91_type 1266 +#define _tmp_92_type 1267 #define _loop0_94_type 1268 #define _gather_93_type 1269 #define _loop1_95_type 1270 -#define _loop0_96_type 1271 -#define _loop0_97_type 1272 -#define _loop0_98_type 1273 -#define _loop1_99_type 1274 +#define _loop0_97_type 1271 +#define _gather_96_type 1272 +#define _loop1_98_type 1273 +#define _loop0_99_type 1274 #define _loop0_100_type 1275 -#define _loop1_101_type 1276 +#define _loop0_101_type 1276 #define _loop1_102_type 1277 -#define _loop1_103_type 1278 -#define _loop0_104_type 1279 +#define _loop0_103_type 1278 +#define _loop1_104_type 1279 #define _loop1_105_type 1280 -#define _loop0_106_type 1281 -#define _loop1_107_type 1282 -#define _loop0_108_type 1283 -#define _loop1_109_type 1284 +#define _loop1_106_type 1281 +#define _loop0_107_type 1282 +#define _loop1_108_type 1283 +#define _loop0_109_type 1284 #define _loop1_110_type 1285 -#define _loop1_111_type 1286 +#define _loop0_111_type 1286 #define _loop1_112_type 1287 -#define _tmp_113_type 1288 -#define _loop0_115_type 1289 -#define _gather_114_type 1290 +#define _loop1_113_type 1288 +#define _loop1_114_type 1289 +#define _loop1_115_type 1290 #define _tmp_116_type 1291 -#define _tmp_117_type 1292 -#define _tmp_118_type 1293 +#define _loop0_118_type 1292 +#define _gather_117_type 1293 #define _tmp_119_type 1294 -#define _loop1_120_type 1295 +#define _tmp_120_type 1295 #define _tmp_121_type 1296 #define _tmp_122_type 1297 -#define _loop0_124_type 1298 -#define _gather_123_type 1299 -#define _loop1_125_type 1300 -#define _loop0_126_type 1301 -#define _loop0_127_type 1302 -#define _tmp_128_type 1303 -#define _tmp_129_type 1304 -#define _loop0_131_type 1305 -#define _gather_130_type 1306 -#define _loop0_133_type 1307 -#define _gather_132_type 1308 -#define _loop0_135_type 1309 -#define _gather_134_type 1310 -#define _loop0_137_type 1311 -#define _gather_136_type 1312 -#define _loop0_138_type 1313 +#define _loop1_123_type 1298 +#define _tmp_124_type 1299 +#define _tmp_125_type 1300 +#define _loop0_127_type 1301 +#define _gather_126_type 1302 +#define _loop1_128_type 1303 +#define _loop0_129_type 1304 +#define _loop0_130_type 1305 +#define _tmp_131_type 1306 +#define _tmp_132_type 1307 +#define _loop0_134_type 1308 +#define _gather_133_type 1309 +#define _loop0_136_type 1310 +#define _gather_135_type 1311 +#define _loop0_138_type 1312 +#define _gather_137_type 1313 #define _loop0_140_type 1314 #define _gather_139_type 1315 -#define _tmp_141_type 1316 +#define _loop0_141_type 1316 #define _loop0_143_type 1317 #define _gather_142_type 1318 -#define _loop0_145_type 1319 -#define _gather_144_type 1320 -#define _tmp_146_type 1321 -#define _loop0_147_type 1322 -#define _tmp_148_type 1323 +#define _tmp_144_type 1319 +#define _loop0_146_type 1320 +#define _gather_145_type 1321 +#define _loop0_148_type 1322 +#define _gather_147_type 1323 #define _tmp_149_type 1324 -#define _tmp_150_type 1325 +#define _loop0_150_type 1325 #define _tmp_151_type 1326 -#define _loop0_152_type 1327 +#define _tmp_152_type 1327 #define _tmp_153_type 1328 #define _tmp_154_type 1329 -#define _tmp_155_type 1330 +#define _loop0_155_type 1330 #define _tmp_156_type 1331 #define _tmp_157_type 1332 #define _tmp_158_type 1333 -#define _loop0_160_type 1334 -#define _gather_159_type 1335 -#define _loop0_162_type 1336 -#define _gather_161_type 1337 -#define _tmp_163_type 1338 -#define _tmp_164_type 1339 -#define _tmp_165_type 1340 -#define _tmp_166_type 1341 -#define _tmp_167_type 1342 -#define _tmp_168_type 1343 -#define _tmp_169_type 1344 +#define _tmp_159_type 1334 +#define _tmp_160_type 1335 +#define _tmp_161_type 1336 +#define _loop0_163_type 1337 +#define _gather_162_type 1338 +#define _loop0_165_type 1339 +#define _gather_164_type 1340 +#define _loop0_167_type 1341 +#define _gather_166_type 1342 +#define _loop0_169_type 1343 +#define _gather_168_type 1344 #define _tmp_170_type 1345 -#define _loop1_171_type 1346 +#define _tmp_171_type 1346 #define _tmp_172_type 1347 #define _tmp_173_type 1348 #define _tmp_174_type 1349 +#define _tmp_175_type 1350 +#define _tmp_176_type 1351 +#define _tmp_177_type 1352 +#define _loop1_178_type 1353 +#define _tmp_179_type 1354 +#define _tmp_180_type 1355 +#define _tmp_181_type 1356 +#define _tmp_182_type 1357 +#define _tmp_183_type 1358 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -466,7 +475,7 @@ static excepthandler_ty except_block_rule(Parser *p); static asdl_seq* finally_block_rule(Parser *p); static void *match_stmt_rule(Parser *p); static void *case_block_rule(Parser *p); -static void *pattern_rule(Parser *p); +static expr_ty pattern_rule(Parser *p); static void *guard_rule(Parser *p); static void *or_pattern_rule(Parser *p); static void *closed_pattern_rule(Parser *p); @@ -480,8 +489,8 @@ static void *class_pattern_rule(Parser *p); static void *name_or_attr_rule(Parser *p); static void *values_pattern_rule(Parser *p); static void *items_pattern_rule(Parser *p); -static expr_ty arg_pattern_rule(Parser *p); static void *keyword_pattern_rule(Parser *p); +static expr_ty error_star_rule(Parser *p); static void *value_pattern_rule(Parser *p); static void *key_value_pattern_rule(Parser *p); static stmt_ty return_stmt_rule(Parser *p); @@ -666,116 +675,125 @@ static void *_tmp_61_rule(Parser *p); static asdl_seq *_loop0_63_rule(Parser *p); static asdl_seq *_gather_62_rule(Parser *p); static void *_tmp_64_rule(Parser *p); -static asdl_seq *_loop0_66_rule(Parser *p); -static asdl_seq *_gather_65_rule(Parser *p); +static void *_tmp_65_rule(Parser *p); +static void *_tmp_66_rule(Parser *p); static asdl_seq *_loop0_68_rule(Parser *p); static asdl_seq *_gather_67_rule(Parser *p); -static void *_tmp_69_rule(Parser *p); -static void *_tmp_70_rule(Parser *p); +static asdl_seq *_loop0_70_rule(Parser *p); +static asdl_seq *_gather_69_rule(Parser *p); static void *_tmp_71_rule(Parser *p); static void *_tmp_72_rule(Parser *p); static void *_tmp_73_rule(Parser *p); -static asdl_seq *_loop0_74_rule(Parser *p); -static asdl_seq *_loop0_75_rule(Parser *p); -static asdl_seq *_loop0_76_rule(Parser *p); -static asdl_seq *_loop1_77_rule(Parser *p); +static void *_tmp_74_rule(Parser *p); +static void *_tmp_75_rule(Parser *p); +static void *_tmp_76_rule(Parser *p); +static asdl_seq *_loop0_77_rule(Parser *p); static asdl_seq *_loop0_78_rule(Parser *p); -static asdl_seq *_loop1_79_rule(Parser *p); +static asdl_seq *_loop0_79_rule(Parser *p); static asdl_seq *_loop1_80_rule(Parser *p); -static asdl_seq *_loop1_81_rule(Parser *p); -static asdl_seq *_loop0_82_rule(Parser *p); +static asdl_seq *_loop0_81_rule(Parser *p); +static asdl_seq *_loop1_82_rule(Parser *p); static asdl_seq *_loop1_83_rule(Parser *p); -static asdl_seq *_loop0_84_rule(Parser *p); -static asdl_seq *_loop1_85_rule(Parser *p); -static asdl_seq *_loop0_86_rule(Parser *p); -static asdl_seq *_loop1_87_rule(Parser *p); +static asdl_seq *_loop1_84_rule(Parser *p); +static asdl_seq *_loop0_85_rule(Parser *p); +static asdl_seq *_loop1_86_rule(Parser *p); +static asdl_seq *_loop0_87_rule(Parser *p); static asdl_seq *_loop1_88_rule(Parser *p); -static void *_tmp_89_rule(Parser *p); -static asdl_seq *_loop0_91_rule(Parser *p); -static asdl_seq *_gather_90_rule(Parser *p); -static asdl_seq *_loop1_92_rule(Parser *p); +static asdl_seq *_loop0_89_rule(Parser *p); +static asdl_seq *_loop1_90_rule(Parser *p); +static asdl_seq *_loop1_91_rule(Parser *p); +static void *_tmp_92_rule(Parser *p); static asdl_seq *_loop0_94_rule(Parser *p); static asdl_seq *_gather_93_rule(Parser *p); static asdl_seq *_loop1_95_rule(Parser *p); -static asdl_seq *_loop0_96_rule(Parser *p); static asdl_seq *_loop0_97_rule(Parser *p); -static asdl_seq *_loop0_98_rule(Parser *p); -static asdl_seq *_loop1_99_rule(Parser *p); +static asdl_seq *_gather_96_rule(Parser *p); +static asdl_seq *_loop1_98_rule(Parser *p); +static asdl_seq *_loop0_99_rule(Parser *p); static asdl_seq *_loop0_100_rule(Parser *p); -static asdl_seq *_loop1_101_rule(Parser *p); +static asdl_seq *_loop0_101_rule(Parser *p); static asdl_seq *_loop1_102_rule(Parser *p); -static asdl_seq *_loop1_103_rule(Parser *p); -static asdl_seq *_loop0_104_rule(Parser *p); +static asdl_seq *_loop0_103_rule(Parser *p); +static asdl_seq *_loop1_104_rule(Parser *p); static asdl_seq *_loop1_105_rule(Parser *p); -static asdl_seq *_loop0_106_rule(Parser *p); -static asdl_seq *_loop1_107_rule(Parser *p); -static asdl_seq *_loop0_108_rule(Parser *p); -static asdl_seq *_loop1_109_rule(Parser *p); +static asdl_seq *_loop1_106_rule(Parser *p); +static asdl_seq *_loop0_107_rule(Parser *p); +static asdl_seq *_loop1_108_rule(Parser *p); +static asdl_seq *_loop0_109_rule(Parser *p); static asdl_seq *_loop1_110_rule(Parser *p); -static asdl_seq *_loop1_111_rule(Parser *p); +static asdl_seq *_loop0_111_rule(Parser *p); static asdl_seq *_loop1_112_rule(Parser *p); -static void *_tmp_113_rule(Parser *p); -static asdl_seq *_loop0_115_rule(Parser *p); -static asdl_seq *_gather_114_rule(Parser *p); +static asdl_seq *_loop1_113_rule(Parser *p); +static asdl_seq *_loop1_114_rule(Parser *p); +static asdl_seq *_loop1_115_rule(Parser *p); static void *_tmp_116_rule(Parser *p); -static void *_tmp_117_rule(Parser *p); -static void *_tmp_118_rule(Parser *p); +static asdl_seq *_loop0_118_rule(Parser *p); +static asdl_seq *_gather_117_rule(Parser *p); static void *_tmp_119_rule(Parser *p); -static asdl_seq *_loop1_120_rule(Parser *p); +static void *_tmp_120_rule(Parser *p); static void *_tmp_121_rule(Parser *p); static void *_tmp_122_rule(Parser *p); -static asdl_seq *_loop0_124_rule(Parser *p); -static asdl_seq *_gather_123_rule(Parser *p); -static asdl_seq *_loop1_125_rule(Parser *p); -static asdl_seq *_loop0_126_rule(Parser *p); +static asdl_seq *_loop1_123_rule(Parser *p); +static void *_tmp_124_rule(Parser *p); +static void *_tmp_125_rule(Parser *p); static asdl_seq *_loop0_127_rule(Parser *p); -static void *_tmp_128_rule(Parser *p); -static void *_tmp_129_rule(Parser *p); -static asdl_seq *_loop0_131_rule(Parser *p); -static asdl_seq *_gather_130_rule(Parser *p); -static asdl_seq *_loop0_133_rule(Parser *p); -static asdl_seq *_gather_132_rule(Parser *p); -static asdl_seq *_loop0_135_rule(Parser *p); -static asdl_seq *_gather_134_rule(Parser *p); -static asdl_seq *_loop0_137_rule(Parser *p); -static asdl_seq *_gather_136_rule(Parser *p); +static asdl_seq *_gather_126_rule(Parser *p); +static asdl_seq *_loop1_128_rule(Parser *p); +static asdl_seq *_loop0_129_rule(Parser *p); +static asdl_seq *_loop0_130_rule(Parser *p); +static void *_tmp_131_rule(Parser *p); +static void *_tmp_132_rule(Parser *p); +static asdl_seq *_loop0_134_rule(Parser *p); +static asdl_seq *_gather_133_rule(Parser *p); +static asdl_seq *_loop0_136_rule(Parser *p); +static asdl_seq *_gather_135_rule(Parser *p); static asdl_seq *_loop0_138_rule(Parser *p); +static asdl_seq *_gather_137_rule(Parser *p); static asdl_seq *_loop0_140_rule(Parser *p); static asdl_seq *_gather_139_rule(Parser *p); -static void *_tmp_141_rule(Parser *p); +static asdl_seq *_loop0_141_rule(Parser *p); static asdl_seq *_loop0_143_rule(Parser *p); static asdl_seq *_gather_142_rule(Parser *p); -static asdl_seq *_loop0_145_rule(Parser *p); -static asdl_seq *_gather_144_rule(Parser *p); -static void *_tmp_146_rule(Parser *p); -static asdl_seq *_loop0_147_rule(Parser *p); -static void *_tmp_148_rule(Parser *p); +static void *_tmp_144_rule(Parser *p); +static asdl_seq *_loop0_146_rule(Parser *p); +static asdl_seq *_gather_145_rule(Parser *p); +static asdl_seq *_loop0_148_rule(Parser *p); +static asdl_seq *_gather_147_rule(Parser *p); static void *_tmp_149_rule(Parser *p); -static void *_tmp_150_rule(Parser *p); +static asdl_seq *_loop0_150_rule(Parser *p); static void *_tmp_151_rule(Parser *p); -static asdl_seq *_loop0_152_rule(Parser *p); +static void *_tmp_152_rule(Parser *p); static void *_tmp_153_rule(Parser *p); static void *_tmp_154_rule(Parser *p); -static void *_tmp_155_rule(Parser *p); +static asdl_seq *_loop0_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_160_rule(Parser *p); -static asdl_seq *_gather_159_rule(Parser *p); -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 void *_tmp_167_rule(Parser *p); -static void *_tmp_168_rule(Parser *p); -static void *_tmp_169_rule(Parser *p); +static void *_tmp_159_rule(Parser *p); +static void *_tmp_160_rule(Parser *p); +static void *_tmp_161_rule(Parser *p); +static asdl_seq *_loop0_163_rule(Parser *p); +static asdl_seq *_gather_162_rule(Parser *p); +static asdl_seq *_loop0_165_rule(Parser *p); +static asdl_seq *_gather_164_rule(Parser *p); +static asdl_seq *_loop0_167_rule(Parser *p); +static asdl_seq *_gather_166_rule(Parser *p); +static asdl_seq *_loop0_169_rule(Parser *p); +static asdl_seq *_gather_168_rule(Parser *p); static void *_tmp_170_rule(Parser *p); -static asdl_seq *_loop1_171_rule(Parser *p); +static void *_tmp_171_rule(Parser *p); static void *_tmp_172_rule(Parser *p); static void *_tmp_173_rule(Parser *p); static void *_tmp_174_rule(Parser *p); +static void *_tmp_175_rule(Parser *p); +static void *_tmp_176_rule(Parser *p); +static void *_tmp_177_rule(Parser *p); +static asdl_seq *_loop1_178_rule(Parser *p); +static void *_tmp_179_rule(Parser *p); +static void *_tmp_180_rule(Parser *p); +static void *_tmp_181_rule(Parser *p); +static void *_tmp_182_rule(Parser *p); +static void *_tmp_183_rule(Parser *p); // file: statements? $ @@ -4728,7 +4746,7 @@ case_block_rule(Parser *p) Token * _literal; asdl_seq* body; void *guard; - void *pattern; + expr_ty pattern; if ( (_keyword = _PyPegen_expect_soft_keyword(p, "case")) // soft_keyword='"case"' && @@ -4761,7 +4779,7 @@ case_block_rule(Parser *p) } // pattern: NAME ':=' or_pattern | or_pattern -static void * +static expr_ty pattern_rule(Parser *p) { D(p->level++); @@ -4769,7 +4787,7 @@ pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -5129,7 +5147,7 @@ closed_pattern_rule(Parser *p) return _res; } -// name_pattern: NAME !('.' | '(') +// name_pattern: NAME !('.' | '(' | '=') static void * name_pattern_rule(Parser *p) { @@ -5140,12 +5158,12 @@ name_pattern_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // NAME !('.' | '(') + { // NAME !('.' | '(' | '=') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> name_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME !('.' | '(')")); + D(fprintf(stderr, "%*c> name_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME !('.' | '(' | '=')")); expr_ty a; if ( (a = _PyPegen_name_token(p)) // NAME @@ -5153,7 +5171,7 @@ name_pattern_rule(Parser *p) _PyPegen_lookahead(0, _tmp_52_rule, p) ) { - D(fprintf(stderr, "%*c+ name_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME !('.' | '(')")); + D(fprintf(stderr, "%*c+ name_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME !('.' | '(' | '=')")); _res = _PyPegen_set_expr_context ( p , a , Store ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -5164,7 +5182,7 @@ name_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s name_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME !('.' | '(')")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME !('.' | '(' | '=')")); } _res = NULL; done: @@ -5448,7 +5466,7 @@ group_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> group_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' pattern ')'")); Token * _literal; Token * _literal_1; - void *pattern; + expr_ty pattern; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && @@ -5608,10 +5626,11 @@ mapping_pattern_rule(Parser *p) // class_pattern: // | name_or_attr '(' ')' -// | name_or_attr '(' ','.arg_pattern+ ','? ')' +// | name_or_attr '(' ','.pattern+ ','? ')' // | name_or_attr '(' ','.keyword_pattern+ ','? ')' -// | name_or_attr '(' ','.arg_pattern+ ',' ','.keyword_pattern+ ','? ')' -// | name_or_attr '(' [','.arg_pattern+ ','] ','.keyword_pattern+ ',' arg_pattern [',' ','.(arg_pattern | keyword_pattern)+] ','? ')' +// | name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')' +// | name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.(pattern | keyword_pattern)+] ','? ')' +// | name_or_attr '(' [','.(pattern | keyword_pattern)+ ','] error_star [',' ','.(pattern | keyword_pattern | error_star)+] ','? ')' static void * class_pattern_rule(Parser *p) { @@ -5670,12 +5689,12 @@ class_pattern_rule(Parser *p) D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ')'")); } - { // name_or_attr '(' ','.arg_pattern+ ','? ')' + { // name_or_attr '(' ','.pattern+ ','? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.arg_pattern+ ','? ')'")); + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ','? ')'")); Token * _literal; Token * _literal_1; void *_opt_var; @@ -5687,14 +5706,14 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (args = _gather_53_rule(p)) // ','.arg_pattern+ + (args = _gather_53_rule(p)) // ','.pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.arg_pattern+ ','? ')'")); + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ','? ')'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5714,7 +5733,7 @@ class_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.arg_pattern+ ','? ')'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.pattern+ ','? ')'")); } { // name_or_attr '(' ','.keyword_pattern+ ','? ')' if (p->error_indicator) { @@ -5762,12 +5781,12 @@ class_pattern_rule(Parser *p) D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.keyword_pattern+ ','? ')'")); } - { // name_or_attr '(' ','.arg_pattern+ ',' ','.keyword_pattern+ ','? ')' + { // name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.arg_pattern+ ',' ','.keyword_pattern+ ','? ')'")); + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'")); Token * _literal; Token * _literal_1; Token * _literal_2; @@ -5781,7 +5800,7 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (args = _gather_57_rule(p)) // ','.arg_pattern+ + (args = _gather_57_rule(p)) // ','.pattern+ && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && @@ -5792,7 +5811,7 @@ class_pattern_rule(Parser *p) (_literal_2 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.arg_pattern+ ',' ','.keyword_pattern+ ','? ')'")); + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5812,14 +5831,14 @@ class_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.arg_pattern+ ',' ','.keyword_pattern+ ','? ')'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'")); } - { // name_or_attr '(' [','.arg_pattern+ ','] ','.keyword_pattern+ ',' arg_pattern [',' ','.(arg_pattern | keyword_pattern)+] ','? ')' + { // name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.(pattern | keyword_pattern)+] ','? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.arg_pattern+ ','] ','.keyword_pattern+ ',' arg_pattern [',' ','.(arg_pattern | keyword_pattern)+] ','? ')'")); + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.(pattern | keyword_pattern)+] ','? ')'")); asdl_seq * _gather_62_var; Token * _literal; Token * _literal_1; @@ -5837,22 +5856,22 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_opt_var = _tmp_61_rule(p), 1) // [','.arg_pattern+ ','] + (_opt_var = _tmp_61_rule(p), 1) // [','.pattern+ ','] && (_gather_62_var = _gather_62_rule(p)) // ','.keyword_pattern+ && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (error = arg_pattern_rule(p)) // arg_pattern + (error = pattern_rule(p)) // pattern && - (_opt_var_1 = _tmp_64_rule(p), 1) // [',' ','.(arg_pattern | keyword_pattern)+] + (_opt_var_1 = _tmp_64_rule(p), 1) // [',' ','.(pattern | keyword_pattern)+] && (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? && (_literal_2 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.arg_pattern+ ','] ','.keyword_pattern+ ',' arg_pattern [',' ','.(arg_pattern | keyword_pattern)+] ','? ')'")); + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.(pattern | keyword_pattern)+] ','? ')'")); _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "positional pattern follows keyword pattern" ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -5863,7 +5882,52 @@ class_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' [','.arg_pattern+ ','] ','.keyword_pattern+ ',' arg_pattern [',' ','.(arg_pattern | keyword_pattern)+] ','? ')'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.(pattern | keyword_pattern)+] ','? ')'")); + } + { // name_or_attr '(' [','.(pattern | keyword_pattern)+ ','] error_star [',' ','.(pattern | keyword_pattern | error_star)+] ','? ')' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.(pattern | keyword_pattern)+ ','] error_star [',' ','.(pattern | keyword_pattern | error_star)+] ','? ')'")); + Token * _literal; + Token * _literal_1; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *_opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + void *_opt_var_2; + UNUSED(_opt_var_2); // Silence compiler warnings + expr_ty error; + void *func; + if ( + (func = name_or_attr_rule(p)) // name_or_attr + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (_opt_var = _tmp_65_rule(p), 1) // [','.(pattern | keyword_pattern)+ ','] + && + (error = error_star_rule(p)) // error_star + && + (_opt_var_1 = _tmp_66_rule(p), 1) // [',' ','.(pattern | keyword_pattern | error_star)+] + && + (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.(pattern | keyword_pattern)+ ','] error_star [',' ','.(pattern | keyword_pattern | error_star)+] ','? ')'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "can't use starred pattern here" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' [','.(pattern | keyword_pattern)+ ','] error_star [',' ','.(pattern | keyword_pattern | error_star)+] ','? ')'")); } _res = NULL; done: @@ -6006,7 +6070,7 @@ values_pattern_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * values; if ( - (values = _gather_65_rule(p)) // ','.value_pattern+ + (values = _gather_67_rule(p)) // ','.value_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -6051,7 +6115,7 @@ items_pattern_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * items; if ( - (items = _gather_67_rule(p)) // ','.key_value_pattern+ + (items = _gather_69_rule(p)) // ','.key_value_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -6075,72 +6139,7 @@ items_pattern_rule(Parser *p) return _res; } -// arg_pattern: pattern !'=' | '*' NAME -static expr_ty -arg_pattern_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - expr_ty _res = NULL; - int _mark = p->mark; - { // pattern !'=' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> arg_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern !'='")); - void *pattern_var; - if ( - (pattern_var = pattern_rule(p)) // pattern - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' - ) - { - D(fprintf(stderr, "%*c+ arg_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern !'='")); - _res = pattern_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s arg_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern !'='")); - } - { // '*' NAME - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> arg_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' NAME")); - Token * error; - expr_ty name_var; - if ( - (error = _PyPegen_expect_token(p, 16)) // token='*' - && - (name_var = _PyPegen_name_token(p)) // NAME - ) - { - D(fprintf(stderr, "%*c+ arg_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' NAME")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "can't use starred pattern here" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s arg_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' NAME")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// keyword_pattern: NAME '=' or_pattern | '**' NAME +// keyword_pattern: NAME '=' or_pattern static void * keyword_pattern_rule(Parser *p) { @@ -6199,22 +6198,39 @@ keyword_pattern_rule(Parser *p) D(fprintf(stderr, "%*c%s keyword_pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' or_pattern")); } - { // '**' NAME + _res = NULL; + done: + D(p->level--); + return _res; +} + +// error_star: ('*' | '**') NAME +static expr_ty +error_star_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + { // ('*' | '**') NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> keyword_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' NAME")); - Token * error; - expr_ty name_var; + D(fprintf(stderr, "%*c> error_star[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('*' | '**') NAME")); + void *_tmp_71_var; + expr_ty error; if ( - (error = _PyPegen_expect_token(p, 35)) // token='**' + (_tmp_71_var = _tmp_71_rule(p)) // '*' | '**' && - (name_var = _PyPegen_name_token(p)) // NAME + (error = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ keyword_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' NAME")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "can't use starred pattern here" ); + D(fprintf(stderr, "%*c+ error_star[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('*' | '**') NAME")); + _res = error; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6223,8 +6239,8 @@ keyword_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s keyword_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' NAME")); + D(fprintf(stderr, "%*c%s error_star[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('*' | '**') NAME")); } _res = NULL; done: @@ -6294,7 +6310,7 @@ value_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); - void *pattern_var; + expr_ty pattern_var; if ( (pattern_var = pattern_rule(p)) // pattern ) @@ -6336,7 +6352,7 @@ key_value_pattern_rule(Parser *p) void *key; void *value; if ( - (key = _tmp_69_rule(p)) // literal_pattern | constant_pattern + (key = _tmp_72_rule(p)) // literal_pattern | constant_pattern && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -6485,7 +6501,7 @@ raise_stmt_rule(Parser *p) && (a = expression_rule(p)) // expression && - (b = _tmp_70_rule(p), 1) // ['from' expression] + (b = _tmp_73_rule(p), 1) // ['from' expression] ) { D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); @@ -6660,7 +6676,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_71_rule(p), 1) // ['->' expression] + (a = _tmp_74_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -6720,7 +6736,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_72_rule(p), 1) // ['->' expression] + (a = _tmp_75_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -6784,7 +6800,7 @@ func_type_comment_rule(Parser *p) && (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' && - _PyPegen_lookahead(1, _tmp_73_rule, p) + _PyPegen_lookahead(1, _tmp_76_rule, p) ) { D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); @@ -6928,9 +6944,9 @@ parameters_rule(Parser *p) if ( (a = slash_no_default_rule(p)) // slash_no_default && - (b = _loop0_74_rule(p)) // param_no_default* + (b = _loop0_77_rule(p)) // param_no_default* && - (c = _loop0_75_rule(p)) // param_with_default* + (c = _loop0_78_rule(p)) // param_with_default* && (d = star_etc_rule(p), 1) // star_etc? ) @@ -6960,7 +6976,7 @@ parameters_rule(Parser *p) if ( (a = slash_with_default_rule(p)) // slash_with_default && - (b = _loop0_76_rule(p)) // param_with_default* + (b = _loop0_79_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -6988,9 +7004,9 @@ parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = _loop1_77_rule(p)) // param_no_default+ + (a = _loop1_80_rule(p)) // param_no_default+ && - (b = _loop0_78_rule(p)) // param_with_default* + (b = _loop0_81_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -7017,7 +7033,7 @@ parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_79_rule(p)) // param_with_default+ + (a = _loop1_82_rule(p)) // param_with_default+ && (b = star_etc_rule(p), 1) // star_etc? ) @@ -7086,7 +7102,7 @@ slash_no_default_rule(Parser *p) Token * _literal_1; asdl_seq * a; if ( - (a = _loop1_80_rule(p)) // param_no_default+ + (a = _loop1_83_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7115,7 +7131,7 @@ slash_no_default_rule(Parser *p) Token * _literal; asdl_seq * a; if ( - (a = _loop1_81_rule(p)) // param_no_default+ + (a = _loop1_84_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7165,9 +7181,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_82_rule(p)) // param_no_default* + (a = _loop0_85_rule(p)) // param_no_default* && - (b = _loop1_83_rule(p)) // param_with_default+ + (b = _loop1_86_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7197,9 +7213,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_84_rule(p)) // param_no_default* + (a = _loop0_87_rule(p)) // param_no_default* && - (b = _loop1_85_rule(p)) // param_with_default+ + (b = _loop1_88_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7255,7 +7271,7 @@ star_etc_rule(Parser *p) && (a = param_no_default_rule(p)) // param_no_default && - (b = _loop0_86_rule(p)) // param_maybe_default* + (b = _loop0_89_rule(p)) // param_maybe_default* && (c = kwds_rule(p), 1) // kwds? ) @@ -7288,7 +7304,7 @@ star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_87_rule(p)) // param_maybe_default+ + (b = _loop1_90_rule(p)) // param_maybe_default+ && (c = kwds_rule(p), 1) // kwds? ) @@ -7810,7 +7826,7 @@ decorators_rule(Parser *p) D(fprintf(stderr, "%*c> decorators[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); asdl_seq * a; if ( - (a = _loop1_88_rule(p)) // (('@' named_expression NEWLINE))+ + (a = _loop1_91_rule(p)) // (('@' named_expression NEWLINE))+ ) { D(fprintf(stderr, "%*c+ decorators[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); @@ -7931,7 +7947,7 @@ class_def_raw_rule(Parser *p) && (a = _PyPegen_name_token(p)) // NAME && - (b = _tmp_89_rule(p), 1) // ['(' arguments? ')'] + (b = _tmp_92_rule(p), 1) // ['(' arguments? ')'] && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -8080,7 +8096,7 @@ expressions_list_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_90_rule(p)) // ','.star_expression+ + (a = _gather_93_rule(p)) // ','.star_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8140,7 +8156,7 @@ star_expressions_rule(Parser *p) if ( (a = star_expression_rule(p)) // star_expression && - (b = _loop1_92_rule(p)) // ((',' star_expression))+ + (b = _loop1_95_rule(p)) // ((',' star_expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8335,7 +8351,7 @@ star_named_expressions_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_93_rule(p)) // ','.star_named_expression+ + (a = _gather_96_rule(p)) // ','.star_named_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8633,7 +8649,7 @@ expressions_rule(Parser *p) if ( (a = expression_rule(p)) // expression && - (b = _loop1_95_rule(p)) // ((',' expression))+ + (b = _loop1_98_rule(p)) // ((',' expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8932,9 +8948,9 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default && - (b = _loop0_96_rule(p)) // lambda_param_no_default* + (b = _loop0_99_rule(p)) // lambda_param_no_default* && - (c = _loop0_97_rule(p)) // lambda_param_with_default* + (c = _loop0_100_rule(p)) // lambda_param_with_default* && (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -8964,7 +8980,7 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default && - (b = _loop0_98_rule(p)) // lambda_param_with_default* + (b = _loop0_101_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -8992,9 +9008,9 @@ lambda_parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = _loop1_99_rule(p)) // lambda_param_no_default+ + (a = _loop1_102_rule(p)) // lambda_param_no_default+ && - (b = _loop0_100_rule(p)) // lambda_param_with_default* + (b = _loop0_103_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9021,7 +9037,7 @@ lambda_parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_101_rule(p)) // lambda_param_with_default+ + (a = _loop1_104_rule(p)) // lambda_param_with_default+ && (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9092,7 +9108,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal_1; asdl_seq * a; if ( - (a = _loop1_102_rule(p)) // lambda_param_no_default+ + (a = _loop1_105_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9121,7 +9137,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal; asdl_seq * a; if ( - (a = _loop1_103_rule(p)) // lambda_param_no_default+ + (a = _loop1_106_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9171,9 +9187,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_104_rule(p)) // lambda_param_no_default* + (a = _loop0_107_rule(p)) // lambda_param_no_default* && - (b = _loop1_105_rule(p)) // lambda_param_with_default+ + (b = _loop1_108_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9203,9 +9219,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_106_rule(p)) // lambda_param_no_default* + (a = _loop0_109_rule(p)) // lambda_param_no_default* && - (b = _loop1_107_rule(p)) // lambda_param_with_default+ + (b = _loop1_110_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9261,7 +9277,7 @@ lambda_star_etc_rule(Parser *p) && (a = lambda_param_no_default_rule(p)) // lambda_param_no_default && - (b = _loop0_108_rule(p)) // lambda_param_maybe_default* + (b = _loop0_111_rule(p)) // lambda_param_maybe_default* && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -9294,7 +9310,7 @@ lambda_star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_109_rule(p)) // lambda_param_maybe_default+ + (b = _loop1_112_rule(p)) // lambda_param_maybe_default+ && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -9721,7 +9737,7 @@ disjunction_rule(Parser *p) if ( (a = conjunction_rule(p)) // conjunction && - (b = _loop1_110_rule(p)) // (('or' conjunction))+ + (b = _loop1_113_rule(p)) // (('or' conjunction))+ ) { D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); @@ -9807,7 +9823,7 @@ conjunction_rule(Parser *p) if ( (a = inversion_rule(p)) // inversion && - (b = _loop1_111_rule(p)) // (('and' inversion))+ + (b = _loop1_114_rule(p)) // (('and' inversion))+ ) { D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); @@ -9975,7 +9991,7 @@ comparison_rule(Parser *p) if ( (a = bitwise_or_rule(p)) // bitwise_or && - (b = _loop1_112_rule(p)) // compare_op_bitwise_or_pair+ + (b = _loop1_115_rule(p)) // compare_op_bitwise_or_pair+ ) { D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); @@ -10303,10 +10319,10 @@ noteq_bitwise_or_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); - void *_tmp_113_var; + void *_tmp_116_var; expr_ty a; if ( - (_tmp_113_var = _tmp_113_rule(p)) // '!=' + (_tmp_116_var = _tmp_116_rule(p)) // '!=' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -12235,7 +12251,7 @@ slices_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_114_rule(p)) // ','.slice+ + (a = _gather_117_rule(p)) // ','.slice+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -12305,7 +12321,7 @@ slice_rule(Parser *p) && (b = expression_rule(p), 1) // expression? && - (c = _tmp_116_rule(p), 1) // [':' expression?] + (c = _tmp_119_rule(p), 1) // [':' expression?] ) { D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); @@ -12579,15 +12595,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - void *_tmp_117_var; + void *_tmp_120_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' && - (_tmp_117_var = _tmp_117_rule(p)) // tuple | group | genexp + (_tmp_120_var = _tmp_120_rule(p)) // tuple | group | genexp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - _res = _tmp_117_var; + _res = _tmp_120_var; goto done; } p->mark = _mark; @@ -12600,15 +12616,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - void *_tmp_118_var; + void *_tmp_121_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' && - (_tmp_118_var = _tmp_118_rule(p)) // list | listcomp + (_tmp_121_var = _tmp_121_rule(p)) // list | listcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - _res = _tmp_118_var; + _res = _tmp_121_var; goto done; } p->mark = _mark; @@ -12621,15 +12637,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - void *_tmp_119_var; + void *_tmp_122_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' && - (_tmp_119_var = _tmp_119_rule(p)) // dict | set | dictcomp | setcomp + (_tmp_122_var = _tmp_122_rule(p)) // dict | set | dictcomp | setcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - _res = _tmp_119_var; + _res = _tmp_122_var; goto done; } p->mark = _mark; @@ -12698,7 +12714,7 @@ strings_rule(Parser *p) D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+")); asdl_seq * a; if ( - (a = _loop1_120_rule(p)) // STRING+ + (a = _loop1_123_rule(p)) // STRING+ ) { D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+")); @@ -12905,7 +12921,7 @@ tuple_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_121_rule(p), 1) // [star_named_expression ',' star_named_expressions?] + (a = _tmp_124_rule(p), 1) // [star_named_expression ',' star_named_expressions?] && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -12961,7 +12977,7 @@ group_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_122_rule(p)) // yield_expr | named_expression + (a = _tmp_125_rule(p)) // yield_expr | named_expression && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -13397,7 +13413,7 @@ double_starred_kvpairs_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_123_rule(p)) // ','.double_starred_kvpair+ + (a = _gather_126_rule(p)) // ','.double_starred_kvpair+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -13548,13 +13564,13 @@ for_if_clauses_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); - asdl_seq * _loop1_125_var; + asdl_seq * _loop1_128_var; if ( - (_loop1_125_var = _loop1_125_rule(p)) // for_if_clause+ + (_loop1_128_var = _loop1_128_rule(p)) // for_if_clause+ ) { D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); - _res = _loop1_125_var; + _res = _loop1_128_var; goto done; } p->mark = _mark; @@ -13603,7 +13619,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = _loop0_126_rule(p)) // (('if' disjunction))* + (c = _loop0_129_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*")); @@ -13639,7 +13655,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = _loop0_127_rule(p)) // (('if' disjunction))* + (c = _loop0_130_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*")); @@ -13864,7 +13880,7 @@ args_rule(Parser *p) if ( (a = starred_expression_rule(p)) // starred_expression && - (b = _tmp_128_rule(p), 1) // [',' args] + (b = _tmp_131_rule(p), 1) // [',' args] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]")); @@ -13933,7 +13949,7 @@ args_rule(Parser *p) if ( (a = named_expression_rule(p)) // named_expression && - (b = _tmp_129_rule(p), 1) // [',' args] + (b = _tmp_132_rule(p), 1) // [',' args] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]")); @@ -13988,11 +14004,11 @@ kwargs_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _gather_130_rule(p)) // ','.kwarg_or_starred+ + (a = _gather_133_rule(p)) // ','.kwarg_or_starred+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _gather_132_rule(p)) // ','.kwarg_or_double_starred+ + (b = _gather_135_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); @@ -14014,13 +14030,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - asdl_seq * _gather_134_var; + asdl_seq * _gather_137_var; if ( - (_gather_134_var = _gather_134_rule(p)) // ','.kwarg_or_starred+ + (_gather_137_var = _gather_137_rule(p)) // ','.kwarg_or_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - _res = _gather_134_var; + _res = _gather_137_var; goto done; } p->mark = _mark; @@ -14033,13 +14049,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - asdl_seq * _gather_136_var; + asdl_seq * _gather_139_var; if ( - (_gather_136_var = _gather_136_rule(p)) // ','.kwarg_or_double_starred+ + (_gather_139_var = _gather_139_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - _res = _gather_136_var; + _res = _gather_139_var; goto done; } p->mark = _mark; @@ -14401,7 +14417,7 @@ star_targets_rule(Parser *p) if ( (a = star_target_rule(p)) // star_target && - (b = _loop0_138_rule(p)) // ((',' star_target))* + (b = _loop0_141_rule(p)) // ((',' star_target))* && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -14455,7 +14471,7 @@ star_targets_seq_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_139_rule(p)) // ','.star_target+ + (a = _gather_142_rule(p)) // ','.star_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -14518,7 +14534,7 @@ star_target_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (a = _tmp_141_rule(p)) // !'*' star_target + (a = _tmp_144_rule(p)) // !'*' star_target ) { D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); @@ -15040,7 +15056,7 @@ del_targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_142_rule(p)) // ','.del_target+ + (a = _gather_145_rule(p)) // ','.del_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -15519,7 +15535,7 @@ targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_144_rule(p)) // ','.target+ + (a = _gather_147_rule(p)) // ','.target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -16231,7 +16247,7 @@ incorrect_arguments_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_opt_var = _tmp_146_rule(p), 1) // [args | expression for_if_clauses] + (_opt_var = _tmp_149_rule(p), 1) // [args | expression for_if_clauses] ) { D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); @@ -16513,14 +16529,14 @@ invalid_assignment_rule(Parser *p) D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'")); Token * _literal; Token * _literal_1; - asdl_seq * _loop0_147_var; + asdl_seq * _loop0_150_var; expr_ty a; if ( (a = star_named_expression_rule(p)) // star_named_expression && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_loop0_147_var = _loop0_147_rule(p)) // star_named_expressions* + (_loop0_150_var = _loop0_150_rule(p)) // star_named_expressions* && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' ) @@ -16556,7 +16572,7 @@ invalid_assignment_rule(Parser *p) && (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_148_rule(p), 1) // ['=' annotated_rhs] + (_opt_var = _tmp_151_rule(p), 1) // ['=' annotated_rhs] ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]")); @@ -16579,14 +16595,14 @@ invalid_assignment_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); Token * _literal; - void *_tmp_149_var; + void *_tmp_152_var; expr_ty a; if ( (a = star_expressions_rule(p)) // star_expressions && (_literal = _PyPegen_expect_token(p, 22)) // token='=' && - (_tmp_149_var = _tmp_149_rule(p)) // yield_expr | star_expressions + (_tmp_152_var = _tmp_152_rule(p)) // yield_expr | star_expressions ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); @@ -16608,7 +16624,7 @@ invalid_assignment_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); - void *_tmp_150_var; + void *_tmp_153_var; expr_ty a; AugOperator* augassign_var; if ( @@ -16616,7 +16632,7 @@ invalid_assignment_rule(Parser *p) && (augassign_var = augassign_rule(p)) // augassign && - (_tmp_150_var = _tmp_150_rule(p)) // yield_expr | star_expressions + (_tmp_153_var = _tmp_153_rule(p)) // yield_expr | star_expressions ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); @@ -16698,11 +16714,11 @@ invalid_comprehension_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); - void *_tmp_151_var; + void *_tmp_154_var; expr_ty a; asdl_seq* for_if_clauses_var; if ( - (_tmp_151_var = _tmp_151_rule(p)) // '[' | '(' | '{' + (_tmp_154_var = _tmp_154_rule(p)) // '[' | '(' | '{' && (a = starred_expression_rule(p)) // starred_expression && @@ -16799,13 +16815,13 @@ invalid_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); - asdl_seq * _loop0_152_var; - void *_tmp_153_var; + asdl_seq * _loop0_155_var; + void *_tmp_156_var; arg_ty param_no_default_var; if ( - (_loop0_152_var = _loop0_152_rule(p)) // param_no_default* + (_loop0_155_var = _loop0_155_rule(p)) // param_no_default* && - (_tmp_153_var = _tmp_153_rule(p)) // slash_with_default | param_with_default+ + (_tmp_156_var = _tmp_156_rule(p)) // slash_with_default | param_with_default+ && (param_no_default_var = param_no_default_rule(p)) // param_no_default ) @@ -16847,11 +16863,11 @@ invalid_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); Token * _literal; - void *_tmp_154_var; + void *_tmp_157_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_154_var = _tmp_154_rule(p)) // ')' | ',' (')' | '**') + (_tmp_157_var = _tmp_157_rule(p)) // ')' | ',' (')' | '**') ) { D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); @@ -16921,11 +16937,11 @@ invalid_lambda_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); Token * _literal; - void *_tmp_155_var; + void *_tmp_158_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_155_var = _tmp_155_rule(p)) // ':' | ',' (':' | '**') + (_tmp_158_var = _tmp_158_rule(p)) // ':' | ',' (':' | '**') ) { D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); @@ -18335,12 +18351,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_156_var; + void *_tmp_159_var; while ( - (_tmp_156_var = _tmp_156_rule(p)) // star_targets '=' + (_tmp_159_var = _tmp_159_rule(p)) // star_targets '=' ) { - _res = _tmp_156_var; + _res = _tmp_159_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -18788,12 +18804,12 @@ _loop0_30_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop0_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_157_var; + void *_tmp_160_var; while ( - (_tmp_157_var = _tmp_157_rule(p)) // '.' | '...' + (_tmp_160_var = _tmp_160_rule(p)) // '.' | '...' ) { - _res = _tmp_157_var; + _res = _tmp_160_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -18854,12 +18870,12 @@ _loop1_31_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_158_var; + void *_tmp_161_var; while ( - (_tmp_158_var = _tmp_158_rule(p)) // '.' | '...' + (_tmp_161_var = _tmp_161_rule(p)) // '.' | '...' ) { - _res = _tmp_158_var; + _res = _tmp_161_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -20014,7 +20030,7 @@ _gather_50_rule(Parser *p) return _res; } -// _tmp_52: '.' | '(' +// _tmp_52: '.' | '(' | '=' static void * _tmp_52_rule(Parser *p) { @@ -20063,13 +20079,32 @@ _tmp_52_rule(Parser *p) D(fprintf(stderr, "%*c%s _tmp_52[%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_52[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ _tmp_52[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_52[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); + } _res = NULL; done: D(p->level--); return _res; } -// _loop0_54: ',' arg_pattern +// _loop0_54: ',' pattern static asdl_seq * _loop0_54_rule(Parser *p) { @@ -20090,18 +20125,18 @@ _loop0_54_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' arg_pattern + { // ',' pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' arg_pattern")); + D(fprintf(stderr, "%*c> _loop0_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = arg_pattern_rule(p)) // arg_pattern + (elem = pattern_rule(p)) // pattern ) { _res = elem; @@ -20127,7 +20162,7 @@ _loop0_54_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s _loop0_54[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' arg_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -20144,7 +20179,7 @@ _loop0_54_rule(Parser *p) return _seq; } -// _gather_53: arg_pattern _loop0_54 +// _gather_53: pattern _loop0_54 static asdl_seq * _gather_53_rule(Parser *p) { @@ -20155,27 +20190,27 @@ _gather_53_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // arg_pattern _loop0_54 + { // pattern _loop0_54 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "arg_pattern _loop0_54")); + D(fprintf(stderr, "%*c> _gather_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_54")); expr_ty elem; asdl_seq * seq; if ( - (elem = arg_pattern_rule(p)) // arg_pattern + (elem = pattern_rule(p)) // pattern && (seq = _loop0_54_rule(p)) // _loop0_54 ) { - D(fprintf(stderr, "%*c+ _gather_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "arg_pattern _loop0_54")); + D(fprintf(stderr, "%*c+ _gather_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_54")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _gather_53[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "arg_pattern _loop0_54")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_54")); } _res = NULL; done: @@ -20297,7 +20332,7 @@ _gather_55_rule(Parser *p) return _res; } -// _loop0_58: ',' arg_pattern +// _loop0_58: ',' pattern static asdl_seq * _loop0_58_rule(Parser *p) { @@ -20318,18 +20353,18 @@ _loop0_58_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' arg_pattern + { // ',' pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' arg_pattern")); + D(fprintf(stderr, "%*c> _loop0_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = arg_pattern_rule(p)) // arg_pattern + (elem = pattern_rule(p)) // pattern ) { _res = elem; @@ -20355,7 +20390,7 @@ _loop0_58_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s _loop0_58[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' arg_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -20372,7 +20407,7 @@ _loop0_58_rule(Parser *p) return _seq; } -// _gather_57: arg_pattern _loop0_58 +// _gather_57: pattern _loop0_58 static asdl_seq * _gather_57_rule(Parser *p) { @@ -20383,27 +20418,27 @@ _gather_57_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // arg_pattern _loop0_58 + { // pattern _loop0_58 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "arg_pattern _loop0_58")); + D(fprintf(stderr, "%*c> _gather_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_58")); expr_ty elem; asdl_seq * seq; if ( - (elem = arg_pattern_rule(p)) // arg_pattern + (elem = pattern_rule(p)) // pattern && (seq = _loop0_58_rule(p)) // _loop0_58 ) { - D(fprintf(stderr, "%*c+ _gather_57[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "arg_pattern _loop0_58")); + D(fprintf(stderr, "%*c+ _gather_57[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_58")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _gather_57[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "arg_pattern _loop0_58")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_58")); } _res = NULL; done: @@ -20525,7 +20560,7 @@ _gather_59_rule(Parser *p) return _res; } -// _tmp_61: ','.arg_pattern+ ',' +// _tmp_61: ','.pattern+ ',' static void * _tmp_61_rule(Parser *p) { @@ -20536,27 +20571,27 @@ _tmp_61_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ','.arg_pattern+ ',' + { // ','.pattern+ ',' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.arg_pattern+ ','")); - asdl_seq * _gather_159_var; + D(fprintf(stderr, "%*c> _tmp_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); + asdl_seq * _gather_162_var; Token * _literal; if ( - (_gather_159_var = _gather_159_rule(p)) // ','.arg_pattern+ + (_gather_162_var = _gather_162_rule(p)) // ','.pattern+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_61[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.arg_pattern+ ','")); - _res = _PyPegen_dummy_name(p, _gather_159_var, _literal); + D(fprintf(stderr, "%*c+ _tmp_61[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); + _res = _PyPegen_dummy_name(p, _gather_162_var, _literal); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_61[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.arg_pattern+ ','")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.pattern+ ','")); } _res = NULL; done: @@ -20678,7 +20713,7 @@ _gather_62_rule(Parser *p) return _res; } -// _tmp_64: ',' ','.(arg_pattern | keyword_pattern)+ +// _tmp_64: ',' ','.(pattern | keyword_pattern)+ static void * _tmp_64_rule(Parser *p) { @@ -20689,27 +20724,105 @@ _tmp_64_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ',' ','.(arg_pattern | keyword_pattern)+ + { // ',' ','.(pattern | keyword_pattern)+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(arg_pattern | keyword_pattern)+")); - asdl_seq * _gather_161_var; + D(fprintf(stderr, "%*c> _tmp_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(pattern | keyword_pattern)+")); + asdl_seq * _gather_164_var; Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_gather_161_var = _gather_161_rule(p)) // ','.(arg_pattern | keyword_pattern)+ + (_gather_164_var = _gather_164_rule(p)) // ','.(pattern | keyword_pattern)+ ) { - D(fprintf(stderr, "%*c+ _tmp_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(arg_pattern | keyword_pattern)+")); - _res = _PyPegen_dummy_name(p, _literal, _gather_161_var); + D(fprintf(stderr, "%*c+ _tmp_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(pattern | keyword_pattern)+")); + _res = _PyPegen_dummy_name(p, _literal, _gather_164_var); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_64[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.(arg_pattern | keyword_pattern)+")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.(pattern | keyword_pattern)+")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_65: ','.(pattern | keyword_pattern)+ ',' +static void * +_tmp_65_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ','.(pattern | keyword_pattern)+ ',' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.(pattern | keyword_pattern)+ ','")); + asdl_seq * _gather_166_var; + Token * _literal; + if ( + (_gather_166_var = _gather_166_rule(p)) // ','.(pattern | keyword_pattern)+ + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.(pattern | keyword_pattern)+ ','")); + _res = _PyPegen_dummy_name(p, _gather_166_var, _literal); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_65[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.(pattern | keyword_pattern)+ ','")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_66: ',' ','.(pattern | keyword_pattern | error_star)+ +static void * +_tmp_66_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // ',' ','.(pattern | keyword_pattern | error_star)+ + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(pattern | keyword_pattern | error_star)+")); + asdl_seq * _gather_168_var; + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (_gather_168_var = _gather_168_rule(p)) // ','.(pattern | keyword_pattern | error_star)+ + ) + { + D(fprintf(stderr, "%*c+ _tmp_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(pattern | keyword_pattern | error_star)+")); + _res = _PyPegen_dummy_name(p, _literal, _gather_168_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_66[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.(pattern | keyword_pattern | error_star)+")); } _res = NULL; done: @@ -20717,9 +20830,9 @@ _tmp_64_rule(Parser *p) return _res; } -// _loop0_66: ',' value_pattern +// _loop0_68: ',' value_pattern static asdl_seq * -_loop0_66_rule(Parser *p) +_loop0_68_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20743,7 +20856,7 @@ _loop0_66_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' value_pattern")); + D(fprintf(stderr, "%*c> _loop0_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' value_pattern")); Token * _literal; void *elem; while ( @@ -20774,7 +20887,7 @@ _loop0_66_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_66[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_68[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' value_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20787,14 +20900,14 @@ _loop0_66_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_66_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_68_type, _seq); D(p->level--); return _seq; } -// _gather_65: value_pattern _loop0_66 +// _gather_67: value_pattern _loop0_68 static asdl_seq * -_gather_65_rule(Parser *p) +_gather_67_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20803,27 +20916,27 @@ _gather_65_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // value_pattern _loop0_66 + { // value_pattern _loop0_68 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_66")); + D(fprintf(stderr, "%*c> _gather_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_68")); void *elem; asdl_seq * seq; if ( (elem = value_pattern_rule(p)) // value_pattern && - (seq = _loop0_66_rule(p)) // _loop0_66 + (seq = _loop0_68_rule(p)) // _loop0_68 ) { - D(fprintf(stderr, "%*c+ _gather_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_66")); + D(fprintf(stderr, "%*c+ _gather_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_68")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_65[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern _loop0_66")); + D(fprintf(stderr, "%*c%s _gather_67[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern _loop0_68")); } _res = NULL; done: @@ -20831,9 +20944,9 @@ _gather_65_rule(Parser *p) return _res; } -// _loop0_68: ',' key_value_pattern +// _loop0_70: ',' key_value_pattern static asdl_seq * -_loop0_68_rule(Parser *p) +_loop0_70_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20857,7 +20970,7 @@ _loop0_68_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); + D(fprintf(stderr, "%*c> _loop0_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); Token * _literal; void *elem; while ( @@ -20888,7 +21001,7 @@ _loop0_68_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_68[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_70[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' key_value_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20901,14 +21014,14 @@ _loop0_68_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_68_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_70_type, _seq); D(p->level--); return _seq; } -// _gather_67: key_value_pattern _loop0_68 +// _gather_69: key_value_pattern _loop0_70 static asdl_seq * -_gather_67_rule(Parser *p) +_gather_69_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20917,27 +21030,27 @@ _gather_67_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // key_value_pattern _loop0_68 + { // key_value_pattern _loop0_70 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_68")); + D(fprintf(stderr, "%*c> _gather_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_70")); void *elem; asdl_seq * seq; if ( (elem = key_value_pattern_rule(p)) // key_value_pattern && - (seq = _loop0_68_rule(p)) // _loop0_68 + (seq = _loop0_70_rule(p)) // _loop0_70 ) { - D(fprintf(stderr, "%*c+ _gather_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_68")); + D(fprintf(stderr, "%*c+ _gather_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_70")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_67[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_68")); + D(fprintf(stderr, "%*c%s _gather_69[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_70")); } _res = NULL; done: @@ -20945,9 +21058,9 @@ _gather_67_rule(Parser *p) return _res; } -// _tmp_69: literal_pattern | constant_pattern +// _tmp_71: '*' | '**' static void * -_tmp_69_rule(Parser *p) +_tmp_71_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20956,43 +21069,43 @@ _tmp_69_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // literal_pattern + { // '*' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); - void *literal_pattern_var; + D(fprintf(stderr, "%*c> _tmp_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); + Token * _literal; if ( - (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern + (_literal = _PyPegen_expect_token(p, 16)) // token='*' ) { - D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); - _res = literal_pattern_var; + D(fprintf(stderr, "%*c+ _tmp_71[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_69[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern")); + D(fprintf(stderr, "%*c%s _tmp_71[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); } - { // constant_pattern + { // '**' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern")); - void *constant_pattern_var; + D(fprintf(stderr, "%*c> _tmp_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + Token * _literal; if ( - (constant_pattern_var = constant_pattern_rule(p)) // constant_pattern + (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "constant_pattern")); - _res = constant_pattern_var; + D(fprintf(stderr, "%*c+ _tmp_71[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_69[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "constant_pattern")); + D(fprintf(stderr, "%*c%s _tmp_71[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; done: @@ -21000,9 +21113,9 @@ _tmp_69_rule(Parser *p) return _res; } -// _tmp_70: 'from' expression +// _tmp_72: literal_pattern | constant_pattern static void * -_tmp_70_rule(Parser *p) +_tmp_72_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21011,42 +21124,97 @@ _tmp_70_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // 'from' expression + { // literal_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); - Token * _keyword; - expr_ty z; + D(fprintf(stderr, "%*c> _tmp_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + void *literal_pattern_var; if ( - (_keyword = _PyPegen_expect_token(p, 514)) // token='from' - && - (z = expression_rule(p)) // expression + (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); - _res = z; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + _res = literal_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_70[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression")); + D(fprintf(stderr, "%*c%s _tmp_72[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern")); } - _res = NULL; - done: - D(p->level--); + { // constant_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern")); + void *constant_pattern_var; + if ( + (constant_pattern_var = constant_pattern_rule(p)) // constant_pattern + ) + { + D(fprintf(stderr, "%*c+ _tmp_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "constant_pattern")); + _res = constant_pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_72[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "constant_pattern")); + } + _res = NULL; + done: + D(p->level--); return _res; } -// _tmp_71: '->' expression +// _tmp_73: 'from' expression static void * -_tmp_71_rule(Parser *p) +_tmp_73_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'from' expression + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); + Token * _keyword; + expr_ty z; + if ( + (_keyword = _PyPegen_expect_token(p, 514)) // token='from' + && + (z = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ _tmp_73[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); + _res = z; + 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_73[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_74: '->' expression +static void * +_tmp_74_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21060,7 +21228,7 @@ _tmp_71_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -21069,7 +21237,7 @@ _tmp_71_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_71[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_74[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21079,7 +21247,7 @@ _tmp_71_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_71[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_74[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -21088,9 +21256,9 @@ _tmp_71_rule(Parser *p) return _res; } -// _tmp_72: '->' expression +// _tmp_75: '->' expression static void * -_tmp_72_rule(Parser *p) +_tmp_75_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21104,7 +21272,7 @@ _tmp_72_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -21113,7 +21281,7 @@ _tmp_72_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_75[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21123,7 +21291,7 @@ _tmp_72_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_72[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_75[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -21132,9 +21300,9 @@ _tmp_72_rule(Parser *p) return _res; } -// _tmp_73: NEWLINE INDENT +// _tmp_76: NEWLINE INDENT static void * -_tmp_73_rule(Parser *p) +_tmp_76_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21148,7 +21316,7 @@ _tmp_73_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c> _tmp_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); Token * indent_var; Token * newline_var; if ( @@ -21157,12 +21325,12 @@ _tmp_73_rule(Parser *p) (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' ) { - D(fprintf(stderr, "%*c+ _tmp_73[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c+ _tmp_76[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); _res = _PyPegen_dummy_name(p, newline_var, indent_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_73[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_76[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); } _res = NULL; @@ -21171,9 +21339,9 @@ _tmp_73_rule(Parser *p) return _res; } -// _loop0_74: param_no_default +// _loop0_77: param_no_default static asdl_seq * -_loop0_74_rule(Parser *p) +_loop0_77_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21197,7 +21365,7 @@ _loop0_74_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_77[%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 @@ -21219,7 +21387,7 @@ _loop0_74_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_74[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_77[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21232,14 +21400,14 @@ _loop0_74_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_74_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_77_type, _seq); D(p->level--); return _seq; } -// _loop0_75: param_with_default +// _loop0_78: param_with_default static asdl_seq * -_loop0_75_rule(Parser *p) +_loop0_78_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21263,7 +21431,7 @@ _loop0_75_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21285,7 +21453,7 @@ _loop0_75_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_75[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_78[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21298,14 +21466,14 @@ _loop0_75_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_75_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_78_type, _seq); D(p->level--); return _seq; } -// _loop0_76: param_with_default +// _loop0_79: param_with_default static asdl_seq * -_loop0_76_rule(Parser *p) +_loop0_79_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21329,7 +21497,7 @@ _loop0_76_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21351,7 +21519,7 @@ _loop0_76_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_76[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_79[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21364,14 +21532,14 @@ _loop0_76_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_76_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq); D(p->level--); return _seq; } -// _loop1_77: param_no_default +// _loop1_80: param_no_default static asdl_seq * -_loop1_77_rule(Parser *p) +_loop1_80_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21395,7 +21563,7 @@ _loop1_77_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_80[%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 @@ -21417,7 +21585,7 @@ _loop1_77_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_77[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_80[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -21435,14 +21603,14 @@ _loop1_77_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_77_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_80_type, _seq); D(p->level--); return _seq; } -// _loop0_78: param_with_default +// _loop0_81: param_with_default static asdl_seq * -_loop0_78_rule(Parser *p) +_loop0_81_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21466,7 +21634,7 @@ _loop0_78_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21488,7 +21656,7 @@ _loop0_78_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_78[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_81[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21501,14 +21669,14 @@ _loop0_78_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_78_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_81_type, _seq); D(p->level--); return _seq; } -// _loop1_79: param_with_default +// _loop1_82: param_with_default static asdl_seq * -_loop1_79_rule(Parser *p) +_loop1_82_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21532,7 +21700,7 @@ _loop1_79_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21554,7 +21722,7 @@ _loop1_79_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_79[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_82[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -21572,14 +21740,14 @@ _loop1_79_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_79_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_82_type, _seq); D(p->level--); return _seq; } -// _loop1_80: param_no_default +// _loop1_83: param_no_default static asdl_seq * -_loop1_80_rule(Parser *p) +_loop1_83_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21603,7 +21771,7 @@ _loop1_80_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_83[%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 @@ -21625,7 +21793,7 @@ _loop1_80_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_80[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -21643,14 +21811,14 @@ _loop1_80_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_80_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); D(p->level--); return _seq; } -// _loop1_81: param_no_default +// _loop1_84: param_no_default static asdl_seq * -_loop1_81_rule(Parser *p) +_loop1_84_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21674,7 +21842,7 @@ _loop1_81_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_84[%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 @@ -21696,7 +21864,7 @@ _loop1_81_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -21714,14 +21882,14 @@ _loop1_81_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); D(p->level--); return _seq; } -// _loop0_82: param_no_default +// _loop0_85: param_no_default static asdl_seq * -_loop0_82_rule(Parser *p) +_loop0_85_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21745,7 +21913,7 @@ _loop0_82_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_85[%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 @@ -21767,7 +21935,7 @@ _loop0_82_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_82[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_85[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21780,14 +21948,14 @@ _loop0_82_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_82_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_85_type, _seq); D(p->level--); return _seq; } -// _loop1_83: param_with_default +// _loop1_86: param_with_default static asdl_seq * -_loop1_83_rule(Parser *p) +_loop1_86_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21811,7 +21979,7 @@ _loop1_83_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21833,7 +22001,7 @@ _loop1_83_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -21851,14 +22019,14 @@ _loop1_83_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_86_type, _seq); D(p->level--); return _seq; } -// _loop0_84: param_no_default +// _loop0_87: param_no_default static asdl_seq * -_loop0_84_rule(Parser *p) +_loop0_87_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21882,7 +22050,7 @@ _loop0_84_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_87[%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 @@ -21904,7 +22072,7 @@ _loop0_84_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_84[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_87[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21917,14 +22085,14 @@ _loop0_84_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_84_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_87_type, _seq); D(p->level--); return _seq; } -// _loop1_85: param_with_default +// _loop1_88: param_with_default static asdl_seq * -_loop1_85_rule(Parser *p) +_loop1_88_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21948,7 +22116,7 @@ _loop1_85_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21970,7 +22138,7 @@ _loop1_85_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_85[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_88[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -21988,14 +22156,14 @@ _loop1_85_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_85_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_88_type, _seq); D(p->level--); return _seq; } -// _loop0_86: param_maybe_default +// _loop0_89: param_maybe_default static asdl_seq * -_loop0_86_rule(Parser *p) +_loop0_89_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22019,7 +22187,7 @@ _loop0_86_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -22041,7 +22209,7 @@ _loop0_86_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_86[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_89[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22054,14 +22222,14 @@ _loop0_86_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_86_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_89_type, _seq); D(p->level--); return _seq; } -// _loop1_87: param_maybe_default +// _loop1_90: param_maybe_default static asdl_seq * -_loop1_87_rule(Parser *p) +_loop1_90_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22085,7 +22253,7 @@ _loop1_87_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -22107,7 +22275,7 @@ _loop1_87_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_90[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -22125,14 +22293,14 @@ _loop1_87_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_87_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_90_type, _seq); D(p->level--); return _seq; } -// _loop1_88: ('@' named_expression NEWLINE) +// _loop1_91: ('@' named_expression NEWLINE) static asdl_seq * -_loop1_88_rule(Parser *p) +_loop1_91_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22156,13 +22324,13 @@ _loop1_88_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); - void *_tmp_163_var; + D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); + void *_tmp_170_var; while ( - (_tmp_163_var = _tmp_163_rule(p)) // '@' named_expression NEWLINE + (_tmp_170_var = _tmp_170_rule(p)) // '@' named_expression NEWLINE ) { - _res = _tmp_163_var; + _res = _tmp_170_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22178,7 +22346,7 @@ _loop1_88_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_88[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)")); } if (_n == 0 || p->error_indicator) { @@ -22196,14 +22364,14 @@ _loop1_88_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_88_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq); D(p->level--); return _seq; } -// _tmp_89: '(' arguments? ')' +// _tmp_92: '(' arguments? ')' static void * -_tmp_89_rule(Parser *p) +_tmp_92_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22217,7 +22385,7 @@ _tmp_89_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c> _tmp_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); Token * _literal; Token * _literal_1; void *z; @@ -22229,7 +22397,7 @@ _tmp_89_rule(Parser *p) (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_89[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c+ _tmp_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -22239,7 +22407,7 @@ _tmp_89_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_89[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_92[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); } _res = NULL; @@ -22248,9 +22416,9 @@ _tmp_89_rule(Parser *p) return _res; } -// _loop0_91: ',' star_expression +// _loop0_94: ',' star_expression static asdl_seq * -_loop0_91_rule(Parser *p) +_loop0_94_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22274,7 +22442,7 @@ _loop0_91_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _loop0_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty elem; while ( @@ -22305,7 +22473,7 @@ _loop0_91_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_91[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_94[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22318,14 +22486,14 @@ _loop0_91_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_91_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_94_type, _seq); D(p->level--); return _seq; } -// _gather_90: star_expression _loop0_91 +// _gather_93: star_expression _loop0_94 static asdl_seq * -_gather_90_rule(Parser *p) +_gather_93_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22334,27 +22502,27 @@ _gather_90_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_expression _loop0_91 + { // star_expression _loop0_94 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_91")); + D(fprintf(stderr, "%*c> _gather_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_94")); expr_ty elem; asdl_seq * seq; if ( (elem = star_expression_rule(p)) // star_expression && - (seq = _loop0_91_rule(p)) // _loop0_91 + (seq = _loop0_94_rule(p)) // _loop0_94 ) { - D(fprintf(stderr, "%*c+ _gather_90[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_91")); + D(fprintf(stderr, "%*c+ _gather_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_94")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_90[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_91")); + D(fprintf(stderr, "%*c%s _gather_93[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_94")); } _res = NULL; done: @@ -22362,9 +22530,9 @@ _gather_90_rule(Parser *p) return _res; } -// _loop1_92: (',' star_expression) +// _loop1_95: (',' star_expression) static asdl_seq * -_loop1_92_rule(Parser *p) +_loop1_95_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22388,13 +22556,13 @@ _loop1_92_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); - void *_tmp_164_var; + D(fprintf(stderr, "%*c> _loop1_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); + void *_tmp_171_var; while ( - (_tmp_164_var = _tmp_164_rule(p)) // ',' star_expression + (_tmp_171_var = _tmp_171_rule(p)) // ',' star_expression ) { - _res = _tmp_164_var; + _res = _tmp_171_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22410,7 +22578,7 @@ _loop1_92_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_92[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); } if (_n == 0 || p->error_indicator) { @@ -22428,14 +22596,14 @@ _loop1_92_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_92_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_95_type, _seq); D(p->level--); return _seq; } -// _loop0_94: ',' star_named_expression +// _loop0_97: ',' star_named_expression static asdl_seq * -_loop0_94_rule(Parser *p) +_loop0_97_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22459,7 +22627,7 @@ _loop0_94_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); + D(fprintf(stderr, "%*c> _loop0_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); Token * _literal; expr_ty elem; while ( @@ -22490,7 +22658,7 @@ _loop0_94_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_94[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_97[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22503,14 +22671,14 @@ _loop0_94_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_94_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_97_type, _seq); D(p->level--); return _seq; } -// _gather_93: star_named_expression _loop0_94 +// _gather_96: star_named_expression _loop0_97 static asdl_seq * -_gather_93_rule(Parser *p) +_gather_96_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22519,27 +22687,27 @@ _gather_93_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_named_expression _loop0_94 + { // star_named_expression _loop0_97 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_94")); + D(fprintf(stderr, "%*c> _gather_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_97")); expr_ty elem; asdl_seq * seq; if ( (elem = star_named_expression_rule(p)) // star_named_expression && - (seq = _loop0_94_rule(p)) // _loop0_94 + (seq = _loop0_97_rule(p)) // _loop0_97 ) { - D(fprintf(stderr, "%*c+ _gather_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_94")); + D(fprintf(stderr, "%*c+ _gather_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_97")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_93[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_94")); + D(fprintf(stderr, "%*c%s _gather_96[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_97")); } _res = NULL; done: @@ -22547,9 +22715,9 @@ _gather_93_rule(Parser *p) return _res; } -// _loop1_95: (',' expression) +// _loop1_98: (',' expression) static asdl_seq * -_loop1_95_rule(Parser *p) +_loop1_98_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22573,13 +22741,13 @@ _loop1_95_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); - void *_tmp_165_var; + D(fprintf(stderr, "%*c> _loop1_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); + void *_tmp_172_var; while ( - (_tmp_165_var = _tmp_165_rule(p)) // ',' expression + (_tmp_172_var = _tmp_172_rule(p)) // ',' expression ) { - _res = _tmp_165_var; + _res = _tmp_172_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22595,7 +22763,7 @@ _loop1_95_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_95[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_98[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); } if (_n == 0 || p->error_indicator) { @@ -22613,14 +22781,14 @@ _loop1_95_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_95_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_98_type, _seq); D(p->level--); return _seq; } -// _loop0_96: lambda_param_no_default +// _loop0_99: lambda_param_no_default static asdl_seq * -_loop0_96_rule(Parser *p) +_loop0_99_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22644,7 +22812,7 @@ _loop0_96_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_99[%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 @@ -22666,7 +22834,7 @@ _loop0_96_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_96[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_99[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22679,14 +22847,14 @@ _loop0_96_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_96_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_99_type, _seq); D(p->level--); return _seq; } -// _loop0_97: lambda_param_with_default +// _loop0_100: lambda_param_with_default static asdl_seq * -_loop0_97_rule(Parser *p) +_loop0_100_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22710,7 +22878,7 @@ _loop0_97_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22732,7 +22900,7 @@ _loop0_97_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_97[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_100[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22745,14 +22913,14 @@ _loop0_97_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_97_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_100_type, _seq); D(p->level--); return _seq; } -// _loop0_98: lambda_param_with_default +// _loop0_101: lambda_param_with_default static asdl_seq * -_loop0_98_rule(Parser *p) +_loop0_101_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22776,7 +22944,7 @@ _loop0_98_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22798,7 +22966,7 @@ _loop0_98_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_98[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_101[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22811,14 +22979,14 @@ _loop0_98_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_98_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_101_type, _seq); D(p->level--); return _seq; } -// _loop1_99: lambda_param_no_default +// _loop1_102: lambda_param_no_default static asdl_seq * -_loop1_99_rule(Parser *p) +_loop1_102_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22842,7 +23010,7 @@ _loop1_99_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_102[%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 @@ -22864,7 +23032,7 @@ _loop1_99_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_99[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_102[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -22882,14 +23050,14 @@ _loop1_99_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_102_type, _seq); D(p->level--); return _seq; } -// _loop0_100: lambda_param_with_default +// _loop0_103: lambda_param_with_default static asdl_seq * -_loop0_100_rule(Parser *p) +_loop0_103_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22913,7 +23081,7 @@ _loop0_100_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22935,7 +23103,7 @@ _loop0_100_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_100[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22948,14 +23116,14 @@ _loop0_100_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_100_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_103_type, _seq); D(p->level--); return _seq; } -// _loop1_101: lambda_param_with_default +// _loop1_104: lambda_param_with_default static asdl_seq * -_loop1_101_rule(Parser *p) +_loop1_104_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22979,7 +23147,7 @@ _loop1_101_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23001,7 +23169,7 @@ _loop1_101_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_101[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_104[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -23019,14 +23187,14 @@ _loop1_101_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_101_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_104_type, _seq); D(p->level--); return _seq; } -// _loop1_102: lambda_param_no_default +// _loop1_105: lambda_param_no_default static asdl_seq * -_loop1_102_rule(Parser *p) +_loop1_105_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23050,7 +23218,7 @@ _loop1_102_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_105[%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 @@ -23072,7 +23240,7 @@ _loop1_102_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_102[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -23090,14 +23258,14 @@ _loop1_102_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_102_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq); D(p->level--); return _seq; } -// _loop1_103: lambda_param_no_default +// _loop1_106: lambda_param_no_default static asdl_seq * -_loop1_103_rule(Parser *p) +_loop1_106_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23121,7 +23289,7 @@ _loop1_103_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_106[%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 @@ -23143,7 +23311,7 @@ _loop1_103_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_103[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -23161,14 +23329,14 @@ _loop1_103_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_103_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_106_type, _seq); D(p->level--); return _seq; } -// _loop0_104: lambda_param_no_default +// _loop0_107: lambda_param_no_default static asdl_seq * -_loop0_104_rule(Parser *p) +_loop0_107_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23192,7 +23360,7 @@ _loop0_104_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_107[%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 @@ -23214,7 +23382,7 @@ _loop0_104_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_104[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_107[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23227,14 +23395,14 @@ _loop0_104_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_104_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_107_type, _seq); D(p->level--); return _seq; } -// _loop1_105: lambda_param_with_default +// _loop1_108: lambda_param_with_default static asdl_seq * -_loop1_105_rule(Parser *p) +_loop1_108_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23258,7 +23426,7 @@ _loop1_105_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23280,7 +23448,7 @@ _loop1_105_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_108[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -23298,14 +23466,14 @@ _loop1_105_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_108_type, _seq); D(p->level--); return _seq; } -// _loop0_106: lambda_param_no_default +// _loop0_109: lambda_param_no_default static asdl_seq * -_loop0_106_rule(Parser *p) +_loop0_109_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23329,7 +23497,7 @@ _loop0_106_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_109[%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 @@ -23351,7 +23519,7 @@ _loop0_106_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_106[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_109[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23364,14 +23532,14 @@ _loop0_106_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_106_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_109_type, _seq); D(p->level--); return _seq; } -// _loop1_107: lambda_param_with_default +// _loop1_110: lambda_param_with_default static asdl_seq * -_loop1_107_rule(Parser *p) +_loop1_110_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23395,7 +23563,7 @@ _loop1_107_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23417,7 +23585,7 @@ _loop1_107_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_107[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_110[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -23435,14 +23603,14 @@ _loop1_107_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_107_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_110_type, _seq); D(p->level--); return _seq; } -// _loop0_108: lambda_param_maybe_default +// _loop0_111: lambda_param_maybe_default static asdl_seq * -_loop0_108_rule(Parser *p) +_loop0_111_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23466,7 +23634,7 @@ _loop0_108_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -23488,7 +23656,7 @@ _loop0_108_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_108[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_111[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23501,14 +23669,14 @@ _loop0_108_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_108_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_111_type, _seq); D(p->level--); return _seq; } -// _loop1_109: lambda_param_maybe_default +// _loop1_112: lambda_param_maybe_default static asdl_seq * -_loop1_109_rule(Parser *p) +_loop1_112_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23532,7 +23700,7 @@ _loop1_109_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -23554,7 +23722,7 @@ _loop1_109_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_109[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_112[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -23572,14 +23740,14 @@ _loop1_109_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_109_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_112_type, _seq); D(p->level--); return _seq; } -// _loop1_110: ('or' conjunction) +// _loop1_113: ('or' conjunction) static asdl_seq * -_loop1_110_rule(Parser *p) +_loop1_113_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23603,13 +23771,13 @@ _loop1_110_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); - void *_tmp_166_var; + D(fprintf(stderr, "%*c> _loop1_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); + void *_tmp_173_var; while ( - (_tmp_166_var = _tmp_166_rule(p)) // 'or' conjunction + (_tmp_173_var = _tmp_173_rule(p)) // 'or' conjunction ) { - _res = _tmp_166_var; + _res = _tmp_173_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23625,7 +23793,7 @@ _loop1_110_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_110[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_113[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); } if (_n == 0 || p->error_indicator) { @@ -23643,14 +23811,14 @@ _loop1_110_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_110_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_113_type, _seq); D(p->level--); return _seq; } -// _loop1_111: ('and' inversion) +// _loop1_114: ('and' inversion) static asdl_seq * -_loop1_111_rule(Parser *p) +_loop1_114_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23674,13 +23842,13 @@ _loop1_111_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); - void *_tmp_167_var; + D(fprintf(stderr, "%*c> _loop1_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); + void *_tmp_174_var; while ( - (_tmp_167_var = _tmp_167_rule(p)) // 'and' inversion + (_tmp_174_var = _tmp_174_rule(p)) // 'and' inversion ) { - _res = _tmp_167_var; + _res = _tmp_174_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23696,7 +23864,7 @@ _loop1_111_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_111[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_114[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); } if (_n == 0 || p->error_indicator) { @@ -23714,14 +23882,14 @@ _loop1_111_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_111_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_114_type, _seq); D(p->level--); return _seq; } -// _loop1_112: compare_op_bitwise_or_pair +// _loop1_115: compare_op_bitwise_or_pair static asdl_seq * -_loop1_112_rule(Parser *p) +_loop1_115_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23745,7 +23913,7 @@ _loop1_112_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); + D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); CmpopExprPair* compare_op_bitwise_or_pair_var; while ( (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair @@ -23767,7 +23935,7 @@ _loop1_112_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_112[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); } if (_n == 0 || p->error_indicator) { @@ -23785,14 +23953,14 @@ _loop1_112_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_112_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_115_type, _seq); D(p->level--); return _seq; } -// _tmp_113: '!=' +// _tmp_116: '!=' static void * -_tmp_113_rule(Parser *p) +_tmp_116_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23806,13 +23974,13 @@ _tmp_113_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); Token * tok; if ( (tok = _PyPegen_expect_token(p, 28)) // token='!=' ) { - D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23822,7 +23990,7 @@ _tmp_113_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); } _res = NULL; @@ -23831,9 +23999,9 @@ _tmp_113_rule(Parser *p) return _res; } -// _loop0_115: ',' slice +// _loop0_118: ',' slice static asdl_seq * -_loop0_115_rule(Parser *p) +_loop0_118_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23857,7 +24025,7 @@ _loop0_115_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); + D(fprintf(stderr, "%*c> _loop0_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); Token * _literal; expr_ty elem; while ( @@ -23888,7 +24056,7 @@ _loop0_115_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_115[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_118[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' slice")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23901,14 +24069,14 @@ _loop0_115_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_115_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_118_type, _seq); D(p->level--); return _seq; } -// _gather_114: slice _loop0_115 +// _gather_117: slice _loop0_118 static asdl_seq * -_gather_114_rule(Parser *p) +_gather_117_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23917,27 +24085,27 @@ _gather_114_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // slice _loop0_115 + { // slice _loop0_118 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_115")); + D(fprintf(stderr, "%*c> _gather_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_118")); expr_ty elem; asdl_seq * seq; if ( (elem = slice_rule(p)) // slice && - (seq = _loop0_115_rule(p)) // _loop0_115 + (seq = _loop0_118_rule(p)) // _loop0_118 ) { - D(fprintf(stderr, "%*c+ _gather_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_115")); + D(fprintf(stderr, "%*c+ _gather_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_118")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_114[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_115")); + D(fprintf(stderr, "%*c%s _gather_117[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_118")); } _res = NULL; done: @@ -23945,9 +24113,9 @@ _gather_114_rule(Parser *p) return _res; } -// _tmp_116: ':' expression? +// _tmp_119: ':' expression? static void * -_tmp_116_rule(Parser *p) +_tmp_119_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23961,7 +24129,7 @@ _tmp_116_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); Token * _literal; void *d; if ( @@ -23970,7 +24138,7 @@ _tmp_116_rule(Parser *p) (d = expression_rule(p), 1) // expression? ) { - D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); _res = d; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23980,7 +24148,7 @@ _tmp_116_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); } _res = NULL; @@ -23989,9 +24157,9 @@ _tmp_116_rule(Parser *p) return _res; } -// _tmp_117: tuple | group | genexp +// _tmp_120: tuple | group | genexp static void * -_tmp_117_rule(Parser *p) +_tmp_120_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24005,18 +24173,18 @@ _tmp_117_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); expr_ty tuple_var; if ( (tuple_var = tuple_rule(p)) // tuple ) { - D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); _res = tuple_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); } { // group @@ -24024,18 +24192,18 @@ _tmp_117_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); expr_ty group_var; if ( (group_var = group_rule(p)) // group ) { - D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); _res = group_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group")); } { // genexp @@ -24043,18 +24211,18 @@ _tmp_117_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); expr_ty genexp_var; if ( (genexp_var = genexp_rule(p)) // genexp ) { - D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); _res = genexp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); } _res = NULL; @@ -24063,9 +24231,9 @@ _tmp_117_rule(Parser *p) return _res; } -// _tmp_118: list | listcomp +// _tmp_121: list | listcomp static void * -_tmp_118_rule(Parser *p) +_tmp_121_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24079,18 +24247,18 @@ _tmp_118_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); expr_ty list_var; if ( (list_var = list_rule(p)) // list ) { - D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); _res = list_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); } { // listcomp @@ -24098,18 +24266,18 @@ _tmp_118_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); expr_ty listcomp_var; if ( (listcomp_var = listcomp_rule(p)) // listcomp ) { - D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); _res = listcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp")); } _res = NULL; @@ -24118,9 +24286,9 @@ _tmp_118_rule(Parser *p) return _res; } -// _tmp_119: dict | set | dictcomp | setcomp +// _tmp_122: dict | set | dictcomp | setcomp static void * -_tmp_119_rule(Parser *p) +_tmp_122_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24134,18 +24302,18 @@ _tmp_119_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); expr_ty dict_var; if ( (dict_var = dict_rule(p)) // dict ) { - D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); _res = dict_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict")); } { // set @@ -24153,18 +24321,18 @@ _tmp_119_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); expr_ty set_var; if ( (set_var = set_rule(p)) // set ) { - D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); _res = set_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set")); } { // dictcomp @@ -24172,18 +24340,18 @@ _tmp_119_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); expr_ty dictcomp_var; if ( (dictcomp_var = dictcomp_rule(p)) // dictcomp ) { - D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); _res = dictcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp")); } { // setcomp @@ -24191,18 +24359,18 @@ _tmp_119_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); expr_ty setcomp_var; if ( (setcomp_var = setcomp_rule(p)) // setcomp ) { - D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); _res = setcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp")); } _res = NULL; @@ -24211,9 +24379,9 @@ _tmp_119_rule(Parser *p) return _res; } -// _loop1_120: STRING +// _loop1_123: STRING static asdl_seq * -_loop1_120_rule(Parser *p) +_loop1_123_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24237,7 +24405,7 @@ _loop1_120_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); + D(fprintf(stderr, "%*c> _loop1_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); expr_ty string_var; while ( (string_var = _PyPegen_string_token(p)) // STRING @@ -24259,7 +24427,7 @@ _loop1_120_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_120[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); } if (_n == 0 || p->error_indicator) { @@ -24277,14 +24445,14 @@ _loop1_120_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_120_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_123_type, _seq); D(p->level--); return _seq; } -// _tmp_121: star_named_expression ',' star_named_expressions? +// _tmp_124: star_named_expression ',' star_named_expressions? static void * -_tmp_121_rule(Parser *p) +_tmp_124_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24298,7 +24466,7 @@ _tmp_121_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); Token * _literal; expr_ty y; void *z; @@ -24310,7 +24478,7 @@ _tmp_121_rule(Parser *p) (z = star_named_expressions_rule(p), 1) // star_named_expressions? ) { - D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); _res = _PyPegen_seq_insert_in_front ( p , y , z ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -24320,7 +24488,7 @@ _tmp_121_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); } _res = NULL; @@ -24329,9 +24497,9 @@ _tmp_121_rule(Parser *p) return _res; } -// _tmp_122: yield_expr | named_expression +// _tmp_125: yield_expr | named_expression static void * -_tmp_122_rule(Parser *p) +_tmp_125_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24345,18 +24513,18 @@ _tmp_122_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // named_expression @@ -24364,18 +24532,18 @@ _tmp_122_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); expr_ty named_expression_var; if ( (named_expression_var = named_expression_rule(p)) // named_expression ) { - D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); _res = named_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); } _res = NULL; @@ -24384,9 +24552,9 @@ _tmp_122_rule(Parser *p) return _res; } -// _loop0_124: ',' double_starred_kvpair +// _loop0_127: ',' double_starred_kvpair static asdl_seq * -_loop0_124_rule(Parser *p) +_loop0_127_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24410,7 +24578,7 @@ _loop0_124_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); + D(fprintf(stderr, "%*c> _loop0_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); Token * _literal; KeyValuePair* elem; while ( @@ -24441,7 +24609,7 @@ _loop0_124_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_124[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_127[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24454,14 +24622,14 @@ _loop0_124_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_124_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_127_type, _seq); D(p->level--); return _seq; } -// _gather_123: double_starred_kvpair _loop0_124 +// _gather_126: double_starred_kvpair _loop0_127 static asdl_seq * -_gather_123_rule(Parser *p) +_gather_126_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24470,27 +24638,27 @@ _gather_123_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // double_starred_kvpair _loop0_124 + { // double_starred_kvpair _loop0_127 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_124")); + D(fprintf(stderr, "%*c> _gather_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_127")); KeyValuePair* elem; asdl_seq * seq; if ( (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair && - (seq = _loop0_124_rule(p)) // _loop0_124 + (seq = _loop0_127_rule(p)) // _loop0_127 ) { - D(fprintf(stderr, "%*c+ _gather_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_124")); + D(fprintf(stderr, "%*c+ _gather_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_127")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_123[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_124")); + D(fprintf(stderr, "%*c%s _gather_126[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_127")); } _res = NULL; done: @@ -24498,9 +24666,9 @@ _gather_123_rule(Parser *p) return _res; } -// _loop1_125: for_if_clause +// _loop1_128: for_if_clause static asdl_seq * -_loop1_125_rule(Parser *p) +_loop1_128_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24524,7 +24692,7 @@ _loop1_125_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); + D(fprintf(stderr, "%*c> _loop1_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); comprehension_ty for_if_clause_var; while ( (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause @@ -24546,7 +24714,7 @@ _loop1_125_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_128[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); } if (_n == 0 || p->error_indicator) { @@ -24564,14 +24732,14 @@ _loop1_125_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_125_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_128_type, _seq); D(p->level--); return _seq; } -// _loop0_126: ('if' disjunction) +// _loop0_129: ('if' disjunction) static asdl_seq * -_loop0_126_rule(Parser *p) +_loop0_129_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24595,13 +24763,13 @@ _loop0_126_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_168_var; + D(fprintf(stderr, "%*c> _loop0_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_175_var; while ( - (_tmp_168_var = _tmp_168_rule(p)) // 'if' disjunction + (_tmp_175_var = _tmp_175_rule(p)) // 'if' disjunction ) { - _res = _tmp_168_var; + _res = _tmp_175_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24617,7 +24785,7 @@ _loop0_126_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_126[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_129[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24630,14 +24798,14 @@ _loop0_126_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_126_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_129_type, _seq); D(p->level--); return _seq; } -// _loop0_127: ('if' disjunction) +// _loop0_130: ('if' disjunction) static asdl_seq * -_loop0_127_rule(Parser *p) +_loop0_130_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24661,13 +24829,13 @@ _loop0_127_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_169_var; + D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_176_var; while ( - (_tmp_169_var = _tmp_169_rule(p)) // 'if' disjunction + (_tmp_176_var = _tmp_176_rule(p)) // 'if' disjunction ) { - _res = _tmp_169_var; + _res = _tmp_176_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24683,7 +24851,7 @@ _loop0_127_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_127[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24696,14 +24864,14 @@ _loop0_127_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_127_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq); D(p->level--); return _seq; } -// _tmp_128: ',' args +// _tmp_131: ',' args static void * -_tmp_128_rule(Parser *p) +_tmp_131_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24717,7 +24885,7 @@ _tmp_128_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); Token * _literal; expr_ty c; if ( @@ -24726,7 +24894,7 @@ _tmp_128_rule(Parser *p) (c = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -24736,7 +24904,7 @@ _tmp_128_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); } _res = NULL; @@ -24745,9 +24913,9 @@ _tmp_128_rule(Parser *p) return _res; } -// _tmp_129: ',' args +// _tmp_132: ',' args static void * -_tmp_129_rule(Parser *p) +_tmp_132_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24761,7 +24929,7 @@ _tmp_129_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c> _tmp_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); Token * _literal; expr_ty c; if ( @@ -24770,7 +24938,7 @@ _tmp_129_rule(Parser *p) (c = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c+ _tmp_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -24780,7 +24948,7 @@ _tmp_129_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_129[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_132[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); } _res = NULL; @@ -24789,9 +24957,9 @@ _tmp_129_rule(Parser *p) return _res; } -// _loop0_131: ',' kwarg_or_starred +// _loop0_134: ',' kwarg_or_starred static asdl_seq * -_loop0_131_rule(Parser *p) +_loop0_134_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24815,7 +24983,7 @@ _loop0_131_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -24846,7 +25014,7 @@ _loop0_131_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_131[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_134[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24859,14 +25027,14 @@ _loop0_131_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_131_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_134_type, _seq); D(p->level--); return _seq; } -// _gather_130: kwarg_or_starred _loop0_131 +// _gather_133: kwarg_or_starred _loop0_134 static asdl_seq * -_gather_130_rule(Parser *p) +_gather_133_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24875,27 +25043,27 @@ _gather_130_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_131 + { // kwarg_or_starred _loop0_134 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_131")); + D(fprintf(stderr, "%*c> _gather_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_134")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_131_rule(p)) // _loop0_131 + (seq = _loop0_134_rule(p)) // _loop0_134 ) { - D(fprintf(stderr, "%*c+ _gather_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_131")); + D(fprintf(stderr, "%*c+ _gather_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_134")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_130[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_131")); + D(fprintf(stderr, "%*c%s _gather_133[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_134")); } _res = NULL; done: @@ -24903,9 +25071,9 @@ _gather_130_rule(Parser *p) return _res; } -// _loop0_133: ',' kwarg_or_double_starred +// _loop0_136: ',' kwarg_or_double_starred static asdl_seq * -_loop0_133_rule(Parser *p) +_loop0_136_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24929,7 +25097,7 @@ _loop0_133_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -24960,7 +25128,7 @@ _loop0_133_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_133[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_136[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24973,14 +25141,14 @@ _loop0_133_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_133_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_136_type, _seq); D(p->level--); return _seq; } -// _gather_132: kwarg_or_double_starred _loop0_133 +// _gather_135: kwarg_or_double_starred _loop0_136 static asdl_seq * -_gather_132_rule(Parser *p) +_gather_135_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24989,27 +25157,27 @@ _gather_132_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_133 + { // kwarg_or_double_starred _loop0_136 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_133")); + D(fprintf(stderr, "%*c> _gather_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_136")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_133_rule(p)) // _loop0_133 + (seq = _loop0_136_rule(p)) // _loop0_136 ) { - D(fprintf(stderr, "%*c+ _gather_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_133")); + D(fprintf(stderr, "%*c+ _gather_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_136")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_132[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_133")); + D(fprintf(stderr, "%*c%s _gather_135[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_136")); } _res = NULL; done: @@ -25017,9 +25185,9 @@ _gather_132_rule(Parser *p) return _res; } -// _loop0_135: ',' kwarg_or_starred +// _loop0_138: ',' kwarg_or_starred static asdl_seq * -_loop0_135_rule(Parser *p) +_loop0_138_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25043,7 +25211,7 @@ _loop0_135_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -25074,7 +25242,7 @@ _loop0_135_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_135[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_138[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25087,14 +25255,14 @@ _loop0_135_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_135_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_138_type, _seq); D(p->level--); return _seq; } -// _gather_134: kwarg_or_starred _loop0_135 +// _gather_137: kwarg_or_starred _loop0_138 static asdl_seq * -_gather_134_rule(Parser *p) +_gather_137_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25103,27 +25271,27 @@ _gather_134_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_135 + { // kwarg_or_starred _loop0_138 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_135")); + D(fprintf(stderr, "%*c> _gather_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_138")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_135_rule(p)) // _loop0_135 + (seq = _loop0_138_rule(p)) // _loop0_138 ) { - D(fprintf(stderr, "%*c+ _gather_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_135")); + D(fprintf(stderr, "%*c+ _gather_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_138")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_134[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_135")); + D(fprintf(stderr, "%*c%s _gather_137[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_138")); } _res = NULL; done: @@ -25131,9 +25299,9 @@ _gather_134_rule(Parser *p) return _res; } -// _loop0_137: ',' kwarg_or_double_starred +// _loop0_140: ',' kwarg_or_double_starred static asdl_seq * -_loop0_137_rule(Parser *p) +_loop0_140_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25157,7 +25325,7 @@ _loop0_137_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -25188,7 +25356,7 @@ _loop0_137_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_137[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_140[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25201,14 +25369,14 @@ _loop0_137_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_137_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_140_type, _seq); D(p->level--); return _seq; } -// _gather_136: kwarg_or_double_starred _loop0_137 +// _gather_139: kwarg_or_double_starred _loop0_140 static asdl_seq * -_gather_136_rule(Parser *p) +_gather_139_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25217,27 +25385,27 @@ _gather_136_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_137 + { // kwarg_or_double_starred _loop0_140 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_137")); + D(fprintf(stderr, "%*c> _gather_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_140")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_137_rule(p)) // _loop0_137 + (seq = _loop0_140_rule(p)) // _loop0_140 ) { - D(fprintf(stderr, "%*c+ _gather_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_137")); + D(fprintf(stderr, "%*c+ _gather_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_140")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_136[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_137")); + D(fprintf(stderr, "%*c%s _gather_139[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_140")); } _res = NULL; done: @@ -25245,9 +25413,9 @@ _gather_136_rule(Parser *p) return _res; } -// _loop0_138: (',' star_target) +// _loop0_141: (',' star_target) static asdl_seq * -_loop0_138_rule(Parser *p) +_loop0_141_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25271,13 +25439,13 @@ _loop0_138_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_170_var; + D(fprintf(stderr, "%*c> _loop0_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_177_var; while ( - (_tmp_170_var = _tmp_170_rule(p)) // ',' star_target + (_tmp_177_var = _tmp_177_rule(p)) // ',' star_target ) { - _res = _tmp_170_var; + _res = _tmp_177_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -25293,7 +25461,7 @@ _loop0_138_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_138[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_141[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25306,14 +25474,14 @@ _loop0_138_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_138_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_141_type, _seq); D(p->level--); return _seq; } -// _loop0_140: ',' star_target +// _loop0_143: ',' star_target static asdl_seq * -_loop0_140_rule(Parser *p) +_loop0_143_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25337,7 +25505,7 @@ _loop0_140_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _loop0_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty elem; while ( @@ -25368,7 +25536,7 @@ _loop0_140_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_140[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_143[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25381,14 +25549,14 @@ _loop0_140_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_140_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_143_type, _seq); D(p->level--); return _seq; } -// _gather_139: star_target _loop0_140 +// _gather_142: star_target _loop0_143 static asdl_seq * -_gather_139_rule(Parser *p) +_gather_142_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25397,27 +25565,27 @@ _gather_139_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_target _loop0_140 + { // star_target _loop0_143 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_140")); + D(fprintf(stderr, "%*c> _gather_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_143")); expr_ty elem; asdl_seq * seq; if ( (elem = star_target_rule(p)) // star_target && - (seq = _loop0_140_rule(p)) // _loop0_140 + (seq = _loop0_143_rule(p)) // _loop0_143 ) { - D(fprintf(stderr, "%*c+ _gather_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_140")); + D(fprintf(stderr, "%*c+ _gather_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_143")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_139[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_140")); + D(fprintf(stderr, "%*c%s _gather_142[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_143")); } _res = NULL; done: @@ -25425,9 +25593,9 @@ _gather_139_rule(Parser *p) return _res; } -// _tmp_141: !'*' star_target +// _tmp_144: !'*' star_target static void * -_tmp_141_rule(Parser *p) +_tmp_144_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25441,7 +25609,7 @@ _tmp_141_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); expr_ty star_target_var; if ( _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' @@ -25449,12 +25617,12 @@ _tmp_141_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); _res = star_target_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_141[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); } _res = NULL; @@ -25463,9 +25631,9 @@ _tmp_141_rule(Parser *p) return _res; } -// _loop0_143: ',' del_target +// _loop0_146: ',' del_target static asdl_seq * -_loop0_143_rule(Parser *p) +_loop0_146_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25489,7 +25657,7 @@ _loop0_143_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); + D(fprintf(stderr, "%*c> _loop0_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); Token * _literal; expr_ty elem; while ( @@ -25520,7 +25688,7 @@ _loop0_143_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_143[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_146[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25533,14 +25701,14 @@ _loop0_143_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_143_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_146_type, _seq); D(p->level--); return _seq; } -// _gather_142: del_target _loop0_143 +// _gather_145: del_target _loop0_146 static asdl_seq * -_gather_142_rule(Parser *p) +_gather_145_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25549,27 +25717,27 @@ _gather_142_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // del_target _loop0_143 + { // del_target _loop0_146 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_143")); + D(fprintf(stderr, "%*c> _gather_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_146")); expr_ty elem; asdl_seq * seq; if ( (elem = del_target_rule(p)) // del_target && - (seq = _loop0_143_rule(p)) // _loop0_143 + (seq = _loop0_146_rule(p)) // _loop0_146 ) { - D(fprintf(stderr, "%*c+ _gather_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_143")); + D(fprintf(stderr, "%*c+ _gather_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_146")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_142[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_143")); + D(fprintf(stderr, "%*c%s _gather_145[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_146")); } _res = NULL; done: @@ -25577,9 +25745,9 @@ _gather_142_rule(Parser *p) return _res; } -// _loop0_145: ',' target +// _loop0_148: ',' target static asdl_seq * -_loop0_145_rule(Parser *p) +_loop0_148_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25603,7 +25771,7 @@ _loop0_145_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); + D(fprintf(stderr, "%*c> _loop0_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); Token * _literal; expr_ty elem; while ( @@ -25634,7 +25802,7 @@ _loop0_145_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_145[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_148[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25647,14 +25815,14 @@ _loop0_145_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_145_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_148_type, _seq); D(p->level--); return _seq; } -// _gather_144: target _loop0_145 +// _gather_147: target _loop0_148 static asdl_seq * -_gather_144_rule(Parser *p) +_gather_147_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25663,27 +25831,27 @@ _gather_144_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // target _loop0_145 + { // target _loop0_148 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_145")); + D(fprintf(stderr, "%*c> _gather_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_148")); expr_ty elem; asdl_seq * seq; if ( (elem = target_rule(p)) // target && - (seq = _loop0_145_rule(p)) // _loop0_145 + (seq = _loop0_148_rule(p)) // _loop0_148 ) { - D(fprintf(stderr, "%*c+ _gather_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_145")); + D(fprintf(stderr, "%*c+ _gather_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_148")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_144[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_145")); + D(fprintf(stderr, "%*c%s _gather_147[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_148")); } _res = NULL; done: @@ -25691,9 +25859,9 @@ _gather_144_rule(Parser *p) return _res; } -// _tmp_146: args | expression for_if_clauses +// _tmp_149: args | expression for_if_clauses static void * -_tmp_146_rule(Parser *p) +_tmp_149_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25707,18 +25875,18 @@ _tmp_146_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); expr_ty args_var; if ( (args_var = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); _res = args_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); } { // expression for_if_clauses @@ -25726,7 +25894,7 @@ _tmp_146_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); expr_ty expression_var; asdl_seq* for_if_clauses_var; if ( @@ -25735,12 +25903,12 @@ _tmp_146_rule(Parser *p) (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses ) { - D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); } _res = NULL; @@ -25749,9 +25917,9 @@ _tmp_146_rule(Parser *p) return _res; } -// _loop0_147: star_named_expressions +// _loop0_150: star_named_expressions static asdl_seq * -_loop0_147_rule(Parser *p) +_loop0_150_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25775,7 +25943,7 @@ _loop0_147_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); + D(fprintf(stderr, "%*c> _loop0_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); asdl_seq* star_named_expressions_var; while ( (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions @@ -25797,7 +25965,7 @@ _loop0_147_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_147[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_150[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25810,14 +25978,14 @@ _loop0_147_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_147_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_150_type, _seq); D(p->level--); return _seq; } -// _tmp_148: '=' annotated_rhs +// _tmp_151: '=' annotated_rhs static void * -_tmp_148_rule(Parser *p) +_tmp_151_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25831,7 +25999,7 @@ _tmp_148_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); Token * _literal; expr_ty annotated_rhs_var; if ( @@ -25840,12 +26008,12 @@ _tmp_148_rule(Parser *p) (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs ) { - D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); } _res = NULL; @@ -25854,9 +26022,9 @@ _tmp_148_rule(Parser *p) return _res; } -// _tmp_149: yield_expr | star_expressions +// _tmp_152: yield_expr | star_expressions static void * -_tmp_149_rule(Parser *p) +_tmp_152_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25870,18 +26038,18 @@ _tmp_149_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -25889,18 +26057,18 @@ _tmp_149_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -25909,9 +26077,9 @@ _tmp_149_rule(Parser *p) return _res; } -// _tmp_150: yield_expr | star_expressions +// _tmp_153: yield_expr | star_expressions static void * -_tmp_150_rule(Parser *p) +_tmp_153_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25925,18 +26093,18 @@ _tmp_150_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -25944,18 +26112,18 @@ _tmp_150_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -25964,9 +26132,9 @@ _tmp_150_rule(Parser *p) return _res; } -// _tmp_151: '[' | '(' | '{' +// _tmp_154: '[' | '(' | '{' static void * -_tmp_151_rule(Parser *p) +_tmp_154_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25980,18 +26148,18 @@ _tmp_151_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); } { // '(' @@ -25999,18 +26167,18 @@ _tmp_151_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' ) { - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } { // '{' @@ -26018,18 +26186,18 @@ _tmp_151_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' ) { - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); } _res = NULL; @@ -26038,9 +26206,9 @@ _tmp_151_rule(Parser *p) return _res; } -// _loop0_152: param_no_default +// _loop0_155: param_no_default static asdl_seq * -_loop0_152_rule(Parser *p) +_loop0_155_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26064,7 +26232,7 @@ _loop0_152_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_155[%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 @@ -26086,7 +26254,7 @@ _loop0_152_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_152[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26099,14 +26267,14 @@ _loop0_152_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_152_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_155_type, _seq); D(p->level--); return _seq; } -// _tmp_153: slash_with_default | param_with_default+ +// _tmp_156: slash_with_default | param_with_default+ static void * -_tmp_153_rule(Parser *p) +_tmp_156_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26120,18 +26288,18 @@ _tmp_153_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c> _tmp_156[%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_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c+ _tmp_156[%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_153[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); } { // param_with_default+ @@ -26139,18 +26307,18 @@ _tmp_153_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - asdl_seq * _loop1_171_var; + D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + asdl_seq * _loop1_178_var; if ( - (_loop1_171_var = _loop1_171_rule(p)) // param_with_default+ + (_loop1_178_var = _loop1_178_rule(p)) // param_with_default+ ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - _res = _loop1_171_var; + D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + _res = _loop1_178_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+")); } _res = NULL; @@ -26159,9 +26327,9 @@ _tmp_153_rule(Parser *p) return _res; } -// _tmp_154: ')' | ',' (')' | '**') +// _tmp_157: ')' | ',' (')' | '**') static void * -_tmp_154_rule(Parser *p) +_tmp_157_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26175,18 +26343,18 @@ _tmp_154_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // ',' (')' | '**') @@ -26194,21 +26362,21 @@ _tmp_154_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); Token * _literal; - void *_tmp_172_var; + void *_tmp_179_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_172_var = _tmp_172_rule(p)) // ')' | '**' + (_tmp_179_var = _tmp_179_rule(p)) // ')' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_172_var); + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_179_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); } _res = NULL; @@ -26217,9 +26385,9 @@ _tmp_154_rule(Parser *p) return _res; } -// _tmp_155: ':' | ',' (':' | '**') +// _tmp_158: ':' | ',' (':' | '**') static void * -_tmp_155_rule(Parser *p) +_tmp_158_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26233,18 +26401,18 @@ _tmp_155_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // ',' (':' | '**') @@ -26252,21 +26420,21 @@ _tmp_155_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); Token * _literal; - void *_tmp_173_var; + void *_tmp_180_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_173_var = _tmp_173_rule(p)) // ':' | '**' + (_tmp_180_var = _tmp_180_rule(p)) // ':' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_173_var); + D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_180_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); } _res = NULL; @@ -26275,9 +26443,9 @@ _tmp_155_rule(Parser *p) return _res; } -// _tmp_156: star_targets '=' +// _tmp_159: star_targets '=' static void * -_tmp_156_rule(Parser *p) +_tmp_159_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26291,7 +26459,7 @@ _tmp_156_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty z; if ( @@ -26300,7 +26468,7 @@ _tmp_156_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26310,7 +26478,7 @@ _tmp_156_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -26319,9 +26487,9 @@ _tmp_156_rule(Parser *p) return _res; } -// _tmp_157: '.' | '...' +// _tmp_160: '.' | '...' static void * -_tmp_157_rule(Parser *p) +_tmp_160_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26335,18 +26503,18 @@ _tmp_157_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -26354,18 +26522,18 @@ _tmp_157_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -26374,9 +26542,9 @@ _tmp_157_rule(Parser *p) return _res; } -// _tmp_158: '.' | '...' +// _tmp_161: '.' | '...' static void * -_tmp_158_rule(Parser *p) +_tmp_161_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26390,18 +26558,18 @@ _tmp_158_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -26409,18 +26577,18 @@ _tmp_158_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -26429,9 +26597,9 @@ _tmp_158_rule(Parser *p) return _res; } -// _loop0_160: ',' arg_pattern +// _loop0_163: ',' pattern static asdl_seq * -_loop0_160_rule(Parser *p) +_loop0_163_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26450,18 +26618,18 @@ _loop0_160_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' arg_pattern + { // ',' pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' arg_pattern")); + D(fprintf(stderr, "%*c> _loop0_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = arg_pattern_rule(p)) // arg_pattern + (elem = pattern_rule(p)) // pattern ) { _res = elem; @@ -26486,8 +26654,8 @@ _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, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' arg_pattern")); + D(fprintf(stderr, "%*c%s _loop0_163[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -26499,14 +26667,14 @@ _loop0_160_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_160_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_163_type, _seq); D(p->level--); return _seq; } -// _gather_159: arg_pattern _loop0_160 +// _gather_162: pattern _loop0_163 static asdl_seq * -_gather_159_rule(Parser *p) +_gather_162_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26515,27 +26683,141 @@ _gather_159_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // arg_pattern _loop0_160 + { // pattern _loop0_163 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "arg_pattern _loop0_160")); + D(fprintf(stderr, "%*c> _gather_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_163")); expr_ty elem; asdl_seq * seq; if ( - (elem = arg_pattern_rule(p)) // arg_pattern + (elem = pattern_rule(p)) // pattern + && + (seq = _loop0_163_rule(p)) // _loop0_163 + ) + { + D(fprintf(stderr, "%*c+ _gather_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_163")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_162[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_163")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_165: ',' (pattern | keyword_pattern) +static asdl_seq * +_loop0_165_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' (pattern | keyword_pattern) + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (pattern | keyword_pattern)")); + Token * _literal; + void *elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = _tmp_181_rule(p)) // pattern | keyword_pattern + ) + { + _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_165[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (pattern | keyword_pattern)")); + } + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_165_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_164: (pattern | keyword_pattern) _loop0_165 +static asdl_seq * +_gather_164_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // (pattern | keyword_pattern) _loop0_165 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _gather_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(pattern | keyword_pattern) _loop0_165")); + void *elem; + asdl_seq * seq; + if ( + (elem = _tmp_181_rule(p)) // pattern | keyword_pattern && - (seq = _loop0_160_rule(p)) // _loop0_160 + (seq = _loop0_165_rule(p)) // _loop0_165 ) { - D(fprintf(stderr, "%*c+ _gather_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "arg_pattern _loop0_160")); + D(fprintf(stderr, "%*c+ _gather_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(pattern | keyword_pattern) _loop0_165")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_159[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "arg_pattern _loop0_160")); + D(fprintf(stderr, "%*c%s _gather_164[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(pattern | keyword_pattern) _loop0_165")); } _res = NULL; done: @@ -26543,9 +26825,9 @@ _gather_159_rule(Parser *p) return _res; } -// _loop0_162: ',' (arg_pattern | keyword_pattern) +// _loop0_167: ',' (pattern | keyword_pattern) static asdl_seq * -_loop0_162_rule(Parser *p) +_loop0_167_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26564,18 +26846,18 @@ _loop0_162_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' (arg_pattern | keyword_pattern) + { // ',' (pattern | keyword_pattern) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (arg_pattern | keyword_pattern)")); + D(fprintf(stderr, "%*c> _loop0_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (pattern | keyword_pattern)")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_174_rule(p)) // arg_pattern | keyword_pattern + (elem = _tmp_182_rule(p)) // pattern | keyword_pattern ) { _res = elem; @@ -26600,8 +26882,8 @@ _loop0_162_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_162[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (arg_pattern | keyword_pattern)")); + D(fprintf(stderr, "%*c%s _loop0_167[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (pattern | keyword_pattern)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -26613,14 +26895,14 @@ _loop0_162_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_162_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_167_type, _seq); D(p->level--); return _seq; } -// _gather_161: (arg_pattern | keyword_pattern) _loop0_162 +// _gather_166: (pattern | keyword_pattern) _loop0_167 static asdl_seq * -_gather_161_rule(Parser *p) +_gather_166_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26629,27 +26911,27 @@ _gather_161_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (arg_pattern | keyword_pattern) _loop0_162 + { // (pattern | keyword_pattern) _loop0_167 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(arg_pattern | keyword_pattern) _loop0_162")); + D(fprintf(stderr, "%*c> _gather_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(pattern | keyword_pattern) _loop0_167")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_174_rule(p)) // arg_pattern | keyword_pattern + (elem = _tmp_182_rule(p)) // pattern | keyword_pattern && - (seq = _loop0_162_rule(p)) // _loop0_162 + (seq = _loop0_167_rule(p)) // _loop0_167 ) { - D(fprintf(stderr, "%*c+ _gather_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(arg_pattern | keyword_pattern) _loop0_162")); + D(fprintf(stderr, "%*c+ _gather_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(pattern | keyword_pattern) _loop0_167")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_161[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(arg_pattern | keyword_pattern) _loop0_162")); + D(fprintf(stderr, "%*c%s _gather_166[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(pattern | keyword_pattern) _loop0_167")); } _res = NULL; done: @@ -26657,9 +26939,123 @@ _gather_161_rule(Parser *p) return _res; } -// _tmp_163: '@' named_expression NEWLINE +// _loop0_169: ',' (pattern | keyword_pattern | error_star) +static asdl_seq * +_loop0_169_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' (pattern | keyword_pattern | error_star) + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (pattern | keyword_pattern | error_star)")); + Token * _literal; + void *elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = _tmp_183_rule(p)) // pattern | keyword_pattern | error_star + ) + { + _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_169[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (pattern | keyword_pattern | error_star)")); + } + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_169_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_168: (pattern | keyword_pattern | error_star) _loop0_169 +static asdl_seq * +_gather_168_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // (pattern | keyword_pattern | error_star) _loop0_169 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _gather_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(pattern | keyword_pattern | error_star) _loop0_169")); + void *elem; + asdl_seq * seq; + if ( + (elem = _tmp_183_rule(p)) // pattern | keyword_pattern | error_star + && + (seq = _loop0_169_rule(p)) // _loop0_169 + ) + { + D(fprintf(stderr, "%*c+ _gather_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(pattern | keyword_pattern | error_star) _loop0_169")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_168[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(pattern | keyword_pattern | error_star) _loop0_169")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_170: '@' named_expression NEWLINE static void * -_tmp_163_rule(Parser *p) +_tmp_170_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26673,7 +27069,7 @@ _tmp_163_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c> _tmp_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); Token * _literal; expr_ty f; Token * newline_var; @@ -26685,7 +27081,7 @@ _tmp_163_rule(Parser *p) (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); _res = f; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26695,7 +27091,7 @@ _tmp_163_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_163[%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, "'@' named_expression NEWLINE")); } _res = NULL; @@ -26704,9 +27100,9 @@ _tmp_163_rule(Parser *p) return _res; } -// _tmp_164: ',' star_expression +// _tmp_171: ',' star_expression static void * -_tmp_164_rule(Parser *p) +_tmp_171_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26720,7 +27116,7 @@ _tmp_164_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _tmp_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty c; if ( @@ -26729,7 +27125,7 @@ _tmp_164_rule(Parser *p) (c = star_expression_rule(p)) // star_expression ) { - D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26739,7 +27135,7 @@ _tmp_164_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_164[%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, "',' star_expression")); } _res = NULL; @@ -26748,9 +27144,9 @@ _tmp_164_rule(Parser *p) return _res; } -// _tmp_165: ',' expression +// _tmp_172: ',' expression static void * -_tmp_165_rule(Parser *p) +_tmp_172_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26764,7 +27160,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, "',' expression")); + D(fprintf(stderr, "%*c> _tmp_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty c; if ( @@ -26773,7 +27169,7 @@ _tmp_165_rule(Parser *p) (c = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26783,7 +27179,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_172[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } _res = NULL; @@ -26792,9 +27188,9 @@ _tmp_165_rule(Parser *p) return _res; } -// _tmp_166: 'or' conjunction +// _tmp_173: 'or' conjunction static void * -_tmp_166_rule(Parser *p) +_tmp_173_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26808,7 +27204,7 @@ _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, "'or' conjunction")); + D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); Token * _keyword; expr_ty c; if ( @@ -26817,7 +27213,7 @@ _tmp_166_rule(Parser *p) (c = conjunction_rule(p)) // conjunction ) { - D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26827,7 +27223,7 @@ _tmp_166_rule(Parser *p) 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_173[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); } _res = NULL; @@ -26836,9 +27232,9 @@ _tmp_166_rule(Parser *p) return _res; } -// _tmp_167: 'and' inversion +// _tmp_174: 'and' inversion static void * -_tmp_167_rule(Parser *p) +_tmp_174_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26852,7 +27248,7 @@ _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, "'and' inversion")); + D(fprintf(stderr, "%*c> _tmp_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); Token * _keyword; expr_ty c; if ( @@ -26861,7 +27257,7 @@ _tmp_167_rule(Parser *p) (c = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26871,7 +27267,7 @@ _tmp_167_rule(Parser *p) 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_174[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); } _res = NULL; @@ -26880,9 +27276,9 @@ _tmp_167_rule(Parser *p) return _res; } -// _tmp_168: 'if' disjunction +// _tmp_175: 'if' disjunction static void * -_tmp_168_rule(Parser *p) +_tmp_175_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26896,7 +27292,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, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -26905,7 +27301,7 @@ _tmp_168_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26915,7 +27311,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_175[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -26924,9 +27320,9 @@ _tmp_168_rule(Parser *p) return _res; } -// _tmp_169: 'if' disjunction +// _tmp_176: 'if' disjunction static void * -_tmp_169_rule(Parser *p) +_tmp_176_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26940,7 +27336,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, "'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 ( @@ -26949,7 +27345,7 @@ _tmp_169_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_169[%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; @@ -26959,7 +27355,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_176[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -26968,9 +27364,9 @@ _tmp_169_rule(Parser *p) return _res; } -// _tmp_170: ',' star_target +// _tmp_177: ',' star_target static void * -_tmp_170_rule(Parser *p) +_tmp_177_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26984,7 +27380,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, "',' star_target")); + D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty c; if ( @@ -26993,7 +27389,7 @@ _tmp_170_rule(Parser *p) (c = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' 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; @@ -27003,7 +27399,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_177[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } _res = NULL; @@ -27012,9 +27408,9 @@ _tmp_170_rule(Parser *p) return _res; } -// _loop1_171: param_with_default +// _loop1_178: param_with_default static asdl_seq * -_loop1_171_rule(Parser *p) +_loop1_178_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27038,7 +27434,7 @@ _loop1_171_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -27060,7 +27456,7 @@ _loop1_171_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_171[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_178[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -27078,14 +27474,14 @@ _loop1_171_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_171_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_178_type, _seq); D(p->level--); return _seq; } -// _tmp_172: ')' | '**' +// _tmp_179: ')' | '**' static void * -_tmp_172_rule(Parser *p) +_tmp_179_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27099,18 +27495,18 @@ _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, "')'")); + D(fprintf(stderr, "%*c> _tmp_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; 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_179[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // '**' @@ -27118,18 +27514,18 @@ _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, "'**'")); + D(fprintf(stderr, "%*c> _tmp_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; 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_179[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -27138,9 +27534,9 @@ _tmp_172_rule(Parser *p) return _res; } -// _tmp_173: ':' | '**' +// _tmp_180: ':' | '**' static void * -_tmp_173_rule(Parser *p) +_tmp_180_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27154,18 +27550,18 @@ _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, "':'")); + D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; 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_180[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // '**' @@ -27173,18 +27569,18 @@ _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, "'**'")); + D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; 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_180[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -27193,9 +27589,9 @@ _tmp_173_rule(Parser *p) return _res; } -// _tmp_174: arg_pattern | keyword_pattern +// _tmp_181: pattern | keyword_pattern static void * -_tmp_174_rule(Parser *p) +_tmp_181_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27204,42 +27600,42 @@ _tmp_174_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // arg_pattern + { // pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "arg_pattern")); - expr_ty arg_pattern_var; + D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); + expr_ty pattern_var; if ( - (arg_pattern_var = arg_pattern_rule(p)) // arg_pattern + (pattern_var = pattern_rule(p)) // pattern ) { - D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "arg_pattern")); - _res = arg_pattern_var; + D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); + _res = pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_174[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "arg_pattern")); + D(fprintf(stderr, "%*c%s _tmp_181[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); } { // keyword_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); + D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); void *keyword_pattern_var; if ( (keyword_pattern_var = keyword_pattern_rule(p)) // keyword_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); + D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); _res = keyword_pattern_var; 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_181[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern")); } _res = NULL; @@ -27248,6 +27644,135 @@ _tmp_174_rule(Parser *p) return _res; } +// _tmp_182: pattern | keyword_pattern +static void * +_tmp_182_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); + expr_ty pattern_var; + if ( + (pattern_var = pattern_rule(p)) // pattern + ) + { + D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); + _res = pattern_var; + 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, "pattern")); + } + { // keyword_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); + void *keyword_pattern_var; + if ( + (keyword_pattern_var = keyword_pattern_rule(p)) // keyword_pattern + ) + { + D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); + _res = keyword_pattern_var; + 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, "keyword_pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_183: pattern | keyword_pattern | error_star +static void * +_tmp_183_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); + expr_ty pattern_var; + if ( + (pattern_var = pattern_rule(p)) // pattern + ) + { + D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); + _res = pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); + } + { // keyword_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); + void *keyword_pattern_var; + if ( + (keyword_pattern_var = keyword_pattern_rule(p)) // keyword_pattern + ) + { + D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); + _res = keyword_pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern")); + } + { // error_star + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_star")); + expr_ty error_star_var; + if ( + (error_star_var = error_star_rule(p)) // error_star + ) + { + D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_star")); + _res = error_star_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_star")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + void * _PyPegen_parse(Parser *p) { From 89974f09d937a7d305a807bff25e545877757418 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 1 Jun 2020 15:55:33 -0700 Subject: [PATCH 050/189] Convert AST tests to native syntax --- Grammar/python.gram | 2 +- Lib/ast.py | 12 +- Lib/test/test_patma.py | 895 ++++++++++++++++++++++++++++++++++---- Parser/pegen/parse.c | 956 +++++++++++++++++++---------------------- Python/compile.c | 2 +- 5 files changed, 1253 insertions(+), 614 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 099fe6a324d635..be11bf2900cffc 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -286,7 +286,7 @@ value_pattern: _Py_Starred(value, Store, EXTRA) } | pattern key_value_pattern: - | key=(literal_pattern | constant_pattern) ':' value=closed_pattern { + | key=(literal_pattern | constant_pattern) ':' value=or_pattern { _PyPegen_key_value_pair(p, key, value) } | '**' value=name_pattern { _PyPegen_key_value_pair(p, NULL, value) } diff --git a/Lib/ast.py b/Lib/ast.py index 658323bf194483..0a63a08a18bf5c 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -1330,16 +1330,14 @@ def visit_Compare(self, node): self.write(" " + self.cmpops[o.__class__.__name__] + " ") self.traverse(e) - boolops = {"And": "and", "Or": "or"} - boolop_precedence = {"and": _Precedence.AND, "or": _Precedence.OR} + boolops = {("And", False): "and", ("Or", False): "or", ("Or", True): "|"} + boolop_precedence = { + "and": _Precedence.AND, "or": _Precedence.OR, "|": _Precedence.OR, + } def visit_BoolOp(self, node): - if self.in_pattern(): - self.interleave(lambda: self.write(" | "), self.traverse, node.values) - return - - operator = self.boolops[node.op.__class__.__name__] + operator = self.boolops[node.op.__class__.__name__, self.in_pattern()] operator_precedence = self.boolop_precedence[operator] def increasing_level_traverse(node): diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 806a19abb50445..ec651f755ec57a 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -56,109 +56,109 @@ def execute_match( exec(cls.compile_match(pre, target, match_cases, post), None, namespace) return namespace - def test_steroid_switch_00(self) -> None: + def test_patma_ast_00(self) -> None: match_cases = [MatchCase("0", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) - def test_steroid_switch_01(self) -> None: + def test_patma_ast_01(self) -> None: match_cases = [MatchCase("False", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) - def test_steroid_switch_02(self) -> None: + def test_patma_ast_02(self) -> None: match_cases = [MatchCase("1", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertNotIn("y", namespace) - def test_steroid_switch_03(self) -> None: + def test_patma_ast_03(self) -> None: match_cases = [MatchCase("None", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertNotIn("y", namespace) - def test_steroid_switch_04(self) -> None: + def test_patma_ast_04(self) -> None: match_cases = [MatchCase("0", "y = 0"), MatchCase("0", "y = 1")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) - def test_steroid_switch_05(self) -> None: + def test_patma_ast_05(self) -> None: match_cases = [MatchCase("1", "y = 0"), MatchCase("1", "y = 1")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertNotIn("y", namespace) - def test_steroid_switch_06(self) -> None: + def test_patma_ast_06(self) -> None: match_cases = [MatchCase("'x'", "y = 0"), MatchCase("'y'", "y = 1")] namespace = self.execute_match("x = 'x'", "x", match_cases, "") self.assertEqual(namespace.get("x"), "x") self.assertEqual(namespace.get("y"), 0) - def test_steroid_switch_07(self) -> None: + def test_patma_ast_07(self) -> None: match_cases = [MatchCase("'y'", "y = 0"), MatchCase("'x'", "y = 1")] namespace = self.execute_match("x = 'x'", "x", match_cases, "") self.assertEqual(namespace.get("x"), "x") self.assertEqual(namespace.get("y"), 1) - def test_steroid_switch_08(self) -> None: + def test_patma_ast_08(self) -> None: match_cases = [MatchCase("'x'", "y = 0"), MatchCase("'y'", "y = 1")] namespace = self.execute_match("x = 'x'", "x", match_cases, "") self.assertEqual(namespace.get("x"), "x") self.assertEqual(namespace.get("y"), 0) - def test_steroid_switch_09(self) -> None: + def test_patma_ast_09(self) -> None: match_cases = [MatchCase("b'y'", "y = 0"), MatchCase("b'x'", "y = 1")] namespace = self.execute_match("x = b'x'", "x", match_cases, "") self.assertEqual(namespace.get("x"), b"x") self.assertEqual(namespace.get("y"), 1) - def test_steroid_switch_guard_00(self) -> None: + def test_patma_ast_10(self) -> None: match_cases = [MatchCase("0", "y = 0", "False"), MatchCase("0", "y = 1")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 1) - def test_steroid_switch_guard_01(self) -> None: + def test_patma_ast_11(self) -> None: match_cases = [MatchCase("0", "y = 0", "0"), MatchCase("0", "y = 1", "0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertNotIn("y", namespace) - def test_steroid_switch_guard_02(self) -> None: + def test_patma_ast_12(self) -> None: match_cases = [MatchCase("0", "y = 0", "True"), MatchCase("0", "y = 1", "True")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) - def test_steroid_switch_guard_03(self) -> None: + def test_patma_ast_13(self) -> None: match_cases = [MatchCase("0", "y = 0", "True"), MatchCase("0", "y = 1", "True")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) - def test_steroid_switch_guard_04(self) -> None: + def test_patma_ast_14(self) -> None: match_cases = [MatchCase("0", "y = 0", "True"), MatchCase("0", "y = 1", "True")] namespace = self.execute_match("x = 0", "x", match_cases, "y = 2") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 2) - def test_steroid_switch_guard_05(self) -> None: + def test_patma_ast_15(self) -> None: match_cases = [MatchCase("0", "y = 0", "0"), MatchCase("0", "y = 1", "1")] namespace = self.execute_match("x = 0", "x", match_cases, "y = 2") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 2) - def test_steroid_switch_guard_06(self) -> None: + def test_patma_ast_16(self) -> None: match_cases = [MatchCase("0", "y = 0", "not (x := 1)"), MatchCase("1", "y = 1")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 1) self.assertNotIn("y", namespace) - def test_walrus_00(self) -> None: + def test_patma_ast_17(self) -> None: match_cases = [ MatchCase("0", "y = 0", "not (x := 1)"), MatchCase("(z := 0)", "y = 1"), @@ -168,7 +168,7 @@ def test_walrus_00(self) -> None: self.assertEqual(namespace.get("y"), 1) self.assertEqual(namespace.get("z"), 0) - def test_walrus_01(self) -> None: + def test_patma_ast_18(self) -> None: match_cases = [ MatchCase("(z := 1)", "y = 0", "not (x := 1)"), MatchCase("0", "y = 1"), @@ -178,21 +178,21 @@ def test_walrus_01(self) -> None: self.assertEqual(namespace.get("y"), 1) self.assertNotIn("z", namespace) - def test_walrus_02(self) -> None: + def test_patma_ast_19(self) -> None: match_cases = [MatchCase("(z := 0)", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 0) - def test_walrus_03(self) -> None: + def test_patma_ast_20(self) -> None: match_cases = [MatchCase("(z := 1)", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertNotIn("y", namespace) self.assertNotIn("z", namespace) - def test_walrus_04(self) -> None: + def test_patma_ast_21(self) -> None: match_cases = [MatchCase("(z := 0)", "y = 0", "(w := 0)")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("w"), 0) @@ -200,7 +200,7 @@ def test_walrus_04(self) -> None: self.assertNotIn("y", namespace) self.assertEqual(namespace.get("z"), 0) - def test_walrus_05(self) -> None: + def test_patma_ast_22(self) -> None: match_cases = [MatchCase("(z := (w := 0))", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("w"), 0) @@ -208,31 +208,31 @@ def test_walrus_05(self) -> None: self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 0) - def test_pipe_00(self) -> None: + def test_patma_ast_23(self) -> None: match_cases = [MatchCase("0 or 1 or 2", "y = 0")] namespace = self.execute_match("x = 0", "x", match_cases, "") self.assertEqual(namespace.get("x"), 0) self.assertEqual(namespace.get("y"), 0) - def test_pipe_01(self) -> None: + def test_patma_ast_24(self) -> None: match_cases = [MatchCase("0 or 1 or 2", "y = 0")] namespace = self.execute_match("x = 1", "x", match_cases, "") self.assertEqual(namespace.get("x"), 1) self.assertEqual(namespace.get("y"), 0) - def test_pipe_02(self) -> None: + def test_patma_ast_25(self) -> None: match_cases = [MatchCase("0 or 1 or 2", "y = 0")] namespace = self.execute_match("x = 2", "x", match_cases, "") self.assertEqual(namespace.get("x"), 2) self.assertEqual(namespace.get("y"), 0) - def test_pipe_03(self) -> None: + def test_patma_ast_26(self) -> None: match_cases = [MatchCase("0 or 1 or 2", "y = 0")] namespace = self.execute_match("x = 3", "x", match_cases, "") self.assertEqual(namespace.get("x"), 3) self.assertNotIn("y", namespace) - def test_pipe_04(self) -> None: + def test_patma_ast_27(self) -> None: match_cases = [ MatchCase("(z := 0) or (z := 1) or (z := 2)", "y = 0", "z == x % 2") ] @@ -241,7 +241,7 @@ def test_pipe_04(self) -> None: self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 0) - def test_pipe_05(self) -> None: + def test_patma_ast_28(self) -> None: match_cases = [ MatchCase("(z := 0) or (z := 1) or (z := 2)", "y = 0", "z == x % 2") ] @@ -250,7 +250,7 @@ def test_pipe_05(self) -> None: self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 1) - def test_pipe_06(self) -> None: + def test_patma_ast_29(self) -> None: match_cases = [ MatchCase("(z := 0) or (z := 1) or (z := 2)", "y = 0", "z == x % 2") ] @@ -259,7 +259,7 @@ def test_pipe_06(self) -> None: self.assertNotIn("y", namespace) self.assertEqual(namespace.get("z"), 2) - def test_pipe_07(self) -> None: + def test_patma_ast_30(self) -> None: match_cases = [ MatchCase("(z := 0) or (z := 1) or (z := 2)", "y = 0", "z == x % 2") ] @@ -268,49 +268,49 @@ def test_pipe_07(self) -> None: self.assertNotIn("y", namespace) self.assertNotIn("z", namespace) - def test_sequence_00(self) -> None: + def test_patma_ast_31(self) -> None: match_cases = [MatchCase("[]", "y = 0")] namespace = self.execute_match("x = ()", "x", match_cases, "") self.assertEqual(namespace.get("x"), ()) self.assertEqual(namespace.get("y"), 0) - def test_sequence_01(self) -> None: + def test_patma_ast_32(self) -> None: match_cases = [MatchCase("[]", "y = 0")] namespace = self.execute_match("x = ()", "x", match_cases, "") self.assertEqual(namespace.get("x"), ()) self.assertEqual(namespace.get("y"), 0) - def test_sequence_02(self) -> None: + def test_patma_ast_33(self) -> None: match_cases = [MatchCase("[0]", "y = 0")] namespace = self.execute_match("x = (0,)", "x", match_cases, "") self.assertEqual(namespace.get("x"), (0,)) self.assertEqual(namespace.get("y"), 0) - def test_sequence_03(self) -> None: + def test_patma_ast_34(self) -> None: match_cases = [MatchCase("[[]]", "y = 0")] namespace = self.execute_match("x = ((),)", "x", match_cases, "") self.assertEqual(namespace.get("x"), ((),)) self.assertEqual(namespace.get("y"), 0) - def test_sequence_04(self) -> None: + def test_patma_ast_35(self) -> None: match_cases = [MatchCase("[0, 1] or [1, 0]", "y = 0")] namespace = self.execute_match("x = [0, 1]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [0, 1]) self.assertEqual(namespace.get("y"), 0) - def test_sequence_05(self) -> None: + def test_patma_ast_36(self) -> None: match_cases = [MatchCase("[0, 1] or [1, 0]", "y = 0")] namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [1, 0]) self.assertEqual(namespace.get("y"), 0) - def test_sequence_06(self) -> None: + def test_patma_ast_37(self) -> None: match_cases = [MatchCase("[0, 1] or [1, 0]", "y = 0")] namespace = self.execute_match("x = [0, 0]", "x", match_cases, "") self.assertEqual(namespace.get("x"), [0, 0]) self.assertNotIn("y", namespace) - def test_sequence_07(self) -> None: + def test_patma_ast_38(self) -> None: match_cases = [ MatchCase("[w := 0,]", "y = 0"), MatchCase("[] or [1, z := (0 or 1)] or []", "y = 1"), @@ -321,7 +321,7 @@ def test_sequence_07(self) -> None: self.assertEqual(namespace.get("y"), 1) self.assertEqual(namespace.get("z"), 0) - def test_sequence_08(self) -> None: + def test_patma_ast_39(self) -> None: match_cases = [ MatchCase("[0,]", "y = 0"), MatchCase("[1, 0]", "y = 1", "(x := x[:0])"), @@ -331,43 +331,43 @@ def test_sequence_08(self) -> None: self.assertEqual(namespace.get("x"), []) self.assertEqual(namespace.get("y"), 2) - def test_sequence_09(self) -> None: + def test_patma_ast_40(self) -> None: match_cases = [MatchCase("[0]", "y = 0")] namespace = self.execute_match("x = {0}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0}) self.assertNotIn("y", namespace) - def test_sequence_10(self) -> None: + def test_patma_ast_41(self) -> None: match_cases = [MatchCase("[]", "y = 0")] namespace = self.execute_match("x = set()", "x", match_cases, "") self.assertEqual(namespace.get("x"), set()) self.assertNotIn("y", namespace) - def test_sequence_11(self) -> None: + def test_patma_ast_42(self) -> None: match_cases = [MatchCase("[]", "y = 0")] namespace = self.execute_match("x = iter([1,2,3])", "x", match_cases, "") self.assertEqual(list(namespace.get("x")), [1, 2, 3]) self.assertNotIn("y", namespace) - def test_sequence_12(self) -> None: + def test_patma_ast_43(self) -> None: match_cases = [MatchCase("[]", "y = 0")] namespace = self.execute_match("x = {}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {}) self.assertNotIn("y", namespace) - def test_sequence_13(self) -> None: + def test_patma_ast_44(self) -> None: match_cases = [MatchCase("[0, 1]", "y = 0")] namespace = self.execute_match("x = {0: False, 1: True}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0: False, 1: True}) self.assertNotIn("y", namespace) - def test_string_00(self) -> None: + def test_patma_ast_45(self) -> None: match_cases = [MatchCase("['x']", "y = 0"), MatchCase("'x'", "y = 1")] namespace = self.execute_match("x = 'x'", "x", match_cases, "") self.assertEqual(namespace.get("x"), "x") self.assertEqual(namespace.get("y"), 1) - def test_string_01(self) -> None: + def test_patma_ast_46(self) -> None: match_cases = [ MatchCase("[b'x']", "y = 0"), MatchCase("['x']", "y = 1"), @@ -378,13 +378,13 @@ def test_string_01(self) -> None: self.assertEqual(namespace.get("x"), b"x") self.assertEqual(namespace.get("y"), 4) - def test_string_02(self) -> None: + def test_patma_ast_47(self) -> None: match_cases = [MatchCase("[120]", "y = 0"), MatchCase("120", "y = 1")] namespace = self.execute_match("x = bytearray(b'x')", "x", match_cases, "") self.assertEqual(namespace.get("x"), b"x") self.assertNotIn("y", namespace) - def test_string_03(self) -> None: + def test_patma_ast_48(self) -> None: match_cases = [ MatchCase("[]", "y = 0"), MatchCase("['']", "y = 1"), @@ -394,7 +394,7 @@ def test_string_03(self) -> None: self.assertEqual(namespace.get("x"), "") self.assertEqual(namespace.get("y"), 2) - def test_string_04(self) -> None: + def test_patma_ast_49(self) -> None: match_cases = [ MatchCase("['x', 'x', 'x']", "y = 0"), MatchCase("['xxx']", "y = 1"), @@ -404,7 +404,7 @@ def test_string_04(self) -> None: self.assertEqual(namespace.get("x"), "xxx") self.assertEqual(namespace.get("y"), 2) - def test_string_05(self) -> None: + def test_patma_ast_50(self) -> None: match_cases = [ MatchCase("[120, 120, 120]", "y = 0"), MatchCase("[b'xxx']", "y = 1"), @@ -414,53 +414,53 @@ def test_string_05(self) -> None: self.assertEqual(namespace.get("x"), b"xxx") self.assertEqual(namespace.get("y"), 2) - def test_mapping_00(self) -> None: + def test_patma_ast_51(self) -> None: match_cases = [MatchCase("{}", "y = 0")] namespace = self.execute_match("x = {}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {}) self.assertEqual(namespace.get("y"), 0) - def test_mapping_01(self) -> None: + def test_patma_ast_52(self) -> None: match_cases = [MatchCase("{}", "y = 0")] namespace = self.execute_match("x = {0: 0}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0: 0}) self.assertEqual(namespace.get("y"), 0) - def test_mapping_02(self) -> None: + def test_patma_ast_53(self) -> None: match_cases = [MatchCase("{0: 0}", "y = 0")] namespace = self.execute_match("x = {}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {}) self.assertNotIn("y", namespace) - def test_mapping_03(self) -> None: + def test_patma_ast_54(self) -> None: match_cases = [MatchCase("{0: (z := (0 or 1 or 2))}", "y = 0")] namespace = self.execute_match("x = {0: 0}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0: 0}) self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 0) - def test_mapping_04(self) -> None: + def test_patma_ast_55(self) -> None: match_cases = [MatchCase("{0: (z := (0 or 1 or 2))}", "y = 0")] namespace = self.execute_match("x = {0: 1}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0: 1}) self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 1) - def test_mapping_05(self) -> None: + def test_patma_ast_56(self) -> None: match_cases = [MatchCase("{0: (z := (0 or 1 or 2))}", "y = 0")] namespace = self.execute_match("x = {0: 2}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0: 2}) self.assertEqual(namespace.get("y"), 0) self.assertEqual(namespace.get("z"), 2) - def test_mapping_06(self) -> None: + def test_patma_ast_57(self) -> None: match_cases = [MatchCase("{0: (z := (0 or 1 or 2))}", "y = 0")] namespace = self.execute_match("x = {0: 3}", "x", match_cases, "") self.assertEqual(namespace.get("x"), {0: 3}) self.assertNotIn("y", namespace) self.assertNotIn("z", namespace) - def test_mapping_07(self) -> None: + def test_patma_ast_58(self) -> None: match_cases = [ MatchCase("{0: [1, 2, {}]}", "y = 0"), MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), @@ -470,7 +470,7 @@ def test_mapping_07(self) -> None: self.assertEqual(namespace.get("x"), {}) self.assertNotIn("y", namespace) - def test_mapping_08(self) -> None: + def test_patma_ast_59(self) -> None: match_cases = [ MatchCase("{0: [1, 2, {}]}", "y = 0"), MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), @@ -482,7 +482,7 @@ def test_mapping_08(self) -> None: self.assertEqual(namespace.get("x"), {False: (True, 2.0, {})}) self.assertEqual(namespace.get("y"), 0) - def test_mapping_09(self) -> None: + def test_patma_ast_60(self) -> None: match_cases = [ MatchCase("{0: [1, 2, {}]}", "y = 0"), MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), @@ -494,7 +494,7 @@ def test_mapping_09(self) -> None: self.assertEqual(namespace.get("x"), {False: (True, 2.0, {}), 1: [[]], 2: 0}) self.assertEqual(namespace.get("y"), 0) - def test_mapping_10(self) -> None: + def test_patma_ast_61(self) -> None: match_cases = [ MatchCase("{0: [1, 2]}", "y = 0"), MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), @@ -506,7 +506,7 @@ def test_mapping_10(self) -> None: self.assertEqual(namespace.get("x"), {False: (True, 2.0, {}), 1: [[]], 2: 0}) self.assertEqual(namespace.get("y"), 1) - def test_mapping_11(self) -> None: + def test_patma_ast_62(self) -> None: match_cases = [ MatchCase("{0: [1, 2, {}]}", "y = 0"), MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), @@ -516,7 +516,7 @@ def test_mapping_11(self) -> None: self.assertEqual(namespace.get("x"), []) self.assertEqual(namespace.get("y"), 2) - def test_mapping_12(self) -> None: + def test_patma_ast_63(self) -> None: match_cases = [ MatchCase("{0: [1, 2, {}]}", "y = 0"), MatchCase( @@ -529,7 +529,7 @@ def test_mapping_12(self) -> None: self.assertEqual(namespace.get("x"), {0: 0}) self.assertEqual(namespace.get("y"), 1) - def test_mapping_13(self) -> None: + def test_patma_ast_64(self) -> None: match_cases = [ MatchCase("{0: [1, 2, {}]}", "y = 0"), MatchCase( @@ -545,13 +545,13 @@ def test_mapping_13(self) -> None: class TestMatch(unittest.TestCase): - def test_grammar_00(self) -> None: + def test_patma_000(self) -> None: match 0: case 0: x = True self.assertEqual(x, True) - def test_grammar_01(self) -> None: + def test_patma_001(self) -> None: match 0: case 0 if False: x = False @@ -559,7 +559,7 @@ def test_grammar_01(self) -> None: x = True self.assertEqual(x, True) - def test_grammar_02(self) -> None: + def test_patma_002(self) -> None: match 0: case 0: x = True @@ -567,53 +567,53 @@ def test_grammar_02(self) -> None: x = False self.assertEqual(x, True) - def test_grammar_03(self) -> None: + def test_patma_003(self) -> None: x = False match 0: case 0 | 1 | 2 | 3: x = True self.assertEqual(x, True) - def test_grammar_04(self) -> None: + def test_patma_004(self) -> None: x = False match 1: case 0 | 1 | 2 | 3: x = True self.assertEqual(x, True) - def test_grammar_05(self) -> None: + def test_patma_005(self) -> None: x = False match 2: case 0 | 1 | 2 | 3: x = True self.assertEqual(x, True) - def test_grammar_06(self) -> None: + def test_patma_006(self) -> None: x = False match 3: case 0 | 1 | 2 | 3: x = True self.assertEqual(x, True) - def test_grammar_07(self) -> None: + def test_patma_007(self) -> None: x = False match 4: case 0 | 1 | 2 | 3: x = True self.assertEqual(x, False) - def test_grammar_08(self) -> None: + def test_patma_008(self) -> None: x = 0 y = 1 + z = None match x: case z := .y: pass self.assertEqual(x, 0) self.assertEqual(y, 1) - with self.assertRaises(NameError): - z + self.assertEqual(z, None) - def test_grammar_09(self) -> None: + def test_patma_009(self) -> None: class A: B = 0 match 0: @@ -628,89 +628,806 @@ class A: self.assertEqual(y, 0) self.assertEqual(z, 2) - def test_grammar_10(self) -> None: + def test_patma_010(self) -> None: match (): case []: x = 0 self.assertEqual(x, 0) - def test_grammar_11(self) -> None: + def test_patma_011(self) -> None: match (0, 1, 2): case [*x]: y = 0 self.assertEqual(x, [0, 1, 2]) self.assertEqual(y, 0) - def test_grammar_12(self) -> None: + def test_patma_012(self) -> None: match (0, 1, 2): case [0, *x]: y = 0 self.assertEqual(x, [1, 2]) self.assertEqual(y, 0) - def test_grammar_13(self) -> None: + def test_patma_013(self) -> None: match (0, 1, 2): case [0, 1, *x,]: y = 0 self.assertEqual(x, [2]) self.assertEqual(y, 0) - def test_grammar_14(self) -> None: + def test_patma_014(self) -> None: match (0, 1, 2): case [0, 1, 2, *x]: y = 0 self.assertEqual(x, []) self.assertEqual(y, 0) - def test_grammar_15(self) -> None: + def test_patma_015(self) -> None: match (0, 1, 2): case [*x, 2,]: y = 0 self.assertEqual(x, [0, 1]) self.assertEqual(y, 0) - def test_grammar_16(self) -> None: + def test_patma_016(self) -> None: match (0, 1, 2): case [*x, 1, 2]: y = 0 self.assertEqual(x, [0]) self.assertEqual(y, 0) - def test_grammar_17(self) -> None: + def test_patma_017(self) -> None: match (0, 1, 2): case [*x, 0, 1, 2,]: y = 0 self.assertEqual(x, []) self.assertEqual(y, 0) - def test_grammar_18(self) -> None: + def test_patma_018(self) -> None: match (0, 1, 2): case [0, *x, 2]: y = 0 self.assertEqual(x, [1]) self.assertEqual(y, 0) - def test_grammar_19(self) -> None: + def test_patma_019(self) -> None: match (0, 1, 2): case [0, 1, *x, 2,]: y = 0 self.assertEqual(x, []) self.assertEqual(y, 0) - def test_grammar_20(self) -> None: + def test_patma_020(self) -> None: match (0, 1, 2): case [0, *x, 1, 2]: y = 0 self.assertEqual(x, []) self.assertEqual(y, 0) - def test_grammar_21(self) -> None: + def test_patma_021(self) -> None: match (0, 1, 2): case [*x,]: y = 0 self.assertEqual(x, [0, 1, 2]) self.assertEqual(y, 0) + def test_patma_022(self) -> None: + x = {} + match x: + case {}: + y = 0 + self.assertEqual(x, {}) + self.assertEqual(y, 0) + + def test_patma_023(self) -> None: + x = {0: 0} + match x: + case {}: + y = 0 + self.assertEqual(x, {0: 0}) + self.assertEqual(y, 0) + + def test_patma_024(self) -> None: + x = {} + y = None + match x: + case {0: 0}: + y = 0 + self.assertEqual(x, {}) + self.assertEqual(y, None) + + def test_patma_025(self) -> None: + x = {0: 0} + match x: + case {0: (z := 0 | 1 | 2)}: + y = 0 + self.assertEqual(x, {0: 0}) + self.assertEqual(y, 0) + self.assertEqual(z, 0) + + def test_patma_026(self) -> None: + x = {0: 1} + match x: + case {0: (z := 0 | 1 | 2)}: + y = 0 + self.assertEqual(x, {0: 1}) + self.assertEqual(y, 0) + self.assertEqual(z, 1) + + def test_patma_027(self) -> None: + x = {0: 2} + match x: + case {0: (z := 0 | 1 | 2)}: + y = 0 + self.assertEqual(x, {0: 2}) + self.assertEqual(y, 0) + self.assertEqual(z, 2) + + def test_patma_028(self) -> None: + x = {0: 3} + y = None + z = None + match x: + case {0: (z := 0 | 1 | 2)}: + y = 0 + self.assertEqual(x, {0: 3}) + self.assertEqual(y, None) + self.assertEqual(z, None) + + def test_patma_029(self) -> None: + x = {} + y = None + match x: + case {0: [1, 2, {}]}: + y = 0 + case {0: [1, 2, {}], 1: [[]]}: + y = 1 + case []: + y = 2 + self.assertEqual(x, {}) + self.assertEqual(y, None) + + def test_patma_030(self) -> None: + x = {False: (True, 2.0, {})} + match x: + case {0: [1, 2, {}]}: + y = 0 + case {0: [1, 2, {}], 1: [[]]}: + y = 1 + case []: + y = 2 + self.assertEqual(x, {False: (True, 2.0, {})}) + self.assertEqual(y, 0) + + def test_patma_031(self) -> None: + x = {False: (True, 2.0, {}), 1: [[]], 2: 0} + match x: + case {0: [1, 2, {}]}: + y = 0 + case {0: [1, 2, {}], 1: [[]]}: + y = 1 + case []: + y = 2 + self.assertEqual(x, {False: (True, 2.0, {}), 1: [[]], 2: 0}) + self.assertEqual(y, 0) + + def test_patma_032(self) -> None: + x = {False: (True, 2.0, {}), 1: [[]], 2: 0} + match x: + case {0: [1, 2]}: + y = 0 + case {0: [1, 2, {}], 1: [[]]}: + y = 1 + case []: + y = 2 + self.assertEqual(x, {False: (True, 2.0, {}), 1: [[]], 2: 0}) + self.assertEqual(y, 1) + + def test_patma_033(self) -> None: + x = [] + match x: + case {0: [1, 2, {}]}: + y = 0 + case {0: [1, 2, {}], 1: [[]]}: + y = 1 + case []: + y = 2 + self.assertEqual(x, []) + self.assertEqual(y, 2) + + def test_patma_034(self) -> None: + x = {0: 0} + match x: + case {0: [1, 2, {}]}: + y = 0 + case {0: ([1, 2, {}] | False)} | {1: [[]]} | {0: [1, 2, {}]} | [] | 'X' | {}: + y = 1 + case []: + y = 2 + self.assertEqual(x, {0: 0}) + self.assertEqual(y, 1) + + def test_patma_035(self) -> None: + x = {0: 0} + match x: + case {0: [1, 2, {}]}: + y = 0 + case {0: [1, 2, {}] | True} | {1: [[]]} | {0: [1, 2, {}]} | [] | 'X' | {}: + y = 1 + case []: + y = 2 + self.assertEqual(x, {0: 0}) + self.assertEqual(y, 1) + + def test_patma_036(self) -> None: + x = 0 + match x: + case 0 | 1 | 2: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_037(self) -> None: + x = 1 + match x: + case 0 | 1 | 2: + y = 0 + self.assertEqual(x, 1) + self.assertEqual(y, 0) + + def test_patma_038(self) -> None: + x = 2 + match x: + case 0 | 1 | 2: + y = 0 + self.assertEqual(x, 2) + self.assertEqual(y, 0) + + def test_patma_039(self) -> None: + x = 3 + y = None + match x: + case 0 | 1 | 2: + y = 0 + self.assertEqual(x, 3) + self.assertEqual(y, None) + + def test_patma_040(self) -> None: + x = 0 + match x: + case (z := 0) | (z := 1) | (z := 2) if z == x % 2: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertEqual(z, 0) + + def test_patma_041(self) -> None: + x = 1 + match x: + case (z := 0) | (z := 1) | (z := 2) if z == x % 2: + y = 0 + self.assertEqual(x, 1) + self.assertEqual(y, 0) + self.assertEqual(z, 1) + + def test_patma_042(self) -> None: + x = 2 + y = None + match x: + case (z := 0) | (z := 1) | (z := 2) if z == x % 2: + y = 0 + self.assertEqual(x, 2) + self.assertEqual(y, None) + self.assertEqual(z, 2) + + def test_patma_043(self) -> None: + x = 3 + y = None + z = None + match x: + case (z := 0) | (z := 1) | (z := 2) if z == x % 2: + y = 0 + self.assertEqual(x, 3) + self.assertEqual(y, None) + self.assertEqual(z, None) + + def test_patma_044(self) -> None: + x = () + match x: + case []: + y = 0 + self.assertEqual(x, ()) + self.assertEqual(y, 0) + + def test_patma_045(self) -> None: + x = () + match x: + case []: + y = 0 + self.assertEqual(x, ()) + self.assertEqual(y, 0) + + def test_patma_046(self) -> None: + x = (0,) + match x: + case [0]: + y = 0 + self.assertEqual(x, (0,)) + self.assertEqual(y, 0) + + def test_patma_047(self) -> None: + x = ((),) + match x: + case [[]]: + y = 0 + self.assertEqual(x, ((),)) + self.assertEqual(y, 0) + + def test_patma_048(self) -> None: + x = [0, 1] + match x: + case [0, 1] | [1, 0]: + y = 0 + self.assertEqual(x, [0, 1]) + self.assertEqual(y, 0) + + def test_patma_049(self) -> None: + x = [1, 0] + match x: + case [0, 1] | [1, 0]: + y = 0 + self.assertEqual(x, [1, 0]) + self.assertEqual(y, 0) + + def test_patma_050(self) -> None: + x = [0, 0] + y = None + match x: + case [0, 1] | [1, 0]: + y = 0 + self.assertEqual(x, [0, 0]) + self.assertEqual(y, None) + + def test_patma_051(self) -> None: + w = None + x = [1, 0] + match x: + case [(w := 0)]: + y = 0 + case [] | [1, (z := 0 | 1)] | []: + y = 1 + self.assertEqual(w, None) + self.assertEqual(x, [1, 0]) + self.assertEqual(y, 1) + self.assertEqual(z, 0) + + def test_patma_052(self) -> None: + x = [1, 0] + match x: + case [0]: + y = 0 + case [1, 0] if (x := x[:0]): + y = 1 + case [1, 0]: + y = 2 + self.assertEqual(x, []) + self.assertEqual(y, 2) + + def test_patma_053(self) -> None: + x = {0} + y = None + match x: + case [0]: + y = 0 + self.assertEqual(x, {0}) + self.assertEqual(y, None) + + def test_patma_054(self) -> None: + x = set() + y = None + match x: + case []: + y = 0 + self.assertEqual(x, set()) + self.assertEqual(y, None) + + def test_patma_055(self) -> None: + x = iter([1, 2, 3]) + y = None + match x: + case []: + y = 0 + self.assertEqual([*x], [1, 2, 3]) + self.assertEqual(y, None) + + def test_patma_056(self) -> None: + x = {} + y = None + match x: + case []: + y = 0 + self.assertEqual(x, {}) + self.assertEqual(y, None) + + def test_patma_057(self) -> None: + x = {0: False, 1: True} + y = None + match x: + case [0, 1]: + y = 0 + self.assertEqual(x, {0: False, 1: True}) + self.assertEqual(y, None) + + def test_patma_058(self) -> None: + x = 0 + match x: + case 0: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_059(self) -> None: + x = 0 + match x: + case False: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_060(self) -> None: + x = 0 + y = None + match x: + case 1: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, None) + + def test_patma_061(self) -> None: + x = 0 + y = None + match x: + case None: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, None) + + def test_patma_062(self) -> None: + x = 0 + match x: + case 0: + y = 0 + case 0: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_063(self) -> None: + x = 0 + y = None + match x: + case 1: + y = 0 + case 1: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, None) + + def test_patma_064(self) -> None: + x = 'x' + match x: + case 'x': + y = 0 + case 'y': + y = 1 + self.assertEqual(x, 'x') + self.assertEqual(y, 0) + + def test_patma_065(self) -> None: + x = 'x' + match x: + case 'y': + y = 0 + case 'x': + y = 1 + self.assertEqual(x, 'x') + self.assertEqual(y, 1) + + def test_patma_066(self) -> None: + x = 'x' + match x: + case 'x': + y = 0 + case 'y': + y = 1 + self.assertEqual(x, 'x') + self.assertEqual(y, 0) + + def test_patma_067(self) -> None: + x = b'x' + match x: + case b'y': + y = 0 + case b'x': + y = 1 + self.assertEqual(x, b'x') + self.assertEqual(y, 1) + + def test_patma_068(self) -> None: + x = 0 + match x: + case 0 if False: + y = 0 + case 0: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 1) + + def test_patma_069(self) -> None: + x = 0 + y = None + match x: + case 0 if 0: + y = 0 + case 0 if 0: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, None) + + def test_patma_070(self) -> None: + x = 0 + match x: + case 0 if True: + y = 0 + case 0 if True: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_071(self) -> None: + x = 0 + match x: + case 0 if True: + y = 0 + case 0 if True: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_072(self) -> None: + x = 0 + match x: + case 0 if True: + y = 0 + case 0 if True: + y = 1 + y = 2 + self.assertEqual(x, 0) + self.assertEqual(y, 2) + + def test_patma_073(self) -> None: + x = 0 + match x: + case 0 if 0: + y = 0 + case 0 if 1: + y = 1 + y = 2 + self.assertEqual(x, 0) + self.assertEqual(y, 2) + + def test_patma_074(self) -> None: + x = 0 + y = None + match x: + case 0 if not (x := 1): + y = 0 + case 1: + y = 1 + self.assertEqual(x, 1) + self.assertEqual(y, None) + + def test_patma_075(self) -> None: + x = 'x' + match x: + case ['x']: + y = 0 + case 'x': + y = 1 + self.assertEqual(x, 'x') + self.assertEqual(y, 1) + + def test_patma_076(self) -> None: + x = b'x' + match x: + case [b'x']: + y = 0 + case ['x']: + y = 1 + case [120]: + y = 2 + case b'x': + y = 4 + self.assertEqual(x, b'x') + self.assertEqual(y, 4) + + def test_patma_077(self) -> None: + x = bytearray(b'x') + y = None + match x: + case [120]: + y = 0 + case 120: + y = 1 + self.assertEqual(x, b'x') + self.assertEqual(y, None) + + def test_patma_078(self) -> None: + x = '' + match x: + case []: + y = 0 + case ['']: + y = 1 + case '': + y = 2 + self.assertEqual(x, '') + self.assertEqual(y, 2) + + def test_patma_079(self) -> None: + x = 'xxx' + match x: + case ['x', 'x', 'x']: + y = 0 + case ['xxx']: + y = 1 + case 'xxx': + y = 2 + self.assertEqual(x, 'xxx') + self.assertEqual(y, 2) + + def test_patma_080(self) -> None: + x = b'xxx' + match x: + case [120, 120, 120]: + y = 0 + case [b'xxx']: + y = 1 + case b'xxx': + y = 2 + self.assertEqual(x, b'xxx') + self.assertEqual(y, 2) + + def test_patma_081(self) -> None: + x = 0 + match x: + case 0 if not (x := 1): + y = 0 + case (z := 0): + y = 1 + self.assertEqual(x, 1) + self.assertEqual(y, 1) + self.assertEqual(z, 0) + + def test_patma_082(self) -> None: + x = 0 + z = None + match x: + case (z := 1) if not (x := 1): + y = 0 + case 0: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 1) + self.assertEqual(z, None) + + def test_patma_083(self) -> None: + x = 0 + match x: + case (z := 0): + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertEqual(z, 0) + + def test_patma_084(self) -> None: + x = 0 + y = None + z = None + match x: + case (z := 1): + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, None) + self.assertEqual(z, None) + + def test_patma_085(self) -> None: + x = 0 + y = None + match x: + case (z := 0) if (w := 0): + y = 0 + self.assertEqual(w, 0) + self.assertEqual(x, 0) + self.assertEqual(y, None) + self.assertEqual(z, 0) + + def test_patma_086(self) -> None: + x = 0 + match x: + case (z := (w := 0)): + y = 0 + self.assertEqual(w, 0) + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertEqual(z, 0) + + def test_patma_087(self) -> None: + x = 0 + match x: + case (0 | 1) | 2: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_088(self) -> None: + x = 1 + match x: + case (0 | 1) | 2: + y = 0 + self.assertEqual(x, 1) + self.assertEqual(y, 0) + + def test_patma_089(self) -> None: + x = 2 + match x: + case (0 | 1) | 2: + y = 0 + self.assertEqual(x, 2) + self.assertEqual(y, 0) + + def test_patma_090(self) -> None: + x = 3 + y = None + match x: + case (0 | 1) | 2: + y = 0 + self.assertEqual(x, 3) + self.assertEqual(y, None) + + def test_patma_091(self) -> None: + x = 0 + match x: + case 0 | (1 | 2): + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_092(self) -> None: + x = 1 + match x: + case 0 | (1 | 2): + y = 0 + self.assertEqual(x, 1) + self.assertEqual(y, 0) + + def test_patma_093(self) -> None: + x = 2 + match x: + case 0 | (1 | 2): + y = 0 + self.assertEqual(x, 2) + self.assertEqual(y, 0) + + def test_patma_094(self) -> None: + x = 3 + y = None + match x: + case 0 | (1 | 2): + y = 0 + self.assertEqual(x, 3) + self.assertEqual(y, None) + if __name__ == "__main__": # XXX: For quick test debugging... import dis diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index 697fe1fdfe79a5..6bccd0013c99df 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -130,310 +130,309 @@ static KeywordToken *reserved_keywords[] = { #define values_pattern_type 1052 #define items_pattern_type 1053 #define keyword_pattern_type 1054 -#define error_star_type 1055 -#define value_pattern_type 1056 -#define key_value_pattern_type 1057 -#define return_stmt_type 1058 -#define raise_stmt_type 1059 -#define function_def_type 1060 -#define function_def_raw_type 1061 -#define func_type_comment_type 1062 -#define params_type 1063 -#define parameters_type 1064 -#define slash_no_default_type 1065 -#define slash_with_default_type 1066 -#define star_etc_type 1067 -#define kwds_type 1068 -#define param_no_default_type 1069 -#define param_with_default_type 1070 -#define param_maybe_default_type 1071 -#define param_type 1072 -#define annotation_type 1073 -#define default_type 1074 -#define decorators_type 1075 -#define class_def_type 1076 -#define class_def_raw_type 1077 -#define block_type 1078 -#define expressions_list_type 1079 -#define star_expressions_type 1080 -#define star_expression_type 1081 -#define star_named_expressions_type 1082 -#define star_named_expression_type 1083 -#define named_expression_type 1084 -#define annotated_rhs_type 1085 -#define expressions_type 1086 -#define expression_type 1087 -#define lambdef_type 1088 -#define lambda_parameters_type 1089 -#define lambda_slash_no_default_type 1090 -#define lambda_slash_with_default_type 1091 -#define lambda_star_etc_type 1092 -#define lambda_kwds_type 1093 -#define lambda_param_no_default_type 1094 -#define lambda_param_with_default_type 1095 -#define lambda_param_maybe_default_type 1096 -#define lambda_param_type 1097 -#define disjunction_type 1098 -#define conjunction_type 1099 -#define inversion_type 1100 -#define comparison_type 1101 -#define compare_op_bitwise_or_pair_type 1102 -#define eq_bitwise_or_type 1103 -#define noteq_bitwise_or_type 1104 -#define lte_bitwise_or_type 1105 -#define lt_bitwise_or_type 1106 -#define gte_bitwise_or_type 1107 -#define gt_bitwise_or_type 1108 -#define notin_bitwise_or_type 1109 -#define in_bitwise_or_type 1110 -#define isnot_bitwise_or_type 1111 -#define is_bitwise_or_type 1112 -#define bitwise_or_type 1113 // Left-recursive -#define bitwise_xor_type 1114 // Left-recursive -#define bitwise_and_type 1115 // Left-recursive -#define shift_expr_type 1116 // Left-recursive -#define sum_type 1117 // Left-recursive -#define term_type 1118 // Left-recursive -#define factor_type 1119 -#define power_type 1120 -#define await_primary_type 1121 -#define primary_type 1122 // Left-recursive -#define slices_type 1123 -#define slice_type 1124 -#define atom_type 1125 -#define strings_type 1126 -#define list_type 1127 -#define listcomp_type 1128 -#define tuple_type 1129 -#define group_type 1130 -#define genexp_type 1131 -#define set_type 1132 -#define setcomp_type 1133 -#define dict_type 1134 -#define dictcomp_type 1135 -#define double_starred_kvpairs_type 1136 -#define double_starred_kvpair_type 1137 -#define kvpair_type 1138 -#define for_if_clauses_type 1139 -#define for_if_clause_type 1140 -#define yield_expr_type 1141 -#define arguments_type 1142 -#define args_type 1143 -#define kwargs_type 1144 -#define starred_expression_type 1145 -#define kwarg_or_starred_type 1146 -#define kwarg_or_double_starred_type 1147 -#define star_targets_type 1148 -#define star_targets_seq_type 1149 -#define star_target_type 1150 -#define star_atom_type 1151 -#define single_target_type 1152 -#define single_subscript_attribute_target_type 1153 -#define del_targets_type 1154 -#define del_target_type 1155 -#define del_t_atom_type 1156 -#define del_target_end_type 1157 -#define targets_type 1158 -#define target_type 1159 -#define t_primary_type 1160 // Left-recursive -#define t_lookahead_type 1161 -#define t_atom_type 1162 -#define incorrect_arguments_type 1163 -#define invalid_kwarg_type 1164 -#define invalid_named_expression_type 1165 -#define invalid_assignment_type 1166 -#define invalid_block_type 1167 -#define invalid_comprehension_type 1168 -#define invalid_dict_comprehension_type 1169 -#define invalid_parameters_type 1170 -#define invalid_star_etc_type 1171 -#define invalid_lambda_star_etc_type 1172 -#define invalid_double_type_comments_type 1173 -#define invalid_del_target_type 1174 -#define invalid_import_from_targets_type 1175 -#define _loop0_1_type 1176 -#define _loop0_2_type 1177 -#define _loop0_4_type 1178 -#define _gather_3_type 1179 -#define _loop0_6_type 1180 -#define _gather_5_type 1181 -#define _loop0_8_type 1182 -#define _gather_7_type 1183 -#define _loop0_10_type 1184 -#define _gather_9_type 1185 -#define _loop1_11_type 1186 -#define _loop0_13_type 1187 -#define _gather_12_type 1188 -#define _tmp_14_type 1189 -#define _tmp_15_type 1190 -#define _tmp_16_type 1191 -#define _tmp_17_type 1192 -#define _tmp_18_type 1193 -#define _tmp_19_type 1194 -#define _tmp_20_type 1195 -#define _tmp_21_type 1196 -#define _loop1_22_type 1197 -#define _tmp_23_type 1198 -#define _tmp_24_type 1199 -#define _loop0_26_type 1200 -#define _gather_25_type 1201 -#define _loop0_28_type 1202 -#define _gather_27_type 1203 -#define _tmp_29_type 1204 -#define _loop0_30_type 1205 -#define _loop1_31_type 1206 -#define _loop0_33_type 1207 -#define _gather_32_type 1208 -#define _tmp_34_type 1209 -#define _loop0_36_type 1210 -#define _gather_35_type 1211 -#define _tmp_37_type 1212 -#define _loop0_39_type 1213 -#define _gather_38_type 1214 -#define _loop0_41_type 1215 -#define _gather_40_type 1216 -#define _loop0_43_type 1217 -#define _gather_42_type 1218 -#define _loop0_45_type 1219 -#define _gather_44_type 1220 -#define _tmp_46_type 1221 -#define _loop1_47_type 1222 -#define _tmp_48_type 1223 -#define _loop1_49_type 1224 -#define _loop0_51_type 1225 -#define _gather_50_type 1226 -#define _tmp_52_type 1227 -#define _loop0_54_type 1228 -#define _gather_53_type 1229 -#define _loop0_56_type 1230 -#define _gather_55_type 1231 -#define _loop0_58_type 1232 -#define _gather_57_type 1233 -#define _loop0_60_type 1234 -#define _gather_59_type 1235 -#define _tmp_61_type 1236 -#define _loop0_63_type 1237 -#define _gather_62_type 1238 -#define _tmp_64_type 1239 -#define _tmp_65_type 1240 -#define _tmp_66_type 1241 -#define _loop0_68_type 1242 -#define _gather_67_type 1243 -#define _loop0_70_type 1244 -#define _gather_69_type 1245 -#define _tmp_71_type 1246 -#define _tmp_72_type 1247 -#define _tmp_73_type 1248 -#define _tmp_74_type 1249 -#define _tmp_75_type 1250 -#define _tmp_76_type 1251 -#define _loop0_77_type 1252 -#define _loop0_78_type 1253 -#define _loop0_79_type 1254 -#define _loop1_80_type 1255 -#define _loop0_81_type 1256 -#define _loop1_82_type 1257 -#define _loop1_83_type 1258 -#define _loop1_84_type 1259 -#define _loop0_85_type 1260 -#define _loop1_86_type 1261 -#define _loop0_87_type 1262 -#define _loop1_88_type 1263 -#define _loop0_89_type 1264 -#define _loop1_90_type 1265 -#define _loop1_91_type 1266 -#define _tmp_92_type 1267 -#define _loop0_94_type 1268 -#define _gather_93_type 1269 -#define _loop1_95_type 1270 -#define _loop0_97_type 1271 -#define _gather_96_type 1272 -#define _loop1_98_type 1273 -#define _loop0_99_type 1274 -#define _loop0_100_type 1275 -#define _loop0_101_type 1276 -#define _loop1_102_type 1277 -#define _loop0_103_type 1278 -#define _loop1_104_type 1279 -#define _loop1_105_type 1280 -#define _loop1_106_type 1281 -#define _loop0_107_type 1282 -#define _loop1_108_type 1283 -#define _loop0_109_type 1284 -#define _loop1_110_type 1285 -#define _loop0_111_type 1286 -#define _loop1_112_type 1287 -#define _loop1_113_type 1288 -#define _loop1_114_type 1289 -#define _loop1_115_type 1290 -#define _tmp_116_type 1291 -#define _loop0_118_type 1292 -#define _gather_117_type 1293 -#define _tmp_119_type 1294 -#define _tmp_120_type 1295 -#define _tmp_121_type 1296 -#define _tmp_122_type 1297 -#define _loop1_123_type 1298 -#define _tmp_124_type 1299 -#define _tmp_125_type 1300 -#define _loop0_127_type 1301 -#define _gather_126_type 1302 -#define _loop1_128_type 1303 -#define _loop0_129_type 1304 -#define _loop0_130_type 1305 -#define _tmp_131_type 1306 -#define _tmp_132_type 1307 -#define _loop0_134_type 1308 -#define _gather_133_type 1309 -#define _loop0_136_type 1310 -#define _gather_135_type 1311 -#define _loop0_138_type 1312 -#define _gather_137_type 1313 -#define _loop0_140_type 1314 -#define _gather_139_type 1315 -#define _loop0_141_type 1316 -#define _loop0_143_type 1317 -#define _gather_142_type 1318 -#define _tmp_144_type 1319 -#define _loop0_146_type 1320 -#define _gather_145_type 1321 -#define _loop0_148_type 1322 -#define _gather_147_type 1323 -#define _tmp_149_type 1324 -#define _loop0_150_type 1325 -#define _tmp_151_type 1326 -#define _tmp_152_type 1327 -#define _tmp_153_type 1328 -#define _tmp_154_type 1329 -#define _loop0_155_type 1330 -#define _tmp_156_type 1331 -#define _tmp_157_type 1332 -#define _tmp_158_type 1333 -#define _tmp_159_type 1334 -#define _tmp_160_type 1335 -#define _tmp_161_type 1336 -#define _loop0_163_type 1337 -#define _gather_162_type 1338 -#define _loop0_165_type 1339 -#define _gather_164_type 1340 -#define _loop0_167_type 1341 -#define _gather_166_type 1342 -#define _loop0_169_type 1343 -#define _gather_168_type 1344 -#define _tmp_170_type 1345 -#define _tmp_171_type 1346 -#define _tmp_172_type 1347 -#define _tmp_173_type 1348 -#define _tmp_174_type 1349 -#define _tmp_175_type 1350 -#define _tmp_176_type 1351 -#define _tmp_177_type 1352 -#define _loop1_178_type 1353 -#define _tmp_179_type 1354 -#define _tmp_180_type 1355 -#define _tmp_181_type 1356 -#define _tmp_182_type 1357 -#define _tmp_183_type 1358 +#define argument_pattern_type 1055 +#define error_star_type 1056 +#define value_pattern_type 1057 +#define key_value_pattern_type 1058 +#define return_stmt_type 1059 +#define raise_stmt_type 1060 +#define function_def_type 1061 +#define function_def_raw_type 1062 +#define func_type_comment_type 1063 +#define params_type 1064 +#define parameters_type 1065 +#define slash_no_default_type 1066 +#define slash_with_default_type 1067 +#define star_etc_type 1068 +#define kwds_type 1069 +#define param_no_default_type 1070 +#define param_with_default_type 1071 +#define param_maybe_default_type 1072 +#define param_type 1073 +#define annotation_type 1074 +#define default_type 1075 +#define decorators_type 1076 +#define class_def_type 1077 +#define class_def_raw_type 1078 +#define block_type 1079 +#define expressions_list_type 1080 +#define star_expressions_type 1081 +#define star_expression_type 1082 +#define star_named_expressions_type 1083 +#define star_named_expression_type 1084 +#define named_expression_type 1085 +#define annotated_rhs_type 1086 +#define expressions_type 1087 +#define expression_type 1088 +#define lambdef_type 1089 +#define lambda_parameters_type 1090 +#define lambda_slash_no_default_type 1091 +#define lambda_slash_with_default_type 1092 +#define lambda_star_etc_type 1093 +#define lambda_kwds_type 1094 +#define lambda_param_no_default_type 1095 +#define lambda_param_with_default_type 1096 +#define lambda_param_maybe_default_type 1097 +#define lambda_param_type 1098 +#define disjunction_type 1099 +#define conjunction_type 1100 +#define inversion_type 1101 +#define comparison_type 1102 +#define compare_op_bitwise_or_pair_type 1103 +#define eq_bitwise_or_type 1104 +#define noteq_bitwise_or_type 1105 +#define lte_bitwise_or_type 1106 +#define lt_bitwise_or_type 1107 +#define gte_bitwise_or_type 1108 +#define gt_bitwise_or_type 1109 +#define notin_bitwise_or_type 1110 +#define in_bitwise_or_type 1111 +#define isnot_bitwise_or_type 1112 +#define is_bitwise_or_type 1113 +#define bitwise_or_type 1114 // Left-recursive +#define bitwise_xor_type 1115 // Left-recursive +#define bitwise_and_type 1116 // Left-recursive +#define shift_expr_type 1117 // Left-recursive +#define sum_type 1118 // Left-recursive +#define term_type 1119 // Left-recursive +#define factor_type 1120 +#define power_type 1121 +#define await_primary_type 1122 +#define primary_type 1123 // Left-recursive +#define slices_type 1124 +#define slice_type 1125 +#define atom_type 1126 +#define strings_type 1127 +#define list_type 1128 +#define listcomp_type 1129 +#define tuple_type 1130 +#define group_type 1131 +#define genexp_type 1132 +#define set_type 1133 +#define setcomp_type 1134 +#define dict_type 1135 +#define dictcomp_type 1136 +#define double_starred_kvpairs_type 1137 +#define double_starred_kvpair_type 1138 +#define kvpair_type 1139 +#define for_if_clauses_type 1140 +#define for_if_clause_type 1141 +#define yield_expr_type 1142 +#define arguments_type 1143 +#define args_type 1144 +#define kwargs_type 1145 +#define starred_expression_type 1146 +#define kwarg_or_starred_type 1147 +#define kwarg_or_double_starred_type 1148 +#define star_targets_type 1149 +#define star_targets_seq_type 1150 +#define star_target_type 1151 +#define star_atom_type 1152 +#define single_target_type 1153 +#define single_subscript_attribute_target_type 1154 +#define del_targets_type 1155 +#define del_target_type 1156 +#define del_t_atom_type 1157 +#define del_target_end_type 1158 +#define targets_type 1159 +#define target_type 1160 +#define t_primary_type 1161 // Left-recursive +#define t_lookahead_type 1162 +#define t_atom_type 1163 +#define incorrect_arguments_type 1164 +#define invalid_kwarg_type 1165 +#define invalid_named_expression_type 1166 +#define invalid_assignment_type 1167 +#define invalid_block_type 1168 +#define invalid_comprehension_type 1169 +#define invalid_dict_comprehension_type 1170 +#define invalid_parameters_type 1171 +#define invalid_star_etc_type 1172 +#define invalid_lambda_star_etc_type 1173 +#define invalid_double_type_comments_type 1174 +#define invalid_del_target_type 1175 +#define invalid_import_from_targets_type 1176 +#define _loop0_1_type 1177 +#define _loop0_2_type 1178 +#define _loop0_4_type 1179 +#define _gather_3_type 1180 +#define _loop0_6_type 1181 +#define _gather_5_type 1182 +#define _loop0_8_type 1183 +#define _gather_7_type 1184 +#define _loop0_10_type 1185 +#define _gather_9_type 1186 +#define _loop1_11_type 1187 +#define _loop0_13_type 1188 +#define _gather_12_type 1189 +#define _tmp_14_type 1190 +#define _tmp_15_type 1191 +#define _tmp_16_type 1192 +#define _tmp_17_type 1193 +#define _tmp_18_type 1194 +#define _tmp_19_type 1195 +#define _tmp_20_type 1196 +#define _tmp_21_type 1197 +#define _loop1_22_type 1198 +#define _tmp_23_type 1199 +#define _tmp_24_type 1200 +#define _loop0_26_type 1201 +#define _gather_25_type 1202 +#define _loop0_28_type 1203 +#define _gather_27_type 1204 +#define _tmp_29_type 1205 +#define _loop0_30_type 1206 +#define _loop1_31_type 1207 +#define _loop0_33_type 1208 +#define _gather_32_type 1209 +#define _tmp_34_type 1210 +#define _loop0_36_type 1211 +#define _gather_35_type 1212 +#define _tmp_37_type 1213 +#define _loop0_39_type 1214 +#define _gather_38_type 1215 +#define _loop0_41_type 1216 +#define _gather_40_type 1217 +#define _loop0_43_type 1218 +#define _gather_42_type 1219 +#define _loop0_45_type 1220 +#define _gather_44_type 1221 +#define _tmp_46_type 1222 +#define _loop1_47_type 1223 +#define _tmp_48_type 1224 +#define _loop1_49_type 1225 +#define _loop0_51_type 1226 +#define _gather_50_type 1227 +#define _tmp_52_type 1228 +#define _loop0_54_type 1229 +#define _gather_53_type 1230 +#define _loop0_56_type 1231 +#define _gather_55_type 1232 +#define _loop0_58_type 1233 +#define _gather_57_type 1234 +#define _loop0_60_type 1235 +#define _gather_59_type 1236 +#define _tmp_61_type 1237 +#define _loop0_63_type 1238 +#define _gather_62_type 1239 +#define _tmp_64_type 1240 +#define _tmp_65_type 1241 +#define _tmp_66_type 1242 +#define _loop0_68_type 1243 +#define _gather_67_type 1244 +#define _loop0_70_type 1245 +#define _gather_69_type 1246 +#define _tmp_71_type 1247 +#define _tmp_72_type 1248 +#define _tmp_73_type 1249 +#define _tmp_74_type 1250 +#define _tmp_75_type 1251 +#define _tmp_76_type 1252 +#define _loop0_77_type 1253 +#define _loop0_78_type 1254 +#define _loop0_79_type 1255 +#define _loop1_80_type 1256 +#define _loop0_81_type 1257 +#define _loop1_82_type 1258 +#define _loop1_83_type 1259 +#define _loop1_84_type 1260 +#define _loop0_85_type 1261 +#define _loop1_86_type 1262 +#define _loop0_87_type 1263 +#define _loop1_88_type 1264 +#define _loop0_89_type 1265 +#define _loop1_90_type 1266 +#define _loop1_91_type 1267 +#define _tmp_92_type 1268 +#define _loop0_94_type 1269 +#define _gather_93_type 1270 +#define _loop1_95_type 1271 +#define _loop0_97_type 1272 +#define _gather_96_type 1273 +#define _loop1_98_type 1274 +#define _loop0_99_type 1275 +#define _loop0_100_type 1276 +#define _loop0_101_type 1277 +#define _loop1_102_type 1278 +#define _loop0_103_type 1279 +#define _loop1_104_type 1280 +#define _loop1_105_type 1281 +#define _loop1_106_type 1282 +#define _loop0_107_type 1283 +#define _loop1_108_type 1284 +#define _loop0_109_type 1285 +#define _loop1_110_type 1286 +#define _loop0_111_type 1287 +#define _loop1_112_type 1288 +#define _loop1_113_type 1289 +#define _loop1_114_type 1290 +#define _loop1_115_type 1291 +#define _tmp_116_type 1292 +#define _loop0_118_type 1293 +#define _gather_117_type 1294 +#define _tmp_119_type 1295 +#define _tmp_120_type 1296 +#define _tmp_121_type 1297 +#define _tmp_122_type 1298 +#define _loop1_123_type 1299 +#define _tmp_124_type 1300 +#define _tmp_125_type 1301 +#define _loop0_127_type 1302 +#define _gather_126_type 1303 +#define _loop1_128_type 1304 +#define _loop0_129_type 1305 +#define _loop0_130_type 1306 +#define _tmp_131_type 1307 +#define _tmp_132_type 1308 +#define _loop0_134_type 1309 +#define _gather_133_type 1310 +#define _loop0_136_type 1311 +#define _gather_135_type 1312 +#define _loop0_138_type 1313 +#define _gather_137_type 1314 +#define _loop0_140_type 1315 +#define _gather_139_type 1316 +#define _loop0_141_type 1317 +#define _loop0_143_type 1318 +#define _gather_142_type 1319 +#define _tmp_144_type 1320 +#define _loop0_146_type 1321 +#define _gather_145_type 1322 +#define _loop0_148_type 1323 +#define _gather_147_type 1324 +#define _tmp_149_type 1325 +#define _loop0_150_type 1326 +#define _tmp_151_type 1327 +#define _tmp_152_type 1328 +#define _tmp_153_type 1329 +#define _tmp_154_type 1330 +#define _loop0_155_type 1331 +#define _tmp_156_type 1332 +#define _tmp_157_type 1333 +#define _tmp_158_type 1334 +#define _tmp_159_type 1335 +#define _tmp_160_type 1336 +#define _tmp_161_type 1337 +#define _loop0_163_type 1338 +#define _gather_162_type 1339 +#define _loop0_165_type 1340 +#define _gather_164_type 1341 +#define _loop0_167_type 1342 +#define _gather_166_type 1343 +#define _loop0_169_type 1344 +#define _gather_168_type 1345 +#define _tmp_170_type 1346 +#define _tmp_171_type 1347 +#define _tmp_172_type 1348 +#define _tmp_173_type 1349 +#define _tmp_174_type 1350 +#define _tmp_175_type 1351 +#define _tmp_176_type 1352 +#define _tmp_177_type 1353 +#define _loop1_178_type 1354 +#define _tmp_179_type 1355 +#define _tmp_180_type 1356 +#define _tmp_181_type 1357 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -490,6 +489,7 @@ static void *name_or_attr_rule(Parser *p); static void *values_pattern_rule(Parser *p); static void *items_pattern_rule(Parser *p); static void *keyword_pattern_rule(Parser *p); +static void *argument_pattern_rule(Parser *p); static expr_ty error_star_rule(Parser *p); static void *value_pattern_rule(Parser *p); static void *key_value_pattern_rule(Parser *p); @@ -792,8 +792,6 @@ static asdl_seq *_loop1_178_rule(Parser *p); static void *_tmp_179_rule(Parser *p); static void *_tmp_180_rule(Parser *p); static void *_tmp_181_rule(Parser *p); -static void *_tmp_182_rule(Parser *p); -static void *_tmp_183_rule(Parser *p); // file: statements? $ @@ -5629,8 +5627,8 @@ mapping_pattern_rule(Parser *p) // | name_or_attr '(' ','.pattern+ ','? ')' // | name_or_attr '(' ','.keyword_pattern+ ','? ')' // | name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')' -// | name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.(pattern | keyword_pattern)+] ','? ')' -// | name_or_attr '(' [','.(pattern | keyword_pattern)+ ','] error_star [',' ','.(pattern | keyword_pattern | error_star)+] ','? ')' +// | name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.argument_pattern+] ','? ')' +// | name_or_attr '(' [','.argument_pattern+ ','] error_star [',' ','.(argument_pattern | error_star)+] ','? ')' static void * class_pattern_rule(Parser *p) { @@ -5833,12 +5831,12 @@ class_pattern_rule(Parser *p) D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'")); } - { // name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.(pattern | keyword_pattern)+] ','? ')' + { // name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.argument_pattern+] ','? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.(pattern | keyword_pattern)+] ','? ')'")); + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.argument_pattern+] ','? ')'")); asdl_seq * _gather_62_var; Token * _literal; Token * _literal_1; @@ -5864,14 +5862,14 @@ class_pattern_rule(Parser *p) && (error = pattern_rule(p)) // pattern && - (_opt_var_1 = _tmp_64_rule(p), 1) // [',' ','.(pattern | keyword_pattern)+] + (_opt_var_1 = _tmp_64_rule(p), 1) // [',' ','.argument_pattern+] && (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? && (_literal_2 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.(pattern | keyword_pattern)+] ','? ')'")); + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.argument_pattern+] ','? ')'")); _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "positional pattern follows keyword pattern" ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -5882,14 +5880,14 @@ class_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.(pattern | keyword_pattern)+] ','? ')'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.argument_pattern+] ','? ')'")); } - { // name_or_attr '(' [','.(pattern | keyword_pattern)+ ','] error_star [',' ','.(pattern | keyword_pattern | error_star)+] ','? ')' + { // name_or_attr '(' [','.argument_pattern+ ','] error_star [',' ','.(argument_pattern | error_star)+] ','? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.(pattern | keyword_pattern)+ ','] error_star [',' ','.(pattern | keyword_pattern | error_star)+] ','? ')'")); + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.argument_pattern+ ','] error_star [',' ','.(argument_pattern | error_star)+] ','? ')'")); Token * _literal; Token * _literal_1; void *_opt_var; @@ -5905,18 +5903,18 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_opt_var = _tmp_65_rule(p), 1) // [','.(pattern | keyword_pattern)+ ','] + (_opt_var = _tmp_65_rule(p), 1) // [','.argument_pattern+ ','] && (error = error_star_rule(p)) // error_star && - (_opt_var_1 = _tmp_66_rule(p), 1) // [',' ','.(pattern | keyword_pattern | error_star)+] + (_opt_var_1 = _tmp_66_rule(p), 1) // [',' ','.(argument_pattern | error_star)+] && (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.(pattern | keyword_pattern)+ ','] error_star [',' ','.(pattern | keyword_pattern | error_star)+] ','? ')'")); + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.argument_pattern+ ','] error_star [',' ','.(argument_pattern | error_star)+] ','? ')'")); _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "can't use starred pattern here" ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -5927,7 +5925,7 @@ class_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' [','.(pattern | keyword_pattern)+ ','] error_star [',' ','.(pattern | keyword_pattern | error_star)+] ','? ')'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' [','.argument_pattern+ ','] error_star [',' ','.(argument_pattern | error_star)+] ','? ')'")); } _res = NULL; done: @@ -6204,6 +6202,61 @@ keyword_pattern_rule(Parser *p) return _res; } +// argument_pattern: pattern | keyword_pattern +static void * +argument_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> argument_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); + expr_ty pattern_var; + if ( + (pattern_var = pattern_rule(p)) // pattern + ) + { + D(fprintf(stderr, "%*c+ argument_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); + _res = pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s argument_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); + } + { // keyword_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> argument_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); + void *keyword_pattern_var; + if ( + (keyword_pattern_var = keyword_pattern_rule(p)) // keyword_pattern + ) + { + D(fprintf(stderr, "%*c+ argument_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); + _res = keyword_pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s argument_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + // error_star: ('*' | '**') NAME static expr_ty error_star_rule(Parser *p) @@ -6330,7 +6383,7 @@ value_pattern_rule(Parser *p) } // key_value_pattern: -// | (literal_pattern | constant_pattern) ':' closed_pattern +// | (literal_pattern | constant_pattern) ':' or_pattern // | '**' name_pattern static void * key_value_pattern_rule(Parser *p) @@ -6342,12 +6395,12 @@ key_value_pattern_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // (literal_pattern | constant_pattern) ':' closed_pattern + { // (literal_pattern | constant_pattern) ':' or_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(literal_pattern | constant_pattern) ':' closed_pattern")); + D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(literal_pattern | constant_pattern) ':' or_pattern")); Token * _literal; void *key; void *value; @@ -6356,10 +6409,10 @@ key_value_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && - (value = closed_pattern_rule(p)) // closed_pattern + (value = or_pattern_rule(p)) // or_pattern ) { - D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(literal_pattern | constant_pattern) ':' closed_pattern")); + D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(literal_pattern | constant_pattern) ':' or_pattern")); _res = _PyPegen_key_value_pair ( p , key , value ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -6370,7 +6423,7 @@ key_value_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s key_value_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(literal_pattern | constant_pattern) ':' closed_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(literal_pattern | constant_pattern) ':' or_pattern")); } { // '**' name_pattern if (p->error_indicator) { @@ -20713,7 +20766,7 @@ _gather_62_rule(Parser *p) return _res; } -// _tmp_64: ',' ','.(pattern | keyword_pattern)+ +// _tmp_64: ',' ','.argument_pattern+ static void * _tmp_64_rule(Parser *p) { @@ -20724,27 +20777,27 @@ _tmp_64_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ',' ','.(pattern | keyword_pattern)+ + { // ',' ','.argument_pattern+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(pattern | keyword_pattern)+")); + D(fprintf(stderr, "%*c> _tmp_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.argument_pattern+")); asdl_seq * _gather_164_var; Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_gather_164_var = _gather_164_rule(p)) // ','.(pattern | keyword_pattern)+ + (_gather_164_var = _gather_164_rule(p)) // ','.argument_pattern+ ) { - D(fprintf(stderr, "%*c+ _tmp_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(pattern | keyword_pattern)+")); + D(fprintf(stderr, "%*c+ _tmp_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.argument_pattern+")); _res = _PyPegen_dummy_name(p, _literal, _gather_164_var); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_64[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.(pattern | keyword_pattern)+")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.argument_pattern+")); } _res = NULL; done: @@ -20752,7 +20805,7 @@ _tmp_64_rule(Parser *p) return _res; } -// _tmp_65: ','.(pattern | keyword_pattern)+ ',' +// _tmp_65: ','.argument_pattern+ ',' static void * _tmp_65_rule(Parser *p) { @@ -20763,27 +20816,27 @@ _tmp_65_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ','.(pattern | keyword_pattern)+ ',' + { // ','.argument_pattern+ ',' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.(pattern | keyword_pattern)+ ','")); + D(fprintf(stderr, "%*c> _tmp_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.argument_pattern+ ','")); asdl_seq * _gather_166_var; Token * _literal; if ( - (_gather_166_var = _gather_166_rule(p)) // ','.(pattern | keyword_pattern)+ + (_gather_166_var = _gather_166_rule(p)) // ','.argument_pattern+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.(pattern | keyword_pattern)+ ','")); + D(fprintf(stderr, "%*c+ _tmp_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.argument_pattern+ ','")); _res = _PyPegen_dummy_name(p, _gather_166_var, _literal); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_65[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.(pattern | keyword_pattern)+ ','")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.argument_pattern+ ','")); } _res = NULL; done: @@ -20791,7 +20844,7 @@ _tmp_65_rule(Parser *p) return _res; } -// _tmp_66: ',' ','.(pattern | keyword_pattern | error_star)+ +// _tmp_66: ',' ','.(argument_pattern | error_star)+ static void * _tmp_66_rule(Parser *p) { @@ -20802,27 +20855,27 @@ _tmp_66_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ',' ','.(pattern | keyword_pattern | error_star)+ + { // ',' ','.(argument_pattern | error_star)+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(pattern | keyword_pattern | error_star)+")); + D(fprintf(stderr, "%*c> _tmp_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); asdl_seq * _gather_168_var; Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_gather_168_var = _gather_168_rule(p)) // ','.(pattern | keyword_pattern | error_star)+ + (_gather_168_var = _gather_168_rule(p)) // ','.(argument_pattern | error_star)+ ) { - D(fprintf(stderr, "%*c+ _tmp_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(pattern | keyword_pattern | error_star)+")); + D(fprintf(stderr, "%*c+ _tmp_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); _res = _PyPegen_dummy_name(p, _literal, _gather_168_var); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_66[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.(pattern | keyword_pattern | error_star)+")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); } _res = NULL; done: @@ -26711,7 +26764,7 @@ _gather_162_rule(Parser *p) return _res; } -// _loop0_165: ',' (pattern | keyword_pattern) +// _loop0_165: ',' argument_pattern static asdl_seq * _loop0_165_rule(Parser *p) { @@ -26732,18 +26785,18 @@ _loop0_165_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' (pattern | keyword_pattern) + { // ',' argument_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (pattern | keyword_pattern)")); + D(fprintf(stderr, "%*c> _loop0_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' argument_pattern")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_181_rule(p)) // pattern | keyword_pattern + (elem = argument_pattern_rule(p)) // argument_pattern ) { _res = elem; @@ -26769,7 +26822,7 @@ _loop0_165_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s _loop0_165[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (pattern | keyword_pattern)")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' argument_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -26786,7 +26839,7 @@ _loop0_165_rule(Parser *p) return _seq; } -// _gather_164: (pattern | keyword_pattern) _loop0_165 +// _gather_164: argument_pattern _loop0_165 static asdl_seq * _gather_164_rule(Parser *p) { @@ -26797,27 +26850,27 @@ _gather_164_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (pattern | keyword_pattern) _loop0_165 + { // argument_pattern _loop0_165 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(pattern | keyword_pattern) _loop0_165")); + D(fprintf(stderr, "%*c> _gather_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_165")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_181_rule(p)) // pattern | keyword_pattern + (elem = argument_pattern_rule(p)) // argument_pattern && (seq = _loop0_165_rule(p)) // _loop0_165 ) { - D(fprintf(stderr, "%*c+ _gather_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(pattern | keyword_pattern) _loop0_165")); + D(fprintf(stderr, "%*c+ _gather_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_165")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _gather_164[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(pattern | keyword_pattern) _loop0_165")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern _loop0_165")); } _res = NULL; done: @@ -26825,7 +26878,7 @@ _gather_164_rule(Parser *p) return _res; } -// _loop0_167: ',' (pattern | keyword_pattern) +// _loop0_167: ',' argument_pattern static asdl_seq * _loop0_167_rule(Parser *p) { @@ -26846,18 +26899,18 @@ _loop0_167_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' (pattern | keyword_pattern) + { // ',' argument_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (pattern | keyword_pattern)")); + D(fprintf(stderr, "%*c> _loop0_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' argument_pattern")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_182_rule(p)) // pattern | keyword_pattern + (elem = argument_pattern_rule(p)) // argument_pattern ) { _res = elem; @@ -26883,7 +26936,7 @@ _loop0_167_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s _loop0_167[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (pattern | keyword_pattern)")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' argument_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -26900,7 +26953,7 @@ _loop0_167_rule(Parser *p) return _seq; } -// _gather_166: (pattern | keyword_pattern) _loop0_167 +// _gather_166: argument_pattern _loop0_167 static asdl_seq * _gather_166_rule(Parser *p) { @@ -26911,27 +26964,27 @@ _gather_166_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (pattern | keyword_pattern) _loop0_167 + { // argument_pattern _loop0_167 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(pattern | keyword_pattern) _loop0_167")); + D(fprintf(stderr, "%*c> _gather_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_167")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_182_rule(p)) // pattern | keyword_pattern + (elem = argument_pattern_rule(p)) // argument_pattern && (seq = _loop0_167_rule(p)) // _loop0_167 ) { - D(fprintf(stderr, "%*c+ _gather_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(pattern | keyword_pattern) _loop0_167")); + D(fprintf(stderr, "%*c+ _gather_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_167")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _gather_166[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(pattern | keyword_pattern) _loop0_167")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern _loop0_167")); } _res = NULL; done: @@ -26939,7 +26992,7 @@ _gather_166_rule(Parser *p) return _res; } -// _loop0_169: ',' (pattern | keyword_pattern | error_star) +// _loop0_169: ',' (argument_pattern | error_star) static asdl_seq * _loop0_169_rule(Parser *p) { @@ -26960,18 +27013,18 @@ _loop0_169_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' (pattern | keyword_pattern | error_star) + { // ',' (argument_pattern | error_star) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (pattern | keyword_pattern | error_star)")); + D(fprintf(stderr, "%*c> _loop0_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (argument_pattern | error_star)")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_183_rule(p)) // pattern | keyword_pattern | error_star + (elem = _tmp_181_rule(p)) // argument_pattern | error_star ) { _res = elem; @@ -26997,7 +27050,7 @@ _loop0_169_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s _loop0_169[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (pattern | keyword_pattern | error_star)")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (argument_pattern | error_star)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -27014,7 +27067,7 @@ _loop0_169_rule(Parser *p) return _seq; } -// _gather_168: (pattern | keyword_pattern | error_star) _loop0_169 +// _gather_168: (argument_pattern | error_star) _loop0_169 static asdl_seq * _gather_168_rule(Parser *p) { @@ -27025,27 +27078,27 @@ _gather_168_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (pattern | keyword_pattern | error_star) _loop0_169 + { // (argument_pattern | error_star) _loop0_169 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(pattern | keyword_pattern | error_star) _loop0_169")); + D(fprintf(stderr, "%*c> _gather_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(argument_pattern | error_star) _loop0_169")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_183_rule(p)) // pattern | keyword_pattern | error_star + (elem = _tmp_181_rule(p)) // argument_pattern | error_star && (seq = _loop0_169_rule(p)) // _loop0_169 ) { - D(fprintf(stderr, "%*c+ _gather_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(pattern | keyword_pattern | error_star) _loop0_169")); + D(fprintf(stderr, "%*c+ _gather_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(argument_pattern | error_star) _loop0_169")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _gather_168[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(pattern | keyword_pattern | error_star) _loop0_169")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(argument_pattern | error_star) _loop0_169")); } _res = NULL; done: @@ -27589,7 +27642,7 @@ _tmp_180_rule(Parser *p) return _res; } -// _tmp_181: pattern | keyword_pattern +// _tmp_181: argument_pattern | error_star static void * _tmp_181_rule(Parser *p) { @@ -27600,171 +27653,42 @@ _tmp_181_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // pattern + { // argument_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); - expr_ty pattern_var; + D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern")); + void *argument_pattern_var; if ( - (pattern_var = pattern_rule(p)) // pattern + (argument_pattern_var = argument_pattern_rule(p)) // argument_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); - _res = pattern_var; + D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern")); + _res = argument_pattern_var; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_181[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); - } - { // keyword_pattern - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); - void *keyword_pattern_var; - if ( - (keyword_pattern_var = keyword_pattern_rule(p)) // keyword_pattern - ) - { - D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); - _res = keyword_pattern_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_181[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_182: pattern | keyword_pattern -static void * -_tmp_182_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // pattern - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); - expr_ty pattern_var; - if ( - (pattern_var = pattern_rule(p)) // pattern - ) - { - D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); - _res = pattern_var; - 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, "pattern")); - } - { // keyword_pattern - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); - void *keyword_pattern_var; - if ( - (keyword_pattern_var = keyword_pattern_rule(p)) // keyword_pattern - ) - { - D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); - _res = keyword_pattern_var; - 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, "keyword_pattern")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_183: pattern | keyword_pattern | error_star -static void * -_tmp_183_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // pattern - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); - expr_ty pattern_var; - if ( - (pattern_var = pattern_rule(p)) // pattern - ) - { - D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); - _res = pattern_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); - } - { // keyword_pattern - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); - void *keyword_pattern_var; - if ( - (keyword_pattern_var = keyword_pattern_rule(p)) // keyword_pattern - ) - { - D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); - _res = keyword_pattern_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern")); } { // error_star if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_star")); + D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_star")); expr_ty error_star_var; if ( (error_star_var = error_star_rule(p)) // error_star ) { - D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_star")); + D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_star")); _res = error_star_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_181[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_star")); } _res = NULL; diff --git a/Python/compile.c b/Python/compile.c index 62debc301b894d..3c405f4c18e5f5 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2777,7 +2777,7 @@ compiler_pattern_store(struct compiler *c, expr_ty p, int anon_ok) { assert(p->v.Name.ctx == Store); if (_PyUnicode_EqualToASCIIString(p->v.Name.id, "_")) { if (!anon_ok) { - return compiler_error(c, "can't assign to '_' here; consider removing?"); + return compiler_error(c, "can't assign to '_' here; consider removing or renaming?"); } ADDOP(c, POP_TOP); return 1; From ac87fcb2dd0d6b91f41360d47f9817d2056e0129 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 1 Jun 2020 22:58:20 -0700 Subject: [PATCH 051/189] Allow literal negative numbers --- Grammar/python.gram | 6 ++-- Lib/test/test_patma.py | 65 ++++++++++++++++++++++++++++++++++++++++++ Parser/pegen/parse.c | 44 +++++++++++++++++++++++++--- Python/ast.c | 2 ++ Python/ast_opt.c | 36 +++++++++++++++++++++-- 5 files changed, 145 insertions(+), 8 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index be11bf2900cffc..077270ffa47c98 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -222,10 +222,12 @@ closed_pattern: | class_pattern name_pattern: - | a=NAME !('.' | '(' | '=') { - _PyPegen_set_expr_context(p, a, Store) } + | name=NAME !('.' | '(' | '=') { + _PyPegen_set_expr_context(p, name, Store) } literal_pattern: | NUMBER + | '-' number=NUMBER { + _Py_UnaryOp(USub, number, EXTRA) } | strings | 'None' { _Py_Constant(Py_None, NULL, EXTRA) } diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index ec651f755ec57a..ba09678f1f58be 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1428,6 +1428,71 @@ def test_patma_094(self) -> None: self.assertEqual(x, 3) self.assertEqual(y, None) + def test_patma_095(self) -> None: + x = 0 + match x: + case -0: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_096(self) -> None: + x = 0 + match x: + case -0.0: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_097(self) -> None: + x = 0 + match x: + case -0j: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_098(self) -> None: + x = 0 + match x: + case -0.0j: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_099(self) -> None: + x = -1 + match x: + case -1: + y = 0 + self.assertEqual(x, -1) + self.assertEqual(y, 0) + + def test_patma_100(self) -> None: + x = -1.5 + match x: + case -1.5: + y = 0 + self.assertEqual(x, -1.5) + self.assertEqual(y, 0) + + def test_patma_101(self) -> None: + x = -1j + match x: + case -1j: + y = 0 + self.assertEqual(x, -1j) + self.assertEqual(y, 0) + + def test_patma_102(self) -> None: + x = -1.5j + match x: + case -1.5j: + y = 0 + self.assertEqual(x, -1.5j) + self.assertEqual(y, 0) + + if __name__ == "__main__": # XXX: For quick test debugging... import dis diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index 6bccd0013c99df..45397c3ab68004 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -5162,15 +5162,15 @@ name_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> name_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME !('.' | '(' | '=')")); - expr_ty a; + expr_ty name; if ( - (a = _PyPegen_name_token(p)) // NAME + (name = _PyPegen_name_token(p)) // NAME && _PyPegen_lookahead(0, _tmp_52_rule, p) ) { D(fprintf(stderr, "%*c+ name_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME !('.' | '(' | '=')")); - _res = _PyPegen_set_expr_context ( p , a , Store ); + _res = _PyPegen_set_expr_context ( p , name , Store ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5188,7 +5188,7 @@ name_pattern_rule(Parser *p) return _res; } -// literal_pattern: NUMBER | strings | 'None' | 'True' | 'False' +// literal_pattern: NUMBER | '-' NUMBER | strings | 'None' | 'True' | 'False' static void * literal_pattern_rule(Parser *p) { @@ -5227,6 +5227,42 @@ literal_pattern_rule(Parser *p) D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER")); } + { // '-' NUMBER + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-' NUMBER")); + Token * _literal; + expr_ty number; + if ( + (_literal = _PyPegen_expect_token(p, 15)) // token='-' + && + (number = _PyPegen_number_token(p)) // NUMBER + ) + { + D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-' NUMBER")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_UnaryOp ( USub , number , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-' NUMBER")); + } { // strings if (p->error_indicator) { D(p->level--); diff --git a/Python/ast.c b/Python/ast.c index d498acb9eae74e..f91ea0019ebca8 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -386,6 +386,8 @@ validate_pattern(expr_ty p) case NamedExpr_kind: return (validate_pattern(p->v.NamedExpr.value) && validate_expr(p->v.NamedExpr.target, Store)); + case UnaryOp_kind: + return 1; default: PyErr_SetString(PyExc_ValueError, "invalid Match pattern"); return 0; diff --git a/Python/ast_opt.c b/Python/ast_opt.c index d44d9fa641c928..52d3372db8e068 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -716,6 +716,7 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) CALL(astfold_expr, expr_ty, node_->v.Match.target); CALL_SEQ(astfold_match_case, match_case_ty, node_->v.Match.cases); // TODO: Mark unreachable cases for removal? Maybe pattern == NULL? + // TODO: We can even optimize patterns across cases... break; default: break; @@ -745,12 +746,43 @@ astfold_withitem(withitem_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) return 1; } +static int +astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) +{ + // Don't blindly optimize the pattern as an expr; it plays by its own rules! + // TODO: Build out this pattern optimizer. + switch (node_->kind) { + case Attribute_kind: + case Constant_kind: + case BoolOp_kind: + // TODO: Quite a bit of potential here. + case Dict_kind: + case List_kind: + case Name_kind: + case NamedExpr_kind: + return 1; + case UnaryOp_kind: + assert(node_->kind == UnaryOp_kind); + assert(node_->v.UnaryOp.op == USub); + assert(node_->v.UnaryOp.operand->kind == Constant_kind); + PyObject *value = node_->v.UnaryOp.operand->v.Constant.value; + assert(PyComplex_CheckExact(value) || PyFloat_CheckExact(value) || PyLong_CheckExact(value)); + PyObject *negated = PyNumber_Negative(value); + if (!negated) { + return 0; + } + return make_const(node_, negated, ctx_); + default: + Py_UNREACHABLE(); + } + return 1; +} + static int astfold_match_case(match_case_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) { + CALL_OPT(astfold_pattern, expr_ty, node_->pattern); CALL_OPT(astfold_expr, expr_ty, node_->guard); - // TODO: Create pattern optimizer. - // Don't blindly optimize the pattern as an expr; it plays by its own rules! CALL_SEQ(astfold_stmt, stmt_ty, node_->body); return 1; } From e3d07aba6937318cdf3694a361e556625311950c Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 1 Jun 2020 22:58:41 -0700 Subject: [PATCH 052/189] Add checks for name bindings --- Lib/test/test_patma.py | 4 +- Python/ast.c | 18 +++++++++ Python/compile.c | 89 ++++++++++++++++++++++++++++++------------ 3 files changed, 85 insertions(+), 26 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index ba09678f1f58be..e4789bf711f0dd 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -313,7 +313,7 @@ def test_patma_ast_37(self) -> None: def test_patma_ast_38(self) -> None: match_cases = [ MatchCase("[w := 0,]", "y = 0"), - MatchCase("[] or [1, z := (0 or 1)] or []", "y = 1"), + MatchCase("[z := 0] or [1, z := (0 or 1)] or [z := 0]", "y = 1"), ] namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") self.assertNotIn("w", namespace) @@ -994,7 +994,7 @@ def test_patma_051(self) -> None: match x: case [(w := 0)]: y = 0 - case [] | [1, (z := 0 | 1)] | []: + case [z] | [1, (z := 0 | 1)] | [z]: y = 1 self.assertEqual(w, None) self.assertEqual(x, [1, 0]) diff --git a/Python/ast.c b/Python/ast.c index f91ea0019ebca8..08903d60eb010c 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -358,6 +358,17 @@ validate_pattern(expr_ty p) } return validate_expr(key, Load); } + else { + if (i != size - 1) { + // TODO + } + if (key->kind != Name_kind) { + // TODO + } + if (key->v.Name.ctx != Store) { + // TODO + } + } if (!validate_pattern(asdl_seq_GET(values, i))) { return 0; } @@ -370,6 +381,12 @@ validate_pattern(expr_ty p) value = asdl_seq_GET(values, i); if (value->kind == Starred_kind) { value = value->v.Starred.value; + if (value->kind != Name_kind) { + // TODO + } + if (value->v.Name.ctx != Store) { + // TODO + } } if (!validate_pattern(value)) { return 0; @@ -387,6 +404,7 @@ validate_pattern(expr_ty p) return (validate_pattern(p->v.NamedExpr.value) && validate_expr(p->v.NamedExpr.target, Store)); case UnaryOp_kind: + // TODO return 1; default: PyErr_SetString(PyExc_ValueError, "invalid Match pattern"); diff --git a/Python/compile.c b/Python/compile.c index 3c405f4c18e5f5..3aeb317e0db16d 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -222,7 +222,7 @@ static int compiler_async_comprehension_generator( int depth, expr_ty elt, expr_ty val, int type); -static int compiler_pattern(struct compiler *, expr_ty, basicblock *); +static int compiler_pattern(struct compiler *, expr_ty, basicblock *, PyObject *); static PyCodeObject *assemble(struct compiler *, int addNone); static PyObject *__doc__, *__annotations__; @@ -2772,7 +2772,7 @@ compiler_pattern_load(struct compiler *c, expr_ty p, basicblock *fail) } static int -compiler_pattern_store(struct compiler *c, expr_ty p, int anon_ok) { +compiler_pattern_store(struct compiler *c, expr_ty p, int anon_ok, PyObject* names) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); if (_PyUnicode_EqualToASCIIString(p->v.Name.id, "_")) { @@ -2782,31 +2782,35 @@ compiler_pattern_store(struct compiler *c, expr_ty p, int anon_ok) { ADDOP(c, POP_TOP); return 1; } + if (PySet_Contains(names, p->v.Name.id)) { + // TODO: Format this error message with the name. + return compiler_error(c, "multiple assignments to name in pattern"); + } VISIT(c, expr, p); - return 1; + return !PySet_Add(names, p->v.Name.id); } static int -compiler_pattern_name(struct compiler *c, expr_ty p, basicblock *fail) +compiler_pattern_name(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Load || p->v.Name.ctx == Store); if (p->v.Name.ctx == Load) { return compiler_pattern_load(c, p, fail); } - return compiler_pattern_store(c, p, 1); + return compiler_pattern_store(c, p, 1, names); } static int -compiler_pattern_namedexpr(struct compiler *c, expr_ty p, basicblock *fail) +compiler_pattern_namedexpr(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) { assert(p->kind == NamedExpr_kind); basicblock *block, *end; CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); ADDOP(c, DUP_TOP); - CHECK(compiler_pattern(c, p->v.NamedExpr.value, block)); - CHECK(compiler_pattern_store(c, p->v.NamedExpr.target, 0)); + CHECK(compiler_pattern(c, p->v.NamedExpr.value, block, names)); + CHECK(compiler_pattern_store(c, p->v.NamedExpr.target, 0, names)); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); ADDOP(c, POP_TOP); @@ -2816,7 +2820,7 @@ compiler_pattern_namedexpr(struct compiler *c, expr_ty p, basicblock *fail) } static int -compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail) +compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) { basicblock *block, *end; CHECK(block = compiler_new_block(c)); @@ -2837,13 +2841,13 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail) assert(key->kind != Name_kind || key->v.Name.ctx == Load); VISIT(c, expr, key); ADDOP_JREL(c, MATCH_KEY, block); - CHECK(compiler_pattern(c, value, block)); + CHECK(compiler_pattern(c, value, block, names)); } if (!star) { ADDOP(c, POP_TOP); } else { - CHECK(compiler_pattern_store(c, asdl_seq_GET(values, size - 1), 0)); + CHECK(compiler_pattern_store(c, asdl_seq_GET(values, size - 1), 0, names)); } ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); @@ -2854,21 +2858,52 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail) } static int -compiler_pattern_or(struct compiler *c, expr_ty p, basicblock *fail) +compiler_pattern_or(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) { assert(p->kind == BoolOp_kind); - assert(p->v.BoolOp.op== Or); + assert(p->v.BoolOp.op == Or); basicblock *block, *end; + PyObject *control = NULL; CHECK(end = compiler_new_block(c)); Py_ssize_t size = asdl_seq_LEN(p->v.BoolOp.values); + assert(size > 1); for (Py_ssize_t i = 0; i < size; i++) { + PyObject *names_copy = PySet_New(names); + if (!names_copy) { + return 0; + } CHECK(block = compiler_new_block(c)); ADDOP(c, DUP_TOP); - CHECK(compiler_pattern(c, asdl_seq_GET(p->v.BoolOp.values, i), block)); + CHECK(compiler_pattern(c, asdl_seq_GET(p->v.BoolOp.values, i), block, names_copy)); ADDOP(c, POP_TOP); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); + if (!i) { + control = names_copy; + } + else if (PySet_GET_SIZE(control) || PySet_GET_SIZE(names_copy)) { + PyObject *diff = PyNumber_InPlaceXor(names_copy, control); + if (!diff) { + Py_DECREF(control); + return 0; + } + Py_DECREF(names_copy); + if (PySet_GET_SIZE(diff)) { + // TODO: Format this error message with a name. + // PyObject *extra = PySet_Pop(diff); + Py_DECREF(control); + PyObject_Print(PySet_Pop(diff), stderr, Py_PRINT_RAW); + Py_DECREF(diff); + return compiler_error(c, "pattern binds different names based on target"); + } + Py_DECREF(diff); + } + else { + Py_DECREF(names_copy); + } } + assert(control); + Py_DECREF(control); ADDOP(c, POP_TOP); ADDOP_JREL(c, JUMP_FORWARD, fail); compiler_use_next_block(c, end); @@ -2876,7 +2911,7 @@ compiler_pattern_or(struct compiler *c, expr_ty p, basicblock *fail) } static int -compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail) +compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) { assert(p->kind == List_kind); asdl_seq *values = p->v.List.elts; @@ -2906,7 +2941,7 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail) assert(value->kind == Starred_kind); Py_ssize_t remaining = size - i - 1; ADDOP_I(c, UNPACK_EX, remaining << 8); - CHECK(compiler_pattern_store(c, value->v.Starred.value, 1)); + CHECK(compiler_pattern_store(c, value->v.Starred.value, 1, names)); if (remaining) { ADDOP_I(c, BUILD_TUPLE, remaining); if (remaining > 1) { @@ -2923,7 +2958,7 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail) } else { ADDOP_JREL(c, FOR_ITER, fail); - CHECK(compiler_pattern(c, value, block)); + CHECK(compiler_pattern(c, value, block, names)); } } ADDOP_JREL(c, FOR_ITER, end); @@ -2936,22 +2971,22 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail) } static int -compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail) +compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) { switch (p->kind) { case Attribute_kind: case Constant_kind: return compiler_pattern_load(c, p, fail); case BoolOp_kind: - return compiler_pattern_or(c, p, fail); + return compiler_pattern_or(c, p, fail, names); case Dict_kind: - return compiler_pattern_mapping(c, p, fail); + return compiler_pattern_mapping(c, p, fail, names); case List_kind: - return compiler_pattern_sequence(c, p, fail); + return compiler_pattern_sequence(c, p, fail, names); case Name_kind: - return compiler_pattern_name(c, p, fail); + return compiler_pattern_name(c, p, fail, names); case NamedExpr_kind: - return compiler_pattern_namedexpr(c, p, fail); + return compiler_pattern_namedexpr(c, p, fail, names); default: Py_UNREACHABLE(); } @@ -2968,7 +3003,13 @@ compiler_match(struct compiler *c, stmt_ty s) match_case_ty m = asdl_seq_GET(s->v.Match.cases, i); CHECK(next = compiler_new_block(c)); ADDOP(c, DUP_TOP); - compiler_pattern(c, m->pattern, next); + PyObject* names = PySet_New(NULL); + if (!names) { + return 0; + } + int result = compiler_pattern(c, m->pattern, next, names); + Py_DECREF(names); + CHECK(result); if (m->guard) { CHECK(compiler_jump_if(c, m->guard, next, 0)); } From 9da2729b67a7665b9618c6dda0cf208354df1db6 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 1 Jun 2020 23:05:14 -0700 Subject: [PATCH 053/189] Cleanup --- Python/ast.c | 21 --------------------- Python/compile.c | 1 - 2 files changed, 22 deletions(-) diff --git a/Python/ast.c b/Python/ast.c index 08903d60eb010c..8cdee5bf672f76 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -358,17 +358,6 @@ validate_pattern(expr_ty p) } return validate_expr(key, Load); } - else { - if (i != size - 1) { - // TODO - } - if (key->kind != Name_kind) { - // TODO - } - if (key->v.Name.ctx != Store) { - // TODO - } - } if (!validate_pattern(asdl_seq_GET(values, i))) { return 0; } @@ -379,15 +368,6 @@ validate_pattern(expr_ty p) size = asdl_seq_LEN(values); for (i = 0; i < size; i++) { value = asdl_seq_GET(values, i); - if (value->kind == Starred_kind) { - value = value->v.Starred.value; - if (value->kind != Name_kind) { - // TODO - } - if (value->v.Name.ctx != Store) { - // TODO - } - } if (!validate_pattern(value)) { return 0; } @@ -404,7 +384,6 @@ validate_pattern(expr_ty p) return (validate_pattern(p->v.NamedExpr.value) && validate_expr(p->v.NamedExpr.target, Store)); case UnaryOp_kind: - // TODO return 1; default: PyErr_SetString(PyExc_ValueError, "invalid Match pattern"); diff --git a/Python/compile.c b/Python/compile.c index 3aeb317e0db16d..b541ae59d540a2 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2892,7 +2892,6 @@ compiler_pattern_or(struct compiler *c, expr_ty p, basicblock *fail, PyObject* n // TODO: Format this error message with a name. // PyObject *extra = PySet_Pop(diff); Py_DECREF(control); - PyObject_Print(PySet_Pop(diff), stderr, Py_PRINT_RAW); Py_DECREF(diff); return compiler_error(c, "pattern binds different names based on target"); } From 546b6c484f0d9df279da3a36fb473bd53e7b99a6 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 2 Jun 2020 07:53:18 -0700 Subject: [PATCH 054/189] Add support for complex literals --- Grammar/python.gram | 12 +- Lib/test/test_patma.py | 63 + Parser/pegen/parse.c | 2893 +++++++++++++++++++++------------------- Python/ast_opt.c | 57 +- 4 files changed, 1661 insertions(+), 1364 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 077270ffa47c98..02ba1f15b44899 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -225,9 +225,11 @@ name_pattern: | name=NAME !('.' | '(' | '=') { _PyPegen_set_expr_context(p, name, Store) } literal_pattern: - | NUMBER - | '-' number=NUMBER { - _Py_UnaryOp(USub, number, EXTRA) } + | signed_number !('+' | '-') + | real=signed_number '+' imag=NUMBER { + _Py_BinOp(real, Add, imag, EXTRA) } + | real=signed_number '-' imag=NUMBER { + _Py_BinOp(real, Sub, imag, EXTRA) } | strings | 'None' { _Py_Constant(Py_None, NULL, EXTRA) } @@ -263,6 +265,10 @@ class_pattern: | func=name_or_attr '(' [','.argument_pattern+ ','] error=error_star [',' ','.(argument_pattern | error_star)+] ','? ')' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "can't use starred pattern here") } +signed_number: + | NUMBER + | '-' number=NUMBER { + _Py_UnaryOp(USub, number, EXTRA) } name_or_attr: | NAME | value=name_or_attr '.' attr=NAME { diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index e4789bf711f0dd..41980f475688a1 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1492,6 +1492,69 @@ def test_patma_102(self) -> None: self.assertEqual(x, -1.5j) self.assertEqual(y, 0) + def test_patma_103(self) -> None: + x = 0 + match x: + case 0 + 0j: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_104(self) -> None: + x = 0 + match x: + case 0 - 0j: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_105(self) -> None: + x = 0 + match x: + case -0 + 0j: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_106(self) -> None: + x = 0 + match x: + case -0 - 0j: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_107(self) -> None: + x = 0.25 + 1.75j + match x: + case 0.25 + 1.75j: + y = 0 + self.assertEqual(x, 0.25 + 1.75j) + self.assertEqual(y, 0) + + def test_patma_108(self) -> None: + x = 0.25 - 1.75j + match x: + case 0.25 - 1.75j: + y = 0 + self.assertEqual(x, 0.25 - 1.75j) + self.assertEqual(y, 0) + + def test_patma_109(self) -> None: + x = -0.25 + 1.75j + match x: + case -0.25 + 1.75j: + y = 0 + self.assertEqual(x, -0.25 + 1.75j) + self.assertEqual(y, 0) + + def test_patma_110(self) -> None: + x = -0.25 - 1.75j + match x: + case -0.25 - 1.75j: + y = 0 + self.assertEqual(x, -0.25 - 1.75j) + self.assertEqual(y, 0) if __name__ == "__main__": # XXX: For quick test debugging... diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index 45397c3ab68004..25632984bbf7b8 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -126,313 +126,315 @@ static KeywordToken *reserved_keywords[] = { #define sequence_pattern_type 1048 #define mapping_pattern_type 1049 #define class_pattern_type 1050 -#define name_or_attr_type 1051 // Left-recursive -#define values_pattern_type 1052 -#define items_pattern_type 1053 -#define keyword_pattern_type 1054 -#define argument_pattern_type 1055 -#define error_star_type 1056 -#define value_pattern_type 1057 -#define key_value_pattern_type 1058 -#define return_stmt_type 1059 -#define raise_stmt_type 1060 -#define function_def_type 1061 -#define function_def_raw_type 1062 -#define func_type_comment_type 1063 -#define params_type 1064 -#define parameters_type 1065 -#define slash_no_default_type 1066 -#define slash_with_default_type 1067 -#define star_etc_type 1068 -#define kwds_type 1069 -#define param_no_default_type 1070 -#define param_with_default_type 1071 -#define param_maybe_default_type 1072 -#define param_type 1073 -#define annotation_type 1074 -#define default_type 1075 -#define decorators_type 1076 -#define class_def_type 1077 -#define class_def_raw_type 1078 -#define block_type 1079 -#define expressions_list_type 1080 -#define star_expressions_type 1081 -#define star_expression_type 1082 -#define star_named_expressions_type 1083 -#define star_named_expression_type 1084 -#define named_expression_type 1085 -#define annotated_rhs_type 1086 -#define expressions_type 1087 -#define expression_type 1088 -#define lambdef_type 1089 -#define lambda_parameters_type 1090 -#define lambda_slash_no_default_type 1091 -#define lambda_slash_with_default_type 1092 -#define lambda_star_etc_type 1093 -#define lambda_kwds_type 1094 -#define lambda_param_no_default_type 1095 -#define lambda_param_with_default_type 1096 -#define lambda_param_maybe_default_type 1097 -#define lambda_param_type 1098 -#define disjunction_type 1099 -#define conjunction_type 1100 -#define inversion_type 1101 -#define comparison_type 1102 -#define compare_op_bitwise_or_pair_type 1103 -#define eq_bitwise_or_type 1104 -#define noteq_bitwise_or_type 1105 -#define lte_bitwise_or_type 1106 -#define lt_bitwise_or_type 1107 -#define gte_bitwise_or_type 1108 -#define gt_bitwise_or_type 1109 -#define notin_bitwise_or_type 1110 -#define in_bitwise_or_type 1111 -#define isnot_bitwise_or_type 1112 -#define is_bitwise_or_type 1113 -#define bitwise_or_type 1114 // Left-recursive -#define bitwise_xor_type 1115 // Left-recursive -#define bitwise_and_type 1116 // Left-recursive -#define shift_expr_type 1117 // Left-recursive -#define sum_type 1118 // Left-recursive -#define term_type 1119 // Left-recursive -#define factor_type 1120 -#define power_type 1121 -#define await_primary_type 1122 -#define primary_type 1123 // Left-recursive -#define slices_type 1124 -#define slice_type 1125 -#define atom_type 1126 -#define strings_type 1127 -#define list_type 1128 -#define listcomp_type 1129 -#define tuple_type 1130 -#define group_type 1131 -#define genexp_type 1132 -#define set_type 1133 -#define setcomp_type 1134 -#define dict_type 1135 -#define dictcomp_type 1136 -#define double_starred_kvpairs_type 1137 -#define double_starred_kvpair_type 1138 -#define kvpair_type 1139 -#define for_if_clauses_type 1140 -#define for_if_clause_type 1141 -#define yield_expr_type 1142 -#define arguments_type 1143 -#define args_type 1144 -#define kwargs_type 1145 -#define starred_expression_type 1146 -#define kwarg_or_starred_type 1147 -#define kwarg_or_double_starred_type 1148 -#define star_targets_type 1149 -#define star_targets_seq_type 1150 -#define star_target_type 1151 -#define star_atom_type 1152 -#define single_target_type 1153 -#define single_subscript_attribute_target_type 1154 -#define del_targets_type 1155 -#define del_target_type 1156 -#define del_t_atom_type 1157 -#define del_target_end_type 1158 -#define targets_type 1159 -#define target_type 1160 -#define t_primary_type 1161 // Left-recursive -#define t_lookahead_type 1162 -#define t_atom_type 1163 -#define incorrect_arguments_type 1164 -#define invalid_kwarg_type 1165 -#define invalid_named_expression_type 1166 -#define invalid_assignment_type 1167 -#define invalid_block_type 1168 -#define invalid_comprehension_type 1169 -#define invalid_dict_comprehension_type 1170 -#define invalid_parameters_type 1171 -#define invalid_star_etc_type 1172 -#define invalid_lambda_star_etc_type 1173 -#define invalid_double_type_comments_type 1174 -#define invalid_del_target_type 1175 -#define invalid_import_from_targets_type 1176 -#define _loop0_1_type 1177 -#define _loop0_2_type 1178 -#define _loop0_4_type 1179 -#define _gather_3_type 1180 -#define _loop0_6_type 1181 -#define _gather_5_type 1182 -#define _loop0_8_type 1183 -#define _gather_7_type 1184 -#define _loop0_10_type 1185 -#define _gather_9_type 1186 -#define _loop1_11_type 1187 -#define _loop0_13_type 1188 -#define _gather_12_type 1189 -#define _tmp_14_type 1190 -#define _tmp_15_type 1191 -#define _tmp_16_type 1192 -#define _tmp_17_type 1193 -#define _tmp_18_type 1194 -#define _tmp_19_type 1195 -#define _tmp_20_type 1196 -#define _tmp_21_type 1197 -#define _loop1_22_type 1198 -#define _tmp_23_type 1199 -#define _tmp_24_type 1200 -#define _loop0_26_type 1201 -#define _gather_25_type 1202 -#define _loop0_28_type 1203 -#define _gather_27_type 1204 -#define _tmp_29_type 1205 -#define _loop0_30_type 1206 -#define _loop1_31_type 1207 -#define _loop0_33_type 1208 -#define _gather_32_type 1209 -#define _tmp_34_type 1210 -#define _loop0_36_type 1211 -#define _gather_35_type 1212 -#define _tmp_37_type 1213 -#define _loop0_39_type 1214 -#define _gather_38_type 1215 -#define _loop0_41_type 1216 -#define _gather_40_type 1217 -#define _loop0_43_type 1218 -#define _gather_42_type 1219 -#define _loop0_45_type 1220 -#define _gather_44_type 1221 -#define _tmp_46_type 1222 -#define _loop1_47_type 1223 -#define _tmp_48_type 1224 -#define _loop1_49_type 1225 -#define _loop0_51_type 1226 -#define _gather_50_type 1227 -#define _tmp_52_type 1228 -#define _loop0_54_type 1229 -#define _gather_53_type 1230 -#define _loop0_56_type 1231 -#define _gather_55_type 1232 -#define _loop0_58_type 1233 -#define _gather_57_type 1234 -#define _loop0_60_type 1235 -#define _gather_59_type 1236 -#define _tmp_61_type 1237 -#define _loop0_63_type 1238 -#define _gather_62_type 1239 -#define _tmp_64_type 1240 -#define _tmp_65_type 1241 -#define _tmp_66_type 1242 -#define _loop0_68_type 1243 -#define _gather_67_type 1244 -#define _loop0_70_type 1245 -#define _gather_69_type 1246 -#define _tmp_71_type 1247 -#define _tmp_72_type 1248 -#define _tmp_73_type 1249 -#define _tmp_74_type 1250 -#define _tmp_75_type 1251 -#define _tmp_76_type 1252 -#define _loop0_77_type 1253 -#define _loop0_78_type 1254 -#define _loop0_79_type 1255 -#define _loop1_80_type 1256 -#define _loop0_81_type 1257 -#define _loop1_82_type 1258 -#define _loop1_83_type 1259 -#define _loop1_84_type 1260 -#define _loop0_85_type 1261 -#define _loop1_86_type 1262 -#define _loop0_87_type 1263 -#define _loop1_88_type 1264 -#define _loop0_89_type 1265 -#define _loop1_90_type 1266 -#define _loop1_91_type 1267 -#define _tmp_92_type 1268 -#define _loop0_94_type 1269 -#define _gather_93_type 1270 -#define _loop1_95_type 1271 -#define _loop0_97_type 1272 -#define _gather_96_type 1273 -#define _loop1_98_type 1274 -#define _loop0_99_type 1275 -#define _loop0_100_type 1276 -#define _loop0_101_type 1277 -#define _loop1_102_type 1278 -#define _loop0_103_type 1279 -#define _loop1_104_type 1280 -#define _loop1_105_type 1281 -#define _loop1_106_type 1282 -#define _loop0_107_type 1283 -#define _loop1_108_type 1284 -#define _loop0_109_type 1285 -#define _loop1_110_type 1286 -#define _loop0_111_type 1287 -#define _loop1_112_type 1288 -#define _loop1_113_type 1289 -#define _loop1_114_type 1290 -#define _loop1_115_type 1291 -#define _tmp_116_type 1292 -#define _loop0_118_type 1293 -#define _gather_117_type 1294 -#define _tmp_119_type 1295 -#define _tmp_120_type 1296 -#define _tmp_121_type 1297 -#define _tmp_122_type 1298 -#define _loop1_123_type 1299 -#define _tmp_124_type 1300 -#define _tmp_125_type 1301 -#define _loop0_127_type 1302 -#define _gather_126_type 1303 -#define _loop1_128_type 1304 -#define _loop0_129_type 1305 -#define _loop0_130_type 1306 -#define _tmp_131_type 1307 -#define _tmp_132_type 1308 -#define _loop0_134_type 1309 -#define _gather_133_type 1310 -#define _loop0_136_type 1311 -#define _gather_135_type 1312 -#define _loop0_138_type 1313 -#define _gather_137_type 1314 -#define _loop0_140_type 1315 -#define _gather_139_type 1316 +#define signed_number_type 1051 +#define name_or_attr_type 1052 // Left-recursive +#define values_pattern_type 1053 +#define items_pattern_type 1054 +#define keyword_pattern_type 1055 +#define argument_pattern_type 1056 +#define error_star_type 1057 +#define value_pattern_type 1058 +#define key_value_pattern_type 1059 +#define return_stmt_type 1060 +#define raise_stmt_type 1061 +#define function_def_type 1062 +#define function_def_raw_type 1063 +#define func_type_comment_type 1064 +#define params_type 1065 +#define parameters_type 1066 +#define slash_no_default_type 1067 +#define slash_with_default_type 1068 +#define star_etc_type 1069 +#define kwds_type 1070 +#define param_no_default_type 1071 +#define param_with_default_type 1072 +#define param_maybe_default_type 1073 +#define param_type 1074 +#define annotation_type 1075 +#define default_type 1076 +#define decorators_type 1077 +#define class_def_type 1078 +#define class_def_raw_type 1079 +#define block_type 1080 +#define expressions_list_type 1081 +#define star_expressions_type 1082 +#define star_expression_type 1083 +#define star_named_expressions_type 1084 +#define star_named_expression_type 1085 +#define named_expression_type 1086 +#define annotated_rhs_type 1087 +#define expressions_type 1088 +#define expression_type 1089 +#define lambdef_type 1090 +#define lambda_parameters_type 1091 +#define lambda_slash_no_default_type 1092 +#define lambda_slash_with_default_type 1093 +#define lambda_star_etc_type 1094 +#define lambda_kwds_type 1095 +#define lambda_param_no_default_type 1096 +#define lambda_param_with_default_type 1097 +#define lambda_param_maybe_default_type 1098 +#define lambda_param_type 1099 +#define disjunction_type 1100 +#define conjunction_type 1101 +#define inversion_type 1102 +#define comparison_type 1103 +#define compare_op_bitwise_or_pair_type 1104 +#define eq_bitwise_or_type 1105 +#define noteq_bitwise_or_type 1106 +#define lte_bitwise_or_type 1107 +#define lt_bitwise_or_type 1108 +#define gte_bitwise_or_type 1109 +#define gt_bitwise_or_type 1110 +#define notin_bitwise_or_type 1111 +#define in_bitwise_or_type 1112 +#define isnot_bitwise_or_type 1113 +#define is_bitwise_or_type 1114 +#define bitwise_or_type 1115 // Left-recursive +#define bitwise_xor_type 1116 // Left-recursive +#define bitwise_and_type 1117 // Left-recursive +#define shift_expr_type 1118 // Left-recursive +#define sum_type 1119 // Left-recursive +#define term_type 1120 // Left-recursive +#define factor_type 1121 +#define power_type 1122 +#define await_primary_type 1123 +#define primary_type 1124 // Left-recursive +#define slices_type 1125 +#define slice_type 1126 +#define atom_type 1127 +#define strings_type 1128 +#define list_type 1129 +#define listcomp_type 1130 +#define tuple_type 1131 +#define group_type 1132 +#define genexp_type 1133 +#define set_type 1134 +#define setcomp_type 1135 +#define dict_type 1136 +#define dictcomp_type 1137 +#define double_starred_kvpairs_type 1138 +#define double_starred_kvpair_type 1139 +#define kvpair_type 1140 +#define for_if_clauses_type 1141 +#define for_if_clause_type 1142 +#define yield_expr_type 1143 +#define arguments_type 1144 +#define args_type 1145 +#define kwargs_type 1146 +#define starred_expression_type 1147 +#define kwarg_or_starred_type 1148 +#define kwarg_or_double_starred_type 1149 +#define star_targets_type 1150 +#define star_targets_seq_type 1151 +#define star_target_type 1152 +#define star_atom_type 1153 +#define single_target_type 1154 +#define single_subscript_attribute_target_type 1155 +#define del_targets_type 1156 +#define del_target_type 1157 +#define del_t_atom_type 1158 +#define del_target_end_type 1159 +#define targets_type 1160 +#define target_type 1161 +#define t_primary_type 1162 // Left-recursive +#define t_lookahead_type 1163 +#define t_atom_type 1164 +#define incorrect_arguments_type 1165 +#define invalid_kwarg_type 1166 +#define invalid_named_expression_type 1167 +#define invalid_assignment_type 1168 +#define invalid_block_type 1169 +#define invalid_comprehension_type 1170 +#define invalid_dict_comprehension_type 1171 +#define invalid_parameters_type 1172 +#define invalid_star_etc_type 1173 +#define invalid_lambda_star_etc_type 1174 +#define invalid_double_type_comments_type 1175 +#define invalid_del_target_type 1176 +#define invalid_import_from_targets_type 1177 +#define _loop0_1_type 1178 +#define _loop0_2_type 1179 +#define _loop0_4_type 1180 +#define _gather_3_type 1181 +#define _loop0_6_type 1182 +#define _gather_5_type 1183 +#define _loop0_8_type 1184 +#define _gather_7_type 1185 +#define _loop0_10_type 1186 +#define _gather_9_type 1187 +#define _loop1_11_type 1188 +#define _loop0_13_type 1189 +#define _gather_12_type 1190 +#define _tmp_14_type 1191 +#define _tmp_15_type 1192 +#define _tmp_16_type 1193 +#define _tmp_17_type 1194 +#define _tmp_18_type 1195 +#define _tmp_19_type 1196 +#define _tmp_20_type 1197 +#define _tmp_21_type 1198 +#define _loop1_22_type 1199 +#define _tmp_23_type 1200 +#define _tmp_24_type 1201 +#define _loop0_26_type 1202 +#define _gather_25_type 1203 +#define _loop0_28_type 1204 +#define _gather_27_type 1205 +#define _tmp_29_type 1206 +#define _loop0_30_type 1207 +#define _loop1_31_type 1208 +#define _loop0_33_type 1209 +#define _gather_32_type 1210 +#define _tmp_34_type 1211 +#define _loop0_36_type 1212 +#define _gather_35_type 1213 +#define _tmp_37_type 1214 +#define _loop0_39_type 1215 +#define _gather_38_type 1216 +#define _loop0_41_type 1217 +#define _gather_40_type 1218 +#define _loop0_43_type 1219 +#define _gather_42_type 1220 +#define _loop0_45_type 1221 +#define _gather_44_type 1222 +#define _tmp_46_type 1223 +#define _loop1_47_type 1224 +#define _tmp_48_type 1225 +#define _loop1_49_type 1226 +#define _loop0_51_type 1227 +#define _gather_50_type 1228 +#define _tmp_52_type 1229 +#define _tmp_53_type 1230 +#define _loop0_55_type 1231 +#define _gather_54_type 1232 +#define _loop0_57_type 1233 +#define _gather_56_type 1234 +#define _loop0_59_type 1235 +#define _gather_58_type 1236 +#define _loop0_61_type 1237 +#define _gather_60_type 1238 +#define _tmp_62_type 1239 +#define _loop0_64_type 1240 +#define _gather_63_type 1241 +#define _tmp_65_type 1242 +#define _tmp_66_type 1243 +#define _tmp_67_type 1244 +#define _loop0_69_type 1245 +#define _gather_68_type 1246 +#define _loop0_71_type 1247 +#define _gather_70_type 1248 +#define _tmp_72_type 1249 +#define _tmp_73_type 1250 +#define _tmp_74_type 1251 +#define _tmp_75_type 1252 +#define _tmp_76_type 1253 +#define _tmp_77_type 1254 +#define _loop0_78_type 1255 +#define _loop0_79_type 1256 +#define _loop0_80_type 1257 +#define _loop1_81_type 1258 +#define _loop0_82_type 1259 +#define _loop1_83_type 1260 +#define _loop1_84_type 1261 +#define _loop1_85_type 1262 +#define _loop0_86_type 1263 +#define _loop1_87_type 1264 +#define _loop0_88_type 1265 +#define _loop1_89_type 1266 +#define _loop0_90_type 1267 +#define _loop1_91_type 1268 +#define _loop1_92_type 1269 +#define _tmp_93_type 1270 +#define _loop0_95_type 1271 +#define _gather_94_type 1272 +#define _loop1_96_type 1273 +#define _loop0_98_type 1274 +#define _gather_97_type 1275 +#define _loop1_99_type 1276 +#define _loop0_100_type 1277 +#define _loop0_101_type 1278 +#define _loop0_102_type 1279 +#define _loop1_103_type 1280 +#define _loop0_104_type 1281 +#define _loop1_105_type 1282 +#define _loop1_106_type 1283 +#define _loop1_107_type 1284 +#define _loop0_108_type 1285 +#define _loop1_109_type 1286 +#define _loop0_110_type 1287 +#define _loop1_111_type 1288 +#define _loop0_112_type 1289 +#define _loop1_113_type 1290 +#define _loop1_114_type 1291 +#define _loop1_115_type 1292 +#define _loop1_116_type 1293 +#define _tmp_117_type 1294 +#define _loop0_119_type 1295 +#define _gather_118_type 1296 +#define _tmp_120_type 1297 +#define _tmp_121_type 1298 +#define _tmp_122_type 1299 +#define _tmp_123_type 1300 +#define _loop1_124_type 1301 +#define _tmp_125_type 1302 +#define _tmp_126_type 1303 +#define _loop0_128_type 1304 +#define _gather_127_type 1305 +#define _loop1_129_type 1306 +#define _loop0_130_type 1307 +#define _loop0_131_type 1308 +#define _tmp_132_type 1309 +#define _tmp_133_type 1310 +#define _loop0_135_type 1311 +#define _gather_134_type 1312 +#define _loop0_137_type 1313 +#define _gather_136_type 1314 +#define _loop0_139_type 1315 +#define _gather_138_type 1316 #define _loop0_141_type 1317 -#define _loop0_143_type 1318 -#define _gather_142_type 1319 -#define _tmp_144_type 1320 -#define _loop0_146_type 1321 -#define _gather_145_type 1322 -#define _loop0_148_type 1323 -#define _gather_147_type 1324 -#define _tmp_149_type 1325 -#define _loop0_150_type 1326 -#define _tmp_151_type 1327 -#define _tmp_152_type 1328 -#define _tmp_153_type 1329 -#define _tmp_154_type 1330 -#define _loop0_155_type 1331 -#define _tmp_156_type 1332 -#define _tmp_157_type 1333 -#define _tmp_158_type 1334 -#define _tmp_159_type 1335 -#define _tmp_160_type 1336 -#define _tmp_161_type 1337 -#define _loop0_163_type 1338 -#define _gather_162_type 1339 -#define _loop0_165_type 1340 -#define _gather_164_type 1341 -#define _loop0_167_type 1342 -#define _gather_166_type 1343 -#define _loop0_169_type 1344 -#define _gather_168_type 1345 -#define _tmp_170_type 1346 -#define _tmp_171_type 1347 -#define _tmp_172_type 1348 -#define _tmp_173_type 1349 -#define _tmp_174_type 1350 -#define _tmp_175_type 1351 -#define _tmp_176_type 1352 -#define _tmp_177_type 1353 -#define _loop1_178_type 1354 -#define _tmp_179_type 1355 -#define _tmp_180_type 1356 -#define _tmp_181_type 1357 +#define _gather_140_type 1318 +#define _loop0_142_type 1319 +#define _loop0_144_type 1320 +#define _gather_143_type 1321 +#define _tmp_145_type 1322 +#define _loop0_147_type 1323 +#define _gather_146_type 1324 +#define _loop0_149_type 1325 +#define _gather_148_type 1326 +#define _tmp_150_type 1327 +#define _loop0_151_type 1328 +#define _tmp_152_type 1329 +#define _tmp_153_type 1330 +#define _tmp_154_type 1331 +#define _tmp_155_type 1332 +#define _loop0_156_type 1333 +#define _tmp_157_type 1334 +#define _tmp_158_type 1335 +#define _tmp_159_type 1336 +#define _tmp_160_type 1337 +#define _tmp_161_type 1338 +#define _tmp_162_type 1339 +#define _loop0_164_type 1340 +#define _gather_163_type 1341 +#define _loop0_166_type 1342 +#define _gather_165_type 1343 +#define _loop0_168_type 1344 +#define _gather_167_type 1345 +#define _loop0_170_type 1346 +#define _gather_169_type 1347 +#define _tmp_171_type 1348 +#define _tmp_172_type 1349 +#define _tmp_173_type 1350 +#define _tmp_174_type 1351 +#define _tmp_175_type 1352 +#define _tmp_176_type 1353 +#define _tmp_177_type 1354 +#define _tmp_178_type 1355 +#define _loop1_179_type 1356 +#define _tmp_180_type 1357 +#define _tmp_181_type 1358 +#define _tmp_182_type 1359 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -485,6 +487,7 @@ static void *group_pattern_rule(Parser *p); static void *sequence_pattern_rule(Parser *p); static void *mapping_pattern_rule(Parser *p); static void *class_pattern_rule(Parser *p); +static void *signed_number_rule(Parser *p); static void *name_or_attr_rule(Parser *p); static void *values_pattern_rule(Parser *p); static void *items_pattern_rule(Parser *p); @@ -663,124 +666,124 @@ static asdl_seq *_loop1_49_rule(Parser *p); static asdl_seq *_loop0_51_rule(Parser *p); static asdl_seq *_gather_50_rule(Parser *p); static void *_tmp_52_rule(Parser *p); -static asdl_seq *_loop0_54_rule(Parser *p); -static asdl_seq *_gather_53_rule(Parser *p); -static asdl_seq *_loop0_56_rule(Parser *p); -static asdl_seq *_gather_55_rule(Parser *p); -static asdl_seq *_loop0_58_rule(Parser *p); -static asdl_seq *_gather_57_rule(Parser *p); -static asdl_seq *_loop0_60_rule(Parser *p); -static asdl_seq *_gather_59_rule(Parser *p); -static void *_tmp_61_rule(Parser *p); -static asdl_seq *_loop0_63_rule(Parser *p); -static asdl_seq *_gather_62_rule(Parser *p); -static void *_tmp_64_rule(Parser *p); +static void *_tmp_53_rule(Parser *p); +static asdl_seq *_loop0_55_rule(Parser *p); +static asdl_seq *_gather_54_rule(Parser *p); +static asdl_seq *_loop0_57_rule(Parser *p); +static asdl_seq *_gather_56_rule(Parser *p); +static asdl_seq *_loop0_59_rule(Parser *p); +static asdl_seq *_gather_58_rule(Parser *p); +static asdl_seq *_loop0_61_rule(Parser *p); +static asdl_seq *_gather_60_rule(Parser *p); +static void *_tmp_62_rule(Parser *p); +static asdl_seq *_loop0_64_rule(Parser *p); +static asdl_seq *_gather_63_rule(Parser *p); static void *_tmp_65_rule(Parser *p); static void *_tmp_66_rule(Parser *p); -static asdl_seq *_loop0_68_rule(Parser *p); -static asdl_seq *_gather_67_rule(Parser *p); -static asdl_seq *_loop0_70_rule(Parser *p); -static asdl_seq *_gather_69_rule(Parser *p); -static void *_tmp_71_rule(Parser *p); +static void *_tmp_67_rule(Parser *p); +static asdl_seq *_loop0_69_rule(Parser *p); +static asdl_seq *_gather_68_rule(Parser *p); +static asdl_seq *_loop0_71_rule(Parser *p); +static asdl_seq *_gather_70_rule(Parser *p); static void *_tmp_72_rule(Parser *p); static void *_tmp_73_rule(Parser *p); static void *_tmp_74_rule(Parser *p); static void *_tmp_75_rule(Parser *p); static void *_tmp_76_rule(Parser *p); -static asdl_seq *_loop0_77_rule(Parser *p); +static void *_tmp_77_rule(Parser *p); static asdl_seq *_loop0_78_rule(Parser *p); static asdl_seq *_loop0_79_rule(Parser *p); -static asdl_seq *_loop1_80_rule(Parser *p); -static asdl_seq *_loop0_81_rule(Parser *p); -static asdl_seq *_loop1_82_rule(Parser *p); +static asdl_seq *_loop0_80_rule(Parser *p); +static asdl_seq *_loop1_81_rule(Parser *p); +static asdl_seq *_loop0_82_rule(Parser *p); static asdl_seq *_loop1_83_rule(Parser *p); static asdl_seq *_loop1_84_rule(Parser *p); -static asdl_seq *_loop0_85_rule(Parser *p); -static asdl_seq *_loop1_86_rule(Parser *p); -static asdl_seq *_loop0_87_rule(Parser *p); -static asdl_seq *_loop1_88_rule(Parser *p); -static asdl_seq *_loop0_89_rule(Parser *p); -static asdl_seq *_loop1_90_rule(Parser *p); +static asdl_seq *_loop1_85_rule(Parser *p); +static asdl_seq *_loop0_86_rule(Parser *p); +static asdl_seq *_loop1_87_rule(Parser *p); +static asdl_seq *_loop0_88_rule(Parser *p); +static asdl_seq *_loop1_89_rule(Parser *p); +static asdl_seq *_loop0_90_rule(Parser *p); static asdl_seq *_loop1_91_rule(Parser *p); -static void *_tmp_92_rule(Parser *p); -static asdl_seq *_loop0_94_rule(Parser *p); -static asdl_seq *_gather_93_rule(Parser *p); -static asdl_seq *_loop1_95_rule(Parser *p); -static asdl_seq *_loop0_97_rule(Parser *p); -static asdl_seq *_gather_96_rule(Parser *p); -static asdl_seq *_loop1_98_rule(Parser *p); -static asdl_seq *_loop0_99_rule(Parser *p); +static asdl_seq *_loop1_92_rule(Parser *p); +static void *_tmp_93_rule(Parser *p); +static asdl_seq *_loop0_95_rule(Parser *p); +static asdl_seq *_gather_94_rule(Parser *p); +static asdl_seq *_loop1_96_rule(Parser *p); +static asdl_seq *_loop0_98_rule(Parser *p); +static asdl_seq *_gather_97_rule(Parser *p); +static asdl_seq *_loop1_99_rule(Parser *p); static asdl_seq *_loop0_100_rule(Parser *p); static asdl_seq *_loop0_101_rule(Parser *p); -static asdl_seq *_loop1_102_rule(Parser *p); -static asdl_seq *_loop0_103_rule(Parser *p); -static asdl_seq *_loop1_104_rule(Parser *p); +static asdl_seq *_loop0_102_rule(Parser *p); +static asdl_seq *_loop1_103_rule(Parser *p); +static asdl_seq *_loop0_104_rule(Parser *p); static asdl_seq *_loop1_105_rule(Parser *p); static asdl_seq *_loop1_106_rule(Parser *p); -static asdl_seq *_loop0_107_rule(Parser *p); -static asdl_seq *_loop1_108_rule(Parser *p); -static asdl_seq *_loop0_109_rule(Parser *p); -static asdl_seq *_loop1_110_rule(Parser *p); -static asdl_seq *_loop0_111_rule(Parser *p); -static asdl_seq *_loop1_112_rule(Parser *p); +static asdl_seq *_loop1_107_rule(Parser *p); +static asdl_seq *_loop0_108_rule(Parser *p); +static asdl_seq *_loop1_109_rule(Parser *p); +static asdl_seq *_loop0_110_rule(Parser *p); +static asdl_seq *_loop1_111_rule(Parser *p); +static asdl_seq *_loop0_112_rule(Parser *p); static asdl_seq *_loop1_113_rule(Parser *p); static asdl_seq *_loop1_114_rule(Parser *p); static asdl_seq *_loop1_115_rule(Parser *p); -static void *_tmp_116_rule(Parser *p); -static asdl_seq *_loop0_118_rule(Parser *p); -static asdl_seq *_gather_117_rule(Parser *p); -static void *_tmp_119_rule(Parser *p); +static asdl_seq *_loop1_116_rule(Parser *p); +static void *_tmp_117_rule(Parser *p); +static asdl_seq *_loop0_119_rule(Parser *p); +static asdl_seq *_gather_118_rule(Parser *p); static void *_tmp_120_rule(Parser *p); static void *_tmp_121_rule(Parser *p); static void *_tmp_122_rule(Parser *p); -static asdl_seq *_loop1_123_rule(Parser *p); -static void *_tmp_124_rule(Parser *p); +static void *_tmp_123_rule(Parser *p); +static asdl_seq *_loop1_124_rule(Parser *p); static void *_tmp_125_rule(Parser *p); -static asdl_seq *_loop0_127_rule(Parser *p); -static asdl_seq *_gather_126_rule(Parser *p); -static asdl_seq *_loop1_128_rule(Parser *p); -static asdl_seq *_loop0_129_rule(Parser *p); +static void *_tmp_126_rule(Parser *p); +static asdl_seq *_loop0_128_rule(Parser *p); +static asdl_seq *_gather_127_rule(Parser *p); +static asdl_seq *_loop1_129_rule(Parser *p); static asdl_seq *_loop0_130_rule(Parser *p); -static void *_tmp_131_rule(Parser *p); +static asdl_seq *_loop0_131_rule(Parser *p); static void *_tmp_132_rule(Parser *p); -static asdl_seq *_loop0_134_rule(Parser *p); -static asdl_seq *_gather_133_rule(Parser *p); -static asdl_seq *_loop0_136_rule(Parser *p); -static asdl_seq *_gather_135_rule(Parser *p); -static asdl_seq *_loop0_138_rule(Parser *p); -static asdl_seq *_gather_137_rule(Parser *p); -static asdl_seq *_loop0_140_rule(Parser *p); -static asdl_seq *_gather_139_rule(Parser *p); +static void *_tmp_133_rule(Parser *p); +static asdl_seq *_loop0_135_rule(Parser *p); +static asdl_seq *_gather_134_rule(Parser *p); +static asdl_seq *_loop0_137_rule(Parser *p); +static asdl_seq *_gather_136_rule(Parser *p); +static asdl_seq *_loop0_139_rule(Parser *p); +static asdl_seq *_gather_138_rule(Parser *p); static asdl_seq *_loop0_141_rule(Parser *p); -static asdl_seq *_loop0_143_rule(Parser *p); -static asdl_seq *_gather_142_rule(Parser *p); -static void *_tmp_144_rule(Parser *p); -static asdl_seq *_loop0_146_rule(Parser *p); -static asdl_seq *_gather_145_rule(Parser *p); -static asdl_seq *_loop0_148_rule(Parser *p); -static asdl_seq *_gather_147_rule(Parser *p); -static void *_tmp_149_rule(Parser *p); -static asdl_seq *_loop0_150_rule(Parser *p); -static void *_tmp_151_rule(Parser *p); +static asdl_seq *_gather_140_rule(Parser *p); +static asdl_seq *_loop0_142_rule(Parser *p); +static asdl_seq *_loop0_144_rule(Parser *p); +static asdl_seq *_gather_143_rule(Parser *p); +static void *_tmp_145_rule(Parser *p); +static asdl_seq *_loop0_147_rule(Parser *p); +static asdl_seq *_gather_146_rule(Parser *p); +static asdl_seq *_loop0_149_rule(Parser *p); +static asdl_seq *_gather_148_rule(Parser *p); +static void *_tmp_150_rule(Parser *p); +static asdl_seq *_loop0_151_rule(Parser *p); static void *_tmp_152_rule(Parser *p); static void *_tmp_153_rule(Parser *p); static void *_tmp_154_rule(Parser *p); -static asdl_seq *_loop0_155_rule(Parser *p); -static void *_tmp_156_rule(Parser *p); +static void *_tmp_155_rule(Parser *p); +static asdl_seq *_loop0_156_rule(Parser *p); static void *_tmp_157_rule(Parser *p); static void *_tmp_158_rule(Parser *p); static void *_tmp_159_rule(Parser *p); static void *_tmp_160_rule(Parser *p); static void *_tmp_161_rule(Parser *p); -static asdl_seq *_loop0_163_rule(Parser *p); -static asdl_seq *_gather_162_rule(Parser *p); -static asdl_seq *_loop0_165_rule(Parser *p); -static asdl_seq *_gather_164_rule(Parser *p); -static asdl_seq *_loop0_167_rule(Parser *p); -static asdl_seq *_gather_166_rule(Parser *p); -static asdl_seq *_loop0_169_rule(Parser *p); -static asdl_seq *_gather_168_rule(Parser *p); -static void *_tmp_170_rule(Parser *p); +static void *_tmp_162_rule(Parser *p); +static asdl_seq *_loop0_164_rule(Parser *p); +static asdl_seq *_gather_163_rule(Parser *p); +static asdl_seq *_loop0_166_rule(Parser *p); +static asdl_seq *_gather_165_rule(Parser *p); +static asdl_seq *_loop0_168_rule(Parser *p); +static asdl_seq *_gather_167_rule(Parser *p); +static asdl_seq *_loop0_170_rule(Parser *p); +static asdl_seq *_gather_169_rule(Parser *p); static void *_tmp_171_rule(Parser *p); static void *_tmp_172_rule(Parser *p); static void *_tmp_173_rule(Parser *p); @@ -788,10 +791,11 @@ static void *_tmp_174_rule(Parser *p); static void *_tmp_175_rule(Parser *p); static void *_tmp_176_rule(Parser *p); static void *_tmp_177_rule(Parser *p); -static asdl_seq *_loop1_178_rule(Parser *p); -static void *_tmp_179_rule(Parser *p); +static void *_tmp_178_rule(Parser *p); +static asdl_seq *_loop1_179_rule(Parser *p); static void *_tmp_180_rule(Parser *p); static void *_tmp_181_rule(Parser *p); +static void *_tmp_182_rule(Parser *p); // file: statements? $ @@ -5188,7 +5192,14 @@ name_pattern_rule(Parser *p) return _res; } -// literal_pattern: NUMBER | '-' NUMBER | strings | 'None' | 'True' | 'False' +// literal_pattern: +// | signed_number !('+' | '-') +// | signed_number '+' NUMBER +// | signed_number '-' NUMBER +// | strings +// | 'None' +// | 'True' +// | 'False' static void * literal_pattern_rule(Parser *p) { @@ -5208,40 +5219,84 @@ literal_pattern_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NUMBER + { // signed_number !('+' | '-') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NUMBER")); - expr_ty number_var; + D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "signed_number !('+' | '-')")); + void *signed_number_var; if ( - (number_var = _PyPegen_number_token(p)) // NUMBER + (signed_number_var = signed_number_rule(p)) // signed_number + && + _PyPegen_lookahead(0, _tmp_53_rule, p) ) { - D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NUMBER")); - _res = number_var; + D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "signed_number !('+' | '-')")); + _res = signed_number_var; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "signed_number !('+' | '-')")); } - { // '-' NUMBER + { // signed_number '+' NUMBER if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-' NUMBER")); + D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "signed_number '+' NUMBER")); Token * _literal; - expr_ty number; + expr_ty imag; + void *real; + if ( + (real = signed_number_rule(p)) // signed_number + && + (_literal = _PyPegen_expect_token(p, 14)) // token='+' + && + (imag = _PyPegen_number_token(p)) // NUMBER + ) + { + D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "signed_number '+' NUMBER")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_BinOp ( real , Add , imag , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "signed_number '+' NUMBER")); + } + { // signed_number '-' NUMBER + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "signed_number '-' NUMBER")); + Token * _literal; + expr_ty imag; + void *real; if ( + (real = signed_number_rule(p)) // signed_number + && (_literal = _PyPegen_expect_token(p, 15)) // token='-' && - (number = _PyPegen_number_token(p)) // NUMBER + (imag = _PyPegen_number_token(p)) // NUMBER ) { - D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-' NUMBER")); + D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "signed_number '-' NUMBER")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5251,7 +5306,7 @@ literal_pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_UnaryOp ( USub , number , EXTRA ); + _res = _Py_BinOp ( real , Sub , imag , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5261,7 +5316,7 @@ literal_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-' NUMBER")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "signed_number '-' NUMBER")); } { // strings if (p->error_indicator) { @@ -5740,7 +5795,7 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (args = _gather_53_rule(p)) // ','.pattern+ + (args = _gather_54_rule(p)) // ','.pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -5786,7 +5841,7 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (keywords = _gather_55_rule(p)) // ','.keyword_pattern+ + (keywords = _gather_56_rule(p)) // ','.keyword_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -5834,11 +5889,11 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (args = _gather_57_rule(p)) // ','.pattern+ + (args = _gather_58_rule(p)) // ','.pattern+ && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (keywords = _gather_59_rule(p)) // ','.keyword_pattern+ + (keywords = _gather_60_rule(p)) // ','.keyword_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -5873,7 +5928,7 @@ class_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.argument_pattern+] ','? ')'")); - asdl_seq * _gather_62_var; + asdl_seq * _gather_63_var; Token * _literal; Token * _literal_1; Token * _literal_2; @@ -5890,15 +5945,15 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_opt_var = _tmp_61_rule(p), 1) // [','.pattern+ ','] + (_opt_var = _tmp_62_rule(p), 1) // [','.pattern+ ','] && - (_gather_62_var = _gather_62_rule(p)) // ','.keyword_pattern+ + (_gather_63_var = _gather_63_rule(p)) // ','.keyword_pattern+ && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && (error = pattern_rule(p)) // pattern && - (_opt_var_1 = _tmp_64_rule(p), 1) // [',' ','.argument_pattern+] + (_opt_var_1 = _tmp_65_rule(p), 1) // [',' ','.argument_pattern+] && (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -5939,11 +5994,11 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_opt_var = _tmp_65_rule(p), 1) // [','.argument_pattern+ ','] + (_opt_var = _tmp_66_rule(p), 1) // [','.argument_pattern+ ','] && (error = error_star_rule(p)) // error_star && - (_opt_var_1 = _tmp_66_rule(p), 1) // [',' ','.(argument_pattern | error_star)+] + (_opt_var_1 = _tmp_67_rule(p), 1) // [',' ','.(argument_pattern | error_star)+] && (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -5969,6 +6024,87 @@ class_pattern_rule(Parser *p) return _res; } +// signed_number: NUMBER | '-' NUMBER +static void * +signed_number_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // NUMBER + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> signed_number[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NUMBER")); + expr_ty number_var; + if ( + (number_var = _PyPegen_number_token(p)) // NUMBER + ) + { + D(fprintf(stderr, "%*c+ signed_number[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NUMBER")); + _res = number_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s signed_number[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER")); + } + { // '-' NUMBER + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> signed_number[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-' NUMBER")); + Token * _literal; + expr_ty number; + if ( + (_literal = _PyPegen_expect_token(p, 15)) // token='-' + && + (number = _PyPegen_number_token(p)) // NUMBER + ) + { + D(fprintf(stderr, "%*c+ signed_number[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-' NUMBER")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_UnaryOp ( USub , number , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s signed_number[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-' NUMBER")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + // Left-recursive // name_or_attr: NAME | name_or_attr '.' NAME static void * name_or_attr_raw(Parser *); @@ -6104,7 +6240,7 @@ values_pattern_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * values; if ( - (values = _gather_67_rule(p)) // ','.value_pattern+ + (values = _gather_68_rule(p)) // ','.value_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -6149,7 +6285,7 @@ items_pattern_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * items; if ( - (items = _gather_69_rule(p)) // ','.key_value_pattern+ + (items = _gather_70_rule(p)) // ','.key_value_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -6310,10 +6446,10 @@ error_star_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> error_star[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('*' | '**') NAME")); - void *_tmp_71_var; + void *_tmp_72_var; expr_ty error; if ( - (_tmp_71_var = _tmp_71_rule(p)) // '*' | '**' + (_tmp_72_var = _tmp_72_rule(p)) // '*' | '**' && (error = _PyPegen_name_token(p)) // NAME ) @@ -6441,7 +6577,7 @@ key_value_pattern_rule(Parser *p) void *key; void *value; if ( - (key = _tmp_72_rule(p)) // literal_pattern | constant_pattern + (key = _tmp_73_rule(p)) // literal_pattern | constant_pattern && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -6590,7 +6726,7 @@ raise_stmt_rule(Parser *p) && (a = expression_rule(p)) // expression && - (b = _tmp_73_rule(p), 1) // ['from' expression] + (b = _tmp_74_rule(p), 1) // ['from' expression] ) { D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); @@ -6765,7 +6901,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_74_rule(p), 1) // ['->' expression] + (a = _tmp_75_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -6825,7 +6961,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_75_rule(p), 1) // ['->' expression] + (a = _tmp_76_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -6889,7 +7025,7 @@ func_type_comment_rule(Parser *p) && (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' && - _PyPegen_lookahead(1, _tmp_76_rule, p) + _PyPegen_lookahead(1, _tmp_77_rule, p) ) { D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); @@ -7033,9 +7169,9 @@ parameters_rule(Parser *p) if ( (a = slash_no_default_rule(p)) // slash_no_default && - (b = _loop0_77_rule(p)) // param_no_default* + (b = _loop0_78_rule(p)) // param_no_default* && - (c = _loop0_78_rule(p)) // param_with_default* + (c = _loop0_79_rule(p)) // param_with_default* && (d = star_etc_rule(p), 1) // star_etc? ) @@ -7065,7 +7201,7 @@ parameters_rule(Parser *p) if ( (a = slash_with_default_rule(p)) // slash_with_default && - (b = _loop0_79_rule(p)) // param_with_default* + (b = _loop0_80_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -7093,9 +7229,9 @@ parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = _loop1_80_rule(p)) // param_no_default+ + (a = _loop1_81_rule(p)) // param_no_default+ && - (b = _loop0_81_rule(p)) // param_with_default* + (b = _loop0_82_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -7122,7 +7258,7 @@ parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_82_rule(p)) // param_with_default+ + (a = _loop1_83_rule(p)) // param_with_default+ && (b = star_etc_rule(p), 1) // star_etc? ) @@ -7191,7 +7327,7 @@ slash_no_default_rule(Parser *p) Token * _literal_1; asdl_seq * a; if ( - (a = _loop1_83_rule(p)) // param_no_default+ + (a = _loop1_84_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7220,7 +7356,7 @@ slash_no_default_rule(Parser *p) Token * _literal; asdl_seq * a; if ( - (a = _loop1_84_rule(p)) // param_no_default+ + (a = _loop1_85_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7270,9 +7406,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_85_rule(p)) // param_no_default* + (a = _loop0_86_rule(p)) // param_no_default* && - (b = _loop1_86_rule(p)) // param_with_default+ + (b = _loop1_87_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7302,9 +7438,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_87_rule(p)) // param_no_default* + (a = _loop0_88_rule(p)) // param_no_default* && - (b = _loop1_88_rule(p)) // param_with_default+ + (b = _loop1_89_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7360,7 +7496,7 @@ star_etc_rule(Parser *p) && (a = param_no_default_rule(p)) // param_no_default && - (b = _loop0_89_rule(p)) // param_maybe_default* + (b = _loop0_90_rule(p)) // param_maybe_default* && (c = kwds_rule(p), 1) // kwds? ) @@ -7393,7 +7529,7 @@ star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_90_rule(p)) // param_maybe_default+ + (b = _loop1_91_rule(p)) // param_maybe_default+ && (c = kwds_rule(p), 1) // kwds? ) @@ -7915,7 +8051,7 @@ decorators_rule(Parser *p) D(fprintf(stderr, "%*c> decorators[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); asdl_seq * a; if ( - (a = _loop1_91_rule(p)) // (('@' named_expression NEWLINE))+ + (a = _loop1_92_rule(p)) // (('@' named_expression NEWLINE))+ ) { D(fprintf(stderr, "%*c+ decorators[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); @@ -8036,7 +8172,7 @@ class_def_raw_rule(Parser *p) && (a = _PyPegen_name_token(p)) // NAME && - (b = _tmp_92_rule(p), 1) // ['(' arguments? ')'] + (b = _tmp_93_rule(p), 1) // ['(' arguments? ')'] && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -8185,7 +8321,7 @@ expressions_list_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_93_rule(p)) // ','.star_expression+ + (a = _gather_94_rule(p)) // ','.star_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8245,7 +8381,7 @@ star_expressions_rule(Parser *p) if ( (a = star_expression_rule(p)) // star_expression && - (b = _loop1_95_rule(p)) // ((',' star_expression))+ + (b = _loop1_96_rule(p)) // ((',' star_expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8440,7 +8576,7 @@ star_named_expressions_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_96_rule(p)) // ','.star_named_expression+ + (a = _gather_97_rule(p)) // ','.star_named_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8738,7 +8874,7 @@ expressions_rule(Parser *p) if ( (a = expression_rule(p)) // expression && - (b = _loop1_98_rule(p)) // ((',' expression))+ + (b = _loop1_99_rule(p)) // ((',' expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -9037,9 +9173,9 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default && - (b = _loop0_99_rule(p)) // lambda_param_no_default* + (b = _loop0_100_rule(p)) // lambda_param_no_default* && - (c = _loop0_100_rule(p)) // lambda_param_with_default* + (c = _loop0_101_rule(p)) // lambda_param_with_default* && (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9069,7 +9205,7 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default && - (b = _loop0_101_rule(p)) // lambda_param_with_default* + (b = _loop0_102_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9097,9 +9233,9 @@ lambda_parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = _loop1_102_rule(p)) // lambda_param_no_default+ + (a = _loop1_103_rule(p)) // lambda_param_no_default+ && - (b = _loop0_103_rule(p)) // lambda_param_with_default* + (b = _loop0_104_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9126,7 +9262,7 @@ lambda_parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_104_rule(p)) // lambda_param_with_default+ + (a = _loop1_105_rule(p)) // lambda_param_with_default+ && (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9197,7 +9333,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal_1; asdl_seq * a; if ( - (a = _loop1_105_rule(p)) // lambda_param_no_default+ + (a = _loop1_106_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9226,7 +9362,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal; asdl_seq * a; if ( - (a = _loop1_106_rule(p)) // lambda_param_no_default+ + (a = _loop1_107_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9276,9 +9412,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_107_rule(p)) // lambda_param_no_default* + (a = _loop0_108_rule(p)) // lambda_param_no_default* && - (b = _loop1_108_rule(p)) // lambda_param_with_default+ + (b = _loop1_109_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9308,9 +9444,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_109_rule(p)) // lambda_param_no_default* + (a = _loop0_110_rule(p)) // lambda_param_no_default* && - (b = _loop1_110_rule(p)) // lambda_param_with_default+ + (b = _loop1_111_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9366,7 +9502,7 @@ lambda_star_etc_rule(Parser *p) && (a = lambda_param_no_default_rule(p)) // lambda_param_no_default && - (b = _loop0_111_rule(p)) // lambda_param_maybe_default* + (b = _loop0_112_rule(p)) // lambda_param_maybe_default* && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -9399,7 +9535,7 @@ lambda_star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_112_rule(p)) // lambda_param_maybe_default+ + (b = _loop1_113_rule(p)) // lambda_param_maybe_default+ && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -9826,7 +9962,7 @@ disjunction_rule(Parser *p) if ( (a = conjunction_rule(p)) // conjunction && - (b = _loop1_113_rule(p)) // (('or' conjunction))+ + (b = _loop1_114_rule(p)) // (('or' conjunction))+ ) { D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); @@ -9912,7 +10048,7 @@ conjunction_rule(Parser *p) if ( (a = inversion_rule(p)) // inversion && - (b = _loop1_114_rule(p)) // (('and' inversion))+ + (b = _loop1_115_rule(p)) // (('and' inversion))+ ) { D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); @@ -10080,7 +10216,7 @@ comparison_rule(Parser *p) if ( (a = bitwise_or_rule(p)) // bitwise_or && - (b = _loop1_115_rule(p)) // compare_op_bitwise_or_pair+ + (b = _loop1_116_rule(p)) // compare_op_bitwise_or_pair+ ) { D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); @@ -10408,10 +10544,10 @@ noteq_bitwise_or_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); - void *_tmp_116_var; + void *_tmp_117_var; expr_ty a; if ( - (_tmp_116_var = _tmp_116_rule(p)) // '!=' + (_tmp_117_var = _tmp_117_rule(p)) // '!=' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -12340,7 +12476,7 @@ slices_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_117_rule(p)) // ','.slice+ + (a = _gather_118_rule(p)) // ','.slice+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -12410,7 +12546,7 @@ slice_rule(Parser *p) && (b = expression_rule(p), 1) // expression? && - (c = _tmp_119_rule(p), 1) // [':' expression?] + (c = _tmp_120_rule(p), 1) // [':' expression?] ) { D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); @@ -12684,15 +12820,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - void *_tmp_120_var; + void *_tmp_121_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' && - (_tmp_120_var = _tmp_120_rule(p)) // tuple | group | genexp + (_tmp_121_var = _tmp_121_rule(p)) // tuple | group | genexp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - _res = _tmp_120_var; + _res = _tmp_121_var; goto done; } p->mark = _mark; @@ -12705,15 +12841,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - void *_tmp_121_var; + void *_tmp_122_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' && - (_tmp_121_var = _tmp_121_rule(p)) // list | listcomp + (_tmp_122_var = _tmp_122_rule(p)) // list | listcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - _res = _tmp_121_var; + _res = _tmp_122_var; goto done; } p->mark = _mark; @@ -12726,15 +12862,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - void *_tmp_122_var; + void *_tmp_123_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' && - (_tmp_122_var = _tmp_122_rule(p)) // dict | set | dictcomp | setcomp + (_tmp_123_var = _tmp_123_rule(p)) // dict | set | dictcomp | setcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - _res = _tmp_122_var; + _res = _tmp_123_var; goto done; } p->mark = _mark; @@ -12803,7 +12939,7 @@ strings_rule(Parser *p) D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+")); asdl_seq * a; if ( - (a = _loop1_123_rule(p)) // STRING+ + (a = _loop1_124_rule(p)) // STRING+ ) { D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+")); @@ -13010,7 +13146,7 @@ tuple_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_124_rule(p), 1) // [star_named_expression ',' star_named_expressions?] + (a = _tmp_125_rule(p), 1) // [star_named_expression ',' star_named_expressions?] && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -13066,7 +13202,7 @@ group_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_125_rule(p)) // yield_expr | named_expression + (a = _tmp_126_rule(p)) // yield_expr | named_expression && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -13502,7 +13638,7 @@ double_starred_kvpairs_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_126_rule(p)) // ','.double_starred_kvpair+ + (a = _gather_127_rule(p)) // ','.double_starred_kvpair+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -13653,13 +13789,13 @@ for_if_clauses_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); - asdl_seq * _loop1_128_var; + asdl_seq * _loop1_129_var; if ( - (_loop1_128_var = _loop1_128_rule(p)) // for_if_clause+ + (_loop1_129_var = _loop1_129_rule(p)) // for_if_clause+ ) { D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); - _res = _loop1_128_var; + _res = _loop1_129_var; goto done; } p->mark = _mark; @@ -13708,7 +13844,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = _loop0_129_rule(p)) // (('if' disjunction))* + (c = _loop0_130_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*")); @@ -13744,7 +13880,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = _loop0_130_rule(p)) // (('if' disjunction))* + (c = _loop0_131_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*")); @@ -13969,7 +14105,7 @@ args_rule(Parser *p) if ( (a = starred_expression_rule(p)) // starred_expression && - (b = _tmp_131_rule(p), 1) // [',' args] + (b = _tmp_132_rule(p), 1) // [',' args] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]")); @@ -14038,7 +14174,7 @@ args_rule(Parser *p) if ( (a = named_expression_rule(p)) // named_expression && - (b = _tmp_132_rule(p), 1) // [',' args] + (b = _tmp_133_rule(p), 1) // [',' args] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]")); @@ -14093,11 +14229,11 @@ kwargs_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _gather_133_rule(p)) // ','.kwarg_or_starred+ + (a = _gather_134_rule(p)) // ','.kwarg_or_starred+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _gather_135_rule(p)) // ','.kwarg_or_double_starred+ + (b = _gather_136_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); @@ -14119,13 +14255,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - asdl_seq * _gather_137_var; + asdl_seq * _gather_138_var; if ( - (_gather_137_var = _gather_137_rule(p)) // ','.kwarg_or_starred+ + (_gather_138_var = _gather_138_rule(p)) // ','.kwarg_or_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - _res = _gather_137_var; + _res = _gather_138_var; goto done; } p->mark = _mark; @@ -14138,13 +14274,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - asdl_seq * _gather_139_var; + asdl_seq * _gather_140_var; if ( - (_gather_139_var = _gather_139_rule(p)) // ','.kwarg_or_double_starred+ + (_gather_140_var = _gather_140_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - _res = _gather_139_var; + _res = _gather_140_var; goto done; } p->mark = _mark; @@ -14506,7 +14642,7 @@ star_targets_rule(Parser *p) if ( (a = star_target_rule(p)) // star_target && - (b = _loop0_141_rule(p)) // ((',' star_target))* + (b = _loop0_142_rule(p)) // ((',' star_target))* && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -14560,7 +14696,7 @@ star_targets_seq_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_142_rule(p)) // ','.star_target+ + (a = _gather_143_rule(p)) // ','.star_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -14623,7 +14759,7 @@ star_target_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (a = _tmp_144_rule(p)) // !'*' star_target + (a = _tmp_145_rule(p)) // !'*' star_target ) { D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); @@ -15145,7 +15281,7 @@ del_targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_145_rule(p)) // ','.del_target+ + (a = _gather_146_rule(p)) // ','.del_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -15624,7 +15760,7 @@ targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_147_rule(p)) // ','.target+ + (a = _gather_148_rule(p)) // ','.target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -16336,7 +16472,7 @@ incorrect_arguments_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_opt_var = _tmp_149_rule(p), 1) // [args | expression for_if_clauses] + (_opt_var = _tmp_150_rule(p), 1) // [args | expression for_if_clauses] ) { D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); @@ -16618,14 +16754,14 @@ invalid_assignment_rule(Parser *p) D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'")); Token * _literal; Token * _literal_1; - asdl_seq * _loop0_150_var; + asdl_seq * _loop0_151_var; expr_ty a; if ( (a = star_named_expression_rule(p)) // star_named_expression && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_loop0_150_var = _loop0_150_rule(p)) // star_named_expressions* + (_loop0_151_var = _loop0_151_rule(p)) // star_named_expressions* && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' ) @@ -16661,7 +16797,7 @@ invalid_assignment_rule(Parser *p) && (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_151_rule(p), 1) // ['=' annotated_rhs] + (_opt_var = _tmp_152_rule(p), 1) // ['=' annotated_rhs] ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]")); @@ -16684,14 +16820,14 @@ invalid_assignment_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); Token * _literal; - void *_tmp_152_var; + void *_tmp_153_var; expr_ty a; if ( (a = star_expressions_rule(p)) // star_expressions && (_literal = _PyPegen_expect_token(p, 22)) // token='=' && - (_tmp_152_var = _tmp_152_rule(p)) // yield_expr | star_expressions + (_tmp_153_var = _tmp_153_rule(p)) // yield_expr | star_expressions ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); @@ -16713,7 +16849,7 @@ invalid_assignment_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); - void *_tmp_153_var; + void *_tmp_154_var; expr_ty a; AugOperator* augassign_var; if ( @@ -16721,7 +16857,7 @@ invalid_assignment_rule(Parser *p) && (augassign_var = augassign_rule(p)) // augassign && - (_tmp_153_var = _tmp_153_rule(p)) // yield_expr | star_expressions + (_tmp_154_var = _tmp_154_rule(p)) // yield_expr | star_expressions ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); @@ -16803,11 +16939,11 @@ invalid_comprehension_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); - void *_tmp_154_var; + void *_tmp_155_var; expr_ty a; asdl_seq* for_if_clauses_var; if ( - (_tmp_154_var = _tmp_154_rule(p)) // '[' | '(' | '{' + (_tmp_155_var = _tmp_155_rule(p)) // '[' | '(' | '{' && (a = starred_expression_rule(p)) // starred_expression && @@ -16904,13 +17040,13 @@ invalid_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); - asdl_seq * _loop0_155_var; - void *_tmp_156_var; + asdl_seq * _loop0_156_var; + void *_tmp_157_var; arg_ty param_no_default_var; if ( - (_loop0_155_var = _loop0_155_rule(p)) // param_no_default* + (_loop0_156_var = _loop0_156_rule(p)) // param_no_default* && - (_tmp_156_var = _tmp_156_rule(p)) // slash_with_default | param_with_default+ + (_tmp_157_var = _tmp_157_rule(p)) // slash_with_default | param_with_default+ && (param_no_default_var = param_no_default_rule(p)) // param_no_default ) @@ -16952,11 +17088,11 @@ invalid_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); Token * _literal; - void *_tmp_157_var; + void *_tmp_158_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_157_var = _tmp_157_rule(p)) // ')' | ',' (')' | '**') + (_tmp_158_var = _tmp_158_rule(p)) // ')' | ',' (')' | '**') ) { D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); @@ -17026,11 +17162,11 @@ invalid_lambda_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); Token * _literal; - void *_tmp_158_var; + void *_tmp_159_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_158_var = _tmp_158_rule(p)) // ':' | ',' (':' | '**') + (_tmp_159_var = _tmp_159_rule(p)) // ':' | ',' (':' | '**') ) { D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); @@ -18440,12 +18576,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_159_var; + void *_tmp_160_var; while ( - (_tmp_159_var = _tmp_159_rule(p)) // star_targets '=' + (_tmp_160_var = _tmp_160_rule(p)) // star_targets '=' ) { - _res = _tmp_159_var; + _res = _tmp_160_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -18893,12 +19029,12 @@ _loop0_30_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop0_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_160_var; + void *_tmp_161_var; while ( - (_tmp_160_var = _tmp_160_rule(p)) // '.' | '...' + (_tmp_161_var = _tmp_161_rule(p)) // '.' | '...' ) { - _res = _tmp_160_var; + _res = _tmp_161_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -18959,12 +19095,12 @@ _loop1_31_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_161_var; + void *_tmp_162_var; while ( - (_tmp_161_var = _tmp_161_rule(p)) // '.' | '...' + (_tmp_162_var = _tmp_162_rule(p)) // '.' | '...' ) { - _res = _tmp_161_var; + _res = _tmp_162_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -20193,9 +20329,64 @@ _tmp_52_rule(Parser *p) return _res; } -// _loop0_54: ',' pattern +// _tmp_53: '+' | '-' +static void * +_tmp_53_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_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 14)) // token='+' + ) + { + D(fprintf(stderr, "%*c+ _tmp_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_53[%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_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 15)) // token='-' + ) + { + D(fprintf(stderr, "%*c+ _tmp_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_53[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-'")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_55: ',' pattern static asdl_seq * -_loop0_54_rule(Parser *p) +_loop0_55_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20219,7 +20410,7 @@ _loop0_54_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _loop0_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; expr_ty elem; while ( @@ -20250,7 +20441,7 @@ _loop0_54_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_54[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_55[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20263,14 +20454,14 @@ _loop0_54_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_54_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_55_type, _seq); D(p->level--); return _seq; } -// _gather_53: pattern _loop0_54 +// _gather_54: pattern _loop0_55 static asdl_seq * -_gather_53_rule(Parser *p) +_gather_54_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20279,27 +20470,27 @@ _gather_53_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // pattern _loop0_54 + { // pattern _loop0_55 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_54")); + D(fprintf(stderr, "%*c> _gather_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_55")); expr_ty elem; asdl_seq * seq; if ( (elem = pattern_rule(p)) // pattern && - (seq = _loop0_54_rule(p)) // _loop0_54 + (seq = _loop0_55_rule(p)) // _loop0_55 ) { - D(fprintf(stderr, "%*c+ _gather_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_54")); + D(fprintf(stderr, "%*c+ _gather_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_55")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_53[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_54")); + D(fprintf(stderr, "%*c%s _gather_54[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_55")); } _res = NULL; done: @@ -20307,9 +20498,9 @@ _gather_53_rule(Parser *p) return _res; } -// _loop0_56: ',' keyword_pattern +// _loop0_57: ',' keyword_pattern static asdl_seq * -_loop0_56_rule(Parser *p) +_loop0_57_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20333,7 +20524,7 @@ _loop0_56_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); + D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; void *elem; while ( @@ -20364,7 +20555,7 @@ _loop0_56_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_56[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_57[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20377,14 +20568,14 @@ _loop0_56_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_56_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_57_type, _seq); D(p->level--); return _seq; } -// _gather_55: keyword_pattern _loop0_56 +// _gather_56: keyword_pattern _loop0_57 static asdl_seq * -_gather_55_rule(Parser *p) +_gather_56_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20393,27 +20584,27 @@ _gather_55_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // keyword_pattern _loop0_56 + { // keyword_pattern _loop0_57 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_56")); + D(fprintf(stderr, "%*c> _gather_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_57")); void *elem; asdl_seq * seq; if ( (elem = keyword_pattern_rule(p)) // keyword_pattern && - (seq = _loop0_56_rule(p)) // _loop0_56 + (seq = _loop0_57_rule(p)) // _loop0_57 ) { - D(fprintf(stderr, "%*c+ _gather_55[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_56")); + D(fprintf(stderr, "%*c+ _gather_56[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_57")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_55[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_56")); + D(fprintf(stderr, "%*c%s _gather_56[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_57")); } _res = NULL; done: @@ -20421,9 +20612,9 @@ _gather_55_rule(Parser *p) return _res; } -// _loop0_58: ',' pattern +// _loop0_59: ',' pattern static asdl_seq * -_loop0_58_rule(Parser *p) +_loop0_59_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20447,7 +20638,7 @@ _loop0_58_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _loop0_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; expr_ty elem; while ( @@ -20478,7 +20669,7 @@ _loop0_58_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_58[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_59[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20491,14 +20682,14 @@ _loop0_58_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_58_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_59_type, _seq); D(p->level--); return _seq; } -// _gather_57: pattern _loop0_58 +// _gather_58: pattern _loop0_59 static asdl_seq * -_gather_57_rule(Parser *p) +_gather_58_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20507,27 +20698,27 @@ _gather_57_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // pattern _loop0_58 + { // pattern _loop0_59 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_58")); + D(fprintf(stderr, "%*c> _gather_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_59")); expr_ty elem; asdl_seq * seq; if ( (elem = pattern_rule(p)) // pattern && - (seq = _loop0_58_rule(p)) // _loop0_58 + (seq = _loop0_59_rule(p)) // _loop0_59 ) { - D(fprintf(stderr, "%*c+ _gather_57[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_58")); + D(fprintf(stderr, "%*c+ _gather_58[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_59")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_57[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_58")); + D(fprintf(stderr, "%*c%s _gather_58[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_59")); } _res = NULL; done: @@ -20535,9 +20726,9 @@ _gather_57_rule(Parser *p) return _res; } -// _loop0_60: ',' keyword_pattern +// _loop0_61: ',' keyword_pattern static asdl_seq * -_loop0_60_rule(Parser *p) +_loop0_61_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20561,7 +20752,7 @@ _loop0_60_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); + D(fprintf(stderr, "%*c> _loop0_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; void *elem; while ( @@ -20592,7 +20783,7 @@ _loop0_60_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_60[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_61[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20605,14 +20796,14 @@ _loop0_60_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_60_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_61_type, _seq); D(p->level--); return _seq; } -// _gather_59: keyword_pattern _loop0_60 +// _gather_60: keyword_pattern _loop0_61 static asdl_seq * -_gather_59_rule(Parser *p) +_gather_60_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20621,27 +20812,27 @@ _gather_59_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // keyword_pattern _loop0_60 + { // keyword_pattern _loop0_61 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_60")); + D(fprintf(stderr, "%*c> _gather_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_61")); void *elem; asdl_seq * seq; if ( (elem = keyword_pattern_rule(p)) // keyword_pattern && - (seq = _loop0_60_rule(p)) // _loop0_60 + (seq = _loop0_61_rule(p)) // _loop0_61 ) { - D(fprintf(stderr, "%*c+ _gather_59[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_60")); + D(fprintf(stderr, "%*c+ _gather_60[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_61")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_59[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_60")); + D(fprintf(stderr, "%*c%s _gather_60[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_61")); } _res = NULL; done: @@ -20649,9 +20840,9 @@ _gather_59_rule(Parser *p) return _res; } -// _tmp_61: ','.pattern+ ',' +// _tmp_62: ','.pattern+ ',' static void * -_tmp_61_rule(Parser *p) +_tmp_62_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20665,21 +20856,21 @@ _tmp_61_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); - asdl_seq * _gather_162_var; + D(fprintf(stderr, "%*c> _tmp_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); + asdl_seq * _gather_163_var; Token * _literal; if ( - (_gather_162_var = _gather_162_rule(p)) // ','.pattern+ + (_gather_163_var = _gather_163_rule(p)) // ','.pattern+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_61[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); - _res = _PyPegen_dummy_name(p, _gather_162_var, _literal); + D(fprintf(stderr, "%*c+ _tmp_62[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); + _res = _PyPegen_dummy_name(p, _gather_163_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_61[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_62[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.pattern+ ','")); } _res = NULL; @@ -20688,9 +20879,9 @@ _tmp_61_rule(Parser *p) return _res; } -// _loop0_63: ',' keyword_pattern +// _loop0_64: ',' keyword_pattern static asdl_seq * -_loop0_63_rule(Parser *p) +_loop0_64_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20714,7 +20905,7 @@ _loop0_63_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); + D(fprintf(stderr, "%*c> _loop0_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; void *elem; while ( @@ -20745,7 +20936,7 @@ _loop0_63_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_63[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_64[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20758,14 +20949,14 @@ _loop0_63_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_63_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_64_type, _seq); D(p->level--); return _seq; } -// _gather_62: keyword_pattern _loop0_63 +// _gather_63: keyword_pattern _loop0_64 static asdl_seq * -_gather_62_rule(Parser *p) +_gather_63_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20774,27 +20965,27 @@ _gather_62_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // keyword_pattern _loop0_63 + { // keyword_pattern _loop0_64 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_63")); + D(fprintf(stderr, "%*c> _gather_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_64")); void *elem; asdl_seq * seq; if ( (elem = keyword_pattern_rule(p)) // keyword_pattern && - (seq = _loop0_63_rule(p)) // _loop0_63 + (seq = _loop0_64_rule(p)) // _loop0_64 ) { - D(fprintf(stderr, "%*c+ _gather_62[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_63")); + D(fprintf(stderr, "%*c+ _gather_63[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_64")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_62[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_63")); + D(fprintf(stderr, "%*c%s _gather_63[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_64")); } _res = NULL; done: @@ -20802,9 +20993,9 @@ _gather_62_rule(Parser *p) return _res; } -// _tmp_64: ',' ','.argument_pattern+ +// _tmp_65: ',' ','.argument_pattern+ static void * -_tmp_64_rule(Parser *p) +_tmp_65_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20818,21 +21009,21 @@ _tmp_64_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.argument_pattern+")); - asdl_seq * _gather_164_var; + D(fprintf(stderr, "%*c> _tmp_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.argument_pattern+")); + asdl_seq * _gather_165_var; Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_gather_164_var = _gather_164_rule(p)) // ','.argument_pattern+ + (_gather_165_var = _gather_165_rule(p)) // ','.argument_pattern+ ) { - D(fprintf(stderr, "%*c+ _tmp_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.argument_pattern+")); - _res = _PyPegen_dummy_name(p, _literal, _gather_164_var); + D(fprintf(stderr, "%*c+ _tmp_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.argument_pattern+")); + _res = _PyPegen_dummy_name(p, _literal, _gather_165_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_64[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_65[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.argument_pattern+")); } _res = NULL; @@ -20841,9 +21032,9 @@ _tmp_64_rule(Parser *p) return _res; } -// _tmp_65: ','.argument_pattern+ ',' +// _tmp_66: ','.argument_pattern+ ',' static void * -_tmp_65_rule(Parser *p) +_tmp_66_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20857,21 +21048,21 @@ _tmp_65_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.argument_pattern+ ','")); - asdl_seq * _gather_166_var; + D(fprintf(stderr, "%*c> _tmp_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.argument_pattern+ ','")); + asdl_seq * _gather_167_var; Token * _literal; if ( - (_gather_166_var = _gather_166_rule(p)) // ','.argument_pattern+ + (_gather_167_var = _gather_167_rule(p)) // ','.argument_pattern+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.argument_pattern+ ','")); - _res = _PyPegen_dummy_name(p, _gather_166_var, _literal); + D(fprintf(stderr, "%*c+ _tmp_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.argument_pattern+ ','")); + _res = _PyPegen_dummy_name(p, _gather_167_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_65[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_66[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.argument_pattern+ ','")); } _res = NULL; @@ -20880,9 +21071,9 @@ _tmp_65_rule(Parser *p) return _res; } -// _tmp_66: ',' ','.(argument_pattern | error_star)+ +// _tmp_67: ',' ','.(argument_pattern | error_star)+ static void * -_tmp_66_rule(Parser *p) +_tmp_67_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20896,21 +21087,21 @@ _tmp_66_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); - asdl_seq * _gather_168_var; + D(fprintf(stderr, "%*c> _tmp_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); + asdl_seq * _gather_169_var; Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_gather_168_var = _gather_168_rule(p)) // ','.(argument_pattern | error_star)+ + (_gather_169_var = _gather_169_rule(p)) // ','.(argument_pattern | error_star)+ ) { - D(fprintf(stderr, "%*c+ _tmp_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); - _res = _PyPegen_dummy_name(p, _literal, _gather_168_var); + D(fprintf(stderr, "%*c+ _tmp_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); + _res = _PyPegen_dummy_name(p, _literal, _gather_169_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_66[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_67[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); } _res = NULL; @@ -20919,9 +21110,9 @@ _tmp_66_rule(Parser *p) return _res; } -// _loop0_68: ',' value_pattern +// _loop0_69: ',' value_pattern static asdl_seq * -_loop0_68_rule(Parser *p) +_loop0_69_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20945,7 +21136,7 @@ _loop0_68_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' value_pattern")); + D(fprintf(stderr, "%*c> _loop0_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' value_pattern")); Token * _literal; void *elem; while ( @@ -20976,7 +21167,7 @@ _loop0_68_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_68[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_69[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' value_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20989,14 +21180,14 @@ _loop0_68_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_68_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_69_type, _seq); D(p->level--); return _seq; } -// _gather_67: value_pattern _loop0_68 +// _gather_68: value_pattern _loop0_69 static asdl_seq * -_gather_67_rule(Parser *p) +_gather_68_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21005,27 +21196,27 @@ _gather_67_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // value_pattern _loop0_68 + { // value_pattern _loop0_69 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_68")); + D(fprintf(stderr, "%*c> _gather_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_69")); void *elem; asdl_seq * seq; if ( (elem = value_pattern_rule(p)) // value_pattern && - (seq = _loop0_68_rule(p)) // _loop0_68 + (seq = _loop0_69_rule(p)) // _loop0_69 ) { - D(fprintf(stderr, "%*c+ _gather_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_68")); + D(fprintf(stderr, "%*c+ _gather_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_69")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_67[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern _loop0_68")); + D(fprintf(stderr, "%*c%s _gather_68[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern _loop0_69")); } _res = NULL; done: @@ -21033,9 +21224,9 @@ _gather_67_rule(Parser *p) return _res; } -// _loop0_70: ',' key_value_pattern +// _loop0_71: ',' key_value_pattern static asdl_seq * -_loop0_70_rule(Parser *p) +_loop0_71_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21059,7 +21250,7 @@ _loop0_70_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); + D(fprintf(stderr, "%*c> _loop0_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); Token * _literal; void *elem; while ( @@ -21090,7 +21281,7 @@ _loop0_70_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_70[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_71[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' key_value_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21103,14 +21294,14 @@ _loop0_70_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_70_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_71_type, _seq); D(p->level--); return _seq; } -// _gather_69: key_value_pattern _loop0_70 +// _gather_70: key_value_pattern _loop0_71 static asdl_seq * -_gather_69_rule(Parser *p) +_gather_70_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21119,27 +21310,27 @@ _gather_69_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // key_value_pattern _loop0_70 + { // key_value_pattern _loop0_71 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_70")); + D(fprintf(stderr, "%*c> _gather_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_71")); void *elem; asdl_seq * seq; if ( (elem = key_value_pattern_rule(p)) // key_value_pattern && - (seq = _loop0_70_rule(p)) // _loop0_70 + (seq = _loop0_71_rule(p)) // _loop0_71 ) { - D(fprintf(stderr, "%*c+ _gather_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_70")); + D(fprintf(stderr, "%*c+ _gather_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_71")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_69[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_70")); + D(fprintf(stderr, "%*c%s _gather_70[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_71")); } _res = NULL; done: @@ -21147,9 +21338,9 @@ _gather_69_rule(Parser *p) return _res; } -// _tmp_71: '*' | '**' +// _tmp_72: '*' | '**' static void * -_tmp_71_rule(Parser *p) +_tmp_72_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21163,18 +21354,18 @@ _tmp_71_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); + D(fprintf(stderr, "%*c> _tmp_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' ) { - D(fprintf(stderr, "%*c+ _tmp_71[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); + D(fprintf(stderr, "%*c+ _tmp_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_71[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_72[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); } { // '**' @@ -21182,18 +21373,18 @@ _tmp_71_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_71[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_71[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_72[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -21202,9 +21393,9 @@ _tmp_71_rule(Parser *p) return _res; } -// _tmp_72: literal_pattern | constant_pattern +// _tmp_73: literal_pattern | constant_pattern static void * -_tmp_72_rule(Parser *p) +_tmp_73_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21218,18 +21409,18 @@ _tmp_72_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + D(fprintf(stderr, "%*c> _tmp_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); void *literal_pattern_var; if ( (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + D(fprintf(stderr, "%*c+ _tmp_73[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); _res = literal_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_72[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_73[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern")); } { // constant_pattern @@ -21237,18 +21428,18 @@ _tmp_72_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern")); + D(fprintf(stderr, "%*c> _tmp_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern")); void *constant_pattern_var; if ( (constant_pattern_var = constant_pattern_rule(p)) // constant_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "constant_pattern")); + D(fprintf(stderr, "%*c+ _tmp_73[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "constant_pattern")); _res = constant_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_72[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_73[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "constant_pattern")); } _res = NULL; @@ -21257,9 +21448,9 @@ _tmp_72_rule(Parser *p) return _res; } -// _tmp_73: 'from' expression +// _tmp_74: 'from' expression static void * -_tmp_73_rule(Parser *p) +_tmp_74_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21273,7 +21464,7 @@ _tmp_73_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); + D(fprintf(stderr, "%*c> _tmp_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); Token * _keyword; expr_ty z; if ( @@ -21282,7 +21473,7 @@ _tmp_73_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_73[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); + D(fprintf(stderr, "%*c+ _tmp_74[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21292,7 +21483,7 @@ _tmp_73_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_73[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_74[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression")); } _res = NULL; @@ -21301,9 +21492,9 @@ _tmp_73_rule(Parser *p) return _res; } -// _tmp_74: '->' expression +// _tmp_75: '->' expression static void * -_tmp_74_rule(Parser *p) +_tmp_75_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21317,7 +21508,7 @@ _tmp_74_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -21326,7 +21517,7 @@ _tmp_74_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_74[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_75[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21336,7 +21527,7 @@ _tmp_74_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_74[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_75[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -21345,9 +21536,9 @@ _tmp_74_rule(Parser *p) return _res; } -// _tmp_75: '->' expression +// _tmp_76: '->' expression static void * -_tmp_75_rule(Parser *p) +_tmp_76_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21361,7 +21552,7 @@ _tmp_75_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -21370,7 +21561,7 @@ _tmp_75_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_75[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_76[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21380,7 +21571,7 @@ _tmp_75_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_75[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_76[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -21389,9 +21580,9 @@ _tmp_75_rule(Parser *p) return _res; } -// _tmp_76: NEWLINE INDENT +// _tmp_77: NEWLINE INDENT static void * -_tmp_76_rule(Parser *p) +_tmp_77_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21405,7 +21596,7 @@ _tmp_76_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c> _tmp_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); Token * indent_var; Token * newline_var; if ( @@ -21414,12 +21605,12 @@ _tmp_76_rule(Parser *p) (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' ) { - D(fprintf(stderr, "%*c+ _tmp_76[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c+ _tmp_77[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); _res = _PyPegen_dummy_name(p, newline_var, indent_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_76[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_77[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); } _res = NULL; @@ -21428,9 +21619,9 @@ _tmp_76_rule(Parser *p) return _res; } -// _loop0_77: param_no_default +// _loop0_78: param_no_default static asdl_seq * -_loop0_77_rule(Parser *p) +_loop0_78_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21454,7 +21645,7 @@ _loop0_77_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_78[%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 @@ -21476,7 +21667,7 @@ _loop0_77_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_77[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_78[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21489,14 +21680,14 @@ _loop0_77_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_77_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_78_type, _seq); D(p->level--); return _seq; } -// _loop0_78: param_with_default +// _loop0_79: param_with_default static asdl_seq * -_loop0_78_rule(Parser *p) +_loop0_79_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21520,7 +21711,7 @@ _loop0_78_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21542,7 +21733,7 @@ _loop0_78_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_78[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_79[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21555,14 +21746,14 @@ _loop0_78_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_78_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq); D(p->level--); return _seq; } -// _loop0_79: param_with_default +// _loop0_80: param_with_default static asdl_seq * -_loop0_79_rule(Parser *p) +_loop0_80_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21586,7 +21777,7 @@ _loop0_79_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21608,7 +21799,7 @@ _loop0_79_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_79[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_80[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21621,14 +21812,14 @@ _loop0_79_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_80_type, _seq); D(p->level--); return _seq; } -// _loop1_80: param_no_default +// _loop1_81: param_no_default static asdl_seq * -_loop1_80_rule(Parser *p) +_loop1_81_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21652,7 +21843,7 @@ _loop1_80_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_81[%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 @@ -21674,7 +21865,7 @@ _loop1_80_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_80[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -21692,14 +21883,14 @@ _loop1_80_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_80_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq); D(p->level--); return _seq; } -// _loop0_81: param_with_default +// _loop0_82: param_with_default static asdl_seq * -_loop0_81_rule(Parser *p) +_loop0_82_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21723,7 +21914,7 @@ _loop0_81_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21745,7 +21936,7 @@ _loop0_81_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_81[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_82[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21758,14 +21949,14 @@ _loop0_81_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_81_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_82_type, _seq); D(p->level--); return _seq; } -// _loop1_82: param_with_default +// _loop1_83: param_with_default static asdl_seq * -_loop1_82_rule(Parser *p) +_loop1_83_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21789,7 +21980,7 @@ _loop1_82_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21811,7 +22002,7 @@ _loop1_82_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_82[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -21829,14 +22020,14 @@ _loop1_82_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_82_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); D(p->level--); return _seq; } -// _loop1_83: param_no_default +// _loop1_84: param_no_default static asdl_seq * -_loop1_83_rule(Parser *p) +_loop1_84_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21860,7 +22051,7 @@ _loop1_83_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_84[%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 @@ -21882,7 +22073,7 @@ _loop1_83_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -21900,14 +22091,14 @@ _loop1_83_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); D(p->level--); return _seq; } -// _loop1_84: param_no_default +// _loop1_85: param_no_default static asdl_seq * -_loop1_84_rule(Parser *p) +_loop1_85_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21931,7 +22122,7 @@ _loop1_84_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_85[%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 @@ -21953,7 +22144,7 @@ _loop1_84_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_85[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -21971,14 +22162,14 @@ _loop1_84_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_85_type, _seq); D(p->level--); return _seq; } -// _loop0_85: param_no_default +// _loop0_86: param_no_default static asdl_seq * -_loop0_85_rule(Parser *p) +_loop0_86_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22002,7 +22193,7 @@ _loop0_85_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_86[%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 @@ -22024,7 +22215,7 @@ _loop0_85_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_85[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_86[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22037,14 +22228,14 @@ _loop0_85_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_85_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_86_type, _seq); D(p->level--); return _seq; } -// _loop1_86: param_with_default +// _loop1_87: param_with_default static asdl_seq * -_loop1_86_rule(Parser *p) +_loop1_87_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22068,7 +22259,7 @@ _loop1_86_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -22090,7 +22281,7 @@ _loop1_86_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -22108,14 +22299,14 @@ _loop1_86_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_86_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_87_type, _seq); D(p->level--); return _seq; } -// _loop0_87: param_no_default +// _loop0_88: param_no_default static asdl_seq * -_loop0_87_rule(Parser *p) +_loop0_88_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22139,7 +22330,7 @@ _loop0_87_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_88[%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 @@ -22161,7 +22352,7 @@ _loop0_87_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_87[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_88[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22174,14 +22365,14 @@ _loop0_87_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_87_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_88_type, _seq); D(p->level--); return _seq; } -// _loop1_88: param_with_default +// _loop1_89: param_with_default static asdl_seq * -_loop1_88_rule(Parser *p) +_loop1_89_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22205,7 +22396,7 @@ _loop1_88_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -22227,7 +22418,7 @@ _loop1_88_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_88[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -22245,14 +22436,14 @@ _loop1_88_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_88_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq); D(p->level--); return _seq; } -// _loop0_89: param_maybe_default +// _loop0_90: param_maybe_default static asdl_seq * -_loop0_89_rule(Parser *p) +_loop0_90_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22276,7 +22467,7 @@ _loop0_89_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -22298,7 +22489,7 @@ _loop0_89_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_89[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_90[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22311,14 +22502,14 @@ _loop0_89_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_89_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_90_type, _seq); D(p->level--); return _seq; } -// _loop1_90: param_maybe_default +// _loop1_91: param_maybe_default static asdl_seq * -_loop1_90_rule(Parser *p) +_loop1_91_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22342,7 +22533,7 @@ _loop1_90_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -22364,7 +22555,7 @@ _loop1_90_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_90[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -22382,14 +22573,14 @@ _loop1_90_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_90_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq); D(p->level--); return _seq; } -// _loop1_91: ('@' named_expression NEWLINE) +// _loop1_92: ('@' named_expression NEWLINE) static asdl_seq * -_loop1_91_rule(Parser *p) +_loop1_92_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22413,13 +22604,13 @@ _loop1_91_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); - void *_tmp_170_var; + D(fprintf(stderr, "%*c> _loop1_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); + void *_tmp_171_var; while ( - (_tmp_170_var = _tmp_170_rule(p)) // '@' named_expression NEWLINE + (_tmp_171_var = _tmp_171_rule(p)) // '@' named_expression NEWLINE ) { - _res = _tmp_170_var; + _res = _tmp_171_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22435,7 +22626,7 @@ _loop1_91_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_92[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)")); } if (_n == 0 || p->error_indicator) { @@ -22453,14 +22644,14 @@ _loop1_91_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_92_type, _seq); D(p->level--); return _seq; } -// _tmp_92: '(' arguments? ')' +// _tmp_93: '(' arguments? ')' static void * -_tmp_92_rule(Parser *p) +_tmp_93_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22474,7 +22665,7 @@ _tmp_92_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); Token * _literal; Token * _literal_1; void *z; @@ -22486,7 +22677,7 @@ _tmp_92_rule(Parser *p) (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -22496,7 +22687,7 @@ _tmp_92_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_92[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); } _res = NULL; @@ -22505,9 +22696,9 @@ _tmp_92_rule(Parser *p) return _res; } -// _loop0_94: ',' star_expression +// _loop0_95: ',' star_expression static asdl_seq * -_loop0_94_rule(Parser *p) +_loop0_95_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22531,7 +22722,7 @@ _loop0_94_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _loop0_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty elem; while ( @@ -22562,7 +22753,7 @@ _loop0_94_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_94[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22575,14 +22766,14 @@ _loop0_94_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_94_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_95_type, _seq); D(p->level--); return _seq; } -// _gather_93: star_expression _loop0_94 +// _gather_94: star_expression _loop0_95 static asdl_seq * -_gather_93_rule(Parser *p) +_gather_94_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22591,27 +22782,27 @@ _gather_93_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_expression _loop0_94 + { // star_expression _loop0_95 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_94")); + D(fprintf(stderr, "%*c> _gather_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_95")); expr_ty elem; asdl_seq * seq; if ( (elem = star_expression_rule(p)) // star_expression && - (seq = _loop0_94_rule(p)) // _loop0_94 + (seq = _loop0_95_rule(p)) // _loop0_95 ) { - D(fprintf(stderr, "%*c+ _gather_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_94")); + D(fprintf(stderr, "%*c+ _gather_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_95")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_93[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_94")); + D(fprintf(stderr, "%*c%s _gather_94[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_95")); } _res = NULL; done: @@ -22619,9 +22810,9 @@ _gather_93_rule(Parser *p) return _res; } -// _loop1_95: (',' star_expression) +// _loop1_96: (',' star_expression) static asdl_seq * -_loop1_95_rule(Parser *p) +_loop1_96_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22645,13 +22836,13 @@ _loop1_95_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); - void *_tmp_171_var; + D(fprintf(stderr, "%*c> _loop1_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); + void *_tmp_172_var; while ( - (_tmp_171_var = _tmp_171_rule(p)) // ',' star_expression + (_tmp_172_var = _tmp_172_rule(p)) // ',' star_expression ) { - _res = _tmp_171_var; + _res = _tmp_172_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22667,7 +22858,7 @@ _loop1_95_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_95[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_96[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); } if (_n == 0 || p->error_indicator) { @@ -22685,14 +22876,14 @@ _loop1_95_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_95_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_96_type, _seq); D(p->level--); return _seq; } -// _loop0_97: ',' star_named_expression +// _loop0_98: ',' star_named_expression static asdl_seq * -_loop0_97_rule(Parser *p) +_loop0_98_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22716,7 +22907,7 @@ _loop0_97_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); + D(fprintf(stderr, "%*c> _loop0_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); Token * _literal; expr_ty elem; while ( @@ -22747,7 +22938,7 @@ _loop0_97_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_97[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_98[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22760,14 +22951,14 @@ _loop0_97_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_97_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_98_type, _seq); D(p->level--); return _seq; } -// _gather_96: star_named_expression _loop0_97 +// _gather_97: star_named_expression _loop0_98 static asdl_seq * -_gather_96_rule(Parser *p) +_gather_97_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22776,27 +22967,27 @@ _gather_96_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_named_expression _loop0_97 + { // star_named_expression _loop0_98 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_97")); + D(fprintf(stderr, "%*c> _gather_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_98")); expr_ty elem; asdl_seq * seq; if ( (elem = star_named_expression_rule(p)) // star_named_expression && - (seq = _loop0_97_rule(p)) // _loop0_97 + (seq = _loop0_98_rule(p)) // _loop0_98 ) { - D(fprintf(stderr, "%*c+ _gather_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_97")); + D(fprintf(stderr, "%*c+ _gather_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_98")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_96[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_97")); + D(fprintf(stderr, "%*c%s _gather_97[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_98")); } _res = NULL; done: @@ -22804,9 +22995,9 @@ _gather_96_rule(Parser *p) return _res; } -// _loop1_98: (',' expression) +// _loop1_99: (',' expression) static asdl_seq * -_loop1_98_rule(Parser *p) +_loop1_99_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22830,13 +23021,13 @@ _loop1_98_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); - void *_tmp_172_var; + D(fprintf(stderr, "%*c> _loop1_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); + void *_tmp_173_var; while ( - (_tmp_172_var = _tmp_172_rule(p)) // ',' expression + (_tmp_173_var = _tmp_173_rule(p)) // ',' expression ) { - _res = _tmp_172_var; + _res = _tmp_173_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22852,7 +23043,7 @@ _loop1_98_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_98[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_99[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); } if (_n == 0 || p->error_indicator) { @@ -22870,14 +23061,14 @@ _loop1_98_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_98_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq); D(p->level--); return _seq; } -// _loop0_99: lambda_param_no_default +// _loop0_100: lambda_param_no_default static asdl_seq * -_loop0_99_rule(Parser *p) +_loop0_100_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22901,7 +23092,7 @@ _loop0_99_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_100[%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 @@ -22923,7 +23114,7 @@ _loop0_99_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_99[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_100[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22936,14 +23127,14 @@ _loop0_99_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_99_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_100_type, _seq); D(p->level--); return _seq; } -// _loop0_100: lambda_param_with_default +// _loop0_101: lambda_param_with_default static asdl_seq * -_loop0_100_rule(Parser *p) +_loop0_101_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22967,7 +23158,7 @@ _loop0_100_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -22989,7 +23180,7 @@ _loop0_100_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_100[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_101[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23002,14 +23193,14 @@ _loop0_100_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_100_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_101_type, _seq); D(p->level--); return _seq; } -// _loop0_101: lambda_param_with_default +// _loop0_102: lambda_param_with_default static asdl_seq * -_loop0_101_rule(Parser *p) +_loop0_102_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23033,7 +23224,7 @@ _loop0_101_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23055,7 +23246,7 @@ _loop0_101_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_101[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_102[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23068,14 +23259,14 @@ _loop0_101_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_101_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_102_type, _seq); D(p->level--); return _seq; } -// _loop1_102: lambda_param_no_default +// _loop1_103: lambda_param_no_default static asdl_seq * -_loop1_102_rule(Parser *p) +_loop1_103_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23099,7 +23290,7 @@ _loop1_102_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_103[%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 @@ -23121,7 +23312,7 @@ _loop1_102_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_102[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_103[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -23139,14 +23330,14 @@ _loop1_102_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_102_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_103_type, _seq); D(p->level--); return _seq; } -// _loop0_103: lambda_param_with_default +// _loop0_104: lambda_param_with_default static asdl_seq * -_loop0_103_rule(Parser *p) +_loop0_104_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23170,7 +23361,7 @@ _loop0_103_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23192,7 +23383,7 @@ _loop0_103_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_104[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23205,14 +23396,14 @@ _loop0_103_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_103_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_104_type, _seq); D(p->level--); return _seq; } -// _loop1_104: lambda_param_with_default +// _loop1_105: lambda_param_with_default static asdl_seq * -_loop1_104_rule(Parser *p) +_loop1_105_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23236,7 +23427,7 @@ _loop1_104_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23258,7 +23449,7 @@ _loop1_104_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_104[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -23276,14 +23467,14 @@ _loop1_104_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_104_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq); D(p->level--); return _seq; } -// _loop1_105: lambda_param_no_default +// _loop1_106: lambda_param_no_default static asdl_seq * -_loop1_105_rule(Parser *p) +_loop1_106_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23307,7 +23498,7 @@ _loop1_105_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_106[%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 @@ -23329,7 +23520,7 @@ _loop1_105_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -23347,14 +23538,14 @@ _loop1_105_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_106_type, _seq); D(p->level--); return _seq; } -// _loop1_106: lambda_param_no_default +// _loop1_107: lambda_param_no_default static asdl_seq * -_loop1_106_rule(Parser *p) +_loop1_107_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23378,7 +23569,7 @@ _loop1_106_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_107[%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 @@ -23400,7 +23591,7 @@ _loop1_106_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_107[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -23418,14 +23609,14 @@ _loop1_106_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_106_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_107_type, _seq); D(p->level--); return _seq; } -// _loop0_107: lambda_param_no_default +// _loop0_108: lambda_param_no_default static asdl_seq * -_loop0_107_rule(Parser *p) +_loop0_108_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23449,7 +23640,7 @@ _loop0_107_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_108[%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 @@ -23471,7 +23662,7 @@ _loop0_107_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_107[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_108[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23484,14 +23675,14 @@ _loop0_107_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_107_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_108_type, _seq); D(p->level--); return _seq; } -// _loop1_108: lambda_param_with_default +// _loop1_109: lambda_param_with_default static asdl_seq * -_loop1_108_rule(Parser *p) +_loop1_109_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23515,7 +23706,7 @@ _loop1_108_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23537,7 +23728,7 @@ _loop1_108_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_108[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_109[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -23555,14 +23746,14 @@ _loop1_108_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_108_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_109_type, _seq); D(p->level--); return _seq; } -// _loop0_109: lambda_param_no_default +// _loop0_110: lambda_param_no_default static asdl_seq * -_loop0_109_rule(Parser *p) +_loop0_110_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23586,7 +23777,7 @@ _loop0_109_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_110[%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 @@ -23608,7 +23799,7 @@ _loop0_109_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_109[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_110[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23621,14 +23812,14 @@ _loop0_109_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_109_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq); D(p->level--); return _seq; } -// _loop1_110: lambda_param_with_default +// _loop1_111: lambda_param_with_default static asdl_seq * -_loop1_110_rule(Parser *p) +_loop1_111_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23652,7 +23843,7 @@ _loop1_110_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23674,7 +23865,7 @@ _loop1_110_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_110[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_111[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -23692,14 +23883,14 @@ _loop1_110_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_110_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_111_type, _seq); D(p->level--); return _seq; } -// _loop0_111: lambda_param_maybe_default +// _loop0_112: lambda_param_maybe_default static asdl_seq * -_loop0_111_rule(Parser *p) +_loop0_112_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23723,7 +23914,7 @@ _loop0_111_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -23745,7 +23936,7 @@ _loop0_111_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_111[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23758,14 +23949,14 @@ _loop0_111_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_111_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq); D(p->level--); return _seq; } -// _loop1_112: lambda_param_maybe_default +// _loop1_113: lambda_param_maybe_default static asdl_seq * -_loop1_112_rule(Parser *p) +_loop1_113_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23789,7 +23980,7 @@ _loop1_112_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -23811,7 +24002,7 @@ _loop1_112_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_112[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_113[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -23829,14 +24020,14 @@ _loop1_112_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_112_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_113_type, _seq); D(p->level--); return _seq; } -// _loop1_113: ('or' conjunction) +// _loop1_114: ('or' conjunction) static asdl_seq * -_loop1_113_rule(Parser *p) +_loop1_114_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23860,13 +24051,13 @@ _loop1_113_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); - void *_tmp_173_var; + D(fprintf(stderr, "%*c> _loop1_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); + void *_tmp_174_var; while ( - (_tmp_173_var = _tmp_173_rule(p)) // 'or' conjunction + (_tmp_174_var = _tmp_174_rule(p)) // 'or' conjunction ) { - _res = _tmp_173_var; + _res = _tmp_174_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23882,7 +24073,7 @@ _loop1_113_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_113[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_114[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); } if (_n == 0 || p->error_indicator) { @@ -23900,14 +24091,14 @@ _loop1_113_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_113_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_114_type, _seq); D(p->level--); return _seq; } -// _loop1_114: ('and' inversion) +// _loop1_115: ('and' inversion) static asdl_seq * -_loop1_114_rule(Parser *p) +_loop1_115_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23931,13 +24122,13 @@ _loop1_114_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); - void *_tmp_174_var; + D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); + void *_tmp_175_var; while ( - (_tmp_174_var = _tmp_174_rule(p)) // 'and' inversion + (_tmp_175_var = _tmp_175_rule(p)) // 'and' inversion ) { - _res = _tmp_174_var; + _res = _tmp_175_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23953,7 +24144,7 @@ _loop1_114_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_114[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); } if (_n == 0 || p->error_indicator) { @@ -23971,14 +24162,14 @@ _loop1_114_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_114_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_115_type, _seq); D(p->level--); return _seq; } -// _loop1_115: compare_op_bitwise_or_pair +// _loop1_116: compare_op_bitwise_or_pair static asdl_seq * -_loop1_115_rule(Parser *p) +_loop1_116_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24002,7 +24193,7 @@ _loop1_115_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); + D(fprintf(stderr, "%*c> _loop1_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); CmpopExprPair* compare_op_bitwise_or_pair_var; while ( (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair @@ -24024,7 +24215,7 @@ _loop1_115_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_116[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); } if (_n == 0 || p->error_indicator) { @@ -24042,14 +24233,14 @@ _loop1_115_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_115_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_116_type, _seq); D(p->level--); return _seq; } -// _tmp_116: '!=' +// _tmp_117: '!=' static void * -_tmp_116_rule(Parser *p) +_tmp_117_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24063,13 +24254,13 @@ _tmp_116_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); Token * tok; if ( (tok = _PyPegen_expect_token(p, 28)) // token='!=' ) { - D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -24079,7 +24270,7 @@ _tmp_116_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); } _res = NULL; @@ -24088,9 +24279,9 @@ _tmp_116_rule(Parser *p) return _res; } -// _loop0_118: ',' slice +// _loop0_119: ',' slice static asdl_seq * -_loop0_118_rule(Parser *p) +_loop0_119_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24114,7 +24305,7 @@ _loop0_118_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); + D(fprintf(stderr, "%*c> _loop0_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); Token * _literal; expr_ty elem; while ( @@ -24145,7 +24336,7 @@ _loop0_118_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_118[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_119[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' slice")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24158,14 +24349,14 @@ _loop0_118_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_118_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq); D(p->level--); return _seq; } -// _gather_117: slice _loop0_118 +// _gather_118: slice _loop0_119 static asdl_seq * -_gather_117_rule(Parser *p) +_gather_118_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24174,27 +24365,27 @@ _gather_117_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // slice _loop0_118 + { // slice _loop0_119 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_118")); + D(fprintf(stderr, "%*c> _gather_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_119")); expr_ty elem; asdl_seq * seq; if ( (elem = slice_rule(p)) // slice && - (seq = _loop0_118_rule(p)) // _loop0_118 + (seq = _loop0_119_rule(p)) // _loop0_119 ) { - D(fprintf(stderr, "%*c+ _gather_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_118")); + D(fprintf(stderr, "%*c+ _gather_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_119")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_117[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_118")); + D(fprintf(stderr, "%*c%s _gather_118[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_119")); } _res = NULL; done: @@ -24202,9 +24393,9 @@ _gather_117_rule(Parser *p) return _res; } -// _tmp_119: ':' expression? +// _tmp_120: ':' expression? static void * -_tmp_119_rule(Parser *p) +_tmp_120_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24218,7 +24409,7 @@ _tmp_119_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); Token * _literal; void *d; if ( @@ -24227,7 +24418,7 @@ _tmp_119_rule(Parser *p) (d = expression_rule(p), 1) // expression? ) { - D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); _res = d; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -24237,7 +24428,7 @@ _tmp_119_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); } _res = NULL; @@ -24246,9 +24437,9 @@ _tmp_119_rule(Parser *p) return _res; } -// _tmp_120: tuple | group | genexp +// _tmp_121: tuple | group | genexp static void * -_tmp_120_rule(Parser *p) +_tmp_121_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24262,18 +24453,18 @@ _tmp_120_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); expr_ty tuple_var; if ( (tuple_var = tuple_rule(p)) // tuple ) { - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); _res = tuple_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); } { // group @@ -24281,18 +24472,18 @@ _tmp_120_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); expr_ty group_var; if ( (group_var = group_rule(p)) // group ) { - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); _res = group_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group")); } { // genexp @@ -24300,18 +24491,18 @@ _tmp_120_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); expr_ty genexp_var; if ( (genexp_var = genexp_rule(p)) // genexp ) { - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); _res = genexp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); } _res = NULL; @@ -24320,9 +24511,9 @@ _tmp_120_rule(Parser *p) return _res; } -// _tmp_121: list | listcomp +// _tmp_122: list | listcomp static void * -_tmp_121_rule(Parser *p) +_tmp_122_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24336,18 +24527,18 @@ _tmp_121_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); expr_ty list_var; if ( (list_var = list_rule(p)) // list ) { - D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); _res = list_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); } { // listcomp @@ -24355,18 +24546,18 @@ _tmp_121_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); expr_ty listcomp_var; if ( (listcomp_var = listcomp_rule(p)) // listcomp ) { - D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); _res = listcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp")); } _res = NULL; @@ -24375,9 +24566,9 @@ _tmp_121_rule(Parser *p) return _res; } -// _tmp_122: dict | set | dictcomp | setcomp +// _tmp_123: dict | set | dictcomp | setcomp static void * -_tmp_122_rule(Parser *p) +_tmp_123_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24391,18 +24582,18 @@ _tmp_122_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); expr_ty dict_var; if ( (dict_var = dict_rule(p)) // dict ) { - D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); _res = dict_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict")); } { // set @@ -24410,18 +24601,18 @@ _tmp_122_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); expr_ty set_var; if ( (set_var = set_rule(p)) // set ) { - D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); _res = set_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set")); } { // dictcomp @@ -24429,18 +24620,18 @@ _tmp_122_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); expr_ty dictcomp_var; if ( (dictcomp_var = dictcomp_rule(p)) // dictcomp ) { - D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); _res = dictcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp")); } { // setcomp @@ -24448,18 +24639,18 @@ _tmp_122_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); expr_ty setcomp_var; if ( (setcomp_var = setcomp_rule(p)) // setcomp ) { - D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); _res = setcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp")); } _res = NULL; @@ -24468,9 +24659,9 @@ _tmp_122_rule(Parser *p) return _res; } -// _loop1_123: STRING +// _loop1_124: STRING static asdl_seq * -_loop1_123_rule(Parser *p) +_loop1_124_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24494,7 +24685,7 @@ _loop1_123_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); + D(fprintf(stderr, "%*c> _loop1_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); expr_ty string_var; while ( (string_var = _PyPegen_string_token(p)) // STRING @@ -24516,7 +24707,7 @@ _loop1_123_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_124[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); } if (_n == 0 || p->error_indicator) { @@ -24534,14 +24725,14 @@ _loop1_123_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_123_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_124_type, _seq); D(p->level--); return _seq; } -// _tmp_124: star_named_expression ',' star_named_expressions? +// _tmp_125: star_named_expression ',' star_named_expressions? static void * -_tmp_124_rule(Parser *p) +_tmp_125_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24555,7 +24746,7 @@ _tmp_124_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); Token * _literal; expr_ty y; void *z; @@ -24567,7 +24758,7 @@ _tmp_124_rule(Parser *p) (z = star_named_expressions_rule(p), 1) // star_named_expressions? ) { - D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); _res = _PyPegen_seq_insert_in_front ( p , y , z ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -24577,7 +24768,7 @@ _tmp_124_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); } _res = NULL; @@ -24586,9 +24777,9 @@ _tmp_124_rule(Parser *p) return _res; } -// _tmp_125: yield_expr | named_expression +// _tmp_126: yield_expr | named_expression static void * -_tmp_125_rule(Parser *p) +_tmp_126_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24602,18 +24793,18 @@ _tmp_125_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // named_expression @@ -24621,18 +24812,18 @@ _tmp_125_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); expr_ty named_expression_var; if ( (named_expression_var = named_expression_rule(p)) // named_expression ) { - D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); _res = named_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); } _res = NULL; @@ -24641,9 +24832,9 @@ _tmp_125_rule(Parser *p) return _res; } -// _loop0_127: ',' double_starred_kvpair +// _loop0_128: ',' double_starred_kvpair static asdl_seq * -_loop0_127_rule(Parser *p) +_loop0_128_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24667,7 +24858,7 @@ _loop0_127_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); + D(fprintf(stderr, "%*c> _loop0_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); Token * _literal; KeyValuePair* elem; while ( @@ -24698,7 +24889,7 @@ _loop0_127_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_127[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_128[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24711,14 +24902,14 @@ _loop0_127_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_127_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_128_type, _seq); D(p->level--); return _seq; } -// _gather_126: double_starred_kvpair _loop0_127 +// _gather_127: double_starred_kvpair _loop0_128 static asdl_seq * -_gather_126_rule(Parser *p) +_gather_127_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24727,27 +24918,27 @@ _gather_126_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // double_starred_kvpair _loop0_127 + { // double_starred_kvpair _loop0_128 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_127")); + D(fprintf(stderr, "%*c> _gather_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_128")); KeyValuePair* elem; asdl_seq * seq; if ( (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair && - (seq = _loop0_127_rule(p)) // _loop0_127 + (seq = _loop0_128_rule(p)) // _loop0_128 ) { - D(fprintf(stderr, "%*c+ _gather_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_127")); + D(fprintf(stderr, "%*c+ _gather_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_128")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_126[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_127")); + D(fprintf(stderr, "%*c%s _gather_127[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_128")); } _res = NULL; done: @@ -24755,9 +24946,9 @@ _gather_126_rule(Parser *p) return _res; } -// _loop1_128: for_if_clause +// _loop1_129: for_if_clause static asdl_seq * -_loop1_128_rule(Parser *p) +_loop1_129_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24781,7 +24972,7 @@ _loop1_128_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); + D(fprintf(stderr, "%*c> _loop1_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); comprehension_ty for_if_clause_var; while ( (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause @@ -24803,7 +24994,7 @@ _loop1_128_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_128[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_129[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); } if (_n == 0 || p->error_indicator) { @@ -24821,14 +25012,14 @@ _loop1_128_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_128_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_129_type, _seq); D(p->level--); return _seq; } -// _loop0_129: ('if' disjunction) +// _loop0_130: ('if' disjunction) static asdl_seq * -_loop0_129_rule(Parser *p) +_loop0_130_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24852,13 +25043,13 @@ _loop0_129_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_175_var; + D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_176_var; while ( - (_tmp_175_var = _tmp_175_rule(p)) // 'if' disjunction + (_tmp_176_var = _tmp_176_rule(p)) // 'if' disjunction ) { - _res = _tmp_175_var; + _res = _tmp_176_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24874,7 +25065,7 @@ _loop0_129_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_129[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24887,14 +25078,14 @@ _loop0_129_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_129_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq); D(p->level--); return _seq; } -// _loop0_130: ('if' disjunction) +// _loop0_131: ('if' disjunction) static asdl_seq * -_loop0_130_rule(Parser *p) +_loop0_131_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24918,13 +25109,13 @@ _loop0_130_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_176_var; + D(fprintf(stderr, "%*c> _loop0_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_177_var; while ( - (_tmp_176_var = _tmp_176_rule(p)) // 'if' disjunction + (_tmp_177_var = _tmp_177_rule(p)) // 'if' disjunction ) { - _res = _tmp_176_var; + _res = _tmp_177_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24940,7 +25131,7 @@ _loop0_130_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_131[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24953,14 +25144,14 @@ _loop0_130_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_131_type, _seq); D(p->level--); return _seq; } -// _tmp_131: ',' args +// _tmp_132: ',' args static void * -_tmp_131_rule(Parser *p) +_tmp_132_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24974,7 +25165,7 @@ _tmp_131_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c> _tmp_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); Token * _literal; expr_ty c; if ( @@ -24983,7 +25174,7 @@ _tmp_131_rule(Parser *p) (c = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c+ _tmp_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -24993,7 +25184,7 @@ _tmp_131_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_132[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); } _res = NULL; @@ -25002,9 +25193,9 @@ _tmp_131_rule(Parser *p) return _res; } -// _tmp_132: ',' args +// _tmp_133: ',' args static void * -_tmp_132_rule(Parser *p) +_tmp_133_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25018,7 +25209,7 @@ _tmp_132_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); Token * _literal; expr_ty c; if ( @@ -25027,7 +25218,7 @@ _tmp_132_rule(Parser *p) (c = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25037,7 +25228,7 @@ _tmp_132_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_132[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); } _res = NULL; @@ -25046,9 +25237,9 @@ _tmp_132_rule(Parser *p) return _res; } -// _loop0_134: ',' kwarg_or_starred +// _loop0_135: ',' kwarg_or_starred static asdl_seq * -_loop0_134_rule(Parser *p) +_loop0_135_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25072,7 +25263,7 @@ _loop0_134_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -25103,7 +25294,7 @@ _loop0_134_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_134[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_135[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25116,14 +25307,14 @@ _loop0_134_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_134_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_135_type, _seq); D(p->level--); return _seq; } -// _gather_133: kwarg_or_starred _loop0_134 +// _gather_134: kwarg_or_starred _loop0_135 static asdl_seq * -_gather_133_rule(Parser *p) +_gather_134_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25132,27 +25323,27 @@ _gather_133_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_134 + { // kwarg_or_starred _loop0_135 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_134")); + D(fprintf(stderr, "%*c> _gather_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_135")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_134_rule(p)) // _loop0_134 + (seq = _loop0_135_rule(p)) // _loop0_135 ) { - D(fprintf(stderr, "%*c+ _gather_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_134")); + D(fprintf(stderr, "%*c+ _gather_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_135")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_133[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_134")); + D(fprintf(stderr, "%*c%s _gather_134[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_135")); } _res = NULL; done: @@ -25160,9 +25351,9 @@ _gather_133_rule(Parser *p) return _res; } -// _loop0_136: ',' kwarg_or_double_starred +// _loop0_137: ',' kwarg_or_double_starred static asdl_seq * -_loop0_136_rule(Parser *p) +_loop0_137_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25186,7 +25377,7 @@ _loop0_136_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -25217,7 +25408,7 @@ _loop0_136_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_136[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_137[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25230,14 +25421,14 @@ _loop0_136_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_136_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_137_type, _seq); D(p->level--); return _seq; } -// _gather_135: kwarg_or_double_starred _loop0_136 +// _gather_136: kwarg_or_double_starred _loop0_137 static asdl_seq * -_gather_135_rule(Parser *p) +_gather_136_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25246,27 +25437,27 @@ _gather_135_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_136 + { // kwarg_or_double_starred _loop0_137 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_136")); + D(fprintf(stderr, "%*c> _gather_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_137")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_136_rule(p)) // _loop0_136 + (seq = _loop0_137_rule(p)) // _loop0_137 ) { - D(fprintf(stderr, "%*c+ _gather_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_136")); + D(fprintf(stderr, "%*c+ _gather_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_137")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_135[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_136")); + D(fprintf(stderr, "%*c%s _gather_136[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_137")); } _res = NULL; done: @@ -25274,9 +25465,9 @@ _gather_135_rule(Parser *p) return _res; } -// _loop0_138: ',' kwarg_or_starred +// _loop0_139: ',' kwarg_or_starred static asdl_seq * -_loop0_138_rule(Parser *p) +_loop0_139_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25300,7 +25491,7 @@ _loop0_138_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -25331,7 +25522,7 @@ _loop0_138_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_138[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_139[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25344,14 +25535,14 @@ _loop0_138_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_138_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_139_type, _seq); D(p->level--); return _seq; } -// _gather_137: kwarg_or_starred _loop0_138 +// _gather_138: kwarg_or_starred _loop0_139 static asdl_seq * -_gather_137_rule(Parser *p) +_gather_138_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25360,27 +25551,27 @@ _gather_137_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_138 + { // kwarg_or_starred _loop0_139 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_138")); + D(fprintf(stderr, "%*c> _gather_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_139")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_138_rule(p)) // _loop0_138 + (seq = _loop0_139_rule(p)) // _loop0_139 ) { - D(fprintf(stderr, "%*c+ _gather_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_138")); + D(fprintf(stderr, "%*c+ _gather_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_139")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_137[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_138")); + D(fprintf(stderr, "%*c%s _gather_138[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_139")); } _res = NULL; done: @@ -25388,9 +25579,9 @@ _gather_137_rule(Parser *p) return _res; } -// _loop0_140: ',' kwarg_or_double_starred +// _loop0_141: ',' kwarg_or_double_starred static asdl_seq * -_loop0_140_rule(Parser *p) +_loop0_141_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25414,7 +25605,7 @@ _loop0_140_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -25445,7 +25636,7 @@ _loop0_140_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_140[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_141[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25458,14 +25649,14 @@ _loop0_140_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_140_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_141_type, _seq); D(p->level--); return _seq; } -// _gather_139: kwarg_or_double_starred _loop0_140 +// _gather_140: kwarg_or_double_starred _loop0_141 static asdl_seq * -_gather_139_rule(Parser *p) +_gather_140_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25474,27 +25665,27 @@ _gather_139_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_140 + { // kwarg_or_double_starred _loop0_141 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_140")); + D(fprintf(stderr, "%*c> _gather_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_141")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_140_rule(p)) // _loop0_140 + (seq = _loop0_141_rule(p)) // _loop0_141 ) { - D(fprintf(stderr, "%*c+ _gather_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_140")); + D(fprintf(stderr, "%*c+ _gather_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_141")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_139[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_140")); + D(fprintf(stderr, "%*c%s _gather_140[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_141")); } _res = NULL; done: @@ -25502,9 +25693,9 @@ _gather_139_rule(Parser *p) return _res; } -// _loop0_141: (',' star_target) +// _loop0_142: (',' star_target) static asdl_seq * -_loop0_141_rule(Parser *p) +_loop0_142_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25528,13 +25719,13 @@ _loop0_141_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_177_var; + D(fprintf(stderr, "%*c> _loop0_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_178_var; while ( - (_tmp_177_var = _tmp_177_rule(p)) // ',' star_target + (_tmp_178_var = _tmp_178_rule(p)) // ',' star_target ) { - _res = _tmp_177_var; + _res = _tmp_178_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -25550,7 +25741,7 @@ _loop0_141_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_141[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_142[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25563,14 +25754,14 @@ _loop0_141_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_141_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_142_type, _seq); D(p->level--); return _seq; } -// _loop0_143: ',' star_target +// _loop0_144: ',' star_target static asdl_seq * -_loop0_143_rule(Parser *p) +_loop0_144_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25594,7 +25785,7 @@ _loop0_143_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _loop0_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty elem; while ( @@ -25625,7 +25816,7 @@ _loop0_143_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_143[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_144[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25638,14 +25829,14 @@ _loop0_143_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_143_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_144_type, _seq); D(p->level--); return _seq; } -// _gather_142: star_target _loop0_143 +// _gather_143: star_target _loop0_144 static asdl_seq * -_gather_142_rule(Parser *p) +_gather_143_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25654,27 +25845,27 @@ _gather_142_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_target _loop0_143 + { // star_target _loop0_144 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_143")); + D(fprintf(stderr, "%*c> _gather_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_144")); expr_ty elem; asdl_seq * seq; if ( (elem = star_target_rule(p)) // star_target && - (seq = _loop0_143_rule(p)) // _loop0_143 + (seq = _loop0_144_rule(p)) // _loop0_144 ) { - D(fprintf(stderr, "%*c+ _gather_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_143")); + D(fprintf(stderr, "%*c+ _gather_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_144")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_142[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_143")); + D(fprintf(stderr, "%*c%s _gather_143[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_144")); } _res = NULL; done: @@ -25682,9 +25873,9 @@ _gather_142_rule(Parser *p) return _res; } -// _tmp_144: !'*' star_target +// _tmp_145: !'*' star_target static void * -_tmp_144_rule(Parser *p) +_tmp_145_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25698,7 +25889,7 @@ _tmp_144_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); expr_ty star_target_var; if ( _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' @@ -25706,12 +25897,12 @@ _tmp_144_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); _res = star_target_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); } _res = NULL; @@ -25720,9 +25911,9 @@ _tmp_144_rule(Parser *p) return _res; } -// _loop0_146: ',' del_target +// _loop0_147: ',' del_target static asdl_seq * -_loop0_146_rule(Parser *p) +_loop0_147_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25746,7 +25937,7 @@ _loop0_146_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); + D(fprintf(stderr, "%*c> _loop0_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); Token * _literal; expr_ty elem; while ( @@ -25777,7 +25968,7 @@ _loop0_146_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_146[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_147[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25790,14 +25981,14 @@ _loop0_146_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_146_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_147_type, _seq); D(p->level--); return _seq; } -// _gather_145: del_target _loop0_146 +// _gather_146: del_target _loop0_147 static asdl_seq * -_gather_145_rule(Parser *p) +_gather_146_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25806,27 +25997,27 @@ _gather_145_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // del_target _loop0_146 + { // del_target _loop0_147 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_146")); + D(fprintf(stderr, "%*c> _gather_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_147")); expr_ty elem; asdl_seq * seq; if ( (elem = del_target_rule(p)) // del_target && - (seq = _loop0_146_rule(p)) // _loop0_146 + (seq = _loop0_147_rule(p)) // _loop0_147 ) { - D(fprintf(stderr, "%*c+ _gather_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_146")); + D(fprintf(stderr, "%*c+ _gather_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_147")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_145[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_146")); + D(fprintf(stderr, "%*c%s _gather_146[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_147")); } _res = NULL; done: @@ -25834,9 +26025,9 @@ _gather_145_rule(Parser *p) return _res; } -// _loop0_148: ',' target +// _loop0_149: ',' target static asdl_seq * -_loop0_148_rule(Parser *p) +_loop0_149_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25860,7 +26051,7 @@ _loop0_148_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); + D(fprintf(stderr, "%*c> _loop0_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); Token * _literal; expr_ty elem; while ( @@ -25891,7 +26082,7 @@ _loop0_148_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_148[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_149[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25904,14 +26095,14 @@ _loop0_148_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_148_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_149_type, _seq); D(p->level--); return _seq; } -// _gather_147: target _loop0_148 +// _gather_148: target _loop0_149 static asdl_seq * -_gather_147_rule(Parser *p) +_gather_148_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25920,27 +26111,27 @@ _gather_147_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // target _loop0_148 + { // target _loop0_149 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_148")); + D(fprintf(stderr, "%*c> _gather_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_149")); expr_ty elem; asdl_seq * seq; if ( (elem = target_rule(p)) // target && - (seq = _loop0_148_rule(p)) // _loop0_148 + (seq = _loop0_149_rule(p)) // _loop0_149 ) { - D(fprintf(stderr, "%*c+ _gather_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_148")); + D(fprintf(stderr, "%*c+ _gather_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_149")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_147[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_148")); + D(fprintf(stderr, "%*c%s _gather_148[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_149")); } _res = NULL; done: @@ -25948,9 +26139,9 @@ _gather_147_rule(Parser *p) return _res; } -// _tmp_149: args | expression for_if_clauses +// _tmp_150: args | expression for_if_clauses static void * -_tmp_149_rule(Parser *p) +_tmp_150_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25964,18 +26155,18 @@ _tmp_149_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); expr_ty args_var; if ( (args_var = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); _res = args_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); } { // expression for_if_clauses @@ -25983,7 +26174,7 @@ _tmp_149_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); expr_ty expression_var; asdl_seq* for_if_clauses_var; if ( @@ -25992,12 +26183,12 @@ _tmp_149_rule(Parser *p) (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses ) { - D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); } _res = NULL; @@ -26006,9 +26197,9 @@ _tmp_149_rule(Parser *p) return _res; } -// _loop0_150: star_named_expressions +// _loop0_151: star_named_expressions static asdl_seq * -_loop0_150_rule(Parser *p) +_loop0_151_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26032,7 +26223,7 @@ _loop0_150_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); + D(fprintf(stderr, "%*c> _loop0_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); asdl_seq* star_named_expressions_var; while ( (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions @@ -26054,7 +26245,7 @@ _loop0_150_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_150[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_151[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26067,14 +26258,14 @@ _loop0_150_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_150_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_151_type, _seq); D(p->level--); return _seq; } -// _tmp_151: '=' annotated_rhs +// _tmp_152: '=' annotated_rhs static void * -_tmp_151_rule(Parser *p) +_tmp_152_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26088,7 +26279,7 @@ _tmp_151_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); Token * _literal; expr_ty annotated_rhs_var; if ( @@ -26097,12 +26288,12 @@ _tmp_151_rule(Parser *p) (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs ) { - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); } _res = NULL; @@ -26111,9 +26302,9 @@ _tmp_151_rule(Parser *p) return _res; } -// _tmp_152: yield_expr | star_expressions +// _tmp_153: yield_expr | star_expressions static void * -_tmp_152_rule(Parser *p) +_tmp_153_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26127,18 +26318,18 @@ _tmp_152_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -26146,18 +26337,18 @@ _tmp_152_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -26166,9 +26357,9 @@ _tmp_152_rule(Parser *p) return _res; } -// _tmp_153: yield_expr | star_expressions +// _tmp_154: yield_expr | star_expressions static void * -_tmp_153_rule(Parser *p) +_tmp_154_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26182,18 +26373,18 @@ _tmp_153_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -26201,18 +26392,18 @@ _tmp_153_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -26221,9 +26412,9 @@ _tmp_153_rule(Parser *p) return _res; } -// _tmp_154: '[' | '(' | '{' +// _tmp_155: '[' | '(' | '{' static void * -_tmp_154_rule(Parser *p) +_tmp_155_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26237,18 +26428,18 @@ _tmp_154_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); } { // '(' @@ -26256,18 +26447,18 @@ _tmp_154_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' ) { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } { // '{' @@ -26275,18 +26466,18 @@ _tmp_154_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' ) { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); } _res = NULL; @@ -26295,9 +26486,9 @@ _tmp_154_rule(Parser *p) return _res; } -// _loop0_155: param_no_default +// _loop0_156: param_no_default static asdl_seq * -_loop0_155_rule(Parser *p) +_loop0_156_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26321,7 +26512,7 @@ _loop0_155_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_156[%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 @@ -26343,7 +26534,7 @@ _loop0_155_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_155[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_156[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26356,14 +26547,14 @@ _loop0_155_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_155_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_156_type, _seq); D(p->level--); return _seq; } -// _tmp_156: slash_with_default | param_with_default+ +// _tmp_157: slash_with_default | param_with_default+ static void * -_tmp_156_rule(Parser *p) +_tmp_157_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26377,18 +26568,18 @@ _tmp_156_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c> _tmp_157[%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_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c+ _tmp_157[%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_156[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); } { // param_with_default+ @@ -26396,18 +26587,18 @@ _tmp_156_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - asdl_seq * _loop1_178_var; + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + asdl_seq * _loop1_179_var; if ( - (_loop1_178_var = _loop1_178_rule(p)) // param_with_default+ + (_loop1_179_var = _loop1_179_rule(p)) // param_with_default+ ) { - D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - _res = _loop1_178_var; + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + _res = _loop1_179_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+")); } _res = NULL; @@ -26416,9 +26607,9 @@ _tmp_156_rule(Parser *p) return _res; } -// _tmp_157: ')' | ',' (')' | '**') +// _tmp_158: ')' | ',' (')' | '**') static void * -_tmp_157_rule(Parser *p) +_tmp_158_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26432,18 +26623,18 @@ _tmp_157_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // ',' (')' | '**') @@ -26451,21 +26642,21 @@ _tmp_157_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); Token * _literal; - void *_tmp_179_var; + void *_tmp_180_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_179_var = _tmp_179_rule(p)) // ')' | '**' + (_tmp_180_var = _tmp_180_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_179_var); + D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_180_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); } _res = NULL; @@ -26474,9 +26665,9 @@ _tmp_157_rule(Parser *p) return _res; } -// _tmp_158: ':' | ',' (':' | '**') +// _tmp_159: ':' | ',' (':' | '**') static void * -_tmp_158_rule(Parser *p) +_tmp_159_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26490,18 +26681,18 @@ _tmp_158_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // ',' (':' | '**') @@ -26509,21 +26700,21 @@ _tmp_158_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); Token * _literal; - void *_tmp_180_var; + void *_tmp_181_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_180_var = _tmp_180_rule(p)) // ':' | '**' + (_tmp_181_var = _tmp_181_rule(p)) // ':' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_180_var); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_181_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); } _res = NULL; @@ -26532,9 +26723,9 @@ _tmp_158_rule(Parser *p) return _res; } -// _tmp_159: star_targets '=' +// _tmp_160: star_targets '=' static void * -_tmp_159_rule(Parser *p) +_tmp_160_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26548,7 +26739,7 @@ _tmp_159_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty z; if ( @@ -26557,7 +26748,7 @@ _tmp_159_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26567,7 +26758,7 @@ _tmp_159_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -26576,9 +26767,9 @@ _tmp_159_rule(Parser *p) return _res; } -// _tmp_160: '.' | '...' +// _tmp_161: '.' | '...' static void * -_tmp_160_rule(Parser *p) +_tmp_161_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26592,18 +26783,18 @@ _tmp_160_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -26611,18 +26802,18 @@ _tmp_160_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -26631,9 +26822,9 @@ _tmp_160_rule(Parser *p) return _res; } -// _tmp_161: '.' | '...' +// _tmp_162: '.' | '...' static void * -_tmp_161_rule(Parser *p) +_tmp_162_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26647,18 +26838,18 @@ _tmp_161_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -26666,18 +26857,18 @@ _tmp_161_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -26686,9 +26877,9 @@ _tmp_161_rule(Parser *p) return _res; } -// _loop0_163: ',' pattern +// _loop0_164: ',' pattern static asdl_seq * -_loop0_163_rule(Parser *p) +_loop0_164_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26712,7 +26903,7 @@ _loop0_163_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _loop0_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; expr_ty elem; while ( @@ -26743,7 +26934,7 @@ _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, ' ', + D(fprintf(stderr, "%*c%s _loop0_164[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26756,14 +26947,14 @@ _loop0_163_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_163_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_164_type, _seq); D(p->level--); return _seq; } -// _gather_162: pattern _loop0_163 +// _gather_163: pattern _loop0_164 static asdl_seq * -_gather_162_rule(Parser *p) +_gather_163_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26772,27 +26963,27 @@ _gather_162_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // pattern _loop0_163 + { // pattern _loop0_164 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_163")); + D(fprintf(stderr, "%*c> _gather_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_164")); expr_ty elem; asdl_seq * seq; if ( (elem = pattern_rule(p)) // pattern && - (seq = _loop0_163_rule(p)) // _loop0_163 + (seq = _loop0_164_rule(p)) // _loop0_164 ) { - D(fprintf(stderr, "%*c+ _gather_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_163")); + D(fprintf(stderr, "%*c+ _gather_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_164")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_162[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_163")); + D(fprintf(stderr, "%*c%s _gather_163[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_164")); } _res = NULL; done: @@ -26800,9 +26991,9 @@ _gather_162_rule(Parser *p) return _res; } -// _loop0_165: ',' argument_pattern +// _loop0_166: ',' argument_pattern static asdl_seq * -_loop0_165_rule(Parser *p) +_loop0_166_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26826,7 +27017,7 @@ _loop0_165_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' argument_pattern")); + D(fprintf(stderr, "%*c> _loop0_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' argument_pattern")); Token * _literal; void *elem; while ( @@ -26857,7 +27048,7 @@ _loop0_165_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_165[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_166[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' argument_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26870,14 +27061,14 @@ _loop0_165_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_165_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_166_type, _seq); D(p->level--); return _seq; } -// _gather_164: argument_pattern _loop0_165 +// _gather_165: argument_pattern _loop0_166 static asdl_seq * -_gather_164_rule(Parser *p) +_gather_165_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26886,27 +27077,27 @@ _gather_164_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // argument_pattern _loop0_165 + { // argument_pattern _loop0_166 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_165")); + D(fprintf(stderr, "%*c> _gather_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_166")); void *elem; asdl_seq * seq; if ( (elem = argument_pattern_rule(p)) // argument_pattern && - (seq = _loop0_165_rule(p)) // _loop0_165 + (seq = _loop0_166_rule(p)) // _loop0_166 ) { - D(fprintf(stderr, "%*c+ _gather_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_165")); + D(fprintf(stderr, "%*c+ _gather_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_166")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_164[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern _loop0_165")); + D(fprintf(stderr, "%*c%s _gather_165[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern _loop0_166")); } _res = NULL; done: @@ -26914,9 +27105,9 @@ _gather_164_rule(Parser *p) return _res; } -// _loop0_167: ',' argument_pattern +// _loop0_168: ',' argument_pattern static asdl_seq * -_loop0_167_rule(Parser *p) +_loop0_168_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26940,7 +27131,7 @@ _loop0_167_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' argument_pattern")); + D(fprintf(stderr, "%*c> _loop0_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' argument_pattern")); Token * _literal; void *elem; while ( @@ -26971,7 +27162,7 @@ _loop0_167_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_167[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_168[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' argument_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26984,14 +27175,14 @@ _loop0_167_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_167_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_168_type, _seq); D(p->level--); return _seq; } -// _gather_166: argument_pattern _loop0_167 +// _gather_167: argument_pattern _loop0_168 static asdl_seq * -_gather_166_rule(Parser *p) +_gather_167_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27000,27 +27191,27 @@ _gather_166_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // argument_pattern _loop0_167 + { // argument_pattern _loop0_168 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_167")); + D(fprintf(stderr, "%*c> _gather_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_168")); void *elem; asdl_seq * seq; if ( (elem = argument_pattern_rule(p)) // argument_pattern && - (seq = _loop0_167_rule(p)) // _loop0_167 + (seq = _loop0_168_rule(p)) // _loop0_168 ) { - D(fprintf(stderr, "%*c+ _gather_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_167")); + D(fprintf(stderr, "%*c+ _gather_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_168")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_166[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern _loop0_167")); + D(fprintf(stderr, "%*c%s _gather_167[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern _loop0_168")); } _res = NULL; done: @@ -27028,9 +27219,9 @@ _gather_166_rule(Parser *p) return _res; } -// _loop0_169: ',' (argument_pattern | error_star) +// _loop0_170: ',' (argument_pattern | error_star) static asdl_seq * -_loop0_169_rule(Parser *p) +_loop0_170_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27054,13 +27245,13 @@ _loop0_169_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (argument_pattern | error_star)")); + D(fprintf(stderr, "%*c> _loop0_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (argument_pattern | error_star)")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_181_rule(p)) // argument_pattern | error_star + (elem = _tmp_182_rule(p)) // argument_pattern | error_star ) { _res = elem; @@ -27085,7 +27276,7 @@ _loop0_169_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_169[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_170[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (argument_pattern | error_star)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -27098,14 +27289,14 @@ _loop0_169_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_169_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_170_type, _seq); D(p->level--); return _seq; } -// _gather_168: (argument_pattern | error_star) _loop0_169 +// _gather_169: (argument_pattern | error_star) _loop0_170 static asdl_seq * -_gather_168_rule(Parser *p) +_gather_169_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27114,27 +27305,27 @@ _gather_168_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (argument_pattern | error_star) _loop0_169 + { // (argument_pattern | error_star) _loop0_170 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(argument_pattern | error_star) _loop0_169")); + D(fprintf(stderr, "%*c> _gather_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(argument_pattern | error_star) _loop0_170")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_181_rule(p)) // argument_pattern | error_star + (elem = _tmp_182_rule(p)) // argument_pattern | error_star && - (seq = _loop0_169_rule(p)) // _loop0_169 + (seq = _loop0_170_rule(p)) // _loop0_170 ) { - D(fprintf(stderr, "%*c+ _gather_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(argument_pattern | error_star) _loop0_169")); + D(fprintf(stderr, "%*c+ _gather_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(argument_pattern | error_star) _loop0_170")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_168[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(argument_pattern | error_star) _loop0_169")); + D(fprintf(stderr, "%*c%s _gather_169[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(argument_pattern | error_star) _loop0_170")); } _res = NULL; done: @@ -27142,9 +27333,9 @@ _gather_168_rule(Parser *p) return _res; } -// _tmp_170: '@' named_expression NEWLINE +// _tmp_171: '@' named_expression NEWLINE static void * -_tmp_170_rule(Parser *p) +_tmp_171_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27158,7 +27349,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, "'@' 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; @@ -27170,7 +27361,7 @@ _tmp_170_rule(Parser *p) (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_170[%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; @@ -27180,7 +27371,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_171[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); } _res = NULL; @@ -27189,9 +27380,9 @@ _tmp_170_rule(Parser *p) return _res; } -// _tmp_171: ',' star_expression +// _tmp_172: ',' star_expression static void * -_tmp_171_rule(Parser *p) +_tmp_172_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27205,7 +27396,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, "',' 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 ( @@ -27214,7 +27405,7 @@ _tmp_171_rule(Parser *p) (c = star_expression_rule(p)) // star_expression ) { - D(fprintf(stderr, "%*c+ _tmp_171[%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; @@ -27224,7 +27415,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_172[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } _res = NULL; @@ -27233,9 +27424,9 @@ _tmp_171_rule(Parser *p) return _res; } -// _tmp_172: ',' expression +// _tmp_173: ',' expression static void * -_tmp_172_rule(Parser *p) +_tmp_173_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27249,7 +27440,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, "',' expression")); + D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty c; if ( @@ -27258,7 +27449,7 @@ _tmp_172_rule(Parser *p) (c = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_172[%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; @@ -27268,7 +27459,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_173[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } _res = NULL; @@ -27277,9 +27468,9 @@ _tmp_172_rule(Parser *p) return _res; } -// _tmp_173: 'or' conjunction +// _tmp_174: 'or' conjunction static void * -_tmp_173_rule(Parser *p) +_tmp_174_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27293,7 +27484,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, "'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 ( @@ -27302,7 +27493,7 @@ _tmp_173_rule(Parser *p) (c = conjunction_rule(p)) // conjunction ) { - D(fprintf(stderr, "%*c+ _tmp_173[%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; @@ -27312,7 +27503,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_174[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); } _res = NULL; @@ -27321,9 +27512,9 @@ _tmp_173_rule(Parser *p) return _res; } -// _tmp_174: 'and' inversion +// _tmp_175: 'and' inversion static void * -_tmp_174_rule(Parser *p) +_tmp_175_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27337,7 +27528,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, "'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 ( @@ -27346,7 +27537,7 @@ _tmp_174_rule(Parser *p) (c = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ _tmp_174[%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; @@ -27356,7 +27547,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_175[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); } _res = NULL; @@ -27365,9 +27556,9 @@ _tmp_174_rule(Parser *p) return _res; } -// _tmp_175: 'if' disjunction +// _tmp_176: 'if' disjunction static void * -_tmp_175_rule(Parser *p) +_tmp_176_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27381,7 +27572,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, "'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 ( @@ -27390,7 +27581,7 @@ _tmp_175_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_175[%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; @@ -27400,7 +27591,7 @@ _tmp_175_rule(Parser *p) 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_176[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -27409,9 +27600,9 @@ _tmp_175_rule(Parser *p) return _res; } -// _tmp_176: 'if' disjunction +// _tmp_177: 'if' disjunction static void * -_tmp_176_rule(Parser *p) +_tmp_177_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27425,7 +27616,7 @@ _tmp_176_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_176[%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 ( @@ -27434,7 +27625,7 @@ _tmp_176_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_176[%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; @@ -27444,7 +27635,7 @@ _tmp_176_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_176[%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; @@ -27453,9 +27644,9 @@ _tmp_176_rule(Parser *p) return _res; } -// _tmp_177: ',' star_target +// _tmp_178: ',' star_target static void * -_tmp_177_rule(Parser *p) +_tmp_178_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27469,7 +27660,7 @@ _tmp_177_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty c; if ( @@ -27478,7 +27669,7 @@ _tmp_177_rule(Parser *p) (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")); + D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -27488,7 +27679,7 @@ _tmp_177_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_177[%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, "',' star_target")); } _res = NULL; @@ -27497,9 +27688,9 @@ _tmp_177_rule(Parser *p) return _res; } -// _loop1_178: param_with_default +// _loop1_179: param_with_default static asdl_seq * -_loop1_178_rule(Parser *p) +_loop1_179_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27523,7 +27714,7 @@ _loop1_178_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -27545,7 +27736,7 @@ _loop1_178_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_178[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_179[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -27563,14 +27754,14 @@ _loop1_178_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_178_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_179_type, _seq); D(p->level--); return _seq; } -// _tmp_179: ')' | '**' +// _tmp_180: ')' | '**' static void * -_tmp_179_rule(Parser *p) +_tmp_180_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27584,18 +27775,18 @@ _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, "')'")); + D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _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_180[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // '**' @@ -27603,18 +27794,18 @@ _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, "'**'")); + D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _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_180[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -27623,9 +27814,9 @@ _tmp_179_rule(Parser *p) return _res; } -// _tmp_180: ':' | '**' +// _tmp_181: ':' | '**' static void * -_tmp_180_rule(Parser *p) +_tmp_181_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27639,18 +27830,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_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_181[%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_181[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // '**' @@ -27658,18 +27849,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_181[%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_181[%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_181[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -27678,9 +27869,9 @@ _tmp_180_rule(Parser *p) return _res; } -// _tmp_181: argument_pattern | error_star +// _tmp_182: argument_pattern | error_star static void * -_tmp_181_rule(Parser *p) +_tmp_182_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27694,18 +27885,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, "argument_pattern")); + D(fprintf(stderr, "%*c> _tmp_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern")); void *argument_pattern_var; if ( (argument_pattern_var = argument_pattern_rule(p)) // argument_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern")); + D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern")); _res = argument_pattern_var; 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_182[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern")); } { // error_star @@ -27713,18 +27904,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, "error_star")); + D(fprintf(stderr, "%*c> _tmp_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_star")); expr_ty error_star_var; if ( (error_star_var = error_star_rule(p)) // error_star ) { - D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_star")); + D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_star")); _res = error_star_var; 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_182[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_star")); } _res = NULL; diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 52d3372db8e068..0ff36860df3c31 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -746,6 +746,47 @@ astfold_withitem(withitem_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) return 1; } +static int +astfold_pattern_negative(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) +{ + assert(node_->kind == UnaryOp_kind); + assert(node_->v.UnaryOp.op == USub); + assert(node_->v.UnaryOp.operand->kind == Constant_kind); + PyObject *value = node_->v.UnaryOp.operand->v.Constant.value; + assert(PyComplex_CheckExact(value) || PyFloat_CheckExact(value) || PyLong_CheckExact(value)); + PyObject *negated = PyNumber_Negative(value); + if (!negated) { + return 0; + } + return make_const(node_, negated, ctx_); +} + +static int +astfold_pattern_complex(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) +{ + expr_ty left = node_->v.BinOp.left; + if (left->kind == UnaryOp_kind) { + CALL(astfold_pattern_negative, expr_ty, left); + } + expr_ty right = node_->v.BinOp.right; + assert(node_->v.BinOp.op == Add || node_->v.BinOp.op == Sub); + assert(node_->v.BinOp.left->kind = Constant_kind); + assert(node_->v.BinOp.right->kind = Constant_kind); + assert(PyFloat_CheckExact(left->v.Constant.value) || PyLong_CheckExact(left->v.Constant.value)); + assert(PyComplex_CheckExact(right->v.Constant.value)); + PyObject *new; + if (node_->v.BinOp.op == Add) { + new = PyNumber_Add(left->v.Constant.value, right->v.Constant.value); + } + else { + new = PyNumber_Subtract(left->v.Constant.value, right->v.Constant.value); + } + if (!new) { + return 0; + } + return make_const(node_, new, ctx_); +} + static int astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) { @@ -754,6 +795,10 @@ astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) switch (node_->kind) { case Attribute_kind: case Constant_kind: + return 1; + case BinOp_kind: + CALL(astfold_pattern_complex, expr_ty, node_); + return 1; case BoolOp_kind: // TODO: Quite a bit of potential here. case Dict_kind: @@ -762,16 +807,8 @@ astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) case NamedExpr_kind: return 1; case UnaryOp_kind: - assert(node_->kind == UnaryOp_kind); - assert(node_->v.UnaryOp.op == USub); - assert(node_->v.UnaryOp.operand->kind == Constant_kind); - PyObject *value = node_->v.UnaryOp.operand->v.Constant.value; - assert(PyComplex_CheckExact(value) || PyFloat_CheckExact(value) || PyLong_CheckExact(value)); - PyObject *negated = PyNumber_Negative(value); - if (!negated) { - return 0; - } - return make_const(node_, negated, ctx_); + CALL(astfold_pattern_negative, expr_ty, node_); + return 1; default: Py_UNREACHABLE(); } From 1eddf273efd3493065b693400816434bbeecd3cd Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 2 Jun 2020 07:55:05 -0700 Subject: [PATCH 055/189] Fix AST validation --- Python/ast.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Python/ast.c b/Python/ast.c index 8cdee5bf672f76..b149e07a1c8bd7 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -311,6 +311,8 @@ validate_pattern(expr_ty p) switch (p->kind) { case Attribute_kind: return validate_expr(p, Load); + case BinOp_kind: + return 1; case BoolOp_kind: if (p->v.BoolOp.op != Or) { PyErr_SetString(PyExc_ValueError, From 04bad8e5ad470b64d0a03ec598d89eaf112916fc Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 2 Jun 2020 08:41:30 -0700 Subject: [PATCH 056/189] MATCH_TYPE -> DESTRUCTURE --- Doc/library/dis.rst | 13 ++++++++----- Include/opcode.h | 2 +- Lib/importlib/_bootstrap_external.py | 4 ++-- Lib/opcode.py | 2 +- Python/ceval.c | 2 +- Python/compile.c | 4 ++-- Python/importlib_external.h | 2 +- Python/opcode_targets.h | 2 +- 8 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index ce12b7a2fdb2d1..c2d79e9dd6f774 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1019,11 +1019,14 @@ All of the following opcodes use their arguments. .. versionadded:: 3.10 -.. opcode:: MATCH_TYPE (delta) - - Pop TOS and TOS1. If TOS is an instance of :class:`type` and has a - ``__match__`` method, call it on TOS1 and push the result onto the stack if - it is not ``None``. Otherwise, increment the bytecode counter by ``delta``. +.. opcode:: DESTRUCTURE (argcount) + + Pop TOS, TOS1, and TOS2. If TOS1 is an instance of :class:`type` and has a + ``__match__`` method, call it on TOS2. If the result is not ``None``, + destrucuture it into ``argcount`` components (using any keyword names from + the :class:`tuple` at TOS), collect these into a tuple, and push that onto + the stack, followed by ``True``. Otherwise, push ``None``, followed by + ``False``. .. versionadded:: 3.10 diff --git a/Include/opcode.h b/Include/opcode.h index 00e68040f2ae4e..07b1d80dd8986a 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -130,7 +130,7 @@ extern "C" { #define MATCH_KEY 166 #define MATCH_MAP 167 #define MATCH_SEQ 168 -#define MATCH_TYPE 169 +#define DESTRUCTURE 169 /* EXCEPT_HANDLER is a special, implicit block type which is created when entering an except handler. It is not an opcode but we define it here diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 635e62ddaeb01b..47ccd046ee0b84 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3439 (add MATCH_KEY, MATCH_MAP, MATCH_SEQ, MATCH_TYPE) +# Python 3.10a0 3439 (add DESTRUCTURE, MATCH_KEY, MATCH_MAP, MATCH_SEQ) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3439).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3440).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index 37a6ed4be6776b..24315fd55a9315 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -216,6 +216,6 @@ def jabs_op(name, op): jrel_op('MATCH_KEY', 166) jrel_op('MATCH_MAP', 167) jrel_op('MATCH_SEQ', 168) -jrel_op('MATCH_TYPE', 169) +jrel_op('DESTRUCTURE', 169) del def_op, name_op, jrel_op, jabs_op diff --git a/Python/ceval.c b/Python/ceval.c index 0fdd68e2422cd8..08480844459053 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3410,7 +3410,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(MATCH_TYPE): { + case TARGET(DESTRUCTURE): { PyObject *type = TOP(); PyObject *target = SECOND(); if (!PyType_Check(type)) { diff --git a/Python/compile.c b/Python/compile.c index b541ae59d540a2..8c4ec1b3742d36 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -986,8 +986,8 @@ stack_effect(int opcode, int oparg, int jump) case MATCH_MAP: case MATCH_SEQ: return jump > 0 ? -1 : 0; - case MATCH_TYPE: - return jump > 0 ? -2 : 0; + case DESTRUCTURE: + return -1; case STORE_ATTR: return -2; diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 120adff2d1d04e..b0a3575fd29166 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,111,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,112,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 785515709378b6..b0c7e0fe5f6226 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -168,7 +168,7 @@ static void *opcode_targets[256] = { &&TARGET_MATCH_KEY, &&TARGET_MATCH_MAP, &&TARGET_MATCH_SEQ, - &&TARGET_MATCH_TYPE, + &&TARGET_DESTRUCTURE, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From e4be1872dc48c6298dec40608f581324bd529be4 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 2 Jun 2020 11:47:25 -0700 Subject: [PATCH 057/189] Fix attribute parsing --- Grammar/python.gram | 12 +- Lib/test/test_patma.py | 61 + Parser/pegen/parse.c | 3093 +++++++++++++++++++++------------------- 3 files changed, 1701 insertions(+), 1465 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 02ba1f15b44899..f25e710c335f22 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -238,10 +238,10 @@ literal_pattern: | 'False' { _Py_Constant(Py_False, NULL, EXTRA) } constant_pattern: - | '.' name=NAME { + | '.' name=NAME !('.' | '(' | '=') { name } - | value=name_or_attr '.' attr=NAME !'(' { - _Py_Attribute(value, attr->v.Name.id, Load, EXTRA) } + | '.'? attr=attr !('.' | '(' | '=') { + attr } group_pattern: | '(' pattern=pattern ')' { pattern } @@ -269,10 +269,12 @@ signed_number: | NUMBER | '-' number=NUMBER { _Py_UnaryOp(USub, number, EXTRA) } -name_or_attr: - | NAME +attr: | value=name_or_attr '.' attr=NAME { _Py_Attribute(value, attr->v.Name.id, Load, EXTRA) } +name_or_attr: + | attr + | NAME values_pattern: | values=','.value_pattern+ ','? { values } diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 41980f475688a1..2524dd7ec7b28a 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1556,6 +1556,67 @@ def test_patma_110(self) -> None: self.assertEqual(x, -0.25 - 1.75j) self.assertEqual(y, 0) + def test_patma_111(self) -> None: + class A: + B = 0 + x = 0 + match x: + case .A.B: + y = 0 + self.assertEqual(A.B, 0) + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_112(self) -> None: + class A: + class B: + C = 0 + x = 0 + match x: + case A.B.C: + y = 0 + self.assertEqual(A.B.C, 0) + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_113(self) -> None: + class A: + class B: + C = 0 + x = 0 + match x: + case .A.B.C: + y = 0 + self.assertEqual(A.B.C, 0) + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_114(self) -> None: + class A: + class B: + class C: + D = 0 + x = 0 + match x: + case .A.B.C.D: + y = 0 + self.assertEqual(A.B.C.D, 0) + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_115(self) -> None: + class A: + class B: + class C: + D = 0 + x = 0 + match x: + case .A.B.C.D: + y = 0 + self.assertEqual(A.B.C.D, 0) + self.assertEqual(x, 0) + self.assertEqual(y, 0) + if __name__ == "__main__": # XXX: For quick test debugging... import dis diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index 25632984bbf7b8..123d6c3ede8542 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -127,314 +127,317 @@ static KeywordToken *reserved_keywords[] = { #define mapping_pattern_type 1049 #define class_pattern_type 1050 #define signed_number_type 1051 -#define name_or_attr_type 1052 // Left-recursive -#define values_pattern_type 1053 -#define items_pattern_type 1054 -#define keyword_pattern_type 1055 -#define argument_pattern_type 1056 -#define error_star_type 1057 -#define value_pattern_type 1058 -#define key_value_pattern_type 1059 -#define return_stmt_type 1060 -#define raise_stmt_type 1061 -#define function_def_type 1062 -#define function_def_raw_type 1063 -#define func_type_comment_type 1064 -#define params_type 1065 -#define parameters_type 1066 -#define slash_no_default_type 1067 -#define slash_with_default_type 1068 -#define star_etc_type 1069 -#define kwds_type 1070 -#define param_no_default_type 1071 -#define param_with_default_type 1072 -#define param_maybe_default_type 1073 -#define param_type 1074 -#define annotation_type 1075 -#define default_type 1076 -#define decorators_type 1077 -#define class_def_type 1078 -#define class_def_raw_type 1079 -#define block_type 1080 -#define expressions_list_type 1081 -#define star_expressions_type 1082 -#define star_expression_type 1083 -#define star_named_expressions_type 1084 -#define star_named_expression_type 1085 -#define named_expression_type 1086 -#define annotated_rhs_type 1087 -#define expressions_type 1088 -#define expression_type 1089 -#define lambdef_type 1090 -#define lambda_parameters_type 1091 -#define lambda_slash_no_default_type 1092 -#define lambda_slash_with_default_type 1093 -#define lambda_star_etc_type 1094 -#define lambda_kwds_type 1095 -#define lambda_param_no_default_type 1096 -#define lambda_param_with_default_type 1097 -#define lambda_param_maybe_default_type 1098 -#define lambda_param_type 1099 -#define disjunction_type 1100 -#define conjunction_type 1101 -#define inversion_type 1102 -#define comparison_type 1103 -#define compare_op_bitwise_or_pair_type 1104 -#define eq_bitwise_or_type 1105 -#define noteq_bitwise_or_type 1106 -#define lte_bitwise_or_type 1107 -#define lt_bitwise_or_type 1108 -#define gte_bitwise_or_type 1109 -#define gt_bitwise_or_type 1110 -#define notin_bitwise_or_type 1111 -#define in_bitwise_or_type 1112 -#define isnot_bitwise_or_type 1113 -#define is_bitwise_or_type 1114 -#define bitwise_or_type 1115 // Left-recursive -#define bitwise_xor_type 1116 // Left-recursive -#define bitwise_and_type 1117 // Left-recursive -#define shift_expr_type 1118 // Left-recursive -#define sum_type 1119 // Left-recursive -#define term_type 1120 // Left-recursive -#define factor_type 1121 -#define power_type 1122 -#define await_primary_type 1123 -#define primary_type 1124 // Left-recursive -#define slices_type 1125 -#define slice_type 1126 -#define atom_type 1127 -#define strings_type 1128 -#define list_type 1129 -#define listcomp_type 1130 -#define tuple_type 1131 -#define group_type 1132 -#define genexp_type 1133 -#define set_type 1134 -#define setcomp_type 1135 -#define dict_type 1136 -#define dictcomp_type 1137 -#define double_starred_kvpairs_type 1138 -#define double_starred_kvpair_type 1139 -#define kvpair_type 1140 -#define for_if_clauses_type 1141 -#define for_if_clause_type 1142 -#define yield_expr_type 1143 -#define arguments_type 1144 -#define args_type 1145 -#define kwargs_type 1146 -#define starred_expression_type 1147 -#define kwarg_or_starred_type 1148 -#define kwarg_or_double_starred_type 1149 -#define star_targets_type 1150 -#define star_targets_seq_type 1151 -#define star_target_type 1152 -#define star_atom_type 1153 -#define single_target_type 1154 -#define single_subscript_attribute_target_type 1155 -#define del_targets_type 1156 -#define del_target_type 1157 -#define del_t_atom_type 1158 -#define del_target_end_type 1159 -#define targets_type 1160 -#define target_type 1161 -#define t_primary_type 1162 // Left-recursive -#define t_lookahead_type 1163 -#define t_atom_type 1164 -#define incorrect_arguments_type 1165 -#define invalid_kwarg_type 1166 -#define invalid_named_expression_type 1167 -#define invalid_assignment_type 1168 -#define invalid_block_type 1169 -#define invalid_comprehension_type 1170 -#define invalid_dict_comprehension_type 1171 -#define invalid_parameters_type 1172 -#define invalid_star_etc_type 1173 -#define invalid_lambda_star_etc_type 1174 -#define invalid_double_type_comments_type 1175 -#define invalid_del_target_type 1176 -#define invalid_import_from_targets_type 1177 -#define _loop0_1_type 1178 -#define _loop0_2_type 1179 -#define _loop0_4_type 1180 -#define _gather_3_type 1181 -#define _loop0_6_type 1182 -#define _gather_5_type 1183 -#define _loop0_8_type 1184 -#define _gather_7_type 1185 -#define _loop0_10_type 1186 -#define _gather_9_type 1187 -#define _loop1_11_type 1188 -#define _loop0_13_type 1189 -#define _gather_12_type 1190 -#define _tmp_14_type 1191 -#define _tmp_15_type 1192 -#define _tmp_16_type 1193 -#define _tmp_17_type 1194 -#define _tmp_18_type 1195 -#define _tmp_19_type 1196 -#define _tmp_20_type 1197 -#define _tmp_21_type 1198 -#define _loop1_22_type 1199 -#define _tmp_23_type 1200 -#define _tmp_24_type 1201 -#define _loop0_26_type 1202 -#define _gather_25_type 1203 -#define _loop0_28_type 1204 -#define _gather_27_type 1205 -#define _tmp_29_type 1206 -#define _loop0_30_type 1207 -#define _loop1_31_type 1208 -#define _loop0_33_type 1209 -#define _gather_32_type 1210 -#define _tmp_34_type 1211 -#define _loop0_36_type 1212 -#define _gather_35_type 1213 -#define _tmp_37_type 1214 -#define _loop0_39_type 1215 -#define _gather_38_type 1216 -#define _loop0_41_type 1217 -#define _gather_40_type 1218 -#define _loop0_43_type 1219 -#define _gather_42_type 1220 -#define _loop0_45_type 1221 -#define _gather_44_type 1222 -#define _tmp_46_type 1223 -#define _loop1_47_type 1224 -#define _tmp_48_type 1225 -#define _loop1_49_type 1226 -#define _loop0_51_type 1227 -#define _gather_50_type 1228 -#define _tmp_52_type 1229 -#define _tmp_53_type 1230 -#define _loop0_55_type 1231 -#define _gather_54_type 1232 -#define _loop0_57_type 1233 -#define _gather_56_type 1234 -#define _loop0_59_type 1235 -#define _gather_58_type 1236 -#define _loop0_61_type 1237 -#define _gather_60_type 1238 -#define _tmp_62_type 1239 -#define _loop0_64_type 1240 -#define _gather_63_type 1241 -#define _tmp_65_type 1242 -#define _tmp_66_type 1243 -#define _tmp_67_type 1244 -#define _loop0_69_type 1245 -#define _gather_68_type 1246 -#define _loop0_71_type 1247 -#define _gather_70_type 1248 -#define _tmp_72_type 1249 -#define _tmp_73_type 1250 -#define _tmp_74_type 1251 -#define _tmp_75_type 1252 -#define _tmp_76_type 1253 -#define _tmp_77_type 1254 -#define _loop0_78_type 1255 -#define _loop0_79_type 1256 -#define _loop0_80_type 1257 -#define _loop1_81_type 1258 -#define _loop0_82_type 1259 -#define _loop1_83_type 1260 -#define _loop1_84_type 1261 -#define _loop1_85_type 1262 -#define _loop0_86_type 1263 -#define _loop1_87_type 1264 -#define _loop0_88_type 1265 -#define _loop1_89_type 1266 -#define _loop0_90_type 1267 -#define _loop1_91_type 1268 -#define _loop1_92_type 1269 -#define _tmp_93_type 1270 -#define _loop0_95_type 1271 -#define _gather_94_type 1272 -#define _loop1_96_type 1273 -#define _loop0_98_type 1274 -#define _gather_97_type 1275 -#define _loop1_99_type 1276 +#define attr_type 1052 // Left-recursive +#define name_or_attr_type 1053 // Left-recursive +#define values_pattern_type 1054 +#define items_pattern_type 1055 +#define keyword_pattern_type 1056 +#define argument_pattern_type 1057 +#define error_star_type 1058 +#define value_pattern_type 1059 +#define key_value_pattern_type 1060 +#define return_stmt_type 1061 +#define raise_stmt_type 1062 +#define function_def_type 1063 +#define function_def_raw_type 1064 +#define func_type_comment_type 1065 +#define params_type 1066 +#define parameters_type 1067 +#define slash_no_default_type 1068 +#define slash_with_default_type 1069 +#define star_etc_type 1070 +#define kwds_type 1071 +#define param_no_default_type 1072 +#define param_with_default_type 1073 +#define param_maybe_default_type 1074 +#define param_type 1075 +#define annotation_type 1076 +#define default_type 1077 +#define decorators_type 1078 +#define class_def_type 1079 +#define class_def_raw_type 1080 +#define block_type 1081 +#define expressions_list_type 1082 +#define star_expressions_type 1083 +#define star_expression_type 1084 +#define star_named_expressions_type 1085 +#define star_named_expression_type 1086 +#define named_expression_type 1087 +#define annotated_rhs_type 1088 +#define expressions_type 1089 +#define expression_type 1090 +#define lambdef_type 1091 +#define lambda_parameters_type 1092 +#define lambda_slash_no_default_type 1093 +#define lambda_slash_with_default_type 1094 +#define lambda_star_etc_type 1095 +#define lambda_kwds_type 1096 +#define lambda_param_no_default_type 1097 +#define lambda_param_with_default_type 1098 +#define lambda_param_maybe_default_type 1099 +#define lambda_param_type 1100 +#define disjunction_type 1101 +#define conjunction_type 1102 +#define inversion_type 1103 +#define comparison_type 1104 +#define compare_op_bitwise_or_pair_type 1105 +#define eq_bitwise_or_type 1106 +#define noteq_bitwise_or_type 1107 +#define lte_bitwise_or_type 1108 +#define lt_bitwise_or_type 1109 +#define gte_bitwise_or_type 1110 +#define gt_bitwise_or_type 1111 +#define notin_bitwise_or_type 1112 +#define in_bitwise_or_type 1113 +#define isnot_bitwise_or_type 1114 +#define is_bitwise_or_type 1115 +#define bitwise_or_type 1116 // Left-recursive +#define bitwise_xor_type 1117 // Left-recursive +#define bitwise_and_type 1118 // Left-recursive +#define shift_expr_type 1119 // Left-recursive +#define sum_type 1120 // Left-recursive +#define term_type 1121 // Left-recursive +#define factor_type 1122 +#define power_type 1123 +#define await_primary_type 1124 +#define primary_type 1125 // Left-recursive +#define slices_type 1126 +#define slice_type 1127 +#define atom_type 1128 +#define strings_type 1129 +#define list_type 1130 +#define listcomp_type 1131 +#define tuple_type 1132 +#define group_type 1133 +#define genexp_type 1134 +#define set_type 1135 +#define setcomp_type 1136 +#define dict_type 1137 +#define dictcomp_type 1138 +#define double_starred_kvpairs_type 1139 +#define double_starred_kvpair_type 1140 +#define kvpair_type 1141 +#define for_if_clauses_type 1142 +#define for_if_clause_type 1143 +#define yield_expr_type 1144 +#define arguments_type 1145 +#define args_type 1146 +#define kwargs_type 1147 +#define starred_expression_type 1148 +#define kwarg_or_starred_type 1149 +#define kwarg_or_double_starred_type 1150 +#define star_targets_type 1151 +#define star_targets_seq_type 1152 +#define star_target_type 1153 +#define star_atom_type 1154 +#define single_target_type 1155 +#define single_subscript_attribute_target_type 1156 +#define del_targets_type 1157 +#define del_target_type 1158 +#define del_t_atom_type 1159 +#define del_target_end_type 1160 +#define targets_type 1161 +#define target_type 1162 +#define t_primary_type 1163 // Left-recursive +#define t_lookahead_type 1164 +#define t_atom_type 1165 +#define incorrect_arguments_type 1166 +#define invalid_kwarg_type 1167 +#define invalid_named_expression_type 1168 +#define invalid_assignment_type 1169 +#define invalid_block_type 1170 +#define invalid_comprehension_type 1171 +#define invalid_dict_comprehension_type 1172 +#define invalid_parameters_type 1173 +#define invalid_star_etc_type 1174 +#define invalid_lambda_star_etc_type 1175 +#define invalid_double_type_comments_type 1176 +#define invalid_del_target_type 1177 +#define invalid_import_from_targets_type 1178 +#define _loop0_1_type 1179 +#define _loop0_2_type 1180 +#define _loop0_4_type 1181 +#define _gather_3_type 1182 +#define _loop0_6_type 1183 +#define _gather_5_type 1184 +#define _loop0_8_type 1185 +#define _gather_7_type 1186 +#define _loop0_10_type 1187 +#define _gather_9_type 1188 +#define _loop1_11_type 1189 +#define _loop0_13_type 1190 +#define _gather_12_type 1191 +#define _tmp_14_type 1192 +#define _tmp_15_type 1193 +#define _tmp_16_type 1194 +#define _tmp_17_type 1195 +#define _tmp_18_type 1196 +#define _tmp_19_type 1197 +#define _tmp_20_type 1198 +#define _tmp_21_type 1199 +#define _loop1_22_type 1200 +#define _tmp_23_type 1201 +#define _tmp_24_type 1202 +#define _loop0_26_type 1203 +#define _gather_25_type 1204 +#define _loop0_28_type 1205 +#define _gather_27_type 1206 +#define _tmp_29_type 1207 +#define _loop0_30_type 1208 +#define _loop1_31_type 1209 +#define _loop0_33_type 1210 +#define _gather_32_type 1211 +#define _tmp_34_type 1212 +#define _loop0_36_type 1213 +#define _gather_35_type 1214 +#define _tmp_37_type 1215 +#define _loop0_39_type 1216 +#define _gather_38_type 1217 +#define _loop0_41_type 1218 +#define _gather_40_type 1219 +#define _loop0_43_type 1220 +#define _gather_42_type 1221 +#define _loop0_45_type 1222 +#define _gather_44_type 1223 +#define _tmp_46_type 1224 +#define _loop1_47_type 1225 +#define _tmp_48_type 1226 +#define _loop1_49_type 1227 +#define _loop0_51_type 1228 +#define _gather_50_type 1229 +#define _tmp_52_type 1230 +#define _tmp_53_type 1231 +#define _tmp_54_type 1232 +#define _tmp_55_type 1233 +#define _loop0_57_type 1234 +#define _gather_56_type 1235 +#define _loop0_59_type 1236 +#define _gather_58_type 1237 +#define _loop0_61_type 1238 +#define _gather_60_type 1239 +#define _loop0_63_type 1240 +#define _gather_62_type 1241 +#define _tmp_64_type 1242 +#define _loop0_66_type 1243 +#define _gather_65_type 1244 +#define _tmp_67_type 1245 +#define _tmp_68_type 1246 +#define _tmp_69_type 1247 +#define _loop0_71_type 1248 +#define _gather_70_type 1249 +#define _loop0_73_type 1250 +#define _gather_72_type 1251 +#define _tmp_74_type 1252 +#define _tmp_75_type 1253 +#define _tmp_76_type 1254 +#define _tmp_77_type 1255 +#define _tmp_78_type 1256 +#define _tmp_79_type 1257 +#define _loop0_80_type 1258 +#define _loop0_81_type 1259 +#define _loop0_82_type 1260 +#define _loop1_83_type 1261 +#define _loop0_84_type 1262 +#define _loop1_85_type 1263 +#define _loop1_86_type 1264 +#define _loop1_87_type 1265 +#define _loop0_88_type 1266 +#define _loop1_89_type 1267 +#define _loop0_90_type 1268 +#define _loop1_91_type 1269 +#define _loop0_92_type 1270 +#define _loop1_93_type 1271 +#define _loop1_94_type 1272 +#define _tmp_95_type 1273 +#define _loop0_97_type 1274 +#define _gather_96_type 1275 +#define _loop1_98_type 1276 #define _loop0_100_type 1277 -#define _loop0_101_type 1278 -#define _loop0_102_type 1279 -#define _loop1_103_type 1280 -#define _loop0_104_type 1281 -#define _loop1_105_type 1282 -#define _loop1_106_type 1283 -#define _loop1_107_type 1284 -#define _loop0_108_type 1285 -#define _loop1_109_type 1286 -#define _loop0_110_type 1287 -#define _loop1_111_type 1288 -#define _loop0_112_type 1289 -#define _loop1_113_type 1290 -#define _loop1_114_type 1291 -#define _loop1_115_type 1292 -#define _loop1_116_type 1293 -#define _tmp_117_type 1294 -#define _loop0_119_type 1295 -#define _gather_118_type 1296 -#define _tmp_120_type 1297 -#define _tmp_121_type 1298 -#define _tmp_122_type 1299 -#define _tmp_123_type 1300 -#define _loop1_124_type 1301 -#define _tmp_125_type 1302 -#define _tmp_126_type 1303 -#define _loop0_128_type 1304 -#define _gather_127_type 1305 -#define _loop1_129_type 1306 +#define _gather_99_type 1278 +#define _loop1_101_type 1279 +#define _loop0_102_type 1280 +#define _loop0_103_type 1281 +#define _loop0_104_type 1282 +#define _loop1_105_type 1283 +#define _loop0_106_type 1284 +#define _loop1_107_type 1285 +#define _loop1_108_type 1286 +#define _loop1_109_type 1287 +#define _loop0_110_type 1288 +#define _loop1_111_type 1289 +#define _loop0_112_type 1290 +#define _loop1_113_type 1291 +#define _loop0_114_type 1292 +#define _loop1_115_type 1293 +#define _loop1_116_type 1294 +#define _loop1_117_type 1295 +#define _loop1_118_type 1296 +#define _tmp_119_type 1297 +#define _loop0_121_type 1298 +#define _gather_120_type 1299 +#define _tmp_122_type 1300 +#define _tmp_123_type 1301 +#define _tmp_124_type 1302 +#define _tmp_125_type 1303 +#define _loop1_126_type 1304 +#define _tmp_127_type 1305 +#define _tmp_128_type 1306 #define _loop0_130_type 1307 -#define _loop0_131_type 1308 -#define _tmp_132_type 1309 -#define _tmp_133_type 1310 -#define _loop0_135_type 1311 -#define _gather_134_type 1312 -#define _loop0_137_type 1313 -#define _gather_136_type 1314 -#define _loop0_139_type 1315 -#define _gather_138_type 1316 -#define _loop0_141_type 1317 -#define _gather_140_type 1318 -#define _loop0_142_type 1319 -#define _loop0_144_type 1320 -#define _gather_143_type 1321 -#define _tmp_145_type 1322 -#define _loop0_147_type 1323 -#define _gather_146_type 1324 -#define _loop0_149_type 1325 -#define _gather_148_type 1326 -#define _tmp_150_type 1327 +#define _gather_129_type 1308 +#define _loop1_131_type 1309 +#define _loop0_132_type 1310 +#define _loop0_133_type 1311 +#define _tmp_134_type 1312 +#define _tmp_135_type 1313 +#define _loop0_137_type 1314 +#define _gather_136_type 1315 +#define _loop0_139_type 1316 +#define _gather_138_type 1317 +#define _loop0_141_type 1318 +#define _gather_140_type 1319 +#define _loop0_143_type 1320 +#define _gather_142_type 1321 +#define _loop0_144_type 1322 +#define _loop0_146_type 1323 +#define _gather_145_type 1324 +#define _tmp_147_type 1325 +#define _loop0_149_type 1326 +#define _gather_148_type 1327 #define _loop0_151_type 1328 -#define _tmp_152_type 1329 -#define _tmp_153_type 1330 -#define _tmp_154_type 1331 -#define _tmp_155_type 1332 -#define _loop0_156_type 1333 -#define _tmp_157_type 1334 -#define _tmp_158_type 1335 -#define _tmp_159_type 1336 -#define _tmp_160_type 1337 -#define _tmp_161_type 1338 -#define _tmp_162_type 1339 -#define _loop0_164_type 1340 -#define _gather_163_type 1341 -#define _loop0_166_type 1342 -#define _gather_165_type 1343 -#define _loop0_168_type 1344 -#define _gather_167_type 1345 -#define _loop0_170_type 1346 -#define _gather_169_type 1347 -#define _tmp_171_type 1348 -#define _tmp_172_type 1349 -#define _tmp_173_type 1350 -#define _tmp_174_type 1351 -#define _tmp_175_type 1352 -#define _tmp_176_type 1353 -#define _tmp_177_type 1354 -#define _tmp_178_type 1355 -#define _loop1_179_type 1356 -#define _tmp_180_type 1357 -#define _tmp_181_type 1358 -#define _tmp_182_type 1359 +#define _gather_150_type 1329 +#define _tmp_152_type 1330 +#define _loop0_153_type 1331 +#define _tmp_154_type 1332 +#define _tmp_155_type 1333 +#define _tmp_156_type 1334 +#define _tmp_157_type 1335 +#define _loop0_158_type 1336 +#define _tmp_159_type 1337 +#define _tmp_160_type 1338 +#define _tmp_161_type 1339 +#define _tmp_162_type 1340 +#define _tmp_163_type 1341 +#define _tmp_164_type 1342 +#define _loop0_166_type 1343 +#define _gather_165_type 1344 +#define _loop0_168_type 1345 +#define _gather_167_type 1346 +#define _loop0_170_type 1347 +#define _gather_169_type 1348 +#define _loop0_172_type 1349 +#define _gather_171_type 1350 +#define _tmp_173_type 1351 +#define _tmp_174_type 1352 +#define _tmp_175_type 1353 +#define _tmp_176_type 1354 +#define _tmp_177_type 1355 +#define _tmp_178_type 1356 +#define _tmp_179_type 1357 +#define _tmp_180_type 1358 +#define _loop1_181_type 1359 +#define _tmp_182_type 1360 +#define _tmp_183_type 1361 +#define _tmp_184_type 1362 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -488,6 +491,7 @@ static void *sequence_pattern_rule(Parser *p); static void *mapping_pattern_rule(Parser *p); static void *class_pattern_rule(Parser *p); static void *signed_number_rule(Parser *p); +static void *attr_rule(Parser *p); static void *name_or_attr_rule(Parser *p); static void *values_pattern_rule(Parser *p); static void *items_pattern_rule(Parser *p); @@ -667,135 +671,137 @@ static asdl_seq *_loop0_51_rule(Parser *p); static asdl_seq *_gather_50_rule(Parser *p); static void *_tmp_52_rule(Parser *p); static void *_tmp_53_rule(Parser *p); -static asdl_seq *_loop0_55_rule(Parser *p); -static asdl_seq *_gather_54_rule(Parser *p); +static void *_tmp_54_rule(Parser *p); +static void *_tmp_55_rule(Parser *p); static asdl_seq *_loop0_57_rule(Parser *p); static asdl_seq *_gather_56_rule(Parser *p); static asdl_seq *_loop0_59_rule(Parser *p); static asdl_seq *_gather_58_rule(Parser *p); static asdl_seq *_loop0_61_rule(Parser *p); static asdl_seq *_gather_60_rule(Parser *p); -static void *_tmp_62_rule(Parser *p); -static asdl_seq *_loop0_64_rule(Parser *p); -static asdl_seq *_gather_63_rule(Parser *p); -static void *_tmp_65_rule(Parser *p); -static void *_tmp_66_rule(Parser *p); +static asdl_seq *_loop0_63_rule(Parser *p); +static asdl_seq *_gather_62_rule(Parser *p); +static void *_tmp_64_rule(Parser *p); +static asdl_seq *_loop0_66_rule(Parser *p); +static asdl_seq *_gather_65_rule(Parser *p); static void *_tmp_67_rule(Parser *p); -static asdl_seq *_loop0_69_rule(Parser *p); -static asdl_seq *_gather_68_rule(Parser *p); +static void *_tmp_68_rule(Parser *p); +static void *_tmp_69_rule(Parser *p); static asdl_seq *_loop0_71_rule(Parser *p); static asdl_seq *_gather_70_rule(Parser *p); -static void *_tmp_72_rule(Parser *p); -static void *_tmp_73_rule(Parser *p); +static asdl_seq *_loop0_73_rule(Parser *p); +static asdl_seq *_gather_72_rule(Parser *p); static void *_tmp_74_rule(Parser *p); static void *_tmp_75_rule(Parser *p); static void *_tmp_76_rule(Parser *p); static void *_tmp_77_rule(Parser *p); -static asdl_seq *_loop0_78_rule(Parser *p); -static asdl_seq *_loop0_79_rule(Parser *p); +static void *_tmp_78_rule(Parser *p); +static void *_tmp_79_rule(Parser *p); static asdl_seq *_loop0_80_rule(Parser *p); -static asdl_seq *_loop1_81_rule(Parser *p); +static asdl_seq *_loop0_81_rule(Parser *p); static asdl_seq *_loop0_82_rule(Parser *p); static asdl_seq *_loop1_83_rule(Parser *p); -static asdl_seq *_loop1_84_rule(Parser *p); +static asdl_seq *_loop0_84_rule(Parser *p); static asdl_seq *_loop1_85_rule(Parser *p); -static asdl_seq *_loop0_86_rule(Parser *p); +static asdl_seq *_loop1_86_rule(Parser *p); static asdl_seq *_loop1_87_rule(Parser *p); static asdl_seq *_loop0_88_rule(Parser *p); static asdl_seq *_loop1_89_rule(Parser *p); static asdl_seq *_loop0_90_rule(Parser *p); static asdl_seq *_loop1_91_rule(Parser *p); -static asdl_seq *_loop1_92_rule(Parser *p); -static void *_tmp_93_rule(Parser *p); -static asdl_seq *_loop0_95_rule(Parser *p); -static asdl_seq *_gather_94_rule(Parser *p); -static asdl_seq *_loop1_96_rule(Parser *p); -static asdl_seq *_loop0_98_rule(Parser *p); -static asdl_seq *_gather_97_rule(Parser *p); -static asdl_seq *_loop1_99_rule(Parser *p); +static asdl_seq *_loop0_92_rule(Parser *p); +static asdl_seq *_loop1_93_rule(Parser *p); +static asdl_seq *_loop1_94_rule(Parser *p); +static void *_tmp_95_rule(Parser *p); +static asdl_seq *_loop0_97_rule(Parser *p); +static asdl_seq *_gather_96_rule(Parser *p); +static asdl_seq *_loop1_98_rule(Parser *p); static asdl_seq *_loop0_100_rule(Parser *p); -static asdl_seq *_loop0_101_rule(Parser *p); +static asdl_seq *_gather_99_rule(Parser *p); +static asdl_seq *_loop1_101_rule(Parser *p); static asdl_seq *_loop0_102_rule(Parser *p); -static asdl_seq *_loop1_103_rule(Parser *p); +static asdl_seq *_loop0_103_rule(Parser *p); static asdl_seq *_loop0_104_rule(Parser *p); static asdl_seq *_loop1_105_rule(Parser *p); -static asdl_seq *_loop1_106_rule(Parser *p); +static asdl_seq *_loop0_106_rule(Parser *p); static asdl_seq *_loop1_107_rule(Parser *p); -static asdl_seq *_loop0_108_rule(Parser *p); +static asdl_seq *_loop1_108_rule(Parser *p); static asdl_seq *_loop1_109_rule(Parser *p); static asdl_seq *_loop0_110_rule(Parser *p); static asdl_seq *_loop1_111_rule(Parser *p); static asdl_seq *_loop0_112_rule(Parser *p); static asdl_seq *_loop1_113_rule(Parser *p); -static asdl_seq *_loop1_114_rule(Parser *p); +static asdl_seq *_loop0_114_rule(Parser *p); static asdl_seq *_loop1_115_rule(Parser *p); static asdl_seq *_loop1_116_rule(Parser *p); -static void *_tmp_117_rule(Parser *p); -static asdl_seq *_loop0_119_rule(Parser *p); -static asdl_seq *_gather_118_rule(Parser *p); -static void *_tmp_120_rule(Parser *p); -static void *_tmp_121_rule(Parser *p); +static asdl_seq *_loop1_117_rule(Parser *p); +static asdl_seq *_loop1_118_rule(Parser *p); +static void *_tmp_119_rule(Parser *p); +static asdl_seq *_loop0_121_rule(Parser *p); +static asdl_seq *_gather_120_rule(Parser *p); static void *_tmp_122_rule(Parser *p); static void *_tmp_123_rule(Parser *p); -static asdl_seq *_loop1_124_rule(Parser *p); +static void *_tmp_124_rule(Parser *p); static void *_tmp_125_rule(Parser *p); -static void *_tmp_126_rule(Parser *p); -static asdl_seq *_loop0_128_rule(Parser *p); -static asdl_seq *_gather_127_rule(Parser *p); -static asdl_seq *_loop1_129_rule(Parser *p); +static asdl_seq *_loop1_126_rule(Parser *p); +static void *_tmp_127_rule(Parser *p); +static void *_tmp_128_rule(Parser *p); static asdl_seq *_loop0_130_rule(Parser *p); -static asdl_seq *_loop0_131_rule(Parser *p); -static void *_tmp_132_rule(Parser *p); -static void *_tmp_133_rule(Parser *p); -static asdl_seq *_loop0_135_rule(Parser *p); -static asdl_seq *_gather_134_rule(Parser *p); +static asdl_seq *_gather_129_rule(Parser *p); +static asdl_seq *_loop1_131_rule(Parser *p); +static asdl_seq *_loop0_132_rule(Parser *p); +static asdl_seq *_loop0_133_rule(Parser *p); +static void *_tmp_134_rule(Parser *p); +static void *_tmp_135_rule(Parser *p); static asdl_seq *_loop0_137_rule(Parser *p); static asdl_seq *_gather_136_rule(Parser *p); static asdl_seq *_loop0_139_rule(Parser *p); static asdl_seq *_gather_138_rule(Parser *p); static asdl_seq *_loop0_141_rule(Parser *p); static asdl_seq *_gather_140_rule(Parser *p); -static asdl_seq *_loop0_142_rule(Parser *p); +static asdl_seq *_loop0_143_rule(Parser *p); +static asdl_seq *_gather_142_rule(Parser *p); static asdl_seq *_loop0_144_rule(Parser *p); -static asdl_seq *_gather_143_rule(Parser *p); -static void *_tmp_145_rule(Parser *p); -static asdl_seq *_loop0_147_rule(Parser *p); -static asdl_seq *_gather_146_rule(Parser *p); +static asdl_seq *_loop0_146_rule(Parser *p); +static asdl_seq *_gather_145_rule(Parser *p); +static void *_tmp_147_rule(Parser *p); static asdl_seq *_loop0_149_rule(Parser *p); static asdl_seq *_gather_148_rule(Parser *p); -static void *_tmp_150_rule(Parser *p); static asdl_seq *_loop0_151_rule(Parser *p); +static asdl_seq *_gather_150_rule(Parser *p); static void *_tmp_152_rule(Parser *p); -static void *_tmp_153_rule(Parser *p); +static asdl_seq *_loop0_153_rule(Parser *p); static void *_tmp_154_rule(Parser *p); static void *_tmp_155_rule(Parser *p); -static asdl_seq *_loop0_156_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_158_rule(Parser *p); static void *_tmp_159_rule(Parser *p); static void *_tmp_160_rule(Parser *p); static void *_tmp_161_rule(Parser *p); static void *_tmp_162_rule(Parser *p); -static asdl_seq *_loop0_164_rule(Parser *p); -static asdl_seq *_gather_163_rule(Parser *p); +static void *_tmp_163_rule(Parser *p); +static void *_tmp_164_rule(Parser *p); static asdl_seq *_loop0_166_rule(Parser *p); static asdl_seq *_gather_165_rule(Parser *p); static asdl_seq *_loop0_168_rule(Parser *p); static asdl_seq *_gather_167_rule(Parser *p); static asdl_seq *_loop0_170_rule(Parser *p); static asdl_seq *_gather_169_rule(Parser *p); -static void *_tmp_171_rule(Parser *p); -static void *_tmp_172_rule(Parser *p); +static asdl_seq *_loop0_172_rule(Parser *p); +static asdl_seq *_gather_171_rule(Parser *p); static void *_tmp_173_rule(Parser *p); static void *_tmp_174_rule(Parser *p); static void *_tmp_175_rule(Parser *p); static void *_tmp_176_rule(Parser *p); static void *_tmp_177_rule(Parser *p); static void *_tmp_178_rule(Parser *p); -static asdl_seq *_loop1_179_rule(Parser *p); +static void *_tmp_179_rule(Parser *p); static void *_tmp_180_rule(Parser *p); -static void *_tmp_181_rule(Parser *p); +static asdl_seq *_loop1_181_rule(Parser *p); static void *_tmp_182_rule(Parser *p); +static void *_tmp_183_rule(Parser *p); +static void *_tmp_184_rule(Parser *p); // file: statements? $ @@ -5442,7 +5448,7 @@ literal_pattern_rule(Parser *p) return _res; } -// constant_pattern: '.' NAME | name_or_attr '.' NAME !'(' +// constant_pattern: '.' NAME !('.' | '(' | '=') | '.'? attr !('.' | '(' | '=') static void * constant_pattern_rule(Parser *p) { @@ -5453,30 +5459,23 @@ constant_pattern_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '.' NAME + { // '.' NAME !('.' | '(' | '=') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> constant_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.' NAME")); + D(fprintf(stderr, "%*c> constant_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.' NAME !('.' | '(' | '=')")); Token * _literal; expr_ty name; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' && (name = _PyPegen_name_token(p)) // NAME + && + _PyPegen_lookahead(0, _tmp_54_rule, p) ) { - D(fprintf(stderr, "%*c+ constant_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.' NAME")); + D(fprintf(stderr, "%*c+ constant_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.' NAME !('.' | '(' | '=')")); _res = name; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -5487,38 +5486,27 @@ constant_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s constant_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.' NAME")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.' NAME !('.' | '(' | '=')")); } - { // name_or_attr '.' NAME !'(' + { // '.'? attr !('.' | '(' | '=') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> constant_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME !'('")); - Token * _literal; - expr_ty attr; - void *value; + D(fprintf(stderr, "%*c> constant_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'? attr !('.' | '(' | '=')")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + void *attr; if ( - (value = name_or_attr_rule(p)) // name_or_attr + (_opt_var = _PyPegen_expect_token(p, 23), 1) // '.'? && - (_literal = _PyPegen_expect_token(p, 23)) // token='.' - && - (attr = _PyPegen_name_token(p)) // NAME + (attr = attr_rule(p)) // attr && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 7) // token='(' + _PyPegen_lookahead(0, _tmp_55_rule, p) ) { - D(fprintf(stderr, "%*c+ constant_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME !'('")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Attribute ( value , attr -> v . Name . id , Load , EXTRA ); + D(fprintf(stderr, "%*c+ constant_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'? attr !('.' | '(' | '=')")); + _res = attr; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5528,7 +5516,7 @@ constant_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s constant_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '.' NAME !'('")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'? attr !('.' | '(' | '=')")); } _res = NULL; done: @@ -5795,7 +5783,7 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (args = _gather_54_rule(p)) // ','.pattern+ + (args = _gather_56_rule(p)) // ','.pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -5841,7 +5829,7 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (keywords = _gather_56_rule(p)) // ','.keyword_pattern+ + (keywords = _gather_58_rule(p)) // ','.keyword_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -5889,11 +5877,11 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (args = _gather_58_rule(p)) // ','.pattern+ + (args = _gather_60_rule(p)) // ','.pattern+ && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (keywords = _gather_60_rule(p)) // ','.keyword_pattern+ + (keywords = _gather_62_rule(p)) // ','.keyword_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -5928,7 +5916,7 @@ class_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.argument_pattern+] ','? ')'")); - asdl_seq * _gather_63_var; + asdl_seq * _gather_65_var; Token * _literal; Token * _literal_1; Token * _literal_2; @@ -5945,15 +5933,15 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_opt_var = _tmp_62_rule(p), 1) // [','.pattern+ ','] + (_opt_var = _tmp_64_rule(p), 1) // [','.pattern+ ','] && - (_gather_63_var = _gather_63_rule(p)) // ','.keyword_pattern+ + (_gather_65_var = _gather_65_rule(p)) // ','.keyword_pattern+ && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && (error = pattern_rule(p)) // pattern && - (_opt_var_1 = _tmp_65_rule(p), 1) // [',' ','.argument_pattern+] + (_opt_var_1 = _tmp_67_rule(p), 1) // [',' ','.argument_pattern+] && (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -5994,11 +5982,11 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_opt_var = _tmp_66_rule(p), 1) // [','.argument_pattern+ ','] + (_opt_var = _tmp_68_rule(p), 1) // [','.argument_pattern+ ','] && (error = error_star_rule(p)) // error_star && - (_opt_var_1 = _tmp_67_rule(p), 1) // [',' ','.(argument_pattern | error_star)+] + (_opt_var_1 = _tmp_69_rule(p), 1) // [',' ','.(argument_pattern | error_star)+] && (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -6106,27 +6094,27 @@ signed_number_rule(Parser *p) } // Left-recursive -// name_or_attr: NAME | name_or_attr '.' NAME -static void * name_or_attr_raw(Parser *); +// attr: name_or_attr '.' NAME +static void * attr_raw(Parser *); static void * -name_or_attr_rule(Parser *p) +attr_rule(Parser *p) { D(p->level++); void * _res = NULL; - if (_PyPegen_is_memoized(p, name_or_attr_type, &_res)) { + if (_PyPegen_is_memoized(p, attr_type, &_res)) { D(p->level--); return _res; } int _mark = p->mark; int _resmark = p->mark; while (1) { - int tmpvar_1 = _PyPegen_update_memo(p, _mark, name_or_attr_type, _res); + int tmpvar_1 = _PyPegen_update_memo(p, _mark, attr_type, _res); if (tmpvar_1) { D(p->level--); return _res; } p->mark = _mark; - void *_raw = name_or_attr_raw(p); + void *_raw = attr_raw(p); if (_raw == NULL || p->mark <= _resmark) break; _resmark = p->mark; @@ -6137,7 +6125,7 @@ name_or_attr_rule(Parser *p) return _res; } static void * -name_or_attr_raw(Parser *p) +attr_raw(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -6155,31 +6143,12 @@ name_or_attr_raw(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); - expr_ty name_var; - if ( - (name_var = _PyPegen_name_token(p)) // NAME - ) - { - D(fprintf(stderr, "%*c+ name_or_attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); - _res = name_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); - } { // name_or_attr '.' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME")); + D(fprintf(stderr, "%*c> attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME")); Token * _literal; expr_ty attr; void *value; @@ -6191,7 +6160,7 @@ name_or_attr_raw(Parser *p) (attr = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ name_or_attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME")); + D(fprintf(stderr, "%*c+ attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -6210,7 +6179,7 @@ name_or_attr_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s attr[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '.' NAME")); } _res = NULL; @@ -6219,6 +6188,62 @@ name_or_attr_raw(Parser *p) return _res; } +// Left-recursive +// name_or_attr: attr | NAME +static void * +name_or_attr_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // attr + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "attr")); + void *attr_var; + if ( + (attr_var = attr_rule(p)) // attr + ) + { + D(fprintf(stderr, "%*c+ name_or_attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "attr")); + _res = attr_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "attr")); + } + { // NAME + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); + expr_ty name_var; + if ( + (name_var = _PyPegen_name_token(p)) // NAME + ) + { + D(fprintf(stderr, "%*c+ name_or_attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); + _res = name_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + // values_pattern: ','.value_pattern+ ','? static void * values_pattern_rule(Parser *p) @@ -6240,7 +6265,7 @@ values_pattern_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * values; if ( - (values = _gather_68_rule(p)) // ','.value_pattern+ + (values = _gather_70_rule(p)) // ','.value_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -6285,7 +6310,7 @@ items_pattern_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * items; if ( - (items = _gather_70_rule(p)) // ','.key_value_pattern+ + (items = _gather_72_rule(p)) // ','.key_value_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -6446,10 +6471,10 @@ error_star_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> error_star[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('*' | '**') NAME")); - void *_tmp_72_var; + void *_tmp_74_var; expr_ty error; if ( - (_tmp_72_var = _tmp_72_rule(p)) // '*' | '**' + (_tmp_74_var = _tmp_74_rule(p)) // '*' | '**' && (error = _PyPegen_name_token(p)) // NAME ) @@ -6577,7 +6602,7 @@ key_value_pattern_rule(Parser *p) void *key; void *value; if ( - (key = _tmp_73_rule(p)) // literal_pattern | constant_pattern + (key = _tmp_75_rule(p)) // literal_pattern | constant_pattern && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -6726,7 +6751,7 @@ raise_stmt_rule(Parser *p) && (a = expression_rule(p)) // expression && - (b = _tmp_74_rule(p), 1) // ['from' expression] + (b = _tmp_76_rule(p), 1) // ['from' expression] ) { D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); @@ -6901,7 +6926,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_75_rule(p), 1) // ['->' expression] + (a = _tmp_77_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -6961,7 +6986,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_76_rule(p), 1) // ['->' expression] + (a = _tmp_78_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -7025,7 +7050,7 @@ func_type_comment_rule(Parser *p) && (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' && - _PyPegen_lookahead(1, _tmp_77_rule, p) + _PyPegen_lookahead(1, _tmp_79_rule, p) ) { D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); @@ -7169,9 +7194,9 @@ parameters_rule(Parser *p) if ( (a = slash_no_default_rule(p)) // slash_no_default && - (b = _loop0_78_rule(p)) // param_no_default* + (b = _loop0_80_rule(p)) // param_no_default* && - (c = _loop0_79_rule(p)) // param_with_default* + (c = _loop0_81_rule(p)) // param_with_default* && (d = star_etc_rule(p), 1) // star_etc? ) @@ -7201,7 +7226,7 @@ parameters_rule(Parser *p) if ( (a = slash_with_default_rule(p)) // slash_with_default && - (b = _loop0_80_rule(p)) // param_with_default* + (b = _loop0_82_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -7229,9 +7254,9 @@ parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = _loop1_81_rule(p)) // param_no_default+ + (a = _loop1_83_rule(p)) // param_no_default+ && - (b = _loop0_82_rule(p)) // param_with_default* + (b = _loop0_84_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -7258,7 +7283,7 @@ parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_83_rule(p)) // param_with_default+ + (a = _loop1_85_rule(p)) // param_with_default+ && (b = star_etc_rule(p), 1) // star_etc? ) @@ -7327,7 +7352,7 @@ slash_no_default_rule(Parser *p) Token * _literal_1; asdl_seq * a; if ( - (a = _loop1_84_rule(p)) // param_no_default+ + (a = _loop1_86_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7356,7 +7381,7 @@ slash_no_default_rule(Parser *p) Token * _literal; asdl_seq * a; if ( - (a = _loop1_85_rule(p)) // param_no_default+ + (a = _loop1_87_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7406,9 +7431,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_86_rule(p)) // param_no_default* + (a = _loop0_88_rule(p)) // param_no_default* && - (b = _loop1_87_rule(p)) // param_with_default+ + (b = _loop1_89_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7438,9 +7463,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_88_rule(p)) // param_no_default* + (a = _loop0_90_rule(p)) // param_no_default* && - (b = _loop1_89_rule(p)) // param_with_default+ + (b = _loop1_91_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7496,7 +7521,7 @@ star_etc_rule(Parser *p) && (a = param_no_default_rule(p)) // param_no_default && - (b = _loop0_90_rule(p)) // param_maybe_default* + (b = _loop0_92_rule(p)) // param_maybe_default* && (c = kwds_rule(p), 1) // kwds? ) @@ -7529,7 +7554,7 @@ star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_91_rule(p)) // param_maybe_default+ + (b = _loop1_93_rule(p)) // param_maybe_default+ && (c = kwds_rule(p), 1) // kwds? ) @@ -8051,7 +8076,7 @@ decorators_rule(Parser *p) D(fprintf(stderr, "%*c> decorators[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); asdl_seq * a; if ( - (a = _loop1_92_rule(p)) // (('@' named_expression NEWLINE))+ + (a = _loop1_94_rule(p)) // (('@' named_expression NEWLINE))+ ) { D(fprintf(stderr, "%*c+ decorators[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); @@ -8172,7 +8197,7 @@ class_def_raw_rule(Parser *p) && (a = _PyPegen_name_token(p)) // NAME && - (b = _tmp_93_rule(p), 1) // ['(' arguments? ')'] + (b = _tmp_95_rule(p), 1) // ['(' arguments? ')'] && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -8321,7 +8346,7 @@ expressions_list_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_94_rule(p)) // ','.star_expression+ + (a = _gather_96_rule(p)) // ','.star_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8381,7 +8406,7 @@ star_expressions_rule(Parser *p) if ( (a = star_expression_rule(p)) // star_expression && - (b = _loop1_96_rule(p)) // ((',' star_expression))+ + (b = _loop1_98_rule(p)) // ((',' star_expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8576,7 +8601,7 @@ star_named_expressions_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_97_rule(p)) // ','.star_named_expression+ + (a = _gather_99_rule(p)) // ','.star_named_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8874,7 +8899,7 @@ expressions_rule(Parser *p) if ( (a = expression_rule(p)) // expression && - (b = _loop1_99_rule(p)) // ((',' expression))+ + (b = _loop1_101_rule(p)) // ((',' expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -9173,9 +9198,9 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default && - (b = _loop0_100_rule(p)) // lambda_param_no_default* + (b = _loop0_102_rule(p)) // lambda_param_no_default* && - (c = _loop0_101_rule(p)) // lambda_param_with_default* + (c = _loop0_103_rule(p)) // lambda_param_with_default* && (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9205,7 +9230,7 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default && - (b = _loop0_102_rule(p)) // lambda_param_with_default* + (b = _loop0_104_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9233,9 +9258,9 @@ lambda_parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = _loop1_103_rule(p)) // lambda_param_no_default+ + (a = _loop1_105_rule(p)) // lambda_param_no_default+ && - (b = _loop0_104_rule(p)) // lambda_param_with_default* + (b = _loop0_106_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9262,7 +9287,7 @@ lambda_parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_105_rule(p)) // lambda_param_with_default+ + (a = _loop1_107_rule(p)) // lambda_param_with_default+ && (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9333,7 +9358,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal_1; asdl_seq * a; if ( - (a = _loop1_106_rule(p)) // lambda_param_no_default+ + (a = _loop1_108_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9362,7 +9387,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal; asdl_seq * a; if ( - (a = _loop1_107_rule(p)) // lambda_param_no_default+ + (a = _loop1_109_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9412,9 +9437,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_108_rule(p)) // lambda_param_no_default* + (a = _loop0_110_rule(p)) // lambda_param_no_default* && - (b = _loop1_109_rule(p)) // lambda_param_with_default+ + (b = _loop1_111_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9444,9 +9469,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_110_rule(p)) // lambda_param_no_default* + (a = _loop0_112_rule(p)) // lambda_param_no_default* && - (b = _loop1_111_rule(p)) // lambda_param_with_default+ + (b = _loop1_113_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9502,7 +9527,7 @@ lambda_star_etc_rule(Parser *p) && (a = lambda_param_no_default_rule(p)) // lambda_param_no_default && - (b = _loop0_112_rule(p)) // lambda_param_maybe_default* + (b = _loop0_114_rule(p)) // lambda_param_maybe_default* && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -9535,7 +9560,7 @@ lambda_star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_113_rule(p)) // lambda_param_maybe_default+ + (b = _loop1_115_rule(p)) // lambda_param_maybe_default+ && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -9962,7 +9987,7 @@ disjunction_rule(Parser *p) if ( (a = conjunction_rule(p)) // conjunction && - (b = _loop1_114_rule(p)) // (('or' conjunction))+ + (b = _loop1_116_rule(p)) // (('or' conjunction))+ ) { D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); @@ -10048,7 +10073,7 @@ conjunction_rule(Parser *p) if ( (a = inversion_rule(p)) // inversion && - (b = _loop1_115_rule(p)) // (('and' inversion))+ + (b = _loop1_117_rule(p)) // (('and' inversion))+ ) { D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); @@ -10216,7 +10241,7 @@ comparison_rule(Parser *p) if ( (a = bitwise_or_rule(p)) // bitwise_or && - (b = _loop1_116_rule(p)) // compare_op_bitwise_or_pair+ + (b = _loop1_118_rule(p)) // compare_op_bitwise_or_pair+ ) { D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); @@ -10544,10 +10569,10 @@ noteq_bitwise_or_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); - void *_tmp_117_var; + void *_tmp_119_var; expr_ty a; if ( - (_tmp_117_var = _tmp_117_rule(p)) // '!=' + (_tmp_119_var = _tmp_119_rule(p)) // '!=' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -12476,7 +12501,7 @@ slices_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_118_rule(p)) // ','.slice+ + (a = _gather_120_rule(p)) // ','.slice+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -12546,7 +12571,7 @@ slice_rule(Parser *p) && (b = expression_rule(p), 1) // expression? && - (c = _tmp_120_rule(p), 1) // [':' expression?] + (c = _tmp_122_rule(p), 1) // [':' expression?] ) { D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); @@ -12820,15 +12845,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - void *_tmp_121_var; + void *_tmp_123_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' && - (_tmp_121_var = _tmp_121_rule(p)) // tuple | group | genexp + (_tmp_123_var = _tmp_123_rule(p)) // tuple | group | genexp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - _res = _tmp_121_var; + _res = _tmp_123_var; goto done; } p->mark = _mark; @@ -12841,15 +12866,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - void *_tmp_122_var; + void *_tmp_124_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' && - (_tmp_122_var = _tmp_122_rule(p)) // list | listcomp + (_tmp_124_var = _tmp_124_rule(p)) // list | listcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - _res = _tmp_122_var; + _res = _tmp_124_var; goto done; } p->mark = _mark; @@ -12862,15 +12887,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - void *_tmp_123_var; + void *_tmp_125_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' && - (_tmp_123_var = _tmp_123_rule(p)) // dict | set | dictcomp | setcomp + (_tmp_125_var = _tmp_125_rule(p)) // dict | set | dictcomp | setcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - _res = _tmp_123_var; + _res = _tmp_125_var; goto done; } p->mark = _mark; @@ -12939,7 +12964,7 @@ strings_rule(Parser *p) D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+")); asdl_seq * a; if ( - (a = _loop1_124_rule(p)) // STRING+ + (a = _loop1_126_rule(p)) // STRING+ ) { D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+")); @@ -13146,7 +13171,7 @@ tuple_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_125_rule(p), 1) // [star_named_expression ',' star_named_expressions?] + (a = _tmp_127_rule(p), 1) // [star_named_expression ',' star_named_expressions?] && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -13202,7 +13227,7 @@ group_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_126_rule(p)) // yield_expr | named_expression + (a = _tmp_128_rule(p)) // yield_expr | named_expression && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -13638,7 +13663,7 @@ double_starred_kvpairs_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_127_rule(p)) // ','.double_starred_kvpair+ + (a = _gather_129_rule(p)) // ','.double_starred_kvpair+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -13789,13 +13814,13 @@ for_if_clauses_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); - asdl_seq * _loop1_129_var; + asdl_seq * _loop1_131_var; if ( - (_loop1_129_var = _loop1_129_rule(p)) // for_if_clause+ + (_loop1_131_var = _loop1_131_rule(p)) // for_if_clause+ ) { D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); - _res = _loop1_129_var; + _res = _loop1_131_var; goto done; } p->mark = _mark; @@ -13844,7 +13869,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = _loop0_130_rule(p)) // (('if' disjunction))* + (c = _loop0_132_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*")); @@ -13880,7 +13905,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = _loop0_131_rule(p)) // (('if' disjunction))* + (c = _loop0_133_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*")); @@ -14105,7 +14130,7 @@ args_rule(Parser *p) if ( (a = starred_expression_rule(p)) // starred_expression && - (b = _tmp_132_rule(p), 1) // [',' args] + (b = _tmp_134_rule(p), 1) // [',' args] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]")); @@ -14174,7 +14199,7 @@ args_rule(Parser *p) if ( (a = named_expression_rule(p)) // named_expression && - (b = _tmp_133_rule(p), 1) // [',' args] + (b = _tmp_135_rule(p), 1) // [',' args] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]")); @@ -14229,11 +14254,11 @@ kwargs_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _gather_134_rule(p)) // ','.kwarg_or_starred+ + (a = _gather_136_rule(p)) // ','.kwarg_or_starred+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _gather_136_rule(p)) // ','.kwarg_or_double_starred+ + (b = _gather_138_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); @@ -14255,13 +14280,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - asdl_seq * _gather_138_var; + asdl_seq * _gather_140_var; if ( - (_gather_138_var = _gather_138_rule(p)) // ','.kwarg_or_starred+ + (_gather_140_var = _gather_140_rule(p)) // ','.kwarg_or_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - _res = _gather_138_var; + _res = _gather_140_var; goto done; } p->mark = _mark; @@ -14274,13 +14299,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - asdl_seq * _gather_140_var; + asdl_seq * _gather_142_var; if ( - (_gather_140_var = _gather_140_rule(p)) // ','.kwarg_or_double_starred+ + (_gather_142_var = _gather_142_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - _res = _gather_140_var; + _res = _gather_142_var; goto done; } p->mark = _mark; @@ -14642,7 +14667,7 @@ star_targets_rule(Parser *p) if ( (a = star_target_rule(p)) // star_target && - (b = _loop0_142_rule(p)) // ((',' star_target))* + (b = _loop0_144_rule(p)) // ((',' star_target))* && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -14696,7 +14721,7 @@ star_targets_seq_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_143_rule(p)) // ','.star_target+ + (a = _gather_145_rule(p)) // ','.star_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -14759,7 +14784,7 @@ star_target_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (a = _tmp_145_rule(p)) // !'*' star_target + (a = _tmp_147_rule(p)) // !'*' star_target ) { D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); @@ -15281,7 +15306,7 @@ del_targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_146_rule(p)) // ','.del_target+ + (a = _gather_148_rule(p)) // ','.del_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -15760,7 +15785,7 @@ targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_148_rule(p)) // ','.target+ + (a = _gather_150_rule(p)) // ','.target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -16472,7 +16497,7 @@ incorrect_arguments_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_opt_var = _tmp_150_rule(p), 1) // [args | expression for_if_clauses] + (_opt_var = _tmp_152_rule(p), 1) // [args | expression for_if_clauses] ) { D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); @@ -16754,14 +16779,14 @@ invalid_assignment_rule(Parser *p) D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'")); Token * _literal; Token * _literal_1; - asdl_seq * _loop0_151_var; + asdl_seq * _loop0_153_var; expr_ty a; if ( (a = star_named_expression_rule(p)) // star_named_expression && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_loop0_151_var = _loop0_151_rule(p)) // star_named_expressions* + (_loop0_153_var = _loop0_153_rule(p)) // star_named_expressions* && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' ) @@ -16797,7 +16822,7 @@ invalid_assignment_rule(Parser *p) && (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_152_rule(p), 1) // ['=' annotated_rhs] + (_opt_var = _tmp_154_rule(p), 1) // ['=' annotated_rhs] ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]")); @@ -16820,14 +16845,14 @@ invalid_assignment_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); Token * _literal; - void *_tmp_153_var; + void *_tmp_155_var; expr_ty a; if ( (a = star_expressions_rule(p)) // star_expressions && (_literal = _PyPegen_expect_token(p, 22)) // token='=' && - (_tmp_153_var = _tmp_153_rule(p)) // yield_expr | star_expressions + (_tmp_155_var = _tmp_155_rule(p)) // yield_expr | star_expressions ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions '=' (yield_expr | star_expressions)")); @@ -16849,7 +16874,7 @@ invalid_assignment_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); - void *_tmp_154_var; + void *_tmp_156_var; expr_ty a; AugOperator* augassign_var; if ( @@ -16857,7 +16882,7 @@ invalid_assignment_rule(Parser *p) && (augassign_var = augassign_rule(p)) // augassign && - (_tmp_154_var = _tmp_154_rule(p)) // yield_expr | star_expressions + (_tmp_156_var = _tmp_156_rule(p)) // yield_expr | star_expressions ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); @@ -16939,11 +16964,11 @@ invalid_comprehension_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); - void *_tmp_155_var; + void *_tmp_157_var; expr_ty a; asdl_seq* for_if_clauses_var; if ( - (_tmp_155_var = _tmp_155_rule(p)) // '[' | '(' | '{' + (_tmp_157_var = _tmp_157_rule(p)) // '[' | '(' | '{' && (a = starred_expression_rule(p)) // starred_expression && @@ -17040,13 +17065,13 @@ invalid_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); - asdl_seq * _loop0_156_var; - void *_tmp_157_var; + asdl_seq * _loop0_158_var; + void *_tmp_159_var; arg_ty param_no_default_var; if ( - (_loop0_156_var = _loop0_156_rule(p)) // param_no_default* + (_loop0_158_var = _loop0_158_rule(p)) // param_no_default* && - (_tmp_157_var = _tmp_157_rule(p)) // slash_with_default | param_with_default+ + (_tmp_159_var = _tmp_159_rule(p)) // slash_with_default | param_with_default+ && (param_no_default_var = param_no_default_rule(p)) // param_no_default ) @@ -17088,11 +17113,11 @@ invalid_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); Token * _literal; - void *_tmp_158_var; + void *_tmp_160_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_158_var = _tmp_158_rule(p)) // ')' | ',' (')' | '**') + (_tmp_160_var = _tmp_160_rule(p)) // ')' | ',' (')' | '**') ) { D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); @@ -17162,11 +17187,11 @@ invalid_lambda_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); Token * _literal; - void *_tmp_159_var; + void *_tmp_161_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_159_var = _tmp_159_rule(p)) // ':' | ',' (':' | '**') + (_tmp_161_var = _tmp_161_rule(p)) // ':' | ',' (':' | '**') ) { D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); @@ -18576,12 +18601,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_160_var; + void *_tmp_162_var; while ( - (_tmp_160_var = _tmp_160_rule(p)) // star_targets '=' + (_tmp_162_var = _tmp_162_rule(p)) // star_targets '=' ) { - _res = _tmp_160_var; + _res = _tmp_162_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -19029,12 +19054,12 @@ _loop0_30_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop0_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_161_var; + void *_tmp_163_var; while ( - (_tmp_161_var = _tmp_161_rule(p)) // '.' | '...' + (_tmp_163_var = _tmp_163_rule(p)) // '.' | '...' ) { - _res = _tmp_161_var; + _res = _tmp_163_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -19095,12 +19120,12 @@ _loop1_31_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_162_var; + void *_tmp_164_var; while ( - (_tmp_162_var = _tmp_162_rule(p)) // '.' | '...' + (_tmp_164_var = _tmp_164_rule(p)) // '.' | '...' ) { - _res = _tmp_162_var; + _res = _tmp_164_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -20384,113 +20409,73 @@ _tmp_53_rule(Parser *p) return _res; } -// _loop0_55: ',' pattern -static asdl_seq * -_loop0_55_rule(Parser *p) +// _tmp_54: '.' | '(' | '=' +static void * +_tmp_54_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void *_res = 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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ',' pattern + { // '.' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _tmp_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; - expr_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = pattern_rule(p)) // pattern + if ( + (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - _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; + D(fprintf(stderr, "%*c+ _tmp_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + _res = _literal; + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_55[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); - } - asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s _tmp_54[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } - for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); - PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_55_type, _seq); - D(p->level--); - return _seq; -} - -// _gather_54: pattern _loop0_55 -static asdl_seq * -_gather_54_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + { // '(' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + ) + { + D(fprintf(stderr, "%*c+ _tmp_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_54[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // pattern _loop0_55 + { // '=' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_55")); - expr_ty elem; - asdl_seq * seq; + D(fprintf(stderr, "%*c> _tmp_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); + Token * _literal; if ( - (elem = pattern_rule(p)) // pattern - && - (seq = _loop0_55_rule(p)) // _loop0_55 + (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _gather_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_55")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); + D(fprintf(stderr, "%*c+ _tmp_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_54[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_55")); + D(fprintf(stderr, "%*c%s _tmp_54[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); } _res = NULL; done: @@ -20498,47 +20483,121 @@ _gather_54_rule(Parser *p) return _res; } -// _loop0_57: ',' keyword_pattern -static asdl_seq * -_loop0_57_rule(Parser *p) +// _tmp_55: '.' | '(' | '=' +static void * +_tmp_55_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void *_res = 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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ',' keyword_pattern + { // '.' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); + D(fprintf(stderr, "%*c> _tmp_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; - void *elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = keyword_pattern_rule(p)) // keyword_pattern + if ( + (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c+ _tmp_55[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_55[%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_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + ) + { + D(fprintf(stderr, "%*c+ _tmp_55[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_55[%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_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ _tmp_55[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_55[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_57: ',' pattern +static asdl_seq * +_loop0_57_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + Token * _literal; + expr_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = pattern_rule(p)) // pattern + ) + { + _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; @@ -20556,7 +20615,7 @@ _loop0_57_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s _loop0_57[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -20573,7 +20632,7 @@ _loop0_57_rule(Parser *p) return _seq; } -// _gather_56: keyword_pattern _loop0_57 +// _gather_56: pattern _loop0_57 static asdl_seq * _gather_56_rule(Parser *p) { @@ -20584,27 +20643,27 @@ _gather_56_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // keyword_pattern _loop0_57 + { // pattern _loop0_57 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_57")); - void *elem; + D(fprintf(stderr, "%*c> _gather_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_57")); + expr_ty elem; asdl_seq * seq; if ( - (elem = keyword_pattern_rule(p)) // keyword_pattern + (elem = pattern_rule(p)) // pattern && (seq = _loop0_57_rule(p)) // _loop0_57 ) { - D(fprintf(stderr, "%*c+ _gather_56[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_57")); + D(fprintf(stderr, "%*c+ _gather_56[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_57")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _gather_56[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_57")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_57")); } _res = NULL; done: @@ -20612,7 +20671,7 @@ _gather_56_rule(Parser *p) return _res; } -// _loop0_59: ',' pattern +// _loop0_59: ',' keyword_pattern static asdl_seq * _loop0_59_rule(Parser *p) { @@ -20633,18 +20692,18 @@ _loop0_59_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' pattern + { // ',' keyword_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _loop0_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; - expr_ty elem; + void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = pattern_rule(p)) // pattern + (elem = keyword_pattern_rule(p)) // keyword_pattern ) { _res = elem; @@ -20670,7 +20729,7 @@ _loop0_59_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s _loop0_59[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -20687,7 +20746,7 @@ _loop0_59_rule(Parser *p) return _seq; } -// _gather_58: pattern _loop0_59 +// _gather_58: keyword_pattern _loop0_59 static asdl_seq * _gather_58_rule(Parser *p) { @@ -20698,27 +20757,27 @@ _gather_58_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // pattern _loop0_59 + { // keyword_pattern _loop0_59 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_59")); - expr_ty elem; + D(fprintf(stderr, "%*c> _gather_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_59")); + void *elem; asdl_seq * seq; if ( - (elem = pattern_rule(p)) // pattern + (elem = keyword_pattern_rule(p)) // keyword_pattern && (seq = _loop0_59_rule(p)) // _loop0_59 ) { - D(fprintf(stderr, "%*c+ _gather_58[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_59")); + D(fprintf(stderr, "%*c+ _gather_58[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_59")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _gather_58[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_59")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_59")); } _res = NULL; done: @@ -20726,9 +20785,123 @@ _gather_58_rule(Parser *p) return _res; } -// _loop0_61: ',' keyword_pattern +// _loop0_61: ',' pattern static asdl_seq * _loop0_61_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + Token * _literal; + expr_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = pattern_rule(p)) // pattern + ) + { + _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_61[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); + } + asdl_seq *_seq = _Py_asdl_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(_seq, i, _children[i]); + PyMem_Free(_children); + _PyPegen_insert_memo(p, _start_mark, _loop0_61_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_60: pattern _loop0_61 +static asdl_seq * +_gather_60_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // pattern _loop0_61 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _gather_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_61")); + expr_ty elem; + asdl_seq * seq; + if ( + (elem = pattern_rule(p)) // pattern + && + (seq = _loop0_61_rule(p)) // _loop0_61 + ) + { + D(fprintf(stderr, "%*c+ _gather_60[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_61")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_60[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_61")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_63: ',' keyword_pattern +static asdl_seq * +_loop0_63_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20752,7 +20925,7 @@ _loop0_61_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); + D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; void *elem; while ( @@ -20783,7 +20956,7 @@ _loop0_61_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_61[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_63[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20796,14 +20969,14 @@ _loop0_61_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_61_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_63_type, _seq); D(p->level--); return _seq; } -// _gather_60: keyword_pattern _loop0_61 +// _gather_62: keyword_pattern _loop0_63 static asdl_seq * -_gather_60_rule(Parser *p) +_gather_62_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20812,27 +20985,27 @@ _gather_60_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // keyword_pattern _loop0_61 + { // keyword_pattern _loop0_63 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_61")); + D(fprintf(stderr, "%*c> _gather_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_63")); void *elem; asdl_seq * seq; if ( (elem = keyword_pattern_rule(p)) // keyword_pattern && - (seq = _loop0_61_rule(p)) // _loop0_61 + (seq = _loop0_63_rule(p)) // _loop0_63 ) { - D(fprintf(stderr, "%*c+ _gather_60[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_61")); + D(fprintf(stderr, "%*c+ _gather_62[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_63")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_60[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_61")); + D(fprintf(stderr, "%*c%s _gather_62[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_63")); } _res = NULL; done: @@ -20840,9 +21013,9 @@ _gather_60_rule(Parser *p) return _res; } -// _tmp_62: ','.pattern+ ',' +// _tmp_64: ','.pattern+ ',' static void * -_tmp_62_rule(Parser *p) +_tmp_64_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20856,21 +21029,21 @@ _tmp_62_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); - asdl_seq * _gather_163_var; + D(fprintf(stderr, "%*c> _tmp_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); + asdl_seq * _gather_165_var; Token * _literal; if ( - (_gather_163_var = _gather_163_rule(p)) // ','.pattern+ + (_gather_165_var = _gather_165_rule(p)) // ','.pattern+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_62[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); - _res = _PyPegen_dummy_name(p, _gather_163_var, _literal); + D(fprintf(stderr, "%*c+ _tmp_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); + _res = _PyPegen_dummy_name(p, _gather_165_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_62[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_64[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.pattern+ ','")); } _res = NULL; @@ -20879,9 +21052,9 @@ _tmp_62_rule(Parser *p) return _res; } -// _loop0_64: ',' keyword_pattern +// _loop0_66: ',' keyword_pattern static asdl_seq * -_loop0_64_rule(Parser *p) +_loop0_66_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20905,7 +21078,7 @@ _loop0_64_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); + D(fprintf(stderr, "%*c> _loop0_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; void *elem; while ( @@ -20936,7 +21109,7 @@ _loop0_64_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_64[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_66[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -20949,14 +21122,14 @@ _loop0_64_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_64_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_66_type, _seq); D(p->level--); return _seq; } -// _gather_63: keyword_pattern _loop0_64 +// _gather_65: keyword_pattern _loop0_66 static asdl_seq * -_gather_63_rule(Parser *p) +_gather_65_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20965,27 +21138,27 @@ _gather_63_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // keyword_pattern _loop0_64 + { // keyword_pattern _loop0_66 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_64")); + D(fprintf(stderr, "%*c> _gather_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_66")); void *elem; asdl_seq * seq; if ( (elem = keyword_pattern_rule(p)) // keyword_pattern && - (seq = _loop0_64_rule(p)) // _loop0_64 + (seq = _loop0_66_rule(p)) // _loop0_66 ) { - D(fprintf(stderr, "%*c+ _gather_63[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_64")); + D(fprintf(stderr, "%*c+ _gather_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_66")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_63[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_64")); + D(fprintf(stderr, "%*c%s _gather_65[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_66")); } _res = NULL; done: @@ -20993,9 +21166,9 @@ _gather_63_rule(Parser *p) return _res; } -// _tmp_65: ',' ','.argument_pattern+ +// _tmp_67: ',' ','.argument_pattern+ static void * -_tmp_65_rule(Parser *p) +_tmp_67_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21009,21 +21182,21 @@ _tmp_65_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.argument_pattern+")); - asdl_seq * _gather_165_var; + D(fprintf(stderr, "%*c> _tmp_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.argument_pattern+")); + asdl_seq * _gather_167_var; Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_gather_165_var = _gather_165_rule(p)) // ','.argument_pattern+ + (_gather_167_var = _gather_167_rule(p)) // ','.argument_pattern+ ) { - D(fprintf(stderr, "%*c+ _tmp_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.argument_pattern+")); - _res = _PyPegen_dummy_name(p, _literal, _gather_165_var); + D(fprintf(stderr, "%*c+ _tmp_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.argument_pattern+")); + _res = _PyPegen_dummy_name(p, _literal, _gather_167_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_65[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_67[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.argument_pattern+")); } _res = NULL; @@ -21032,9 +21205,9 @@ _tmp_65_rule(Parser *p) return _res; } -// _tmp_66: ','.argument_pattern+ ',' +// _tmp_68: ','.argument_pattern+ ',' static void * -_tmp_66_rule(Parser *p) +_tmp_68_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21048,21 +21221,21 @@ _tmp_66_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.argument_pattern+ ','")); - asdl_seq * _gather_167_var; + D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.argument_pattern+ ','")); + asdl_seq * _gather_169_var; Token * _literal; if ( - (_gather_167_var = _gather_167_rule(p)) // ','.argument_pattern+ + (_gather_169_var = _gather_169_rule(p)) // ','.argument_pattern+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.argument_pattern+ ','")); - _res = _PyPegen_dummy_name(p, _gather_167_var, _literal); + D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.argument_pattern+ ','")); + _res = _PyPegen_dummy_name(p, _gather_169_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_66[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.argument_pattern+ ','")); } _res = NULL; @@ -21071,9 +21244,9 @@ _tmp_66_rule(Parser *p) return _res; } -// _tmp_67: ',' ','.(argument_pattern | error_star)+ +// _tmp_69: ',' ','.(argument_pattern | error_star)+ static void * -_tmp_67_rule(Parser *p) +_tmp_69_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21087,21 +21260,21 @@ _tmp_67_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); - asdl_seq * _gather_169_var; + D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); + asdl_seq * _gather_171_var; Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_gather_169_var = _gather_169_rule(p)) // ','.(argument_pattern | error_star)+ + (_gather_171_var = _gather_171_rule(p)) // ','.(argument_pattern | error_star)+ ) { - D(fprintf(stderr, "%*c+ _tmp_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); - _res = _PyPegen_dummy_name(p, _literal, _gather_169_var); + D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); + _res = _PyPegen_dummy_name(p, _literal, _gather_171_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_67[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_69[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); } _res = NULL; @@ -21110,9 +21283,9 @@ _tmp_67_rule(Parser *p) return _res; } -// _loop0_69: ',' value_pattern +// _loop0_71: ',' value_pattern static asdl_seq * -_loop0_69_rule(Parser *p) +_loop0_71_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21136,7 +21309,7 @@ _loop0_69_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' value_pattern")); + D(fprintf(stderr, "%*c> _loop0_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' value_pattern")); Token * _literal; void *elem; while ( @@ -21167,7 +21340,7 @@ _loop0_69_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_69[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_71[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' value_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21180,14 +21353,14 @@ _loop0_69_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_69_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_71_type, _seq); D(p->level--); return _seq; } -// _gather_68: value_pattern _loop0_69 +// _gather_70: value_pattern _loop0_71 static asdl_seq * -_gather_68_rule(Parser *p) +_gather_70_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21196,27 +21369,27 @@ _gather_68_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // value_pattern _loop0_69 + { // value_pattern _loop0_71 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_69")); + D(fprintf(stderr, "%*c> _gather_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_71")); void *elem; asdl_seq * seq; if ( (elem = value_pattern_rule(p)) // value_pattern && - (seq = _loop0_69_rule(p)) // _loop0_69 + (seq = _loop0_71_rule(p)) // _loop0_71 ) { - D(fprintf(stderr, "%*c+ _gather_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_69")); + D(fprintf(stderr, "%*c+ _gather_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_71")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_68[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern _loop0_69")); + D(fprintf(stderr, "%*c%s _gather_70[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern _loop0_71")); } _res = NULL; done: @@ -21224,9 +21397,9 @@ _gather_68_rule(Parser *p) return _res; } -// _loop0_71: ',' key_value_pattern +// _loop0_73: ',' key_value_pattern static asdl_seq * -_loop0_71_rule(Parser *p) +_loop0_73_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21250,7 +21423,7 @@ _loop0_71_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); + D(fprintf(stderr, "%*c> _loop0_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); Token * _literal; void *elem; while ( @@ -21281,7 +21454,7 @@ _loop0_71_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_71[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_73[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' key_value_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21294,14 +21467,14 @@ _loop0_71_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_71_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_73_type, _seq); D(p->level--); return _seq; } -// _gather_70: key_value_pattern _loop0_71 +// _gather_72: key_value_pattern _loop0_73 static asdl_seq * -_gather_70_rule(Parser *p) +_gather_72_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21310,27 +21483,27 @@ _gather_70_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // key_value_pattern _loop0_71 + { // key_value_pattern _loop0_73 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_71")); + D(fprintf(stderr, "%*c> _gather_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_73")); void *elem; asdl_seq * seq; if ( (elem = key_value_pattern_rule(p)) // key_value_pattern && - (seq = _loop0_71_rule(p)) // _loop0_71 + (seq = _loop0_73_rule(p)) // _loop0_73 ) { - D(fprintf(stderr, "%*c+ _gather_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_71")); + D(fprintf(stderr, "%*c+ _gather_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_73")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_70[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_71")); + D(fprintf(stderr, "%*c%s _gather_72[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_73")); } _res = NULL; done: @@ -21338,9 +21511,9 @@ _gather_70_rule(Parser *p) return _res; } -// _tmp_72: '*' | '**' +// _tmp_74: '*' | '**' static void * -_tmp_72_rule(Parser *p) +_tmp_74_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21354,18 +21527,18 @@ _tmp_72_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); + D(fprintf(stderr, "%*c> _tmp_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' ) { - D(fprintf(stderr, "%*c+ _tmp_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); + D(fprintf(stderr, "%*c+ _tmp_74[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_72[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_74[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); } { // '**' @@ -21373,18 +21546,18 @@ _tmp_72_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_74[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_72[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_74[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -21393,9 +21566,9 @@ _tmp_72_rule(Parser *p) return _res; } -// _tmp_73: literal_pattern | constant_pattern +// _tmp_75: literal_pattern | constant_pattern static void * -_tmp_73_rule(Parser *p) +_tmp_75_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21409,18 +21582,18 @@ _tmp_73_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); void *literal_pattern_var; if ( (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_73[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + D(fprintf(stderr, "%*c+ _tmp_75[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); _res = literal_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_73[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_75[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern")); } { // constant_pattern @@ -21428,18 +21601,18 @@ _tmp_73_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern")); + D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern")); void *constant_pattern_var; if ( (constant_pattern_var = constant_pattern_rule(p)) // constant_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_73[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "constant_pattern")); + D(fprintf(stderr, "%*c+ _tmp_75[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "constant_pattern")); _res = constant_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_73[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_75[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "constant_pattern")); } _res = NULL; @@ -21448,9 +21621,9 @@ _tmp_73_rule(Parser *p) return _res; } -// _tmp_74: 'from' expression +// _tmp_76: 'from' expression static void * -_tmp_74_rule(Parser *p) +_tmp_76_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21464,7 +21637,7 @@ _tmp_74_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); + D(fprintf(stderr, "%*c> _tmp_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); Token * _keyword; expr_ty z; if ( @@ -21473,7 +21646,7 @@ _tmp_74_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_74[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); + D(fprintf(stderr, "%*c+ _tmp_76[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21483,7 +21656,7 @@ _tmp_74_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_74[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_76[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression")); } _res = NULL; @@ -21492,9 +21665,9 @@ _tmp_74_rule(Parser *p) return _res; } -// _tmp_75: '->' expression +// _tmp_77: '->' expression static void * -_tmp_75_rule(Parser *p) +_tmp_77_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21508,7 +21681,7 @@ _tmp_75_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -21517,7 +21690,7 @@ _tmp_75_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_75[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_77[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21527,7 +21700,7 @@ _tmp_75_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_75[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_77[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -21536,9 +21709,9 @@ _tmp_75_rule(Parser *p) return _res; } -// _tmp_76: '->' expression +// _tmp_78: '->' expression static void * -_tmp_76_rule(Parser *p) +_tmp_78_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21552,7 +21725,7 @@ _tmp_76_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -21561,7 +21734,7 @@ _tmp_76_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_76[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_78[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21571,7 +21744,7 @@ _tmp_76_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_76[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_78[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -21580,9 +21753,9 @@ _tmp_76_rule(Parser *p) return _res; } -// _tmp_77: NEWLINE INDENT +// _tmp_79: NEWLINE INDENT static void * -_tmp_77_rule(Parser *p) +_tmp_79_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21596,7 +21769,7 @@ _tmp_77_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c> _tmp_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); Token * indent_var; Token * newline_var; if ( @@ -21605,12 +21778,12 @@ _tmp_77_rule(Parser *p) (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' ) { - D(fprintf(stderr, "%*c+ _tmp_77[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c+ _tmp_79[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); _res = _PyPegen_dummy_name(p, newline_var, indent_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_77[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_79[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); } _res = NULL; @@ -21619,9 +21792,9 @@ _tmp_77_rule(Parser *p) return _res; } -// _loop0_78: param_no_default +// _loop0_80: param_no_default static asdl_seq * -_loop0_78_rule(Parser *p) +_loop0_80_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21645,7 +21818,7 @@ _loop0_78_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_80[%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 @@ -21667,7 +21840,7 @@ _loop0_78_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_78[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_80[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21680,14 +21853,14 @@ _loop0_78_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_78_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_80_type, _seq); D(p->level--); return _seq; } -// _loop0_79: param_with_default +// _loop0_81: param_with_default static asdl_seq * -_loop0_79_rule(Parser *p) +_loop0_81_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21711,7 +21884,7 @@ _loop0_79_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21733,7 +21906,7 @@ _loop0_79_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_79[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_81[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21746,14 +21919,14 @@ _loop0_79_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_81_type, _seq); D(p->level--); return _seq; } -// _loop0_80: param_with_default +// _loop0_82: param_with_default static asdl_seq * -_loop0_80_rule(Parser *p) +_loop0_82_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21777,7 +21950,7 @@ _loop0_80_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21799,7 +21972,7 @@ _loop0_80_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_80[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_82[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21812,14 +21985,14 @@ _loop0_80_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_80_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_82_type, _seq); D(p->level--); return _seq; } -// _loop1_81: param_no_default +// _loop1_83: param_no_default static asdl_seq * -_loop1_81_rule(Parser *p) +_loop1_83_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21843,7 +22016,7 @@ _loop1_81_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_83[%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 @@ -21865,7 +22038,7 @@ _loop1_81_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -21883,14 +22056,14 @@ _loop1_81_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); D(p->level--); return _seq; } -// _loop0_82: param_with_default +// _loop0_84: param_with_default static asdl_seq * -_loop0_82_rule(Parser *p) +_loop0_84_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21914,7 +22087,7 @@ _loop0_82_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -21936,7 +22109,7 @@ _loop0_82_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_82[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_84[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21949,14 +22122,14 @@ _loop0_82_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_82_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_84_type, _seq); D(p->level--); return _seq; } -// _loop1_83: param_with_default +// _loop1_85: param_with_default static asdl_seq * -_loop1_83_rule(Parser *p) +_loop1_85_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21980,7 +22153,7 @@ _loop1_83_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -22002,7 +22175,7 @@ _loop1_83_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_85[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -22020,14 +22193,14 @@ _loop1_83_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_85_type, _seq); D(p->level--); return _seq; } -// _loop1_84: param_no_default +// _loop1_86: param_no_default static asdl_seq * -_loop1_84_rule(Parser *p) +_loop1_86_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22051,7 +22224,7 @@ _loop1_84_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_86[%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 @@ -22073,7 +22246,7 @@ _loop1_84_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -22091,14 +22264,14 @@ _loop1_84_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_86_type, _seq); D(p->level--); return _seq; } -// _loop1_85: param_no_default +// _loop1_87: param_no_default static asdl_seq * -_loop1_85_rule(Parser *p) +_loop1_87_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22122,7 +22295,7 @@ _loop1_85_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_87[%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 @@ -22144,7 +22317,7 @@ _loop1_85_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_85[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -22162,14 +22335,14 @@ _loop1_85_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_85_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_87_type, _seq); D(p->level--); return _seq; } -// _loop0_86: param_no_default +// _loop0_88: param_no_default static asdl_seq * -_loop0_86_rule(Parser *p) +_loop0_88_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22193,7 +22366,7 @@ _loop0_86_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_88[%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 @@ -22215,7 +22388,7 @@ _loop0_86_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_86[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_88[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22228,14 +22401,14 @@ _loop0_86_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_86_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_88_type, _seq); D(p->level--); return _seq; } -// _loop1_87: param_with_default +// _loop1_89: param_with_default static asdl_seq * -_loop1_87_rule(Parser *p) +_loop1_89_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22259,7 +22432,7 @@ _loop1_87_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -22281,7 +22454,7 @@ _loop1_87_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -22299,14 +22472,14 @@ _loop1_87_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_87_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq); D(p->level--); return _seq; } -// _loop0_88: param_no_default +// _loop0_90: param_no_default static asdl_seq * -_loop0_88_rule(Parser *p) +_loop0_90_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22330,7 +22503,7 @@ _loop0_88_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_90[%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 @@ -22352,7 +22525,7 @@ _loop0_88_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_88[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_90[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22365,14 +22538,14 @@ _loop0_88_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_88_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_90_type, _seq); D(p->level--); return _seq; } -// _loop1_89: param_with_default +// _loop1_91: param_with_default static asdl_seq * -_loop1_89_rule(Parser *p) +_loop1_91_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22396,7 +22569,7 @@ _loop1_89_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -22418,7 +22591,7 @@ _loop1_89_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -22436,14 +22609,14 @@ _loop1_89_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq); D(p->level--); return _seq; } -// _loop0_90: param_maybe_default +// _loop0_92: param_maybe_default static asdl_seq * -_loop0_90_rule(Parser *p) +_loop0_92_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22467,7 +22640,7 @@ _loop0_90_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -22489,7 +22662,7 @@ _loop0_90_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_90[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_92[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22502,14 +22675,14 @@ _loop0_90_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_90_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_92_type, _seq); D(p->level--); return _seq; } -// _loop1_91: param_maybe_default +// _loop1_93: param_maybe_default static asdl_seq * -_loop1_91_rule(Parser *p) +_loop1_93_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22533,7 +22706,7 @@ _loop1_91_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -22555,7 +22728,7 @@ _loop1_91_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_93[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -22573,14 +22746,14 @@ _loop1_91_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_93_type, _seq); D(p->level--); return _seq; } -// _loop1_92: ('@' named_expression NEWLINE) +// _loop1_94: ('@' named_expression NEWLINE) static asdl_seq * -_loop1_92_rule(Parser *p) +_loop1_94_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22604,13 +22777,13 @@ _loop1_92_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); - void *_tmp_171_var; + D(fprintf(stderr, "%*c> _loop1_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); + void *_tmp_173_var; while ( - (_tmp_171_var = _tmp_171_rule(p)) // '@' named_expression NEWLINE + (_tmp_173_var = _tmp_173_rule(p)) // '@' named_expression NEWLINE ) { - _res = _tmp_171_var; + _res = _tmp_173_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22626,7 +22799,7 @@ _loop1_92_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_92[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_94[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)")); } if (_n == 0 || p->error_indicator) { @@ -22644,14 +22817,14 @@ _loop1_92_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_92_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_94_type, _seq); D(p->level--); return _seq; } -// _tmp_93: '(' arguments? ')' +// _tmp_95: '(' arguments? ')' static void * -_tmp_93_rule(Parser *p) +_tmp_95_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22665,7 +22838,7 @@ _tmp_93_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); Token * _literal; Token * _literal_1; void *z; @@ -22677,7 +22850,7 @@ _tmp_93_rule(Parser *p) (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -22687,7 +22860,7 @@ _tmp_93_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); } _res = NULL; @@ -22696,9 +22869,9 @@ _tmp_93_rule(Parser *p) return _res; } -// _loop0_95: ',' star_expression +// _loop0_97: ',' star_expression static asdl_seq * -_loop0_95_rule(Parser *p) +_loop0_97_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22722,7 +22895,7 @@ _loop0_95_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _loop0_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty elem; while ( @@ -22753,7 +22926,7 @@ _loop0_95_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_95[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_97[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22766,14 +22939,14 @@ _loop0_95_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_95_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_97_type, _seq); D(p->level--); return _seq; } -// _gather_94: star_expression _loop0_95 +// _gather_96: star_expression _loop0_97 static asdl_seq * -_gather_94_rule(Parser *p) +_gather_96_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22782,27 +22955,27 @@ _gather_94_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_expression _loop0_95 + { // star_expression _loop0_97 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_95")); + D(fprintf(stderr, "%*c> _gather_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_97")); expr_ty elem; asdl_seq * seq; if ( (elem = star_expression_rule(p)) // star_expression && - (seq = _loop0_95_rule(p)) // _loop0_95 + (seq = _loop0_97_rule(p)) // _loop0_97 ) { - D(fprintf(stderr, "%*c+ _gather_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_95")); + D(fprintf(stderr, "%*c+ _gather_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_97")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_94[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_95")); + D(fprintf(stderr, "%*c%s _gather_96[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_97")); } _res = NULL; done: @@ -22810,9 +22983,9 @@ _gather_94_rule(Parser *p) return _res; } -// _loop1_96: (',' star_expression) +// _loop1_98: (',' star_expression) static asdl_seq * -_loop1_96_rule(Parser *p) +_loop1_98_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22836,13 +23009,13 @@ _loop1_96_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); - void *_tmp_172_var; + D(fprintf(stderr, "%*c> _loop1_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); + void *_tmp_174_var; while ( - (_tmp_172_var = _tmp_172_rule(p)) // ',' star_expression + (_tmp_174_var = _tmp_174_rule(p)) // ',' star_expression ) { - _res = _tmp_172_var; + _res = _tmp_174_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22858,7 +23031,7 @@ _loop1_96_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_96[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_98[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); } if (_n == 0 || p->error_indicator) { @@ -22876,14 +23049,14 @@ _loop1_96_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_96_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_98_type, _seq); D(p->level--); return _seq; } -// _loop0_98: ',' star_named_expression +// _loop0_100: ',' star_named_expression static asdl_seq * -_loop0_98_rule(Parser *p) +_loop0_100_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22907,7 +23080,7 @@ _loop0_98_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); + D(fprintf(stderr, "%*c> _loop0_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); Token * _literal; expr_ty elem; while ( @@ -22938,7 +23111,7 @@ _loop0_98_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_98[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_100[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22951,14 +23124,14 @@ _loop0_98_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_98_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_100_type, _seq); D(p->level--); return _seq; } -// _gather_97: star_named_expression _loop0_98 +// _gather_99: star_named_expression _loop0_100 static asdl_seq * -_gather_97_rule(Parser *p) +_gather_99_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22967,27 +23140,27 @@ _gather_97_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_named_expression _loop0_98 + { // star_named_expression _loop0_100 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_98")); + D(fprintf(stderr, "%*c> _gather_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_100")); expr_ty elem; asdl_seq * seq; if ( (elem = star_named_expression_rule(p)) // star_named_expression && - (seq = _loop0_98_rule(p)) // _loop0_98 + (seq = _loop0_100_rule(p)) // _loop0_100 ) { - D(fprintf(stderr, "%*c+ _gather_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_98")); + D(fprintf(stderr, "%*c+ _gather_99[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_100")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_97[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_98")); + D(fprintf(stderr, "%*c%s _gather_99[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_100")); } _res = NULL; done: @@ -22995,9 +23168,9 @@ _gather_97_rule(Parser *p) return _res; } -// _loop1_99: (',' expression) +// _loop1_101: (',' expression) static asdl_seq * -_loop1_99_rule(Parser *p) +_loop1_101_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23021,13 +23194,13 @@ _loop1_99_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); - void *_tmp_173_var; + D(fprintf(stderr, "%*c> _loop1_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); + void *_tmp_175_var; while ( - (_tmp_173_var = _tmp_173_rule(p)) // ',' expression + (_tmp_175_var = _tmp_175_rule(p)) // ',' expression ) { - _res = _tmp_173_var; + _res = _tmp_175_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23043,7 +23216,7 @@ _loop1_99_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_99[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_101[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); } if (_n == 0 || p->error_indicator) { @@ -23061,14 +23234,14 @@ _loop1_99_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_101_type, _seq); D(p->level--); return _seq; } -// _loop0_100: lambda_param_no_default +// _loop0_102: lambda_param_no_default static asdl_seq * -_loop0_100_rule(Parser *p) +_loop0_102_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23092,7 +23265,7 @@ _loop0_100_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_102[%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 @@ -23114,7 +23287,7 @@ _loop0_100_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_100[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_102[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23127,14 +23300,14 @@ _loop0_100_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_100_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_102_type, _seq); D(p->level--); return _seq; } -// _loop0_101: lambda_param_with_default +// _loop0_103: lambda_param_with_default static asdl_seq * -_loop0_101_rule(Parser *p) +_loop0_103_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23158,7 +23331,7 @@ _loop0_101_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23180,7 +23353,7 @@ _loop0_101_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_101[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23193,14 +23366,14 @@ _loop0_101_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_101_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_103_type, _seq); D(p->level--); return _seq; } -// _loop0_102: lambda_param_with_default +// _loop0_104: lambda_param_with_default static asdl_seq * -_loop0_102_rule(Parser *p) +_loop0_104_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23224,7 +23397,7 @@ _loop0_102_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23246,7 +23419,7 @@ _loop0_102_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_102[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_104[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23259,14 +23432,14 @@ _loop0_102_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_102_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_104_type, _seq); D(p->level--); return _seq; } -// _loop1_103: lambda_param_no_default +// _loop1_105: lambda_param_no_default static asdl_seq * -_loop1_103_rule(Parser *p) +_loop1_105_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23290,7 +23463,7 @@ _loop1_103_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_105[%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 @@ -23312,7 +23485,7 @@ _loop1_103_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_103[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -23330,14 +23503,14 @@ _loop1_103_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_103_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq); D(p->level--); return _seq; } -// _loop0_104: lambda_param_with_default +// _loop0_106: lambda_param_with_default static asdl_seq * -_loop0_104_rule(Parser *p) +_loop0_106_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23361,7 +23534,7 @@ _loop0_104_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23383,7 +23556,7 @@ _loop0_104_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_104[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_106[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23396,14 +23569,14 @@ _loop0_104_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_104_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_106_type, _seq); D(p->level--); return _seq; } -// _loop1_105: lambda_param_with_default +// _loop1_107: lambda_param_with_default static asdl_seq * -_loop1_105_rule(Parser *p) +_loop1_107_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23427,7 +23600,7 @@ _loop1_105_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23449,7 +23622,7 @@ _loop1_105_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_107[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -23467,14 +23640,14 @@ _loop1_105_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_107_type, _seq); D(p->level--); return _seq; } -// _loop1_106: lambda_param_no_default +// _loop1_108: lambda_param_no_default static asdl_seq * -_loop1_106_rule(Parser *p) +_loop1_108_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23498,7 +23671,7 @@ _loop1_106_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_108[%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 @@ -23520,7 +23693,7 @@ _loop1_106_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_108[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -23538,14 +23711,14 @@ _loop1_106_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_106_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_108_type, _seq); D(p->level--); return _seq; } -// _loop1_107: lambda_param_no_default +// _loop1_109: lambda_param_no_default static asdl_seq * -_loop1_107_rule(Parser *p) +_loop1_109_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23569,7 +23742,7 @@ _loop1_107_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_109[%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 @@ -23591,7 +23764,7 @@ _loop1_107_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_107[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_109[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -23609,14 +23782,14 @@ _loop1_107_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_107_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_109_type, _seq); D(p->level--); return _seq; } -// _loop0_108: lambda_param_no_default +// _loop0_110: lambda_param_no_default static asdl_seq * -_loop0_108_rule(Parser *p) +_loop0_110_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23640,7 +23813,7 @@ _loop0_108_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_110[%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 @@ -23662,7 +23835,7 @@ _loop0_108_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_108[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_110[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23675,14 +23848,14 @@ _loop0_108_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_108_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq); D(p->level--); return _seq; } -// _loop1_109: lambda_param_with_default +// _loop1_111: lambda_param_with_default static asdl_seq * -_loop1_109_rule(Parser *p) +_loop1_111_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23706,7 +23879,7 @@ _loop1_109_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23728,7 +23901,7 @@ _loop1_109_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_109[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_111[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -23746,14 +23919,14 @@ _loop1_109_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_109_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_111_type, _seq); D(p->level--); return _seq; } -// _loop0_110: lambda_param_no_default +// _loop0_112: lambda_param_no_default static asdl_seq * -_loop0_110_rule(Parser *p) +_loop0_112_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23777,7 +23950,7 @@ _loop0_110_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_112[%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 @@ -23799,7 +23972,7 @@ _loop0_110_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_110[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23812,14 +23985,14 @@ _loop0_110_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq); D(p->level--); return _seq; } -// _loop1_111: lambda_param_with_default +// _loop1_113: lambda_param_with_default static asdl_seq * -_loop1_111_rule(Parser *p) +_loop1_113_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23843,7 +24016,7 @@ _loop1_111_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23865,7 +24038,7 @@ _loop1_111_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_111[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_113[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -23883,14 +24056,14 @@ _loop1_111_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_111_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_113_type, _seq); D(p->level--); return _seq; } -// _loop0_112: lambda_param_maybe_default +// _loop0_114: lambda_param_maybe_default static asdl_seq * -_loop0_112_rule(Parser *p) +_loop0_114_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23914,7 +24087,7 @@ _loop0_112_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -23936,7 +24109,7 @@ _loop0_112_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_114[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23949,14 +24122,14 @@ _loop0_112_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_114_type, _seq); D(p->level--); return _seq; } -// _loop1_113: lambda_param_maybe_default +// _loop1_115: lambda_param_maybe_default static asdl_seq * -_loop1_113_rule(Parser *p) +_loop1_115_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23980,7 +24153,7 @@ _loop1_113_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -24002,7 +24175,7 @@ _loop1_113_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_113[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -24020,14 +24193,14 @@ _loop1_113_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_113_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_115_type, _seq); D(p->level--); return _seq; } -// _loop1_114: ('or' conjunction) +// _loop1_116: ('or' conjunction) static asdl_seq * -_loop1_114_rule(Parser *p) +_loop1_116_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24051,13 +24224,13 @@ _loop1_114_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); - void *_tmp_174_var; + D(fprintf(stderr, "%*c> _loop1_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); + void *_tmp_176_var; while ( - (_tmp_174_var = _tmp_174_rule(p)) // 'or' conjunction + (_tmp_176_var = _tmp_176_rule(p)) // 'or' conjunction ) { - _res = _tmp_174_var; + _res = _tmp_176_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24073,7 +24246,7 @@ _loop1_114_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_114[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_116[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); } if (_n == 0 || p->error_indicator) { @@ -24091,14 +24264,14 @@ _loop1_114_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_114_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_116_type, _seq); D(p->level--); return _seq; } -// _loop1_115: ('and' inversion) +// _loop1_117: ('and' inversion) static asdl_seq * -_loop1_115_rule(Parser *p) +_loop1_117_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24122,13 +24295,13 @@ _loop1_115_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); - void *_tmp_175_var; + D(fprintf(stderr, "%*c> _loop1_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); + void *_tmp_177_var; while ( - (_tmp_175_var = _tmp_175_rule(p)) // 'and' inversion + (_tmp_177_var = _tmp_177_rule(p)) // 'and' inversion ) { - _res = _tmp_175_var; + _res = _tmp_177_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24144,7 +24317,7 @@ _loop1_115_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_117[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); } if (_n == 0 || p->error_indicator) { @@ -24162,14 +24335,14 @@ _loop1_115_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_115_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_117_type, _seq); D(p->level--); return _seq; } -// _loop1_116: compare_op_bitwise_or_pair +// _loop1_118: compare_op_bitwise_or_pair static asdl_seq * -_loop1_116_rule(Parser *p) +_loop1_118_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24193,7 +24366,7 @@ _loop1_116_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); + D(fprintf(stderr, "%*c> _loop1_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); CmpopExprPair* compare_op_bitwise_or_pair_var; while ( (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair @@ -24215,7 +24388,7 @@ _loop1_116_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_116[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_118[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); } if (_n == 0 || p->error_indicator) { @@ -24233,14 +24406,14 @@ _loop1_116_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_116_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_118_type, _seq); D(p->level--); return _seq; } -// _tmp_117: '!=' +// _tmp_119: '!=' static void * -_tmp_117_rule(Parser *p) +_tmp_119_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24254,13 +24427,13 @@ _tmp_117_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); Token * tok; if ( (tok = _PyPegen_expect_token(p, 28)) // token='!=' ) { - D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -24270,7 +24443,7 @@ _tmp_117_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); } _res = NULL; @@ -24279,9 +24452,9 @@ _tmp_117_rule(Parser *p) return _res; } -// _loop0_119: ',' slice +// _loop0_121: ',' slice static asdl_seq * -_loop0_119_rule(Parser *p) +_loop0_121_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24305,7 +24478,7 @@ _loop0_119_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); + D(fprintf(stderr, "%*c> _loop0_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); Token * _literal; expr_ty elem; while ( @@ -24336,7 +24509,7 @@ _loop0_119_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_119[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_121[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' slice")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24349,14 +24522,14 @@ _loop0_119_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_121_type, _seq); D(p->level--); return _seq; } -// _gather_118: slice _loop0_119 +// _gather_120: slice _loop0_121 static asdl_seq * -_gather_118_rule(Parser *p) +_gather_120_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24365,27 +24538,27 @@ _gather_118_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // slice _loop0_119 + { // slice _loop0_121 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_119")); + D(fprintf(stderr, "%*c> _gather_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_121")); expr_ty elem; asdl_seq * seq; if ( (elem = slice_rule(p)) // slice && - (seq = _loop0_119_rule(p)) // _loop0_119 + (seq = _loop0_121_rule(p)) // _loop0_121 ) { - D(fprintf(stderr, "%*c+ _gather_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_119")); + D(fprintf(stderr, "%*c+ _gather_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_121")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_118[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_119")); + D(fprintf(stderr, "%*c%s _gather_120[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_121")); } _res = NULL; done: @@ -24393,9 +24566,9 @@ _gather_118_rule(Parser *p) return _res; } -// _tmp_120: ':' expression? +// _tmp_122: ':' expression? static void * -_tmp_120_rule(Parser *p) +_tmp_122_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24409,7 +24582,7 @@ _tmp_120_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); Token * _literal; void *d; if ( @@ -24418,7 +24591,7 @@ _tmp_120_rule(Parser *p) (d = expression_rule(p), 1) // expression? ) { - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); _res = d; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -24428,7 +24601,7 @@ _tmp_120_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); } _res = NULL; @@ -24437,9 +24610,9 @@ _tmp_120_rule(Parser *p) return _res; } -// _tmp_121: tuple | group | genexp +// _tmp_123: tuple | group | genexp static void * -_tmp_121_rule(Parser *p) +_tmp_123_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24453,18 +24626,18 @@ _tmp_121_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); expr_ty tuple_var; if ( (tuple_var = tuple_rule(p)) // tuple ) { - D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); _res = tuple_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); } { // group @@ -24472,18 +24645,18 @@ _tmp_121_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); expr_ty group_var; if ( (group_var = group_rule(p)) // group ) { - D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); _res = group_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group")); } { // genexp @@ -24491,18 +24664,18 @@ _tmp_121_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); expr_ty genexp_var; if ( (genexp_var = genexp_rule(p)) // genexp ) { - D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); _res = genexp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); } _res = NULL; @@ -24511,9 +24684,9 @@ _tmp_121_rule(Parser *p) return _res; } -// _tmp_122: list | listcomp +// _tmp_124: list | listcomp static void * -_tmp_122_rule(Parser *p) +_tmp_124_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24527,18 +24700,18 @@ _tmp_122_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); expr_ty list_var; if ( (list_var = list_rule(p)) // list ) { - D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); _res = list_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); } { // listcomp @@ -24546,18 +24719,18 @@ _tmp_122_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); expr_ty listcomp_var; if ( (listcomp_var = listcomp_rule(p)) // listcomp ) { - D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); _res = listcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp")); } _res = NULL; @@ -24566,9 +24739,9 @@ _tmp_122_rule(Parser *p) return _res; } -// _tmp_123: dict | set | dictcomp | setcomp +// _tmp_125: dict | set | dictcomp | setcomp static void * -_tmp_123_rule(Parser *p) +_tmp_125_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24582,18 +24755,18 @@ _tmp_123_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); expr_ty dict_var; if ( (dict_var = dict_rule(p)) // dict ) { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); _res = dict_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict")); } { // set @@ -24601,18 +24774,18 @@ _tmp_123_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); expr_ty set_var; if ( (set_var = set_rule(p)) // set ) { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); _res = set_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set")); } { // dictcomp @@ -24620,18 +24793,18 @@ _tmp_123_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); expr_ty dictcomp_var; if ( (dictcomp_var = dictcomp_rule(p)) // dictcomp ) { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); _res = dictcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp")); } { // setcomp @@ -24639,18 +24812,18 @@ _tmp_123_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); expr_ty setcomp_var; if ( (setcomp_var = setcomp_rule(p)) // setcomp ) { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); _res = setcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp")); } _res = NULL; @@ -24659,9 +24832,9 @@ _tmp_123_rule(Parser *p) return _res; } -// _loop1_124: STRING +// _loop1_126: STRING static asdl_seq * -_loop1_124_rule(Parser *p) +_loop1_126_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24685,7 +24858,7 @@ _loop1_124_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); + D(fprintf(stderr, "%*c> _loop1_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); expr_ty string_var; while ( (string_var = _PyPegen_string_token(p)) // STRING @@ -24707,7 +24880,7 @@ _loop1_124_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_124[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_126[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); } if (_n == 0 || p->error_indicator) { @@ -24725,14 +24898,14 @@ _loop1_124_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_124_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_126_type, _seq); D(p->level--); return _seq; } -// _tmp_125: star_named_expression ',' star_named_expressions? +// _tmp_127: star_named_expression ',' star_named_expressions? static void * -_tmp_125_rule(Parser *p) +_tmp_127_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24746,7 +24919,7 @@ _tmp_125_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c> _tmp_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); Token * _literal; expr_ty y; void *z; @@ -24758,7 +24931,7 @@ _tmp_125_rule(Parser *p) (z = star_named_expressions_rule(p), 1) // star_named_expressions? ) { - D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c+ _tmp_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); _res = _PyPegen_seq_insert_in_front ( p , y , z ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -24768,7 +24941,7 @@ _tmp_125_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_127[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); } _res = NULL; @@ -24777,9 +24950,9 @@ _tmp_125_rule(Parser *p) return _res; } -// _tmp_126: yield_expr | named_expression +// _tmp_128: yield_expr | named_expression static void * -_tmp_126_rule(Parser *p) +_tmp_128_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24793,18 +24966,18 @@ _tmp_126_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // named_expression @@ -24812,18 +24985,18 @@ _tmp_126_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); expr_ty named_expression_var; if ( (named_expression_var = named_expression_rule(p)) // named_expression ) { - D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); _res = named_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); } _res = NULL; @@ -24832,9 +25005,9 @@ _tmp_126_rule(Parser *p) return _res; } -// _loop0_128: ',' double_starred_kvpair +// _loop0_130: ',' double_starred_kvpair static asdl_seq * -_loop0_128_rule(Parser *p) +_loop0_130_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24858,7 +25031,7 @@ _loop0_128_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); + D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); Token * _literal; KeyValuePair* elem; while ( @@ -24889,7 +25062,7 @@ _loop0_128_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_128[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24902,14 +25075,14 @@ _loop0_128_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_128_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq); D(p->level--); return _seq; } -// _gather_127: double_starred_kvpair _loop0_128 +// _gather_129: double_starred_kvpair _loop0_130 static asdl_seq * -_gather_127_rule(Parser *p) +_gather_129_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24918,27 +25091,27 @@ _gather_127_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // double_starred_kvpair _loop0_128 + { // double_starred_kvpair _loop0_130 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_128")); + D(fprintf(stderr, "%*c> _gather_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_130")); KeyValuePair* elem; asdl_seq * seq; if ( (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair && - (seq = _loop0_128_rule(p)) // _loop0_128 + (seq = _loop0_130_rule(p)) // _loop0_130 ) { - D(fprintf(stderr, "%*c+ _gather_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_128")); + D(fprintf(stderr, "%*c+ _gather_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_130")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_127[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_128")); + D(fprintf(stderr, "%*c%s _gather_129[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_130")); } _res = NULL; done: @@ -24946,9 +25119,9 @@ _gather_127_rule(Parser *p) return _res; } -// _loop1_129: for_if_clause +// _loop1_131: for_if_clause static asdl_seq * -_loop1_129_rule(Parser *p) +_loop1_131_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24972,7 +25145,7 @@ _loop1_129_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); + D(fprintf(stderr, "%*c> _loop1_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); comprehension_ty for_if_clause_var; while ( (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause @@ -24994,7 +25167,7 @@ _loop1_129_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_129[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_131[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); } if (_n == 0 || p->error_indicator) { @@ -25012,14 +25185,14 @@ _loop1_129_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_129_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_131_type, _seq); D(p->level--); return _seq; } -// _loop0_130: ('if' disjunction) +// _loop0_132: ('if' disjunction) static asdl_seq * -_loop0_130_rule(Parser *p) +_loop0_132_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25043,13 +25216,13 @@ _loop0_130_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_176_var; + D(fprintf(stderr, "%*c> _loop0_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_178_var; while ( - (_tmp_176_var = _tmp_176_rule(p)) // 'if' disjunction + (_tmp_178_var = _tmp_178_rule(p)) // 'if' disjunction ) { - _res = _tmp_176_var; + _res = _tmp_178_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -25065,7 +25238,7 @@ _loop0_130_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_132[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25078,14 +25251,14 @@ _loop0_130_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_132_type, _seq); D(p->level--); return _seq; } -// _loop0_131: ('if' disjunction) +// _loop0_133: ('if' disjunction) static asdl_seq * -_loop0_131_rule(Parser *p) +_loop0_133_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25109,13 +25282,13 @@ _loop0_131_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_177_var; + D(fprintf(stderr, "%*c> _loop0_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_179_var; while ( - (_tmp_177_var = _tmp_177_rule(p)) // 'if' disjunction + (_tmp_179_var = _tmp_179_rule(p)) // 'if' disjunction ) { - _res = _tmp_177_var; + _res = _tmp_179_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -25131,7 +25304,7 @@ _loop0_131_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_131[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_133[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25144,14 +25317,14 @@ _loop0_131_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_131_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_133_type, _seq); D(p->level--); return _seq; } -// _tmp_132: ',' args +// _tmp_134: ',' args static void * -_tmp_132_rule(Parser *p) +_tmp_134_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25165,7 +25338,7 @@ _tmp_132_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c> _tmp_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); Token * _literal; expr_ty c; if ( @@ -25174,7 +25347,7 @@ _tmp_132_rule(Parser *p) (c = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c+ _tmp_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25184,7 +25357,7 @@ _tmp_132_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_132[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_134[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); } _res = NULL; @@ -25193,9 +25366,9 @@ _tmp_132_rule(Parser *p) return _res; } -// _tmp_133: ',' args +// _tmp_135: ',' args static void * -_tmp_133_rule(Parser *p) +_tmp_135_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25209,7 +25382,7 @@ _tmp_133_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c> _tmp_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); Token * _literal; expr_ty c; if ( @@ -25218,7 +25391,7 @@ _tmp_133_rule(Parser *p) (c = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c+ _tmp_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25228,7 +25401,7 @@ _tmp_133_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_135[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); } _res = NULL; @@ -25237,9 +25410,9 @@ _tmp_133_rule(Parser *p) return _res; } -// _loop0_135: ',' kwarg_or_starred +// _loop0_137: ',' kwarg_or_starred static asdl_seq * -_loop0_135_rule(Parser *p) +_loop0_137_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25263,7 +25436,7 @@ _loop0_135_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -25294,7 +25467,7 @@ _loop0_135_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_135[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_137[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25307,14 +25480,14 @@ _loop0_135_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_135_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_137_type, _seq); D(p->level--); return _seq; } -// _gather_134: kwarg_or_starred _loop0_135 +// _gather_136: kwarg_or_starred _loop0_137 static asdl_seq * -_gather_134_rule(Parser *p) +_gather_136_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25323,27 +25496,27 @@ _gather_134_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_135 + { // kwarg_or_starred _loop0_137 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_135")); + D(fprintf(stderr, "%*c> _gather_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_137")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_135_rule(p)) // _loop0_135 + (seq = _loop0_137_rule(p)) // _loop0_137 ) { - D(fprintf(stderr, "%*c+ _gather_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_135")); + D(fprintf(stderr, "%*c+ _gather_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_137")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_134[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_135")); + D(fprintf(stderr, "%*c%s _gather_136[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_137")); } _res = NULL; done: @@ -25351,9 +25524,9 @@ _gather_134_rule(Parser *p) return _res; } -// _loop0_137: ',' kwarg_or_double_starred +// _loop0_139: ',' kwarg_or_double_starred static asdl_seq * -_loop0_137_rule(Parser *p) +_loop0_139_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25377,7 +25550,7 @@ _loop0_137_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -25408,7 +25581,7 @@ _loop0_137_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_137[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_139[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25421,14 +25594,14 @@ _loop0_137_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_137_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_139_type, _seq); D(p->level--); return _seq; } -// _gather_136: kwarg_or_double_starred _loop0_137 +// _gather_138: kwarg_or_double_starred _loop0_139 static asdl_seq * -_gather_136_rule(Parser *p) +_gather_138_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25437,27 +25610,27 @@ _gather_136_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_137 + { // kwarg_or_double_starred _loop0_139 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_137")); + D(fprintf(stderr, "%*c> _gather_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_139")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_137_rule(p)) // _loop0_137 + (seq = _loop0_139_rule(p)) // _loop0_139 ) { - D(fprintf(stderr, "%*c+ _gather_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_137")); + D(fprintf(stderr, "%*c+ _gather_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_139")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_136[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_137")); + D(fprintf(stderr, "%*c%s _gather_138[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_139")); } _res = NULL; done: @@ -25465,9 +25638,9 @@ _gather_136_rule(Parser *p) return _res; } -// _loop0_139: ',' kwarg_or_starred +// _loop0_141: ',' kwarg_or_starred static asdl_seq * -_loop0_139_rule(Parser *p) +_loop0_141_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25491,7 +25664,7 @@ _loop0_139_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -25522,7 +25695,7 @@ _loop0_139_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_139[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_141[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25535,14 +25708,14 @@ _loop0_139_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_139_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_141_type, _seq); D(p->level--); return _seq; } -// _gather_138: kwarg_or_starred _loop0_139 +// _gather_140: kwarg_or_starred _loop0_141 static asdl_seq * -_gather_138_rule(Parser *p) +_gather_140_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25551,27 +25724,27 @@ _gather_138_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_139 + { // kwarg_or_starred _loop0_141 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_139")); + D(fprintf(stderr, "%*c> _gather_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_141")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_139_rule(p)) // _loop0_139 + (seq = _loop0_141_rule(p)) // _loop0_141 ) { - D(fprintf(stderr, "%*c+ _gather_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_139")); + D(fprintf(stderr, "%*c+ _gather_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_141")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_138[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_139")); + D(fprintf(stderr, "%*c%s _gather_140[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_141")); } _res = NULL; done: @@ -25579,9 +25752,9 @@ _gather_138_rule(Parser *p) return _res; } -// _loop0_141: ',' kwarg_or_double_starred +// _loop0_143: ',' kwarg_or_double_starred static asdl_seq * -_loop0_141_rule(Parser *p) +_loop0_143_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25605,7 +25778,7 @@ _loop0_141_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -25636,7 +25809,7 @@ _loop0_141_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_141[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_143[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25649,14 +25822,14 @@ _loop0_141_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_141_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_143_type, _seq); D(p->level--); return _seq; } -// _gather_140: kwarg_or_double_starred _loop0_141 +// _gather_142: kwarg_or_double_starred _loop0_143 static asdl_seq * -_gather_140_rule(Parser *p) +_gather_142_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25665,27 +25838,27 @@ _gather_140_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_141 + { // kwarg_or_double_starred _loop0_143 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_141")); + D(fprintf(stderr, "%*c> _gather_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_143")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_141_rule(p)) // _loop0_141 + (seq = _loop0_143_rule(p)) // _loop0_143 ) { - D(fprintf(stderr, "%*c+ _gather_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_141")); + D(fprintf(stderr, "%*c+ _gather_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_143")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_140[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_141")); + D(fprintf(stderr, "%*c%s _gather_142[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_143")); } _res = NULL; done: @@ -25693,9 +25866,9 @@ _gather_140_rule(Parser *p) return _res; } -// _loop0_142: (',' star_target) +// _loop0_144: (',' star_target) static asdl_seq * -_loop0_142_rule(Parser *p) +_loop0_144_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25719,13 +25892,13 @@ _loop0_142_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_178_var; + D(fprintf(stderr, "%*c> _loop0_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_180_var; while ( - (_tmp_178_var = _tmp_178_rule(p)) // ',' star_target + (_tmp_180_var = _tmp_180_rule(p)) // ',' star_target ) { - _res = _tmp_178_var; + _res = _tmp_180_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -25741,7 +25914,7 @@ _loop0_142_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_142[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_144[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25754,14 +25927,14 @@ _loop0_142_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_142_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_144_type, _seq); D(p->level--); return _seq; } -// _loop0_144: ',' star_target +// _loop0_146: ',' star_target static asdl_seq * -_loop0_144_rule(Parser *p) +_loop0_146_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25785,7 +25958,7 @@ _loop0_144_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _loop0_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty elem; while ( @@ -25816,7 +25989,7 @@ _loop0_144_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_144[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_146[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25829,14 +26002,14 @@ _loop0_144_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_144_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_146_type, _seq); D(p->level--); return _seq; } -// _gather_143: star_target _loop0_144 +// _gather_145: star_target _loop0_146 static asdl_seq * -_gather_143_rule(Parser *p) +_gather_145_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25845,27 +26018,27 @@ _gather_143_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_target _loop0_144 + { // star_target _loop0_146 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_144")); + D(fprintf(stderr, "%*c> _gather_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_146")); expr_ty elem; asdl_seq * seq; if ( (elem = star_target_rule(p)) // star_target && - (seq = _loop0_144_rule(p)) // _loop0_144 + (seq = _loop0_146_rule(p)) // _loop0_146 ) { - D(fprintf(stderr, "%*c+ _gather_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_144")); + D(fprintf(stderr, "%*c+ _gather_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_146")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_143[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_144")); + D(fprintf(stderr, "%*c%s _gather_145[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_146")); } _res = NULL; done: @@ -25873,9 +26046,9 @@ _gather_143_rule(Parser *p) return _res; } -// _tmp_145: !'*' star_target +// _tmp_147: !'*' star_target static void * -_tmp_145_rule(Parser *p) +_tmp_147_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25889,7 +26062,7 @@ _tmp_145_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); expr_ty star_target_var; if ( _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' @@ -25897,12 +26070,12 @@ _tmp_145_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); _res = star_target_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); } _res = NULL; @@ -25911,9 +26084,9 @@ _tmp_145_rule(Parser *p) return _res; } -// _loop0_147: ',' del_target +// _loop0_149: ',' del_target static asdl_seq * -_loop0_147_rule(Parser *p) +_loop0_149_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25937,7 +26110,7 @@ _loop0_147_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); + D(fprintf(stderr, "%*c> _loop0_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); Token * _literal; expr_ty elem; while ( @@ -25968,7 +26141,7 @@ _loop0_147_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_147[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_149[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25981,14 +26154,14 @@ _loop0_147_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_147_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_149_type, _seq); D(p->level--); return _seq; } -// _gather_146: del_target _loop0_147 +// _gather_148: del_target _loop0_149 static asdl_seq * -_gather_146_rule(Parser *p) +_gather_148_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25997,27 +26170,27 @@ _gather_146_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // del_target _loop0_147 + { // del_target _loop0_149 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_147")); + D(fprintf(stderr, "%*c> _gather_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_149")); expr_ty elem; asdl_seq * seq; if ( (elem = del_target_rule(p)) // del_target && - (seq = _loop0_147_rule(p)) // _loop0_147 + (seq = _loop0_149_rule(p)) // _loop0_149 ) { - D(fprintf(stderr, "%*c+ _gather_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_147")); + D(fprintf(stderr, "%*c+ _gather_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_149")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_146[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_147")); + D(fprintf(stderr, "%*c%s _gather_148[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_149")); } _res = NULL; done: @@ -26025,9 +26198,9 @@ _gather_146_rule(Parser *p) return _res; } -// _loop0_149: ',' target +// _loop0_151: ',' target static asdl_seq * -_loop0_149_rule(Parser *p) +_loop0_151_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26051,7 +26224,7 @@ _loop0_149_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); + D(fprintf(stderr, "%*c> _loop0_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); Token * _literal; expr_ty elem; while ( @@ -26082,7 +26255,7 @@ _loop0_149_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_149[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_151[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26095,14 +26268,14 @@ _loop0_149_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_149_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_151_type, _seq); D(p->level--); return _seq; } -// _gather_148: target _loop0_149 +// _gather_150: target _loop0_151 static asdl_seq * -_gather_148_rule(Parser *p) +_gather_150_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26111,27 +26284,27 @@ _gather_148_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // target _loop0_149 + { // target _loop0_151 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_149")); + D(fprintf(stderr, "%*c> _gather_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_151")); expr_ty elem; asdl_seq * seq; if ( (elem = target_rule(p)) // target && - (seq = _loop0_149_rule(p)) // _loop0_149 + (seq = _loop0_151_rule(p)) // _loop0_151 ) { - D(fprintf(stderr, "%*c+ _gather_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_149")); + D(fprintf(stderr, "%*c+ _gather_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_151")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_148[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_149")); + D(fprintf(stderr, "%*c%s _gather_150[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_151")); } _res = NULL; done: @@ -26139,9 +26312,9 @@ _gather_148_rule(Parser *p) return _res; } -// _tmp_150: args | expression for_if_clauses +// _tmp_152: args | expression for_if_clauses static void * -_tmp_150_rule(Parser *p) +_tmp_152_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26155,18 +26328,18 @@ _tmp_150_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); expr_ty args_var; if ( (args_var = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); _res = args_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); } { // expression for_if_clauses @@ -26174,7 +26347,7 @@ _tmp_150_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); expr_ty expression_var; asdl_seq* for_if_clauses_var; if ( @@ -26183,12 +26356,12 @@ _tmp_150_rule(Parser *p) (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses ) { - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); } _res = NULL; @@ -26197,9 +26370,9 @@ _tmp_150_rule(Parser *p) return _res; } -// _loop0_151: star_named_expressions +// _loop0_153: star_named_expressions static asdl_seq * -_loop0_151_rule(Parser *p) +_loop0_153_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26223,7 +26396,7 @@ _loop0_151_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); + D(fprintf(stderr, "%*c> _loop0_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); asdl_seq* star_named_expressions_var; while ( (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions @@ -26245,7 +26418,7 @@ _loop0_151_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_151[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26258,14 +26431,14 @@ _loop0_151_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_151_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_153_type, _seq); D(p->level--); return _seq; } -// _tmp_152: '=' annotated_rhs +// _tmp_154: '=' annotated_rhs static void * -_tmp_152_rule(Parser *p) +_tmp_154_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26279,7 +26452,7 @@ _tmp_152_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); Token * _literal; expr_ty annotated_rhs_var; if ( @@ -26288,12 +26461,12 @@ _tmp_152_rule(Parser *p) (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs ) { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); } _res = NULL; @@ -26302,9 +26475,9 @@ _tmp_152_rule(Parser *p) return _res; } -// _tmp_153: yield_expr | star_expressions +// _tmp_155: yield_expr | star_expressions static void * -_tmp_153_rule(Parser *p) +_tmp_155_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26318,18 +26491,18 @@ _tmp_153_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -26337,18 +26510,18 @@ _tmp_153_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -26357,9 +26530,9 @@ _tmp_153_rule(Parser *p) return _res; } -// _tmp_154: yield_expr | star_expressions +// _tmp_156: yield_expr | star_expressions static void * -_tmp_154_rule(Parser *p) +_tmp_156_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26373,18 +26546,18 @@ _tmp_154_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -26392,18 +26565,18 @@ _tmp_154_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -26412,9 +26585,9 @@ _tmp_154_rule(Parser *p) return _res; } -// _tmp_155: '[' | '(' | '{' +// _tmp_157: '[' | '(' | '{' static void * -_tmp_155_rule(Parser *p) +_tmp_157_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26428,18 +26601,18 @@ _tmp_155_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); } { // '(' @@ -26447,18 +26620,18 @@ _tmp_155_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' ) { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } { // '{' @@ -26466,18 +26639,18 @@ _tmp_155_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' ) { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); } _res = NULL; @@ -26486,9 +26659,9 @@ _tmp_155_rule(Parser *p) return _res; } -// _loop0_156: param_no_default +// _loop0_158: param_no_default static asdl_seq * -_loop0_156_rule(Parser *p) +_loop0_158_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26512,7 +26685,7 @@ _loop0_156_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_158[%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 @@ -26534,7 +26707,7 @@ _loop0_156_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_156[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26547,14 +26720,14 @@ _loop0_156_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_156_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_158_type, _seq); D(p->level--); return _seq; } -// _tmp_157: slash_with_default | param_with_default+ +// _tmp_159: slash_with_default | param_with_default+ static void * -_tmp_157_rule(Parser *p) +_tmp_159_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26568,18 +26741,18 @@ _tmp_157_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + 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_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "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_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); } { // param_with_default+ @@ -26587,18 +26760,18 @@ _tmp_157_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - asdl_seq * _loop1_179_var; + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + asdl_seq * _loop1_181_var; if ( - (_loop1_179_var = _loop1_179_rule(p)) // param_with_default+ + (_loop1_181_var = _loop1_181_rule(p)) // param_with_default+ ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - _res = _loop1_179_var; + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + _res = _loop1_181_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+")); } _res = NULL; @@ -26607,9 +26780,9 @@ _tmp_157_rule(Parser *p) return _res; } -// _tmp_158: ')' | ',' (')' | '**') +// _tmp_160: ')' | ',' (')' | '**') static void * -_tmp_158_rule(Parser *p) +_tmp_160_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26623,18 +26796,18 @@ _tmp_158_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // ',' (')' | '**') @@ -26642,21 +26815,21 @@ _tmp_158_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); Token * _literal; - void *_tmp_180_var; + void *_tmp_182_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_180_var = _tmp_180_rule(p)) // ')' | '**' + (_tmp_182_var = _tmp_182_rule(p)) // ')' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_180_var); + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_182_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); } _res = NULL; @@ -26665,9 +26838,9 @@ _tmp_158_rule(Parser *p) return _res; } -// _tmp_159: ':' | ',' (':' | '**') +// _tmp_161: ':' | ',' (':' | '**') static void * -_tmp_159_rule(Parser *p) +_tmp_161_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26681,18 +26854,18 @@ _tmp_159_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // ',' (':' | '**') @@ -26700,21 +26873,21 @@ _tmp_159_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); Token * _literal; - void *_tmp_181_var; + void *_tmp_183_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_181_var = _tmp_181_rule(p)) // ':' | '**' + (_tmp_183_var = _tmp_183_rule(p)) // ':' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_181_var); + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_183_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); } _res = NULL; @@ -26723,9 +26896,9 @@ _tmp_159_rule(Parser *p) return _res; } -// _tmp_160: star_targets '=' +// _tmp_162: star_targets '=' static void * -_tmp_160_rule(Parser *p) +_tmp_162_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26739,7 +26912,7 @@ _tmp_160_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty z; if ( @@ -26748,7 +26921,7 @@ _tmp_160_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26758,7 +26931,7 @@ _tmp_160_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -26767,9 +26940,9 @@ _tmp_160_rule(Parser *p) return _res; } -// _tmp_161: '.' | '...' +// _tmp_163: '.' | '...' static void * -_tmp_161_rule(Parser *p) +_tmp_163_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26783,18 +26956,18 @@ _tmp_161_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -26802,18 +26975,18 @@ _tmp_161_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -26822,9 +26995,9 @@ _tmp_161_rule(Parser *p) return _res; } -// _tmp_162: '.' | '...' +// _tmp_164: '.' | '...' static void * -_tmp_162_rule(Parser *p) +_tmp_164_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26838,18 +27011,18 @@ _tmp_162_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -26857,18 +27030,18 @@ _tmp_162_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -26877,9 +27050,9 @@ _tmp_162_rule(Parser *p) return _res; } -// _loop0_164: ',' pattern +// _loop0_166: ',' pattern static asdl_seq * -_loop0_164_rule(Parser *p) +_loop0_166_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26903,7 +27076,7 @@ _loop0_164_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _loop0_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; expr_ty elem; while ( @@ -26934,7 +27107,7 @@ _loop0_164_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_164[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_166[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26947,14 +27120,14 @@ _loop0_164_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_164_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_166_type, _seq); D(p->level--); return _seq; } -// _gather_163: pattern _loop0_164 +// _gather_165: pattern _loop0_166 static asdl_seq * -_gather_163_rule(Parser *p) +_gather_165_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26963,27 +27136,27 @@ _gather_163_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // pattern _loop0_164 + { // pattern _loop0_166 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_164")); + D(fprintf(stderr, "%*c> _gather_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_166")); expr_ty elem; asdl_seq * seq; if ( (elem = pattern_rule(p)) // pattern && - (seq = _loop0_164_rule(p)) // _loop0_164 + (seq = _loop0_166_rule(p)) // _loop0_166 ) { - D(fprintf(stderr, "%*c+ _gather_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_164")); + D(fprintf(stderr, "%*c+ _gather_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_166")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_163[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_164")); + D(fprintf(stderr, "%*c%s _gather_165[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_166")); } _res = NULL; done: @@ -26991,9 +27164,9 @@ _gather_163_rule(Parser *p) return _res; } -// _loop0_166: ',' argument_pattern +// _loop0_168: ',' argument_pattern static asdl_seq * -_loop0_166_rule(Parser *p) +_loop0_168_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27017,7 +27190,7 @@ _loop0_166_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' argument_pattern")); + D(fprintf(stderr, "%*c> _loop0_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' argument_pattern")); Token * _literal; void *elem; while ( @@ -27048,7 +27221,7 @@ _loop0_166_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_166[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_168[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' argument_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -27061,14 +27234,14 @@ _loop0_166_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_166_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_168_type, _seq); D(p->level--); return _seq; } -// _gather_165: argument_pattern _loop0_166 +// _gather_167: argument_pattern _loop0_168 static asdl_seq * -_gather_165_rule(Parser *p) +_gather_167_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27077,27 +27250,27 @@ _gather_165_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // argument_pattern _loop0_166 + { // argument_pattern _loop0_168 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_166")); + D(fprintf(stderr, "%*c> _gather_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_168")); void *elem; asdl_seq * seq; if ( (elem = argument_pattern_rule(p)) // argument_pattern && - (seq = _loop0_166_rule(p)) // _loop0_166 + (seq = _loop0_168_rule(p)) // _loop0_168 ) { - D(fprintf(stderr, "%*c+ _gather_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_166")); + D(fprintf(stderr, "%*c+ _gather_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_168")); _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, "argument_pattern _loop0_166")); + D(fprintf(stderr, "%*c%s _gather_167[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern _loop0_168")); } _res = NULL; done: @@ -27105,9 +27278,9 @@ _gather_165_rule(Parser *p) return _res; } -// _loop0_168: ',' argument_pattern +// _loop0_170: ',' argument_pattern static asdl_seq * -_loop0_168_rule(Parser *p) +_loop0_170_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27131,7 +27304,7 @@ _loop0_168_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' argument_pattern")); + D(fprintf(stderr, "%*c> _loop0_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' argument_pattern")); Token * _literal; void *elem; while ( @@ -27162,7 +27335,7 @@ _loop0_168_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_168[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_170[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' argument_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -27175,14 +27348,14 @@ _loop0_168_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_168_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_170_type, _seq); D(p->level--); return _seq; } -// _gather_167: argument_pattern _loop0_168 +// _gather_169: argument_pattern _loop0_170 static asdl_seq * -_gather_167_rule(Parser *p) +_gather_169_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27191,27 +27364,27 @@ _gather_167_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // argument_pattern _loop0_168 + { // argument_pattern _loop0_170 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_168")); + D(fprintf(stderr, "%*c> _gather_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_170")); void *elem; asdl_seq * seq; if ( (elem = argument_pattern_rule(p)) // argument_pattern && - (seq = _loop0_168_rule(p)) // _loop0_168 + (seq = _loop0_170_rule(p)) // _loop0_170 ) { - D(fprintf(stderr, "%*c+ _gather_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_168")); + D(fprintf(stderr, "%*c+ _gather_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_170")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_167[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern _loop0_168")); + D(fprintf(stderr, "%*c%s _gather_169[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern _loop0_170")); } _res = NULL; done: @@ -27219,9 +27392,9 @@ _gather_167_rule(Parser *p) return _res; } -// _loop0_170: ',' (argument_pattern | error_star) +// _loop0_172: ',' (argument_pattern | error_star) static asdl_seq * -_loop0_170_rule(Parser *p) +_loop0_172_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27245,13 +27418,13 @@ _loop0_170_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (argument_pattern | error_star)")); + D(fprintf(stderr, "%*c> _loop0_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (argument_pattern | error_star)")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_182_rule(p)) // argument_pattern | error_star + (elem = _tmp_184_rule(p)) // argument_pattern | error_star ) { _res = elem; @@ -27276,7 +27449,7 @@ _loop0_170_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_170[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_172[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (argument_pattern | error_star)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -27289,14 +27462,14 @@ _loop0_170_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_170_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_172_type, _seq); D(p->level--); return _seq; } -// _gather_169: (argument_pattern | error_star) _loop0_170 +// _gather_171: (argument_pattern | error_star) _loop0_172 static asdl_seq * -_gather_169_rule(Parser *p) +_gather_171_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27305,27 +27478,27 @@ _gather_169_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (argument_pattern | error_star) _loop0_170 + { // (argument_pattern | error_star) _loop0_172 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(argument_pattern | error_star) _loop0_170")); + D(fprintf(stderr, "%*c> _gather_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(argument_pattern | error_star) _loop0_172")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_182_rule(p)) // argument_pattern | error_star + (elem = _tmp_184_rule(p)) // argument_pattern | error_star && - (seq = _loop0_170_rule(p)) // _loop0_170 + (seq = _loop0_172_rule(p)) // _loop0_172 ) { - D(fprintf(stderr, "%*c+ _gather_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(argument_pattern | error_star) _loop0_170")); + D(fprintf(stderr, "%*c+ _gather_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(argument_pattern | error_star) _loop0_172")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_169[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(argument_pattern | error_star) _loop0_170")); + D(fprintf(stderr, "%*c%s _gather_171[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(argument_pattern | error_star) _loop0_172")); } _res = NULL; done: @@ -27333,9 +27506,9 @@ _gather_169_rule(Parser *p) return _res; } -// _tmp_171: '@' named_expression NEWLINE +// _tmp_173: '@' named_expression NEWLINE static void * -_tmp_171_rule(Parser *p) +_tmp_173_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27349,7 +27522,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, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); Token * _literal; expr_ty f; Token * newline_var; @@ -27361,7 +27534,7 @@ _tmp_171_rule(Parser *p) (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); _res = f; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -27371,7 +27544,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_173[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); } _res = NULL; @@ -27380,9 +27553,9 @@ _tmp_171_rule(Parser *p) return _res; } -// _tmp_172: ',' star_expression +// _tmp_174: ',' star_expression static void * -_tmp_172_rule(Parser *p) +_tmp_174_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27396,7 +27569,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, "',' star_expression")); + D(fprintf(stderr, "%*c> _tmp_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty c; if ( @@ -27405,7 +27578,7 @@ _tmp_172_rule(Parser *p) (c = star_expression_rule(p)) // star_expression ) { - D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -27415,7 +27588,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_174[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } _res = NULL; @@ -27424,9 +27597,9 @@ _tmp_172_rule(Parser *p) return _res; } -// _tmp_173: ',' expression +// _tmp_175: ',' expression static void * -_tmp_173_rule(Parser *p) +_tmp_175_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27440,7 +27613,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, "',' expression")); + D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty c; if ( @@ -27449,7 +27622,7 @@ _tmp_173_rule(Parser *p) (c = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -27459,7 +27632,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_175[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } _res = NULL; @@ -27468,9 +27641,9 @@ _tmp_173_rule(Parser *p) return _res; } -// _tmp_174: 'or' conjunction +// _tmp_176: 'or' conjunction static void * -_tmp_174_rule(Parser *p) +_tmp_176_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27484,7 +27657,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, "'or' conjunction")); + D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); Token * _keyword; expr_ty c; if ( @@ -27493,7 +27666,7 @@ _tmp_174_rule(Parser *p) (c = conjunction_rule(p)) // conjunction ) { - D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -27503,7 +27676,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_176[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); } _res = NULL; @@ -27512,9 +27685,9 @@ _tmp_174_rule(Parser *p) return _res; } -// _tmp_175: 'and' inversion +// _tmp_177: 'and' inversion static void * -_tmp_175_rule(Parser *p) +_tmp_177_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27528,7 +27701,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, "'and' inversion")); + D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); Token * _keyword; expr_ty c; if ( @@ -27537,7 +27710,7 @@ _tmp_175_rule(Parser *p) (c = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -27547,7 +27720,7 @@ _tmp_175_rule(Parser *p) 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_177[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); } _res = NULL; @@ -27556,9 +27729,9 @@ _tmp_175_rule(Parser *p) return _res; } -// _tmp_176: 'if' disjunction +// _tmp_178: 'if' disjunction static void * -_tmp_176_rule(Parser *p) +_tmp_178_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27572,7 +27745,7 @@ _tmp_176_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -27581,7 +27754,7 @@ _tmp_176_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -27591,7 +27764,7 @@ _tmp_176_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_176[%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, "'if' disjunction")); } _res = NULL; @@ -27600,9 +27773,9 @@ _tmp_176_rule(Parser *p) return _res; } -// _tmp_177: 'if' disjunction +// _tmp_179: 'if' disjunction static void * -_tmp_177_rule(Parser *p) +_tmp_179_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27616,7 +27789,7 @@ _tmp_177_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -27625,7 +27798,7 @@ _tmp_177_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -27635,7 +27808,7 @@ _tmp_177_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_179[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -27644,9 +27817,9 @@ _tmp_177_rule(Parser *p) return _res; } -// _tmp_178: ',' star_target +// _tmp_180: ',' star_target static void * -_tmp_178_rule(Parser *p) +_tmp_180_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27660,7 +27833,7 @@ _tmp_178_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty c; if ( @@ -27669,7 +27842,7 @@ _tmp_178_rule(Parser *p) (c = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' 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; @@ -27679,7 +27852,7 @@ _tmp_178_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', + 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; @@ -27688,9 +27861,9 @@ _tmp_178_rule(Parser *p) return _res; } -// _loop1_179: param_with_default +// _loop1_181: param_with_default static asdl_seq * -_loop1_179_rule(Parser *p) +_loop1_181_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27714,7 +27887,7 @@ _loop1_179_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -27736,7 +27909,7 @@ _loop1_179_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_179[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_181[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -27754,14 +27927,14 @@ _loop1_179_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_179_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_181_type, _seq); D(p->level--); return _seq; } -// _tmp_180: ')' | '**' +// _tmp_182: ')' | '**' static void * -_tmp_180_rule(Parser *p) +_tmp_182_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27775,18 +27948,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_182[%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_182[%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_182[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // '**' @@ -27794,18 +27967,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_182[%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_182[%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_182[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -27814,9 +27987,9 @@ _tmp_180_rule(Parser *p) return _res; } -// _tmp_181: ':' | '**' +// _tmp_183: ':' | '**' static void * -_tmp_181_rule(Parser *p) +_tmp_183_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27830,18 +28003,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_183[%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_183[%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_183[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // '**' @@ -27849,18 +28022,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_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_181[%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_181[%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; @@ -27869,9 +28042,9 @@ _tmp_181_rule(Parser *p) return _res; } -// _tmp_182: argument_pattern | error_star +// _tmp_184: argument_pattern | error_star static void * -_tmp_182_rule(Parser *p) +_tmp_184_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27885,18 +28058,18 @@ _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, "argument_pattern")); + D(fprintf(stderr, "%*c> _tmp_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern")); void *argument_pattern_var; if ( (argument_pattern_var = argument_pattern_rule(p)) // argument_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern")); + D(fprintf(stderr, "%*c+ _tmp_184[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern")); _res = argument_pattern_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_184[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern")); } { // error_star @@ -27904,18 +28077,18 @@ _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, "error_star")); + D(fprintf(stderr, "%*c> _tmp_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_star")); expr_ty error_star_var; if ( (error_star_var = error_star_rule(p)) // error_star ) { - D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_star")); + D(fprintf(stderr, "%*c+ _tmp_184[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_star")); _res = error_star_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_184[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_star")); } _res = NULL; From 9a06fe331662338bf52c311714dbb87b721bc44d Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 2 Jun 2020 22:23:29 -0700 Subject: [PATCH 058/189] Clean up and add tests --- Lib/ast.py | 15 +++++++------ Lib/test/test_patma.py | 51 ++++++++++++++++++++++++++++++++++++++++++ Python/ast_opt.c | 2 +- 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/Lib/ast.py b/Lib/ast.py index 0a63a08a18bf5c..82f127d60f329c 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -1330,15 +1330,16 @@ def visit_Compare(self, node): self.write(" " + self.cmpops[o.__class__.__name__] + " ") self.traverse(e) - boolops = {("And", False): "and", ("Or", False): "or", ("Or", True): "|"} - boolop_precedence = { - "and": _Precedence.AND, "or": _Precedence.OR, "|": _Precedence.OR, - } + boolops = {"And": "and", "Or": "or"} + boolop_precedence = {"and": _Precedence.AND, "or": _Precedence.OR} def visit_BoolOp(self, node): - - operator = self.boolops[node.op.__class__.__name__, self.in_pattern()] - operator_precedence = self.boolop_precedence[operator] + if self.in_pattern(): + operator = "|" + operator_precedence = _Precedence.OR + else: + operator = self.boolops[node.op.__class__.__name__] + operator_precedence = self.boolop_precedence[operator] def increasing_level_traverse(node): nonlocal operator_precedence diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 2524dd7ec7b28a..2c51cd4187933b 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1617,6 +1617,57 @@ class C: self.assertEqual(x, 0) self.assertEqual(y, 0) + def test_patma_116(self) -> None: + match = case = 0 + match match: + case case: + x = 0 + self.assertEqual(match, 0) + self.assertEqual(case, 0) + self.assertEqual(x, 0) + + def test_patma_117(self) -> None: + match = case = 0 + match case: + case match: + x = 0 + self.assertEqual(match, 0) + self.assertEqual(case, 0) + self.assertEqual(x, 0) + + def test_patma_118(self) -> None: + x = [] + match x: + case [*_, _]: + y = 0 + case []: + y = 1 + self.assertEqual(x, []) + self.assertEqual(y, 1) + + def test_patma_119(self) -> None: + from collections import defaultdict + x = defaultdict(int) + match x: + case {0: 0}: + y = 0 + case {}: + y = 1 + self.assertEqual(x, []) + self.assertEqual(y, 1) + + def test_patma_120(self) -> None: + from collections import defaultdict + x = defaultdict(int) + match x: + case {0: 0}: + y = 0 + case {**z}: + y = 1 + self.assertEqual(x, []) + self.assertEqual(y, 1) + self.assertEqual(z, {}) + if __name__ == "__main__": # XXX: For quick test debugging... import dis diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 0ff36860df3c31..217cd6f43aacd4 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -818,7 +818,7 @@ astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) static int astfold_match_case(match_case_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) { - CALL_OPT(astfold_pattern, expr_ty, node_->pattern); + CALL(astfold_pattern, expr_ty, node_->pattern); CALL_OPT(astfold_expr, expr_ty, node_->guard); CALL_SEQ(astfold_stmt, stmt_ty, node_->body); return 1; From bb0ed117411570fb44334a3f27ffcea7f691c414 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 3 Jun 2020 17:03:21 -0700 Subject: [PATCH 059/189] Support destructuring type matches --- Doc/library/dis.rst | 106 ++++--- Include/opcode.h | 8 +- Lib/ast.py | 2 +- Lib/importlib/_bootstrap_external.py | 4 +- Lib/opcode.py | 8 +- Lib/test/test_patma.py | 4 +- Python/ast.c | 24 ++ Python/ast_opt.c | 1 + Python/ceval.c | 413 +++++++++++++++++++++++---- Python/compile.c | 190 +++++++----- Python/importlib_external.h | 2 +- Python/opcode_targets.h | 8 +- 12 files changed, 583 insertions(+), 187 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index c2d79e9dd6f774..6700d3c645590b 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -737,6 +737,14 @@ iterations of the loop. by :opcode:`CALL_FUNCTION` to construct a class. +.. opcode:: LIST_POP + + TOS is a :class:`list`. Pop the last item from it, and push it onto the + stack. + + .. versionadded:: 3.10 + + .. opcode:: SETUP_WITH (delta) This opcode performs several operations before a with block starts. First, @@ -990,47 +998,6 @@ All of the following opcodes use their arguments. code counter is incremented by *delta*. -.. opcode:: MATCH_KEY (delta) - - Pop TOS. If it is a key in the :class:`dict` at TOS1, remove it and push the - associated value onto the stack. Otherwise, increment the bytecode counter - by ``delta``. - - .. versionadded:: 3.10 - - -.. opcode:: MATCH_MAP (delta) - - Pop TOS. If it is an instance of :class:`collections.abc.Mapping`, copy it - into a :class:`dict` and push that onto the stack. Otherwise, increment the - bytecode counter by ``delta``. - - .. versionadded:: 3.10 - - -.. opcode:: MATCH_SEQ (delta) - - Pop TOS. If it is an instance of :class:`collections.abc.Sequence`, is not - an :term:`iterator`, and is not an instance of - :class:`str`/:class:`bytes`/:class:`bytearray`, get an iterator from it and - push that onto the stack. Otherwise, increment the bytecode counter by - ``delta``. - - .. versionadded:: 3.10 - - -.. opcode:: DESTRUCTURE (argcount) - - Pop TOS, TOS1, and TOS2. If TOS1 is an instance of :class:`type` and has a - ``__match__`` method, call it on TOS2. If the result is not ``None``, - destrucuture it into ``argcount`` components (using any keyword names from - the :class:`tuple` at TOS), collect these into a tuple, and push that onto - the stack, followed by ``True``. Otherwise, push ``None``, followed by - ``False``. - - .. versionadded:: 3.10 - - .. opcode:: LOAD_GLOBAL (namei) Loads the global named ``co_names[namei]`` onto the stack. @@ -1230,6 +1197,63 @@ All of the following opcodes use their arguments. .. versionadded:: 3.6 +.. opcode:: MATCH (delta) + + Pop TOS, TOS1, TOS2, and TOS3. If TOS2 is an instance of :class:`type` and + has a ``__match__`` method, call that method on TOS3. The returned "proxy" + should be non-``None``. + + TOS is an integer argument count, and TOS1 is a :class:`tuple` of attribute + names. Using these together with the ``__match_args__`` and + ``__match_args_required__`` attributes (if present) on the "proxy", discover + and validate the total collection of attribute names required for a + successful match. If it has all of those attributes, push a reversed + :class:`list` of their corresponsing values onto the stack. + + If any part of the above process is unsuccessful, increment the bytecode + counter by ``delta``. + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_MAP (delta) + + Pop TOS and TOS1. TOS is a tuple of keys. If TOS1 is an instance of + :class:`collections.abc.Mapping`, push a reversed list of values mapped from + those keys onto the stack. Otherwise, increment the bytecode counter by + ``delta``. + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_MAP_STAR (delta) + + Perform the same steps as :opcode:`MATCH_MAP`, but prepend a :class:`dict` of + the remaining items to the list of values. + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_SEQ (delta) + + Pop TOS and TOS1. TOS is an :class:`int` length. If TOS1 is an instance of + :class:`collections.abc.Sequence`, is not an :term:`iterator`, is not an + instance of :class:`str`/:class:`bytes`/:class:`bytearray`, and has that + length, collect it into a reversed list and push that onto the stack. + Otherwise, increment the bytecode counter by ``delta``. + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_SEQ_STAR (delta) + + Pop TOS, TOS1, and TOS2. TOS and TOS1 are int lengths. Perform the same + steps as :opcode:`MATCH_SEQ` on TOS2, but fold the middle items of the result + list between TOS1 and -TOS2 into another, nested list. + + .. versionadded:: 3.10 + + .. opcode:: HAVE_ARGUMENT This is not really an opcode. It identifies the dividing line between diff --git a/Include/opcode.h b/Include/opcode.h index 07b1d80dd8986a..13bb9019dc6b1c 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -13,6 +13,7 @@ extern "C" { #define DUP_TOP 4 #define DUP_TOP_TWO 5 #define ROT_FOUR 6 +#define LIST_POP 7 #define NOP 9 #define UNARY_POSITIVE 10 #define UNARY_NEGATIVE 11 @@ -127,10 +128,11 @@ extern "C" { #define SET_UPDATE 163 #define DICT_MERGE 164 #define DICT_UPDATE 165 -#define MATCH_KEY 166 +#define MATCH 166 #define MATCH_MAP 167 -#define MATCH_SEQ 168 -#define DESTRUCTURE 169 +#define MATCH_MAP_STAR 168 +#define MATCH_SEQ 169 +#define MATCH_SEQ_STAR 170 /* EXCEPT_HANDLER is a special, implicit block type which is created when entering an except handler. It is not an opcode but we define it here diff --git a/Lib/ast.py b/Lib/ast.py index 82f127d60f329c..d10852b45d06c4 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -1339,7 +1339,7 @@ def visit_BoolOp(self, node): operator_precedence = _Precedence.OR else: operator = self.boolops[node.op.__class__.__name__] - operator_precedence = self.boolop_precedence[operator] + operator_precedence = self.boolop_precedence[operator] def increasing_level_traverse(node): nonlocal operator_precedence diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 47ccd046ee0b84..49ec198d53e165 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3439 (add DESTRUCTURE, MATCH_KEY, MATCH_MAP, MATCH_SEQ) +# Python 3.10a0 3442 (add LIST_POP, MATCH*) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3440).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3442).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index 24315fd55a9315..98bd21b2380c56 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -60,6 +60,7 @@ def jabs_op(name, op): def_op('DUP_TOP', 4) def_op('DUP_TOP_TWO', 5) def_op('ROT_FOUR', 6) +def_op('LIST_POP', 7) def_op('NOP', 9) def_op('UNARY_POSITIVE', 10) @@ -213,9 +214,10 @@ def jabs_op(name, op): def_op('SET_UPDATE', 163) def_op('DICT_MERGE', 164) def_op('DICT_UPDATE', 165) -jrel_op('MATCH_KEY', 166) +jrel_op('MATCH', 166) jrel_op('MATCH_MAP', 167) -jrel_op('MATCH_SEQ', 168) -jrel_op('DESTRUCTURE', 169) +jrel_op('MATCH_MAP_STAR', 168) +jrel_op('MATCH_SEQ', 169) +jrel_op('MATCH_SEQ_STAR', 170) del def_op, name_op, jrel_op, jabs_op diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 2c51cd4187933b..78d9a9867e1aaf 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1653,7 +1653,7 @@ def test_patma_119(self) -> None: y = 0 case {}: y = 1 - self.assertEqual(x, []) + self.assertEqual(x, {}) self.assertEqual(y, 1) def test_patma_120(self) -> None: @@ -1664,7 +1664,7 @@ def test_patma_120(self) -> None: y = 0 case {**z}: y = 1 - self.assertEqual(x, []) + self.assertEqual(x, {}) self.assertEqual(y, 1) self.assertEqual(z, {}) diff --git a/Python/ast.c b/Python/ast.c index b149e07a1c8bd7..7740c40df02510 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -312,6 +312,7 @@ validate_pattern(expr_ty p) case Attribute_kind: return validate_expr(p, Load); case BinOp_kind: + // TODO return 1; case BoolOp_kind: if (p->v.BoolOp.op != Or) { @@ -332,6 +333,9 @@ validate_pattern(expr_ty p) } } return 1; + case Call_kind: + // TODO + return 1; case Constant_kind: return validate_expr(p, Load); case Dict_kind: @@ -360,6 +364,17 @@ validate_pattern(expr_ty p) } return validate_expr(key, Load); } + else { + if (i != size - 1) { + // TODO + } + if (key->kind != Name_kind) { + // TODO + } + if (key->v.Name.ctx != Store) { + // TODO + } + } if (!validate_pattern(asdl_seq_GET(values, i))) { return 0; } @@ -370,6 +385,15 @@ validate_pattern(expr_ty p) size = asdl_seq_LEN(values); for (i = 0; i < size; i++) { value = asdl_seq_GET(values, i); + if (value->kind == Starred_kind) { + value = value->v.Starred.value; + if (value->kind != Name_kind) { + // TODO + } + if (value->v.Name.ctx != Store) { + // TODO + } + } if (!validate_pattern(value)) { return 0; } diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 217cd6f43aacd4..270192210af362 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -801,6 +801,7 @@ astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) return 1; case BoolOp_kind: // TODO: Quite a bit of potential here. + case Call_kind: case Dict_kind: case List_kind: case Name_kind: diff --git a/Python/ceval.c b/Python/ceval.c index 08480844459053..b78d14e3a0ddea 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -898,6 +898,226 @@ match_seq_type(PyObject *target) ); } +static PyObject* +match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) +{ + assert(PyDict_CheckExact(map)); + assert(PyTuple_CheckExact(keys)); + Py_ssize_t nkeys = PyTuple_GET_SIZE(keys); + PyObject *seen = NULL; + PyObject *values = NULL; + if (PyDict_GET_SIZE(map) < nkeys) { + goto fail; + } + seen = PySet_New(NULL); + if (!seen) { + goto fail; + } + values = PyList_New(nkeys); + if (!values) { + goto fail; + } + for (Py_ssize_t i = 0; i < nkeys; i++) { + PyObject *key = PyTuple_GET_ITEM(keys, i); + int dupe = PySet_Contains(seen, key); + if (dupe || PySet_Add(seen, key)) { + if (!_PyErr_Occurred(tstate)) { + _PyErr_Format(tstate, PyExc_ValueError, + "mapping pattern checks duplicate key (%R)", key); + } + goto fail; + } + PyObject *value = PyDict_GetItemWithError(map, key); + if (!value) { + goto fail; + } + Py_INCREF(value); + PyList_SET_ITEM(values, nkeys - 1 - i, value); + if (PyDict_DelItem(map, key)) { + goto fail; + } + } + Py_DECREF(seen); + return values; +fail: + Py_XDECREF(seen); + Py_XDECREF(values); + return NULL; +} + +static Py_ssize_t +get_match_args_required(PyThreadState *tstate, PyObject *proxy) +{ + if (!PyObject_HasAttrString(proxy, "__match_args_required__")) { + return 0; + } + PyObject *mar = PyObject_GetAttrString(proxy, "__match_args_required__"); + if (!mar) { + return -1; + } + if (!PyLong_CheckExact(mar)) { + _PyErr_Format(tstate, PyExc_TypeError, + "__match_args_required__ must be an int (got %s)", + Py_TYPE(mar)->tp_name); + Py_DECREF(mar); + return -1; + } + Py_ssize_t required = PyLong_AsSsize_t(mar); + Py_DECREF(mar); + if (required < 0) { + if (!_PyErr_Occurred(tstate)) { + _PyErr_Format(tstate, PyExc_TypeError, + "__match_args_required__ must be nonnegative (got %d)", + required); + } + return -1; + } + return required; +} + +static PyObject * +get_match_args(PyThreadState *tstate, PyObject *proxy) +{ + if (!PyObject_HasAttrString(proxy, "__match_args__")) { + return PyTuple_New(0); + } + PyObject *ma = PyObject_GetAttrString(proxy, "__match_args__"); + if (!ma) { + return NULL; + } + if (!PyList_CheckExact(ma)) { + _PyErr_Format(tstate, PyExc_TypeError, + "__match_args__ must be a list (got %s)", + Py_TYPE(ma)->tp_name); + Py_DECREF(ma); + return NULL; + } + return PyList_AsTuple(ma); +} + +static PyObject * +do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *type, PyObject *target) +{ + assert(PyLong_CheckExact(count)); + assert(PyTuple_CheckExact(kwargs)); + if (!PyType_Check(type)) { + _PyErr_Format(tstate, PyExc_TypeError, + "called match pattern must be a type; did you mean '%s'?", + Py_TYPE(type)->tp_name); + return NULL; + } + PyObject *method = PyObject_GetAttrString(type, "__match__"); + if (!method) { + return NULL; + } + if (method == Py_None) { + Py_DECREF(method); + _PyErr_Format(tstate, PyExc_TypeError, + "type %s cannot be matched", + Py_TYPE(type)->tp_name); + return NULL; + } + PyObject *proxy = PyObject_CallOneArg(method, target); + Py_DECREF(method); + if (!proxy) { + return NULL; + } + if (proxy == Py_None) { + Py_DECREF(proxy); + return NULL; + } + Py_ssize_t nkwargs = PyTuple_GET_SIZE(kwargs); + Py_ssize_t nargs = PyLong_AsSsize_t(count); + if (nargs < 0) { + Py_DECREF(proxy); + return NULL; + } + nargs -= nkwargs; + PyObject *args; + if (nargs) { + PyObject *_args = get_match_args(tstate, proxy); + if (!_args) { + Py_DECREF(proxy); + return NULL; + } + if (PyTuple_GET_SIZE(_args) < nargs) { + Py_DECREF(_args); + Py_DECREF(proxy); + // TODO: Add expected and actual counts: + _PyErr_SetString(tstate, PyExc_TypeError, + "too many positional matches in pattern"); + return NULL; + } + args = PyTuple_GetSlice(_args, 0, nargs); + Py_DECREF(_args); + } + else { + args = PyTuple_New(0); + } + if (!args) { + Py_DECREF(proxy); + return NULL; + } + assert(PyTuple_CheckExact(args)); + PyObject *attrs = PyList_New(nargs + nkwargs); + if (!attrs) { + Py_DECREF(proxy); + Py_DECREF(args); + return NULL; + } + PyObject *seen = PySet_New(NULL); + if (!seen) { + Py_DECREF(proxy); + Py_DECREF(args); + Py_DECREF(attrs); + return NULL; + } + PyObject *name; + for (Py_ssize_t i = 0; i < nargs + nkwargs; i++) { + if (i < nargs) { + name = PyTuple_GET_ITEM(args, i); + } + else { + name = PyTuple_GET_ITEM(kwargs, i - nargs); + } + int dupe = PySet_Contains(seen, name); + if (dupe || PySet_Add(seen, name)) { + Py_DECREF(proxy); + Py_DECREF(args); + Py_DECREF(attrs); + Py_DECREF(seen); + if (!_PyErr_Occurred(tstate)) { + _PyErr_Format(tstate, PyExc_TypeError, + "multiple patterns bound to attribute %R", name); + } + return NULL; + } + if (!PyObject_HasAttr(proxy, name)) { + // TODO: typo checking using __match_args__? + Py_DECREF(proxy); + Py_DECREF(args); + Py_DECREF(attrs); + Py_DECREF(seen); + return NULL; + } + PyObject *attr = PyObject_GetAttr(proxy, name); + if (!attr) { + Py_DECREF(proxy); + Py_DECREF(args); + Py_DECREF(attrs); + Py_DECREF(seen); + return NULL; + } + PyList_SET_ITEM(attrs, nargs + nkwargs - i - 1, attr); + } + // TODO: check __match_args_required__. + Py_DECREF(proxy); + Py_DECREF(args); + Py_DECREF(seen); + return attrs; +} + + static int do_raise(PyThreadState *tstate, PyObject *exc, PyObject *cause); static int unpack_iterable(PyThreadState *, PyObject *, int, int, PyObject **); @@ -1577,6 +1797,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(POP_TOP): { + PREDICTED(POP_TOP); PyObject *value = POP(); Py_DECREF(value); FAST_DISPATCH(); @@ -3334,38 +3555,59 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) #endif } - case TARGET(MATCH_KEY): { - PyObject *key = TOP(); - PyObject *map = SECOND(); - assert(PyDict_CheckExact(map)); - PyObject *value = PyDict_GetItemWithError(map, key); - if (!value) { + case TARGET(LIST_POP): { + PREDICTED(LIST_POP); + PyObject *list = TOP(); + assert(PyList_CheckExact(list)); + Py_ssize_t size = PyList_GET_SIZE(list); + assert(size > 0); + PyObject *popped = PyList_GET_ITEM(list, size - 1); + Py_INCREF(popped); + PUSH(popped); + if (PyList_SetSlice(list, size - 1, size, NULL)) { + goto error; + } + DISPATCH(); + } + + case TARGET(MATCH): { + PyObject *count = TOP(); + PyObject *names = SECOND(); + PyObject *type = THIRD(); + PyObject *target = FOURTH(); + PyObject *attrs = do_match(tstate, count, names, type, target); + Py_DECREF(count); + Py_DECREF(names); + Py_DECREF(type); + Py_DECREF(target); + if (!attrs) { + STACK_SHRINK(4); if (_PyErr_Occurred(tstate)) { goto error; } - STACK_SHRINK(1); - Py_DECREF(key); JUMPBY(oparg); DISPATCH(); } - Py_INCREF(value); - if (PyDict_DelItem(map, key)) { - Py_DECREF(value); - goto error; - } - Py_DECREF(key); - SET_TOP(value); + STACK_SHRINK(3); + SET_TOP(attrs); + PREDICT(LIST_POP); + PREDICT(POP_TOP); DISPATCH(); } - case TARGET(MATCH_MAP): { - PyObject *target = TOP(); + case TARGET(MATCH_MAP): + case TARGET(MATCH_MAP_STAR): { + // TODO: JUST PREPEND THE STAR MAP TO THE LIST! + int star = opcode == MATCH_MAP_STAR; + PyObject *keys = TOP(); + PyObject *target = SECOND(); int match = match_map_type(target); if (match < 0) { goto error; } if (!match) { - STACK_SHRINK(1); + STACK_SHRINK(2); + Py_DECREF(keys); Py_DECREF(target); JUMPBY(oparg); DISPATCH(); @@ -3384,71 +3626,130 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) goto error; } } - Py_DECREF(target); - SET_TOP(copy); - DISPATCH(); - } - - case TARGET(MATCH_SEQ): { - PyObject *target = TOP(); - int match = match_seq_type(target); - if (match < 0) { - goto error; - } - if (!match) { - STACK_SHRINK(1); + PyObject *values = match_map_items(tstate, copy, keys); + if (!values) { + Py_DECREF(copy); + if (_PyErr_Occurred(tstate)) { + goto error; + } + STACK_SHRINK(2); + Py_DECREF(keys); Py_DECREF(target); JUMPBY(oparg); DISPATCH(); } - PyObject *iter = PyObject_GetIter(target); - if (!iter) { + // TODO: This is inefficient: + if (star && PyList_Insert(values, 0, copy)) { + Py_DECREF(copy); goto error; } + Py_DECREF(copy); + STACK_SHRINK(1); + SET_TOP(values); + Py_DECREF(keys); Py_DECREF(target); - SET_TOP(iter); + PREDICT(LIST_POP); + PREDICT(POP_TOP); DISPATCH(); } - case TARGET(DESTRUCTURE): { - PyObject *type = TOP(); - PyObject *target = SECOND(); - if (!PyType_Check(type)) { - _PyErr_Format(tstate, PyExc_TypeError, - "called match pattern must be a type; " - "did you mean '%s'?", Py_TYPE(type)->tp_name); + case TARGET(MATCH_SEQ): + case TARGET(MATCH_SEQ_STAR): { + int star = opcode == MATCH_SEQ_STAR; + Py_ssize_t size_pre = -1; + if (star) { + PyObject *_size_pre = POP(); + assert(PyLong_CheckExact(_size_pre)); + size_pre = PyLong_AsSsize_t(_size_pre); + Py_DECREF(_size_pre); + if (size_pre < 0) { + goto error; + } + } + PyObject *_size = TOP(); + assert(PyLong_CheckExact(_size)); + Py_ssize_t size = PyLong_AsSsize_t(_size); + if (size < 0) { goto error; } - PyObject *method = PyObject_GetAttrString(type, "__match__"); - if (method == Py_None) { - Py_DECREF(method); - _PyErr_Format(tstate, PyExc_TypeError, - "type '%s' cannot be matched", - Py_TYPE(type)->tp_name); + PyObject *target = SECOND(); + int match = match_seq_type(target); + if (match < 0) { goto error; } - PyObject *match = PyObject_CallOneArg(method, target); - Py_DECREF(method); if (!match) { + STACK_SHRINK(2); + Py_DECREF(_size); + Py_DECREF(target); + JUMPBY(oparg); + DISPATCH(); + } + // TODO: Break this out: + PyObject *list = PySequence_List(target); + if (!list) { goto error; } - if (match == Py_None) { - Py_DECREF(match); + if (!star) { + assert(size_pre < 0); + if (PyList_GET_SIZE(list) != size) { + Py_DECREF(list); + STACK_SHRINK(2); + Py_DECREF(_size); + Py_DECREF(target); + JUMPBY(oparg); + DISPATCH(); + } + if (PyList_Reverse(list)) { + Py_DECREF(list); + goto error; + } + STACK_SHRINK(1); + SET_TOP(list); + Py_DECREF(_size); + Py_DECREF(target); + DISPATCH(); + } + assert(size_pre >= 0); + Py_ssize_t actual = PyList_GET_SIZE(list); + if (actual < size_pre + size) { + Py_DECREF(list); STACK_SHRINK(2); - Py_DECREF(type); + Py_DECREF(_size); Py_DECREF(target); JUMPBY(oparg); DISPATCH(); } + PyObject *middle = PyList_GetSlice(list, size_pre, actual - size); + if (!middle) { + Py_DECREF(list); + goto error; + } + PyObject *nested = PyTuple_Pack(1, middle); + Py_DECREF(middle); + if (!nested) { + Py_DECREF(list); + goto error; + } + if (PyList_SetSlice(list, size_pre, actual - size, nested)) { + Py_DECREF(nested); + Py_DECREF(list); + goto error; + } + Py_DECREF(nested); + if (PyList_Reverse(list)) { + Py_DECREF(list); + goto error; + } + assert(PyList_GET_SIZE(list) == size_pre + 1 + size); STACK_SHRINK(1); - Py_DECREF(type); + SET_TOP(list); + Py_DECREF(_size); Py_DECREF(target); - SET_TOP(match); + PREDICT(LIST_POP); + PREDICT(POP_TOP); DISPATCH(); } - - case TARGET(GET_ITER): { /* before: [obj]; after [getiter(obj)] */ PyObject *iterable = TOP(); diff --git a/Python/compile.c b/Python/compile.c index 8c4ec1b3742d36..c584e5faeccc6a 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -982,12 +982,6 @@ stack_effect(int opcode, int oparg, int jump) case FOR_ITER: /* -1 at end of iterator, 1 if continue iterating. */ return jump > 0 ? -1 : 1; - case MATCH_KEY: - case MATCH_MAP: - case MATCH_SEQ: - return jump > 0 ? -1 : 0; - case DESTRUCTURE: - return -1; case STORE_ATTR: return -2; @@ -1124,6 +1118,16 @@ stack_effect(int opcode, int oparg, int jump) case DICT_MERGE: case DICT_UPDATE: return -1; + case LIST_POP: + return 1; + case MATCH: + return jump > 0 ? -4 : -3; + case MATCH_MAP: + case MATCH_MAP_STAR: + case MATCH_SEQ: + return jump > 0 ? -2 : -1; + case MATCH_SEQ_STAR: + return jump > 0 ? -3 : -2; default: return PY_INVALID_STACK_EFFECT; } @@ -2771,6 +2775,53 @@ compiler_pattern_load(struct compiler *c, expr_ty p, basicblock *fail) return 1; } +static int +compiler_pattern_call(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) { + asdl_seq *args = p->v.Call.args; + asdl_seq *kwargs = p->v.Call.keywords; + Py_ssize_t nargs = asdl_seq_LEN(args); + Py_ssize_t nkwargs = asdl_seq_LEN(kwargs); + basicblock *block, *end; + CHECK(block = compiler_new_block(c)); + CHECK(end = compiler_new_block(c)); + expr_ty func = p->v.Call.func; + assert(func->kind == Attribute_kind || func->kind == Name_kind); + assert(func->kind != Attribute_kind || func->v.Attribute.ctx == Load); + assert(func->kind != Name_kind || func->v.Name.ctx == Load); + VISIT(c, expr, func); + PyObject *kwnames; + CHECK(kwnames = PyTuple_New(nkwargs)); + // TODO: Catch colliding keywords. + Py_ssize_t i; + for (i = 0; i < nkwargs; i++) { + PyObject *name = ((keyword_ty) asdl_seq_GET(kwargs, i))->arg; + Py_INCREF(name); + PyTuple_SET_ITEM(kwnames, i, name); + } + ADDOP_LOAD_CONST_NEW(c, kwnames); + PyObject *count; + CHECK(count = PyLong_FromSsize_t(nargs + nkwargs)); + ADDOP_LOAD_CONST_NEW(c, count); + ADDOP_JREL(c, MATCH, fail); + for (i = 0; i < nargs; i++) { + expr_ty arg = asdl_seq_GET(args, i); + ADDOP(c, LIST_POP); + CHECK(compiler_pattern(c, arg, block, names)); + } + for (i = 0; i < nkwargs; i++) { + keyword_ty kwarg = asdl_seq_GET(kwargs, i); + ADDOP(c, LIST_POP); + CHECK(compiler_pattern(c, kwarg->value, block, names)); + } + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, end); + compiler_use_next_block(c, block); + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, fail); + compiler_use_next_block(c, end); + return 1; +} + static int compiler_pattern_store(struct compiler *c, expr_ty p, int anon_ok, PyObject* names) { assert(p->kind == Name_kind); @@ -2790,6 +2841,44 @@ compiler_pattern_store(struct compiler *c, expr_ty p, int anon_ok, PyObject* nam return !PySet_Add(names, p->v.Name.id); } +static int +compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) +{ + basicblock *block, *end; + CHECK(block = compiler_new_block(c)); + CHECK(end = compiler_new_block(c)); + asdl_seq *keys = p->v.Dict.keys; + asdl_seq *values = p->v.Dict.values; + Py_ssize_t size = asdl_seq_LEN(values); + int star = size ? !asdl_seq_GET(keys, size - 1) : 0; + Py_ssize_t i; + for (i = 0; i < size - star; i++) { + expr_ty key = asdl_seq_GET(keys, i); + if (!key) { + return compiler_error(c, "can't use starred pattern here; consider moving to end?"); + } + assert(key->kind == Attribute_kind || key->kind == Constant_kind || key->kind == Name_kind); + assert(key->kind != Attribute_kind || key->v.Attribute.ctx == Load); + assert(key->kind != Name_kind || key->v.Name.ctx == Load); + VISIT(c, expr, asdl_seq_GET(keys, i)); + } + ADDOP_I(c, BUILD_TUPLE, size - star); + // TODO: Just drop MATCH_MAP_STAR? + ADDOP_JREL(c, star ? MATCH_MAP_STAR : MATCH_MAP, fail); + for (i = 0; i < size; i++) { + expr_ty value = asdl_seq_GET(values, i); + ADDOP(c, LIST_POP); + CHECK(compiler_pattern(c, value, block, names)); + } + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, end); + compiler_use_next_block(c, block); + ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, fail); + compiler_use_next_block(c, end); + return 1; +} + static int compiler_pattern_name(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) { @@ -2819,44 +2908,6 @@ compiler_pattern_namedexpr(struct compiler *c, expr_ty p, basicblock *fail, PyOb return 1; } -static int -compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) -{ - basicblock *block, *end; - CHECK(block = compiler_new_block(c)); - CHECK(end = compiler_new_block(c)); - asdl_seq *keys = p->v.Dict.keys; - asdl_seq *values = p->v.Dict.values; - Py_ssize_t size = asdl_seq_LEN(values); - int star = size ? !asdl_seq_GET(keys, size - 1) : 0; - ADDOP_JREL(c, MATCH_MAP, fail); - for (Py_ssize_t i = 0; i < size - star; i++) { - expr_ty key = asdl_seq_GET(keys, i); - expr_ty value = asdl_seq_GET(values, i); - if (!key) { - return compiler_error(c, "can't use starred pattern here; consider moving to end?"); - } - assert(key->kind == Attribute_kind || key->kind == Constant_kind || key->kind == Name_kind); - assert(key->kind != Attribute_kind || key->v.Attribute.ctx == Load); - assert(key->kind != Name_kind || key->v.Name.ctx == Load); - VISIT(c, expr, key); - ADDOP_JREL(c, MATCH_KEY, block); - CHECK(compiler_pattern(c, value, block, names)); - } - if (!star) { - ADDOP(c, POP_TOP); - } - else { - CHECK(compiler_pattern_store(c, asdl_seq_GET(values, size - 1), 0, names)); - } - ADDOP_JREL(c, JUMP_FORWARD, end); - compiler_use_next_block(c, block); - ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, fail); - compiler_use_next_block(c, end); - return 1; -} - static int compiler_pattern_or(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) { @@ -2867,17 +2918,16 @@ compiler_pattern_or(struct compiler *c, expr_ty p, basicblock *fail, PyObject* n CHECK(end = compiler_new_block(c)); Py_ssize_t size = asdl_seq_LEN(p->v.BoolOp.values); assert(size > 1); + PyObject *names_copy; for (Py_ssize_t i = 0; i < size; i++) { - PyObject *names_copy = PySet_New(names); - if (!names_copy) { - return 0; - } + CHECK(names_copy = PySet_New(names)); CHECK(block = compiler_new_block(c)); ADDOP(c, DUP_TOP); CHECK(compiler_pattern(c, asdl_seq_GET(p->v.BoolOp.values, i), block, names_copy)); ADDOP(c, POP_TOP); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); + // TODO: Reuse names_copy without actually building a new copy each loop? if (!i) { control = names_copy; } @@ -2924,44 +2974,33 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj if (star >= 0) { return compiler_error(c, "multiple starred names in pattern"); } - // TODO: Test this math: - if ((size - i - 1) << 8 >= INT_MAX) { - return compiler_error(c, "too many sub-patterns follow starred name"); - } star = i; } basicblock *block, *end; CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); - ADDOP_JREL(c, MATCH_SEQ, fail); + if (star >= 0) { + // TODO: ERROR CHECKING FOR THESE: + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - star - 1)) + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(star)) + ADDOP_JREL(c, MATCH_SEQ_STAR, fail); + } + else { + // TODO: ERROR CHECKING FOR THESE: + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)) + ADDOP_JREL(c, MATCH_SEQ, fail); + } for (Py_ssize_t i = 0; i < size; i++) { expr_ty value = asdl_seq_GET(values, i); if (i == star) { assert(value->kind == Starred_kind); - Py_ssize_t remaining = size - i - 1; - ADDOP_I(c, UNPACK_EX, remaining << 8); - CHECK(compiler_pattern_store(c, value->v.Starred.value, 1, names)); - if (remaining) { - ADDOP_I(c, BUILD_TUPLE, remaining); - if (remaining > 1) { - // Argh, our tuple is backwards! - // Unpacking and repacking is the easiest way to reverse it: - ADDOP_I(c, UNPACK_SEQUENCE, remaining); - ADDOP_I(c, BUILD_TUPLE, remaining); - } - ADDOP(c, GET_ITER); - } - else { - ADDOP_JREL(c, JUMP_FORWARD, end); - } - } - else { - ADDOP_JREL(c, FOR_ITER, fail); - CHECK(compiler_pattern(c, value, block, names)); + value = value->v.Starred.value; } + ADDOP(c, LIST_POP); + CHECK(compiler_pattern(c, value, block, names)); } - ADDOP_JREL(c, FOR_ITER, end); ADDOP(c, POP_TOP); + ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); ADDOP(c, POP_TOP); ADDOP_JREL(c, JUMP_FORWARD, fail); @@ -2974,6 +3013,9 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail, PyObject* name { switch (p->kind) { case Attribute_kind: + return compiler_pattern_load(c, p, fail); + case Call_kind: + return compiler_pattern_call(c, p, fail, names); case Constant_kind: return compiler_pattern_load(c, p, fail); case BoolOp_kind: diff --git a/Python/importlib_external.h b/Python/importlib_external.h index b0a3575fd29166..068165d1c53af2 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,112,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,114,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index b0c7e0fe5f6226..4309e5360ca0cc 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -6,7 +6,7 @@ static void *opcode_targets[256] = { &&TARGET_DUP_TOP, &&TARGET_DUP_TOP_TWO, &&TARGET_ROT_FOUR, - &&_unknown_opcode, + &&TARGET_LIST_POP, &&_unknown_opcode, &&TARGET_NOP, &&TARGET_UNARY_POSITIVE, @@ -165,11 +165,11 @@ static void *opcode_targets[256] = { &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, - &&TARGET_MATCH_KEY, + &&TARGET_MATCH, &&TARGET_MATCH_MAP, + &&TARGET_MATCH_MAP_STAR, &&TARGET_MATCH_SEQ, - &&TARGET_DESTRUCTURE, - &&_unknown_opcode, + &&TARGET_MATCH_SEQ_STAR, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From 03212eab43f11b83ed3185588f41c14f1dae6f31 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 3 Jun 2020 18:27:50 -0700 Subject: [PATCH 060/189] Simplify final (or only) case --- Python/compile.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index c584e5faeccc6a..d8d422ab0106ac 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -3040,10 +3040,13 @@ compiler_match(struct compiler *c, stmt_ty s) basicblock *next, *end; CHECK(end = compiler_new_block(c)); Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); + assert(cases); for (Py_ssize_t i = 0; i < cases; i++) { match_case_ty m = asdl_seq_GET(s->v.Match.cases, i); CHECK(next = compiler_new_block(c)); - ADDOP(c, DUP_TOP); + if (i != cases - 1) { + ADDOP(c, DUP_TOP); + } PyObject* names = PySet_New(NULL); if (!names) { return 0; @@ -3054,12 +3057,15 @@ compiler_match(struct compiler *c, stmt_ty s) if (m->guard) { CHECK(compiler_jump_if(c, m->guard, next, 0)); } - ADDOP(c, POP_TOP); + if (i != cases - 1) { + ADDOP(c, POP_TOP); + } VISIT_SEQ(c, stmt, m->body); - ADDOP_JREL(c, JUMP_FORWARD, end); + if (i != cases - 1) { + ADDOP_JREL(c, JUMP_FORWARD, end); + } compiler_use_next_block(c, next); } - ADDOP(c, POP_TOP); compiler_use_next_block(c, end); return 1; } From ccf83741f8deaff99f8c8f429f130a30cd7997dd Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 5 Jun 2020 07:14:03 -0700 Subject: [PATCH 061/189] Tell the peepholer about all of the jumping we do --- Python/peephole.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Python/peephole.c b/Python/peephole.c index 84de1abc175476..7bc5865bab1fa0 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -199,6 +199,11 @@ markblocks(_Py_CODEUNIT *code, Py_ssize_t len) case SETUP_FINALLY: case SETUP_WITH: case SETUP_ASYNC_WITH: + case MATCH: + case MATCH_MAP: + case MATCH_MAP_STAR: + case MATCH_SEQ: + case MATCH_SEQ_STAR: j = GETJUMPTGT(code, i); assert(j < len); blocks[j] = 1; @@ -503,6 +508,11 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, case SETUP_FINALLY: case SETUP_WITH: case SETUP_ASYNC_WITH: + case MATCH: + case MATCH_MAP: + case MATCH_MAP_STAR: + case MATCH_SEQ: + case MATCH_SEQ_STAR: j = blocks[j / sizeof(_Py_CODEUNIT) + i + 1] - blocks[i] - 1; j *= sizeof(_Py_CODEUNIT); break; From c7f121b987ee8e728468a24c1aaf47e413172889 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 5 Jun 2020 08:23:14 -0700 Subject: [PATCH 062/189] Reject f-strings, addition, and subtraction --- Python/ast_opt.c | 12 ++++++++++-- Python/compile.c | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 270192210af362..5079a59547d3af 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -772,8 +772,14 @@ astfold_pattern_complex(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state assert(node_->v.BinOp.op == Add || node_->v.BinOp.op == Sub); assert(node_->v.BinOp.left->kind = Constant_kind); assert(node_->v.BinOp.right->kind = Constant_kind); - assert(PyFloat_CheckExact(left->v.Constant.value) || PyLong_CheckExact(left->v.Constant.value)); - assert(PyComplex_CheckExact(right->v.Constant.value)); + if (!PyFloat_CheckExact(left->v.Constant.value) && !PyLong_CheckExact(left->v.Constant.value)) { + // Not actually valid, but it's the complier's job to complain: + return 1; + } + if (!PyComplex_CheckExact(right->v.Constant.value)) { + // Ditto: + return 1; + } PyObject *new; if (node_->v.BinOp.op == Add) { new = PyNumber_Add(left->v.Constant.value, right->v.Constant.value); @@ -803,6 +809,8 @@ astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) // TODO: Quite a bit of potential here. case Call_kind: case Dict_kind: + // Not actually valid, but it's the complier's job to complain: + case JoinedStr_kind: case List_kind: case Name_kind: case NamedExpr_kind: diff --git a/Python/compile.c b/Python/compile.c index d8d422ab0106ac..9d804193fae348 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -3014,6 +3014,9 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail, PyObject* name switch (p->kind) { case Attribute_kind: return compiler_pattern_load(c, p, fail); + case BinOp_kind: + // Because we allow "2+2j", things like "2+2" make it this far. + return compiler_error(c, "patterns cannot include operators"); case Call_kind: return compiler_pattern_call(c, p, fail, names); case Constant_kind: @@ -3028,6 +3031,9 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail, PyObject* name return compiler_pattern_name(c, p, fail, names); case NamedExpr_kind: return compiler_pattern_namedexpr(c, p, fail, names); + case JoinedStr_kind: + // Because we allow strings, f-strings make it this far. + return compiler_error(c, "patterns cannot include f-strings"); default: Py_UNREACHABLE(); } From 8d61da21a3ca773c41a30d98fb38e9da65e20851 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 5 Jun 2020 11:05:49 -0700 Subject: [PATCH 063/189] __match_args__ must contain strings --- Python/ceval.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Python/ceval.c b/Python/ceval.c index b78d14e3a0ddea..4cfbe90b4cfbb8 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1076,6 +1076,17 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ for (Py_ssize_t i = 0; i < nargs + nkwargs; i++) { if (i < nargs) { name = PyTuple_GET_ITEM(args, i); + if (!PyUnicode_CheckExact(name)) { + _PyErr_Format(tstate, PyExc_TypeError, + "__match_args__ elements must be str (got %s)", + Py_TYPE(name)->tp_name); + Py_DECREF(proxy); + Py_DECREF(args); + Py_DECREF(attrs); + Py_DECREF(seen); + Py_DECREF(name); + return NULL; + } } else { name = PyTuple_GET_ITEM(kwargs, i - nargs); From 0c15e70318e7a9b414d8a4cc0709eabd36cff6e0 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 5 Jun 2020 12:41:45 -0700 Subject: [PATCH 064/189] Better error messages for tuples --- Grammar/python.gram | 13 +- Parser/pegen/parse.c | 775 ++++++++++++++++++++++++------------------- 2 files changed, 448 insertions(+), 340 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index f25e710c335f22..2c35a6f27e734f 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -196,13 +196,22 @@ match_stmt: | "match" target=expression ':' NEWLINE INDENT cases=case_block+ DEDENT { _Py_Match(target, cases, EXTRA) } case_block: - | "case" pattern=pattern guard=guard? ':' body=block { + | "case" pattern=pattern_no_comma guard=guard? ':' body=block { _Py_match_case(pattern, guard, body, p->arena) } +pattern_no_comma: + | pattern=pattern !',' { + pattern } + | pattern error=',' { + RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "tuple displays cannot be used as patterns; did you mean '[...]'?") } + pattern[expr_ty]: | target=NAME ':=' value=or_pattern { _Py_NamedExpr(CHECK(_PyPegen_set_expr_context(p, target, Store)), value, EXTRA) } + | error='(' ')' { + RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "tuple displays cannot be used as patterns; did you mean '[]'?") } | or_pattern + guard: | 'if' guard=named_expression { guard } @@ -243,7 +252,7 @@ constant_pattern: | '.'? attr=attr !('.' | '(' | '=') { attr } group_pattern: - | '(' pattern=pattern ')' { + | '(' pattern=pattern_no_comma ')' { pattern } sequence_pattern: | '[' values=values_pattern? ']' { diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index 123d6c3ede8542..82859de4751dbc 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -115,329 +115,330 @@ static KeywordToken *reserved_keywords[] = { #define finally_block_type 1037 #define match_stmt_type 1038 #define case_block_type 1039 -#define pattern_type 1040 -#define guard_type 1041 -#define or_pattern_type 1042 -#define closed_pattern_type 1043 -#define name_pattern_type 1044 -#define literal_pattern_type 1045 -#define constant_pattern_type 1046 -#define group_pattern_type 1047 -#define sequence_pattern_type 1048 -#define mapping_pattern_type 1049 -#define class_pattern_type 1050 -#define signed_number_type 1051 -#define attr_type 1052 // Left-recursive -#define name_or_attr_type 1053 // Left-recursive -#define values_pattern_type 1054 -#define items_pattern_type 1055 -#define keyword_pattern_type 1056 -#define argument_pattern_type 1057 -#define error_star_type 1058 -#define value_pattern_type 1059 -#define key_value_pattern_type 1060 -#define return_stmt_type 1061 -#define raise_stmt_type 1062 -#define function_def_type 1063 -#define function_def_raw_type 1064 -#define func_type_comment_type 1065 -#define params_type 1066 -#define parameters_type 1067 -#define slash_no_default_type 1068 -#define slash_with_default_type 1069 -#define star_etc_type 1070 -#define kwds_type 1071 -#define param_no_default_type 1072 -#define param_with_default_type 1073 -#define param_maybe_default_type 1074 -#define param_type 1075 -#define annotation_type 1076 -#define default_type 1077 -#define decorators_type 1078 -#define class_def_type 1079 -#define class_def_raw_type 1080 -#define block_type 1081 -#define expressions_list_type 1082 -#define star_expressions_type 1083 -#define star_expression_type 1084 -#define star_named_expressions_type 1085 -#define star_named_expression_type 1086 -#define named_expression_type 1087 -#define annotated_rhs_type 1088 -#define expressions_type 1089 -#define expression_type 1090 -#define lambdef_type 1091 -#define lambda_parameters_type 1092 -#define lambda_slash_no_default_type 1093 -#define lambda_slash_with_default_type 1094 -#define lambda_star_etc_type 1095 -#define lambda_kwds_type 1096 -#define lambda_param_no_default_type 1097 -#define lambda_param_with_default_type 1098 -#define lambda_param_maybe_default_type 1099 -#define lambda_param_type 1100 -#define disjunction_type 1101 -#define conjunction_type 1102 -#define inversion_type 1103 -#define comparison_type 1104 -#define compare_op_bitwise_or_pair_type 1105 -#define eq_bitwise_or_type 1106 -#define noteq_bitwise_or_type 1107 -#define lte_bitwise_or_type 1108 -#define lt_bitwise_or_type 1109 -#define gte_bitwise_or_type 1110 -#define gt_bitwise_or_type 1111 -#define notin_bitwise_or_type 1112 -#define in_bitwise_or_type 1113 -#define isnot_bitwise_or_type 1114 -#define is_bitwise_or_type 1115 -#define bitwise_or_type 1116 // Left-recursive -#define bitwise_xor_type 1117 // Left-recursive -#define bitwise_and_type 1118 // Left-recursive -#define shift_expr_type 1119 // Left-recursive -#define sum_type 1120 // Left-recursive -#define term_type 1121 // Left-recursive -#define factor_type 1122 -#define power_type 1123 -#define await_primary_type 1124 -#define primary_type 1125 // Left-recursive -#define slices_type 1126 -#define slice_type 1127 -#define atom_type 1128 -#define strings_type 1129 -#define list_type 1130 -#define listcomp_type 1131 -#define tuple_type 1132 -#define group_type 1133 -#define genexp_type 1134 -#define set_type 1135 -#define setcomp_type 1136 -#define dict_type 1137 -#define dictcomp_type 1138 -#define double_starred_kvpairs_type 1139 -#define double_starred_kvpair_type 1140 -#define kvpair_type 1141 -#define for_if_clauses_type 1142 -#define for_if_clause_type 1143 -#define yield_expr_type 1144 -#define arguments_type 1145 -#define args_type 1146 -#define kwargs_type 1147 -#define starred_expression_type 1148 -#define kwarg_or_starred_type 1149 -#define kwarg_or_double_starred_type 1150 -#define star_targets_type 1151 -#define star_targets_seq_type 1152 -#define star_target_type 1153 -#define star_atom_type 1154 -#define single_target_type 1155 -#define single_subscript_attribute_target_type 1156 -#define del_targets_type 1157 -#define del_target_type 1158 -#define del_t_atom_type 1159 -#define del_target_end_type 1160 -#define targets_type 1161 -#define target_type 1162 -#define t_primary_type 1163 // Left-recursive -#define t_lookahead_type 1164 -#define t_atom_type 1165 -#define incorrect_arguments_type 1166 -#define invalid_kwarg_type 1167 -#define invalid_named_expression_type 1168 -#define invalid_assignment_type 1169 -#define invalid_block_type 1170 -#define invalid_comprehension_type 1171 -#define invalid_dict_comprehension_type 1172 -#define invalid_parameters_type 1173 -#define invalid_star_etc_type 1174 -#define invalid_lambda_star_etc_type 1175 -#define invalid_double_type_comments_type 1176 -#define invalid_del_target_type 1177 -#define invalid_import_from_targets_type 1178 -#define _loop0_1_type 1179 -#define _loop0_2_type 1180 -#define _loop0_4_type 1181 -#define _gather_3_type 1182 -#define _loop0_6_type 1183 -#define _gather_5_type 1184 -#define _loop0_8_type 1185 -#define _gather_7_type 1186 -#define _loop0_10_type 1187 -#define _gather_9_type 1188 -#define _loop1_11_type 1189 -#define _loop0_13_type 1190 -#define _gather_12_type 1191 -#define _tmp_14_type 1192 -#define _tmp_15_type 1193 -#define _tmp_16_type 1194 -#define _tmp_17_type 1195 -#define _tmp_18_type 1196 -#define _tmp_19_type 1197 -#define _tmp_20_type 1198 -#define _tmp_21_type 1199 -#define _loop1_22_type 1200 -#define _tmp_23_type 1201 -#define _tmp_24_type 1202 -#define _loop0_26_type 1203 -#define _gather_25_type 1204 -#define _loop0_28_type 1205 -#define _gather_27_type 1206 -#define _tmp_29_type 1207 -#define _loop0_30_type 1208 -#define _loop1_31_type 1209 -#define _loop0_33_type 1210 -#define _gather_32_type 1211 -#define _tmp_34_type 1212 -#define _loop0_36_type 1213 -#define _gather_35_type 1214 -#define _tmp_37_type 1215 -#define _loop0_39_type 1216 -#define _gather_38_type 1217 -#define _loop0_41_type 1218 -#define _gather_40_type 1219 -#define _loop0_43_type 1220 -#define _gather_42_type 1221 -#define _loop0_45_type 1222 -#define _gather_44_type 1223 -#define _tmp_46_type 1224 -#define _loop1_47_type 1225 -#define _tmp_48_type 1226 -#define _loop1_49_type 1227 -#define _loop0_51_type 1228 -#define _gather_50_type 1229 -#define _tmp_52_type 1230 -#define _tmp_53_type 1231 -#define _tmp_54_type 1232 -#define _tmp_55_type 1233 -#define _loop0_57_type 1234 -#define _gather_56_type 1235 -#define _loop0_59_type 1236 -#define _gather_58_type 1237 -#define _loop0_61_type 1238 -#define _gather_60_type 1239 -#define _loop0_63_type 1240 -#define _gather_62_type 1241 -#define _tmp_64_type 1242 -#define _loop0_66_type 1243 -#define _gather_65_type 1244 -#define _tmp_67_type 1245 -#define _tmp_68_type 1246 -#define _tmp_69_type 1247 -#define _loop0_71_type 1248 -#define _gather_70_type 1249 -#define _loop0_73_type 1250 -#define _gather_72_type 1251 -#define _tmp_74_type 1252 -#define _tmp_75_type 1253 -#define _tmp_76_type 1254 -#define _tmp_77_type 1255 -#define _tmp_78_type 1256 -#define _tmp_79_type 1257 -#define _loop0_80_type 1258 -#define _loop0_81_type 1259 -#define _loop0_82_type 1260 -#define _loop1_83_type 1261 -#define _loop0_84_type 1262 -#define _loop1_85_type 1263 -#define _loop1_86_type 1264 -#define _loop1_87_type 1265 -#define _loop0_88_type 1266 -#define _loop1_89_type 1267 -#define _loop0_90_type 1268 -#define _loop1_91_type 1269 -#define _loop0_92_type 1270 -#define _loop1_93_type 1271 -#define _loop1_94_type 1272 -#define _tmp_95_type 1273 -#define _loop0_97_type 1274 -#define _gather_96_type 1275 -#define _loop1_98_type 1276 -#define _loop0_100_type 1277 -#define _gather_99_type 1278 -#define _loop1_101_type 1279 -#define _loop0_102_type 1280 -#define _loop0_103_type 1281 -#define _loop0_104_type 1282 -#define _loop1_105_type 1283 -#define _loop0_106_type 1284 -#define _loop1_107_type 1285 -#define _loop1_108_type 1286 -#define _loop1_109_type 1287 -#define _loop0_110_type 1288 -#define _loop1_111_type 1289 -#define _loop0_112_type 1290 -#define _loop1_113_type 1291 -#define _loop0_114_type 1292 -#define _loop1_115_type 1293 -#define _loop1_116_type 1294 -#define _loop1_117_type 1295 -#define _loop1_118_type 1296 -#define _tmp_119_type 1297 -#define _loop0_121_type 1298 -#define _gather_120_type 1299 -#define _tmp_122_type 1300 -#define _tmp_123_type 1301 -#define _tmp_124_type 1302 -#define _tmp_125_type 1303 -#define _loop1_126_type 1304 -#define _tmp_127_type 1305 -#define _tmp_128_type 1306 -#define _loop0_130_type 1307 -#define _gather_129_type 1308 -#define _loop1_131_type 1309 -#define _loop0_132_type 1310 -#define _loop0_133_type 1311 -#define _tmp_134_type 1312 -#define _tmp_135_type 1313 -#define _loop0_137_type 1314 -#define _gather_136_type 1315 -#define _loop0_139_type 1316 -#define _gather_138_type 1317 -#define _loop0_141_type 1318 -#define _gather_140_type 1319 -#define _loop0_143_type 1320 -#define _gather_142_type 1321 -#define _loop0_144_type 1322 -#define _loop0_146_type 1323 -#define _gather_145_type 1324 -#define _tmp_147_type 1325 -#define _loop0_149_type 1326 -#define _gather_148_type 1327 -#define _loop0_151_type 1328 -#define _gather_150_type 1329 -#define _tmp_152_type 1330 -#define _loop0_153_type 1331 -#define _tmp_154_type 1332 -#define _tmp_155_type 1333 -#define _tmp_156_type 1334 -#define _tmp_157_type 1335 -#define _loop0_158_type 1336 -#define _tmp_159_type 1337 -#define _tmp_160_type 1338 -#define _tmp_161_type 1339 -#define _tmp_162_type 1340 -#define _tmp_163_type 1341 -#define _tmp_164_type 1342 -#define _loop0_166_type 1343 -#define _gather_165_type 1344 -#define _loop0_168_type 1345 -#define _gather_167_type 1346 -#define _loop0_170_type 1347 -#define _gather_169_type 1348 -#define _loop0_172_type 1349 -#define _gather_171_type 1350 -#define _tmp_173_type 1351 -#define _tmp_174_type 1352 -#define _tmp_175_type 1353 -#define _tmp_176_type 1354 -#define _tmp_177_type 1355 -#define _tmp_178_type 1356 -#define _tmp_179_type 1357 -#define _tmp_180_type 1358 -#define _loop1_181_type 1359 -#define _tmp_182_type 1360 -#define _tmp_183_type 1361 -#define _tmp_184_type 1362 +#define pattern_no_comma_type 1040 +#define pattern_type 1041 +#define guard_type 1042 +#define or_pattern_type 1043 +#define closed_pattern_type 1044 +#define name_pattern_type 1045 +#define literal_pattern_type 1046 +#define constant_pattern_type 1047 +#define group_pattern_type 1048 +#define sequence_pattern_type 1049 +#define mapping_pattern_type 1050 +#define class_pattern_type 1051 +#define signed_number_type 1052 +#define attr_type 1053 // Left-recursive +#define name_or_attr_type 1054 // Left-recursive +#define values_pattern_type 1055 +#define items_pattern_type 1056 +#define keyword_pattern_type 1057 +#define argument_pattern_type 1058 +#define error_star_type 1059 +#define value_pattern_type 1060 +#define key_value_pattern_type 1061 +#define return_stmt_type 1062 +#define raise_stmt_type 1063 +#define function_def_type 1064 +#define function_def_raw_type 1065 +#define func_type_comment_type 1066 +#define params_type 1067 +#define parameters_type 1068 +#define slash_no_default_type 1069 +#define slash_with_default_type 1070 +#define star_etc_type 1071 +#define kwds_type 1072 +#define param_no_default_type 1073 +#define param_with_default_type 1074 +#define param_maybe_default_type 1075 +#define param_type 1076 +#define annotation_type 1077 +#define default_type 1078 +#define decorators_type 1079 +#define class_def_type 1080 +#define class_def_raw_type 1081 +#define block_type 1082 +#define expressions_list_type 1083 +#define star_expressions_type 1084 +#define star_expression_type 1085 +#define star_named_expressions_type 1086 +#define star_named_expression_type 1087 +#define named_expression_type 1088 +#define annotated_rhs_type 1089 +#define expressions_type 1090 +#define expression_type 1091 +#define lambdef_type 1092 +#define lambda_parameters_type 1093 +#define lambda_slash_no_default_type 1094 +#define lambda_slash_with_default_type 1095 +#define lambda_star_etc_type 1096 +#define lambda_kwds_type 1097 +#define lambda_param_no_default_type 1098 +#define lambda_param_with_default_type 1099 +#define lambda_param_maybe_default_type 1100 +#define lambda_param_type 1101 +#define disjunction_type 1102 +#define conjunction_type 1103 +#define inversion_type 1104 +#define comparison_type 1105 +#define compare_op_bitwise_or_pair_type 1106 +#define eq_bitwise_or_type 1107 +#define noteq_bitwise_or_type 1108 +#define lte_bitwise_or_type 1109 +#define lt_bitwise_or_type 1110 +#define gte_bitwise_or_type 1111 +#define gt_bitwise_or_type 1112 +#define notin_bitwise_or_type 1113 +#define in_bitwise_or_type 1114 +#define isnot_bitwise_or_type 1115 +#define is_bitwise_or_type 1116 +#define bitwise_or_type 1117 // Left-recursive +#define bitwise_xor_type 1118 // Left-recursive +#define bitwise_and_type 1119 // Left-recursive +#define shift_expr_type 1120 // Left-recursive +#define sum_type 1121 // Left-recursive +#define term_type 1122 // Left-recursive +#define factor_type 1123 +#define power_type 1124 +#define await_primary_type 1125 +#define primary_type 1126 // Left-recursive +#define slices_type 1127 +#define slice_type 1128 +#define atom_type 1129 +#define strings_type 1130 +#define list_type 1131 +#define listcomp_type 1132 +#define tuple_type 1133 +#define group_type 1134 +#define genexp_type 1135 +#define set_type 1136 +#define setcomp_type 1137 +#define dict_type 1138 +#define dictcomp_type 1139 +#define double_starred_kvpairs_type 1140 +#define double_starred_kvpair_type 1141 +#define kvpair_type 1142 +#define for_if_clauses_type 1143 +#define for_if_clause_type 1144 +#define yield_expr_type 1145 +#define arguments_type 1146 +#define args_type 1147 +#define kwargs_type 1148 +#define starred_expression_type 1149 +#define kwarg_or_starred_type 1150 +#define kwarg_or_double_starred_type 1151 +#define star_targets_type 1152 +#define star_targets_seq_type 1153 +#define star_target_type 1154 +#define star_atom_type 1155 +#define single_target_type 1156 +#define single_subscript_attribute_target_type 1157 +#define del_targets_type 1158 +#define del_target_type 1159 +#define del_t_atom_type 1160 +#define del_target_end_type 1161 +#define targets_type 1162 +#define target_type 1163 +#define t_primary_type 1164 // Left-recursive +#define t_lookahead_type 1165 +#define t_atom_type 1166 +#define incorrect_arguments_type 1167 +#define invalid_kwarg_type 1168 +#define invalid_named_expression_type 1169 +#define invalid_assignment_type 1170 +#define invalid_block_type 1171 +#define invalid_comprehension_type 1172 +#define invalid_dict_comprehension_type 1173 +#define invalid_parameters_type 1174 +#define invalid_star_etc_type 1175 +#define invalid_lambda_star_etc_type 1176 +#define invalid_double_type_comments_type 1177 +#define invalid_del_target_type 1178 +#define invalid_import_from_targets_type 1179 +#define _loop0_1_type 1180 +#define _loop0_2_type 1181 +#define _loop0_4_type 1182 +#define _gather_3_type 1183 +#define _loop0_6_type 1184 +#define _gather_5_type 1185 +#define _loop0_8_type 1186 +#define _gather_7_type 1187 +#define _loop0_10_type 1188 +#define _gather_9_type 1189 +#define _loop1_11_type 1190 +#define _loop0_13_type 1191 +#define _gather_12_type 1192 +#define _tmp_14_type 1193 +#define _tmp_15_type 1194 +#define _tmp_16_type 1195 +#define _tmp_17_type 1196 +#define _tmp_18_type 1197 +#define _tmp_19_type 1198 +#define _tmp_20_type 1199 +#define _tmp_21_type 1200 +#define _loop1_22_type 1201 +#define _tmp_23_type 1202 +#define _tmp_24_type 1203 +#define _loop0_26_type 1204 +#define _gather_25_type 1205 +#define _loop0_28_type 1206 +#define _gather_27_type 1207 +#define _tmp_29_type 1208 +#define _loop0_30_type 1209 +#define _loop1_31_type 1210 +#define _loop0_33_type 1211 +#define _gather_32_type 1212 +#define _tmp_34_type 1213 +#define _loop0_36_type 1214 +#define _gather_35_type 1215 +#define _tmp_37_type 1216 +#define _loop0_39_type 1217 +#define _gather_38_type 1218 +#define _loop0_41_type 1219 +#define _gather_40_type 1220 +#define _loop0_43_type 1221 +#define _gather_42_type 1222 +#define _loop0_45_type 1223 +#define _gather_44_type 1224 +#define _tmp_46_type 1225 +#define _loop1_47_type 1226 +#define _tmp_48_type 1227 +#define _loop1_49_type 1228 +#define _loop0_51_type 1229 +#define _gather_50_type 1230 +#define _tmp_52_type 1231 +#define _tmp_53_type 1232 +#define _tmp_54_type 1233 +#define _tmp_55_type 1234 +#define _loop0_57_type 1235 +#define _gather_56_type 1236 +#define _loop0_59_type 1237 +#define _gather_58_type 1238 +#define _loop0_61_type 1239 +#define _gather_60_type 1240 +#define _loop0_63_type 1241 +#define _gather_62_type 1242 +#define _tmp_64_type 1243 +#define _loop0_66_type 1244 +#define _gather_65_type 1245 +#define _tmp_67_type 1246 +#define _tmp_68_type 1247 +#define _tmp_69_type 1248 +#define _loop0_71_type 1249 +#define _gather_70_type 1250 +#define _loop0_73_type 1251 +#define _gather_72_type 1252 +#define _tmp_74_type 1253 +#define _tmp_75_type 1254 +#define _tmp_76_type 1255 +#define _tmp_77_type 1256 +#define _tmp_78_type 1257 +#define _tmp_79_type 1258 +#define _loop0_80_type 1259 +#define _loop0_81_type 1260 +#define _loop0_82_type 1261 +#define _loop1_83_type 1262 +#define _loop0_84_type 1263 +#define _loop1_85_type 1264 +#define _loop1_86_type 1265 +#define _loop1_87_type 1266 +#define _loop0_88_type 1267 +#define _loop1_89_type 1268 +#define _loop0_90_type 1269 +#define _loop1_91_type 1270 +#define _loop0_92_type 1271 +#define _loop1_93_type 1272 +#define _loop1_94_type 1273 +#define _tmp_95_type 1274 +#define _loop0_97_type 1275 +#define _gather_96_type 1276 +#define _loop1_98_type 1277 +#define _loop0_100_type 1278 +#define _gather_99_type 1279 +#define _loop1_101_type 1280 +#define _loop0_102_type 1281 +#define _loop0_103_type 1282 +#define _loop0_104_type 1283 +#define _loop1_105_type 1284 +#define _loop0_106_type 1285 +#define _loop1_107_type 1286 +#define _loop1_108_type 1287 +#define _loop1_109_type 1288 +#define _loop0_110_type 1289 +#define _loop1_111_type 1290 +#define _loop0_112_type 1291 +#define _loop1_113_type 1292 +#define _loop0_114_type 1293 +#define _loop1_115_type 1294 +#define _loop1_116_type 1295 +#define _loop1_117_type 1296 +#define _loop1_118_type 1297 +#define _tmp_119_type 1298 +#define _loop0_121_type 1299 +#define _gather_120_type 1300 +#define _tmp_122_type 1301 +#define _tmp_123_type 1302 +#define _tmp_124_type 1303 +#define _tmp_125_type 1304 +#define _loop1_126_type 1305 +#define _tmp_127_type 1306 +#define _tmp_128_type 1307 +#define _loop0_130_type 1308 +#define _gather_129_type 1309 +#define _loop1_131_type 1310 +#define _loop0_132_type 1311 +#define _loop0_133_type 1312 +#define _tmp_134_type 1313 +#define _tmp_135_type 1314 +#define _loop0_137_type 1315 +#define _gather_136_type 1316 +#define _loop0_139_type 1317 +#define _gather_138_type 1318 +#define _loop0_141_type 1319 +#define _gather_140_type 1320 +#define _loop0_143_type 1321 +#define _gather_142_type 1322 +#define _loop0_144_type 1323 +#define _loop0_146_type 1324 +#define _gather_145_type 1325 +#define _tmp_147_type 1326 +#define _loop0_149_type 1327 +#define _gather_148_type 1328 +#define _loop0_151_type 1329 +#define _gather_150_type 1330 +#define _tmp_152_type 1331 +#define _loop0_153_type 1332 +#define _tmp_154_type 1333 +#define _tmp_155_type 1334 +#define _tmp_156_type 1335 +#define _tmp_157_type 1336 +#define _loop0_158_type 1337 +#define _tmp_159_type 1338 +#define _tmp_160_type 1339 +#define _tmp_161_type 1340 +#define _tmp_162_type 1341 +#define _tmp_163_type 1342 +#define _tmp_164_type 1343 +#define _loop0_166_type 1344 +#define _gather_165_type 1345 +#define _loop0_168_type 1346 +#define _gather_167_type 1347 +#define _loop0_170_type 1348 +#define _gather_169_type 1349 +#define _loop0_172_type 1350 +#define _gather_171_type 1351 +#define _tmp_173_type 1352 +#define _tmp_174_type 1353 +#define _tmp_175_type 1354 +#define _tmp_176_type 1355 +#define _tmp_177_type 1356 +#define _tmp_178_type 1357 +#define _tmp_179_type 1358 +#define _tmp_180_type 1359 +#define _loop1_181_type 1360 +#define _tmp_182_type 1361 +#define _tmp_183_type 1362 +#define _tmp_184_type 1363 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -479,6 +480,7 @@ static excepthandler_ty except_block_rule(Parser *p); static asdl_seq* finally_block_rule(Parser *p); static void *match_stmt_rule(Parser *p); static void *case_block_rule(Parser *p); +static void *pattern_no_comma_rule(Parser *p); static expr_ty pattern_rule(Parser *p); static void *guard_rule(Parser *p); static void *or_pattern_rule(Parser *p); @@ -4733,7 +4735,7 @@ match_stmt_rule(Parser *p) return _res; } -// case_block: "case" pattern guard? ':' block +// case_block: "case" pattern_no_comma guard? ':' block static void * case_block_rule(Parser *p) { @@ -4744,21 +4746,21 @@ case_block_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // "case" pattern guard? ':' block + { // "case" pattern_no_comma guard? ':' block if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> case_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" pattern guard? ':' block")); + D(fprintf(stderr, "%*c> case_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" pattern_no_comma guard? ':' block")); expr_ty _keyword; Token * _literal; asdl_seq* body; void *guard; - expr_ty pattern; + void *pattern; if ( (_keyword = _PyPegen_expect_soft_keyword(p, "case")) // soft_keyword='"case"' && - (pattern = pattern_rule(p)) // pattern + (pattern = pattern_no_comma_rule(p)) // pattern_no_comma && (guard = guard_rule(p), 1) // guard? && @@ -4767,7 +4769,7 @@ case_block_rule(Parser *p) (body = block_rule(p)) // block ) { - D(fprintf(stderr, "%*c+ case_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" pattern guard? ':' block")); + D(fprintf(stderr, "%*c+ case_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" pattern_no_comma guard? ':' block")); _res = _Py_match_case ( pattern , guard , body , p -> arena ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -4778,7 +4780,7 @@ case_block_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s case_block[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" pattern guard? ':' block")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" pattern_no_comma guard? ':' block")); } _res = NULL; done: @@ -4786,7 +4788,77 @@ case_block_rule(Parser *p) return _res; } -// pattern: NAME ':=' or_pattern | or_pattern +// pattern_no_comma: pattern !',' | pattern ',' +static void * +pattern_no_comma_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // pattern !',' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> pattern_no_comma[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern !','")); + expr_ty pattern; + if ( + (pattern = pattern_rule(p)) // pattern + && + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' + ) + { + D(fprintf(stderr, "%*c+ pattern_no_comma[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern !','")); + _res = pattern; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s pattern_no_comma[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern !','")); + } + { // pattern ',' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> pattern_no_comma[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern ','")); + Token * error; + expr_ty pattern_var; + if ( + (pattern_var = pattern_rule(p)) // pattern + && + (error = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ pattern_no_comma[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern ','")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "tuple displays cannot be used as patterns; did you mean '[...]'?" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s pattern_no_comma[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern ','")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// pattern: NAME ':=' or_pattern | '(' ')' | or_pattern static expr_ty pattern_rule(Parser *p) { @@ -4845,6 +4917,33 @@ pattern_rule(Parser *p) D(fprintf(stderr, "%*c%s pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':=' or_pattern")); } + { // '(' ')' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' ')'")); + Token * _literal; + Token * error; + if ( + (error = _PyPegen_expect_token(p, 7)) // token='(' + && + (_literal = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' ')'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "tuple displays cannot be used as patterns; did you mean '[]'?" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' ')'")); + } { // or_pattern if (p->error_indicator) { D(p->level--); @@ -5524,7 +5623,7 @@ constant_pattern_rule(Parser *p) return _res; } -// group_pattern: '(' pattern ')' +// group_pattern: '(' pattern_no_comma ')' static void * group_pattern_rule(Parser *p) { @@ -5535,24 +5634,24 @@ group_pattern_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '(' pattern ')' + { // '(' pattern_no_comma ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> group_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' pattern ')'")); + D(fprintf(stderr, "%*c> group_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' pattern_no_comma ')'")); Token * _literal; Token * _literal_1; - expr_ty pattern; + void *pattern; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (pattern = pattern_rule(p)) // pattern + (pattern = pattern_no_comma_rule(p)) // pattern_no_comma && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ group_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' pattern ')'")); + D(fprintf(stderr, "%*c+ group_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' pattern_no_comma ')'")); _res = pattern; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -5563,7 +5662,7 @@ group_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s group_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' pattern ')'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' pattern_no_comma ')'")); } _res = NULL; done: From 28bf07be4c0b644433d022aa99fc4a60fc17086f Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 7 Jun 2020 08:35:29 -0700 Subject: [PATCH 065/189] Add length-checking opcodes --- Doc/library/dis.rst | 24 ++++++++++--- Include/opcode.h | 2 ++ Lib/importlib/_bootstrap_external.py | 4 +-- Lib/opcode.py | 2 ++ Python/ceval.c | 52 ++++++++++++++++------------ Python/compile.c | 18 ++++++++-- Python/importlib_external.h | 2 +- Python/opcode_targets.h | 4 +-- 8 files changed, 72 insertions(+), 36 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 6700d3c645590b..7b18b2c0eec603 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1236,11 +1236,11 @@ All of the following opcodes use their arguments. .. opcode:: MATCH_SEQ (delta) - Pop TOS and TOS1. TOS is an :class:`int` length. If TOS1 is an instance of - :class:`collections.abc.Sequence`, is not an :term:`iterator`, is not an - instance of :class:`str`/:class:`bytes`/:class:`bytearray`, and has that - length, collect it into a reversed list and push that onto the stack. - Otherwise, increment the bytecode counter by ``delta``. + Pop TOS. If it is an instance of :class:`collections.abc.Sequence`, is not an + :term:`iterator`, and is not an instance of + :class:`str`/:class:`bytes`/:class:`bytearray`, collect it into a reversed + list and push that onto the stack. Otherwise, increment the bytecode counter + by ``delta``. .. versionadded:: 3.10 @@ -1254,6 +1254,20 @@ All of the following opcodes use their arguments. .. versionadded:: 3.10 +.. opcode:: MATCH_LEN_EQ (size) + + TODO + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_LEN_GE (size) + + TODO + + .. versionadded:: 3.10 + + .. opcode:: HAVE_ARGUMENT This is not really an opcode. It identifies the dividing line between diff --git a/Include/opcode.h b/Include/opcode.h index 13bb9019dc6b1c..3d1a3a181e1c6d 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -133,6 +133,8 @@ extern "C" { #define MATCH_MAP_STAR 168 #define MATCH_SEQ 169 #define MATCH_SEQ_STAR 170 +#define MATCH_LEN_EQ 171 +#define MATCH_LEN_GE 172 /* EXCEPT_HANDLER is a special, implicit block type which is created when entering an except handler. It is not an opcode but we define it here diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 49ec198d53e165..cf8c50554af3a0 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3442 (add LIST_POP, MATCH*) +# Python 3.10a0 3444 (add LIST_POP, MATCH*) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3442).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3444).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index 98bd21b2380c56..3c8e0f3c8e6534 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -219,5 +219,7 @@ def jabs_op(name, op): jrel_op('MATCH_MAP_STAR', 168) jrel_op('MATCH_SEQ', 169) jrel_op('MATCH_SEQ_STAR', 170) +def_op('MATCH_LEN_EQ', 171) +def_op('MATCH_LEN_GE', 172) del def_op, name_op, jrel_op, jabs_op diff --git a/Python/ceval.c b/Python/ceval.c index 4cfbe90b4cfbb8..6554dc995b01cc 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3668,6 +3668,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(MATCH_SEQ_STAR): { int star = opcode == MATCH_SEQ_STAR; Py_ssize_t size_pre = -1; + Py_ssize_t size = -1; if (star) { PyObject *_size_pre = POP(); assert(PyLong_CheckExact(_size_pre)); @@ -3676,21 +3677,21 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (size_pre < 0) { goto error; } + PyObject *_size = POP(); + assert(PyLong_CheckExact(_size)); + size = PyLong_AsSsize_t(_size); + Py_DECREF(_size); + if (size < 0) { + goto error; + } } - PyObject *_size = TOP(); - assert(PyLong_CheckExact(_size)); - Py_ssize_t size = PyLong_AsSsize_t(_size); - if (size < 0) { - goto error; - } - PyObject *target = SECOND(); + PyObject *target = TOP(); int match = match_seq_type(target); if (match < 0) { goto error; } if (!match) { - STACK_SHRINK(2); - Py_DECREF(_size); + STACK_SHRINK(1); Py_DECREF(target); JUMPBY(oparg); DISPATCH(); @@ -3702,30 +3703,21 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } if (!star) { assert(size_pre < 0); - if (PyList_GET_SIZE(list) != size) { - Py_DECREF(list); - STACK_SHRINK(2); - Py_DECREF(_size); - Py_DECREF(target); - JUMPBY(oparg); - DISPATCH(); - } + assert(size < 0); if (PyList_Reverse(list)) { Py_DECREF(list); goto error; } - STACK_SHRINK(1); SET_TOP(list); - Py_DECREF(_size); Py_DECREF(target); DISPATCH(); } assert(size_pre >= 0); + assert(size >= 0); Py_ssize_t actual = PyList_GET_SIZE(list); if (actual < size_pre + size) { Py_DECREF(list); - STACK_SHRINK(2); - Py_DECREF(_size); + STACK_SHRINK(1); Py_DECREF(target); JUMPBY(oparg); DISPATCH(); @@ -3752,15 +3744,29 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) goto error; } assert(PyList_GET_SIZE(list) == size_pre + 1 + size); - STACK_SHRINK(1); SET_TOP(list); - Py_DECREF(_size); Py_DECREF(target); PREDICT(LIST_POP); PREDICT(POP_TOP); DISPATCH(); } + case TARGET(MATCH_LEN_EQ): + case TARGET(MATCH_LEN_GE): { + Py_ssize_t len = PyObject_Length(TOP()); + if (len < 0) { + goto error; + } + if (opcode == MATCH_LEN_EQ ? len == oparg : len >= oparg) { + PUSH(Py_True); + } + else { + PUSH(Py_False); + } + Py_INCREF(TOP()); + DISPATCH(); + } + case TARGET(GET_ITER): { /* before: [obj]; after [getiter(obj)] */ PyObject *iterable = TOP(); diff --git a/Python/compile.c b/Python/compile.c index 9d804193fae348..d3b3e5fb7b4c3a 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1124,10 +1124,14 @@ stack_effect(int opcode, int oparg, int jump) return jump > 0 ? -4 : -3; case MATCH_MAP: case MATCH_MAP_STAR: - case MATCH_SEQ: return jump > 0 ? -2 : -1; + case MATCH_SEQ: + return jump > 0 ? -1 : 0; case MATCH_SEQ_STAR: return jump > 0 ? -3 : -2; + case MATCH_LEN_EQ: + case MATCH_LEN_GE: + return 1; default: return PY_INVALID_STACK_EFFECT; } @@ -2865,6 +2869,10 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje ADDOP_I(c, BUILD_TUPLE, size - star); // TODO: Just drop MATCH_MAP_STAR? ADDOP_JREL(c, star ? MATCH_MAP_STAR : MATCH_MAP, fail); + if (size - star) { + ADDOP_I(c, MATCH_LEN_GE, size - star); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + } for (i = 0; i < size; i++) { expr_ty value = asdl_seq_GET(values, i); ADDOP(c, LIST_POP); @@ -2984,11 +2992,15 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - star - 1)) ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(star)) ADDOP_JREL(c, MATCH_SEQ_STAR, fail); + if (size) { + ADDOP_I(c, MATCH_LEN_GE, size - 1); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + } } else { - // TODO: ERROR CHECKING FOR THESE: - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)) ADDOP_JREL(c, MATCH_SEQ, fail); + ADDOP_I(c, MATCH_LEN_EQ, size); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); } for (Py_ssize_t i = 0; i < size; i++) { expr_ty value = asdl_seq_GET(values, i); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 068165d1c53af2..142d343cca504e 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,114,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,116,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 4309e5360ca0cc..a0ed60263a024e 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -170,8 +170,8 @@ static void *opcode_targets[256] = { &&TARGET_MATCH_MAP_STAR, &&TARGET_MATCH_SEQ, &&TARGET_MATCH_SEQ_STAR, - &&_unknown_opcode, - &&_unknown_opcode, + &&TARGET_MATCH_LEN_EQ, + &&TARGET_MATCH_LEN_GE, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From 009ca7ebd8ab2bb2187e6cef797491d3b227e928 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 7 Jun 2020 11:39:43 -0700 Subject: [PATCH 066/189] Start phasing in new opcodes --- Include/opcode.h | 10 ++-- Lib/importlib/_bootstrap_external.py | 4 +- Lib/opcode.py | 12 +++-- Python/ceval.c | 72 ++++++++++++++-------------- Python/compile.c | 36 ++++++++------ Python/importlib_external.h | 2 +- Python/opcode_targets.h | 12 ++--- Python/peephole.c | 16 +++---- 8 files changed, 89 insertions(+), 75 deletions(-) diff --git a/Include/opcode.h b/Include/opcode.h index 3d1a3a181e1c6d..989720f5303c29 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -31,6 +31,8 @@ extern "C" { #define BINARY_TRUE_DIVIDE 27 #define INPLACE_FLOOR_DIVIDE 28 #define INPLACE_TRUE_DIVIDE 29 +#define MATCH_SEQ 30 +#define MATCH_MAP 31 #define RERAISE 48 #define WITH_EXCEPT_START 49 #define GET_AITER 50 @@ -129,10 +131,10 @@ extern "C" { #define DICT_MERGE 164 #define DICT_UPDATE 165 #define MATCH 166 -#define MATCH_MAP 167 -#define MATCH_MAP_STAR 168 -#define MATCH_SEQ 169 -#define MATCH_SEQ_STAR 170 +#define OLD_MATCH_MAP 167 +#define OLD_MATCH_MAP_STAR 168 +#define OLD_MATCH_SEQ 169 +#define OLD_MATCH_SEQ_STAR 170 #define MATCH_LEN_EQ 171 #define MATCH_LEN_GE 172 diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index cf8c50554af3a0..e11bf149a82bd5 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3444 (add LIST_POP, MATCH*) +# Python 3.10a0 3445 (add MATCH*) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3444).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3445).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index 3c8e0f3c8e6534..71dbd7428013c5 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -84,6 +84,9 @@ def jabs_op(name, op): def_op('INPLACE_FLOOR_DIVIDE', 28) def_op('INPLACE_TRUE_DIVIDE', 29) +def_op('MATCH_SEQ', 30) +def_op('MATCH_MAP', 31) + def_op('RERAISE', 48) def_op('WITH_EXCEPT_START', 49) def_op('GET_AITER', 50) @@ -214,11 +217,12 @@ def jabs_op(name, op): def_op('SET_UPDATE', 163) def_op('DICT_MERGE', 164) def_op('DICT_UPDATE', 165) + jrel_op('MATCH', 166) -jrel_op('MATCH_MAP', 167) -jrel_op('MATCH_MAP_STAR', 168) -jrel_op('MATCH_SEQ', 169) -jrel_op('MATCH_SEQ_STAR', 170) +jrel_op('OLD_MATCH_MAP', 167) +jrel_op('OLD_MATCH_MAP_STAR', 168) +jrel_op('OLD_MATCH_SEQ', 169) +jrel_op('OLD_MATCH_SEQ_STAR', 170) def_op('MATCH_LEN_EQ', 171) def_op('MATCH_LEN_GE', 172) diff --git a/Python/ceval.c b/Python/ceval.c index 6554dc995b01cc..f41fd58bbe5494 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -851,7 +851,7 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) // Need these for pattern matching: static int -match_map_type(PyObject *target) +match_map(PyObject *target) { PyInterpreterState *interp = PyInterpreterState_Get(); if (!interp) { @@ -872,7 +872,7 @@ match_map_type(PyObject *target) } static int -match_seq_type(PyObject *target) +match_seq(PyObject *target) { PyInterpreterState *interp = PyInterpreterState_Get(); if (!interp) { @@ -3606,23 +3606,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(MATCH_MAP): - case TARGET(MATCH_MAP_STAR): { - // TODO: JUST PREPEND THE STAR MAP TO THE LIST! - int star = opcode == MATCH_MAP_STAR; + case TARGET(OLD_MATCH_MAP): + case TARGET(OLD_MATCH_MAP_STAR): { + int star = opcode == OLD_MATCH_MAP_STAR; PyObject *keys = TOP(); PyObject *target = SECOND(); - int match = match_map_type(target); - if (match < 0) { - goto error; - } - if (!match) { - STACK_SHRINK(2); - Py_DECREF(keys); - Py_DECREF(target); - JUMPBY(oparg); - DISPATCH(); - } PyObject *copy; if (PyDict_CheckExact(target)) { copy = PyDict_Copy(target); @@ -3664,9 +3652,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(MATCH_SEQ): - case TARGET(MATCH_SEQ_STAR): { - int star = opcode == MATCH_SEQ_STAR; + case TARGET(OLD_MATCH_SEQ): + case TARGET(OLD_MATCH_SEQ_STAR): { + int star = opcode == OLD_MATCH_SEQ_STAR; Py_ssize_t size_pre = -1; Py_ssize_t size = -1; if (star) { @@ -3686,16 +3674,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } } PyObject *target = TOP(); - int match = match_seq_type(target); - if (match < 0) { - goto error; - } - if (!match) { - STACK_SHRINK(1); - Py_DECREF(target); - JUMPBY(oparg); - DISPATCH(); - } // TODO: Break this out: PyObject *list = PySequence_List(target); if (!list) { @@ -3751,18 +3729,42 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(MATCH_LEN_EQ): + case TARGET(MATCH_LEN_EQ): { + Py_ssize_t len = PyObject_Length(TOP()); + if (len < 0) { + goto error; + } + PUSH(len == oparg ? Py_True : Py_False); + Py_INCREF(TOP()); + DISPATCH(); + } + case TARGET(MATCH_LEN_GE): { Py_ssize_t len = PyObject_Length(TOP()); if (len < 0) { goto error; } - if (opcode == MATCH_LEN_EQ ? len == oparg : len >= oparg) { - PUSH(Py_True); + PUSH(len >= oparg ? Py_True : Py_False); + Py_INCREF(TOP()); + DISPATCH(); + } + + case TARGET(MATCH_MAP): { + int match = match_map(TOP()); + if (match < 0) { + goto error; } - else { - PUSH(Py_False); + PUSH(match ? Py_True : Py_False); + Py_INCREF(TOP()); + DISPATCH(); + } + + case TARGET(MATCH_SEQ): { + int match = match_seq(TOP()); + if (match < 0) { + goto error; } + PUSH(match ? Py_True : Py_False); Py_INCREF(TOP()); DISPATCH(); } diff --git a/Python/compile.c b/Python/compile.c index d3b3e5fb7b4c3a..e00609885bc0e3 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1122,15 +1122,17 @@ stack_effect(int opcode, int oparg, int jump) return 1; case MATCH: return jump > 0 ? -4 : -3; - case MATCH_MAP: - case MATCH_MAP_STAR: + case OLD_MATCH_MAP: + case OLD_MATCH_MAP_STAR: return jump > 0 ? -2 : -1; - case MATCH_SEQ: + case OLD_MATCH_SEQ: return jump > 0 ? -1 : 0; - case MATCH_SEQ_STAR: + case OLD_MATCH_SEQ_STAR: return jump > 0 ? -3 : -2; case MATCH_LEN_EQ: case MATCH_LEN_GE: + case MATCH_MAP: + case MATCH_SEQ: return 1; default: return PY_INVALID_STACK_EFFECT; @@ -2855,6 +2857,12 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje asdl_seq *values = p->v.Dict.values; Py_ssize_t size = asdl_seq_LEN(values); int star = size ? !asdl_seq_GET(keys, size - 1) : 0; + ADDOP(c, MATCH_MAP); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + if (size - star) { + ADDOP_I(c, MATCH_LEN_GE, size - star); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + } Py_ssize_t i; for (i = 0; i < size - star; i++) { expr_ty key = asdl_seq_GET(keys, i); @@ -2867,12 +2875,8 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje VISIT(c, expr, asdl_seq_GET(keys, i)); } ADDOP_I(c, BUILD_TUPLE, size - star); - // TODO: Just drop MATCH_MAP_STAR? - ADDOP_JREL(c, star ? MATCH_MAP_STAR : MATCH_MAP, fail); - if (size - star) { - ADDOP_I(c, MATCH_LEN_GE, size - star); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); - } + // TODO: Just drop OLD_MATCH_MAP_STAR? + ADDOP_JREL(c, star ? OLD_MATCH_MAP_STAR : OLD_MATCH_MAP, fail); for (i = 0; i < size; i++) { expr_ty value = asdl_seq_GET(values, i); ADDOP(c, LIST_POP); @@ -2987,20 +2991,22 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj basicblock *block, *end; CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); + ADDOP(c, MATCH_SEQ); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); if (star >= 0) { - // TODO: ERROR CHECKING FOR THESE: - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - star - 1)) - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(star)) - ADDOP_JREL(c, MATCH_SEQ_STAR, fail); if (size) { ADDOP_I(c, MATCH_LEN_GE, size - 1); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); } + // TODO: ERROR CHECKING FOR THESE: + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - star - 1)) + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(star)) + ADDOP_JREL(c, OLD_MATCH_SEQ_STAR, fail); } else { - ADDOP_JREL(c, MATCH_SEQ, fail); ADDOP_I(c, MATCH_LEN_EQ, size); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + ADDOP_JREL(c, OLD_MATCH_SEQ, fail); } for (Py_ssize_t i = 0; i < size; i++) { expr_ty value = asdl_seq_GET(values, i); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 142d343cca504e..a1eb0f10fdd9fb 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,116,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,117,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index a0ed60263a024e..b89698e80274ab 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -29,8 +29,8 @@ static void *opcode_targets[256] = { &&TARGET_BINARY_TRUE_DIVIDE, &&TARGET_INPLACE_FLOOR_DIVIDE, &&TARGET_INPLACE_TRUE_DIVIDE, - &&_unknown_opcode, - &&_unknown_opcode, + &&TARGET_MATCH_SEQ, + &&TARGET_MATCH_MAP, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, @@ -166,10 +166,10 @@ static void *opcode_targets[256] = { &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, &&TARGET_MATCH, - &&TARGET_MATCH_MAP, - &&TARGET_MATCH_MAP_STAR, - &&TARGET_MATCH_SEQ, - &&TARGET_MATCH_SEQ_STAR, + &&TARGET_OLD_MATCH_MAP, + &&TARGET_OLD_MATCH_MAP_STAR, + &&TARGET_OLD_MATCH_SEQ, + &&TARGET_OLD_MATCH_SEQ_STAR, &&TARGET_MATCH_LEN_EQ, &&TARGET_MATCH_LEN_GE, &&_unknown_opcode, diff --git a/Python/peephole.c b/Python/peephole.c index 7bc5865bab1fa0..ee1665c4fc8122 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -200,10 +200,10 @@ markblocks(_Py_CODEUNIT *code, Py_ssize_t len) case SETUP_WITH: case SETUP_ASYNC_WITH: case MATCH: - case MATCH_MAP: - case MATCH_MAP_STAR: - case MATCH_SEQ: - case MATCH_SEQ_STAR: + case OLD_MATCH_MAP: + case OLD_MATCH_MAP_STAR: + case OLD_MATCH_SEQ: + case OLD_MATCH_SEQ_STAR: j = GETJUMPTGT(code, i); assert(j < len); blocks[j] = 1; @@ -509,10 +509,10 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, case SETUP_WITH: case SETUP_ASYNC_WITH: case MATCH: - case MATCH_MAP: - case MATCH_MAP_STAR: - case MATCH_SEQ: - case MATCH_SEQ_STAR: + case OLD_MATCH_MAP: + case OLD_MATCH_MAP_STAR: + case OLD_MATCH_SEQ: + case OLD_MATCH_SEQ_STAR: j = blocks[j / sizeof(_Py_CODEUNIT) + i + 1] - blocks[i] - 1; j *= sizeof(_Py_CODEUNIT); break; From 32b396fb00fac83dc17c1c219190cb06919e28ae Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 7 Jun 2020 22:57:53 -0700 Subject: [PATCH 067/189] Refactor sequence-matching opcodes --- Include/opcode.h | 5 +- Lib/importlib/_bootstrap_external.py | 4 +- Lib/opcode.py | 5 +- Python/ceval.c | 177 +++++++++++++-------------- Python/compile.c | 23 ++-- Python/importlib_external.h | 2 +- Python/opcode_targets.h | 10 +- Python/peephole.c | 4 - 8 files changed, 109 insertions(+), 121 deletions(-) diff --git a/Include/opcode.h b/Include/opcode.h index 989720f5303c29..3660f3b2788c3a 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -133,10 +133,11 @@ extern "C" { #define MATCH 166 #define OLD_MATCH_MAP 167 #define OLD_MATCH_MAP_STAR 168 -#define OLD_MATCH_SEQ 169 -#define OLD_MATCH_SEQ_STAR 170 #define MATCH_LEN_EQ 171 #define MATCH_LEN_GE 172 +#define MATCH_SEQ_SLICE 173 +#define MATCH_SEQ_ITEM 174 +#define MATCH_SEQ_ITEM_END 175 /* EXCEPT_HANDLER is a special, implicit block type which is created when entering an except handler. It is not an opcode but we define it here diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index e11bf149a82bd5..ccc0b32befb69c 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3445 (add MATCH*) +# Python 3.10a0 3451 (add MATCH*) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3445).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3451).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index 71dbd7428013c5..0e5a0d1ad013dc 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -221,9 +221,10 @@ def jabs_op(name, op): jrel_op('MATCH', 166) jrel_op('OLD_MATCH_MAP', 167) jrel_op('OLD_MATCH_MAP_STAR', 168) -jrel_op('OLD_MATCH_SEQ', 169) -jrel_op('OLD_MATCH_SEQ_STAR', 170) def_op('MATCH_LEN_EQ', 171) def_op('MATCH_LEN_GE', 172) +def_op('MATCH_SEQ_SLICE', 173) +def_op('MATCH_SEQ_ITEM', 174) +def_op('MATCH_SEQ_ITEM_END', 175) del def_op, name_op, jrel_op, jabs_op diff --git a/Python/ceval.c b/Python/ceval.c index f41fd58bbe5494..cd43dc0452c8b8 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3611,23 +3611,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) int star = opcode == OLD_MATCH_MAP_STAR; PyObject *keys = TOP(); PyObject *target = SECOND(); - PyObject *copy; - if (PyDict_CheckExact(target)) { - copy = PyDict_Copy(target); - if (!copy) { - goto error; - } - } - else { - copy = PyDict_New(); - if (!copy || PyDict_Update(copy, target)) { - Py_XDECREF(copy); - goto error; - } - } - PyObject *values = match_map_items(tstate, copy, keys); + PyObject *values = match_map_items(tstate, target, keys); if (!values) { - Py_DECREF(copy); if (_PyErr_Occurred(tstate)) { goto error; } @@ -3638,11 +3623,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } // TODO: This is inefficient: - if (star && PyList_Insert(values, 0, copy)) { - Py_DECREF(copy); + if (star && PyList_Insert(values, 0, target)) { goto error; } - Py_DECREF(copy); STACK_SHRINK(1); SET_TOP(values); Py_DECREF(keys); @@ -3652,87 +3635,60 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(OLD_MATCH_SEQ): - case TARGET(OLD_MATCH_SEQ_STAR): { - int star = opcode == OLD_MATCH_SEQ_STAR; - Py_ssize_t size_pre = -1; - Py_ssize_t size = -1; - if (star) { - PyObject *_size_pre = POP(); - assert(PyLong_CheckExact(_size_pre)); - size_pre = PyLong_AsSsize_t(_size_pre); - Py_DECREF(_size_pre); - if (size_pre < 0) { - goto error; - } - PyObject *_size = POP(); - assert(PyLong_CheckExact(_size)); - size = PyLong_AsSsize_t(_size); - Py_DECREF(_size); - if (size < 0) { - goto error; - } - } + case TARGET(MATCH_SEQ_ITEM): { PyObject *target = TOP(); - // TODO: Break this out: - PyObject *list = PySequence_List(target); - if (!list) { - goto error; + assert(PyList_CheckExact(target) || PyTuple_CheckExact(target)); + PyObject *item = PySequence_Fast_GET_ITEM(target, oparg); + Py_INCREF(item); + PUSH(item); + DISPATCH(); + } + + case TARGET(MATCH_SEQ_ITEM_END): { + PyObject *target = TOP(); + assert(PyList_CheckExact(target) || PyTuple_CheckExact(target)); + Py_ssize_t i = PySequence_Fast_GET_SIZE(target) - 1 - oparg; + PyObject *item = PySequence_Fast_GET_ITEM(target, i); + Py_INCREF(item); + PUSH(item); + DISPATCH(); + } + + case TARGET(MATCH_SEQ_SLICE): { + PyObject *target = TOP(); + assert(PyList_CheckExact(target) || PyTuple_CheckExact(target)); + Py_ssize_t pre = oparg >> 16; + Py_ssize_t post = oparg & 0xFF; + PyObject *slice; + if (PyList_CheckExact(target)) { + post = PyList_GET_SIZE(target) - post; + slice = PyList_GetSlice(target, pre, post); } - if (!star) { - assert(size_pre < 0); - assert(size < 0); - if (PyList_Reverse(list)) { - Py_DECREF(list); + else { + post = PyTuple_GET_SIZE(target) - post; + PyObject *tslice = PyTuple_GetSlice(target, pre, post); + if (!tslice) { goto error; } - SET_TOP(list); - Py_DECREF(target); - DISPATCH(); - } - assert(size_pre >= 0); - assert(size >= 0); - Py_ssize_t actual = PyList_GET_SIZE(list); - if (actual < size_pre + size) { - Py_DECREF(list); - STACK_SHRINK(1); - Py_DECREF(target); - JUMPBY(oparg); - DISPATCH(); - } - PyObject *middle = PyList_GetSlice(list, size_pre, actual - size); - if (!middle) { - Py_DECREF(list); - goto error; + slice = PySequence_List(tslice); + Py_DECREF(tslice); } - PyObject *nested = PyTuple_Pack(1, middle); - Py_DECREF(middle); - if (!nested) { - Py_DECREF(list); + if (!slice) { goto error; } - if (PyList_SetSlice(list, size_pre, actual - size, nested)) { - Py_DECREF(nested); - Py_DECREF(list); - goto error; - } - Py_DECREF(nested); - if (PyList_Reverse(list)) { - Py_DECREF(list); - goto error; - } - assert(PyList_GET_SIZE(list) == size_pre + 1 + size); - SET_TOP(list); - Py_DECREF(target); - PREDICT(LIST_POP); - PREDICT(POP_TOP); + PUSH(slice); DISPATCH(); } case TARGET(MATCH_LEN_EQ): { - Py_ssize_t len = PyObject_Length(TOP()); - if (len < 0) { - goto error; + PyObject *target = TOP(); + Py_ssize_t len; + if (PyDict_CheckExact(target)) { + len = PyDict_GET_SIZE(target); + } + else { + assert(PyList_CheckExact(target) || PyTuple_CheckExact(target)); + len = PySequence_Fast_GET_SIZE(target); } PUSH(len == oparg ? Py_True : Py_False); Py_INCREF(TOP()); @@ -3740,9 +3696,14 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_LEN_GE): { - Py_ssize_t len = PyObject_Length(TOP()); - if (len < 0) { - goto error; + PyObject *target = TOP(); + Py_ssize_t len; + if (PyDict_CheckExact(target)) { + len = PyDict_GET_SIZE(target); + } + else { + assert(PyList_CheckExact(target) || PyTuple_CheckExact(target)); + len = PySequence_Fast_GET_SIZE(target); } PUSH(len >= oparg ? Py_True : Py_False); Py_INCREF(TOP()); @@ -3750,20 +3711,48 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_MAP): { - int match = match_map(TOP()); + PyObject *target = TOP(); + int match = match_map(target); if (match < 0) { goto error; } + if (match) { + PyObject *map; + if (PyDict_CheckExact(target)) { + map = PyDict_Copy(target); + if (!map) { + goto error; + } + } + else { + map = PyDict_New(); + if (!map || PyDict_Update(map, target)) { + Py_XDECREF(map); + goto error; + } + } + SET_TOP(map); + Py_DECREF(target); + } PUSH(match ? Py_True : Py_False); Py_INCREF(TOP()); DISPATCH(); } case TARGET(MATCH_SEQ): { - int match = match_seq(TOP()); + PyObject *target = TOP(); + int match = match_seq(target); if (match < 0) { goto error; } + if (match) { + PyObject *seq = PySequence_Fast(target, "TODO"); // TODO + if (!seq) { + goto error; + } + SET_TOP(seq); + Py_DECREF(target); + } PUSH(match ? Py_True : Py_False); Py_INCREF(TOP()); DISPATCH(); diff --git a/Python/compile.c b/Python/compile.c index e00609885bc0e3..d8d8cfa39d3755 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1125,14 +1125,13 @@ stack_effect(int opcode, int oparg, int jump) case OLD_MATCH_MAP: case OLD_MATCH_MAP_STAR: return jump > 0 ? -2 : -1; - case OLD_MATCH_SEQ: - return jump > 0 ? -1 : 0; - case OLD_MATCH_SEQ_STAR: - return jump > 0 ? -3 : -2; case MATCH_LEN_EQ: case MATCH_LEN_GE: case MATCH_MAP: case MATCH_SEQ: + case MATCH_SEQ_ITEM: + case MATCH_SEQ_ITEM_END: + case MATCH_SEQ_SLICE: return 1; default: return PY_INVALID_STACK_EFFECT; @@ -2998,23 +2997,25 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj ADDOP_I(c, MATCH_LEN_GE, size - 1); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); } - // TODO: ERROR CHECKING FOR THESE: - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - star - 1)) - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(star)) - ADDOP_JREL(c, OLD_MATCH_SEQ_STAR, fail); } else { ADDOP_I(c, MATCH_LEN_EQ, size); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); - ADDOP_JREL(c, OLD_MATCH_SEQ, fail); } for (Py_ssize_t i = 0; i < size; i++) { expr_ty value = asdl_seq_GET(values, i); - if (i == star) { + if (star < 0 || i < star) { + ADDOP_I(c, MATCH_SEQ_ITEM, i); + } + else if (i == star) { assert(value->kind == Starred_kind); value = value->v.Starred.value; + // TODO: ERROR CHECKING FOR THESE: + ADDOP_I(c, MATCH_SEQ_SLICE, (i << 16) + (size - 1 - i)); + } + else { + ADDOP_I(c, MATCH_SEQ_ITEM_END, size - 1 - i); } - ADDOP(c, LIST_POP); CHECK(compiler_pattern(c, value, block, names)); } ADDOP(c, POP_TOP); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index a1eb0f10fdd9fb..0843140e349fbd 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,117,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,123,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index b89698e80274ab..339ce9aca0c292 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -168,13 +168,13 @@ static void *opcode_targets[256] = { &&TARGET_MATCH, &&TARGET_OLD_MATCH_MAP, &&TARGET_OLD_MATCH_MAP_STAR, - &&TARGET_OLD_MATCH_SEQ, - &&TARGET_OLD_MATCH_SEQ_STAR, - &&TARGET_MATCH_LEN_EQ, - &&TARGET_MATCH_LEN_GE, - &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, + &&TARGET_MATCH_LEN_EQ, + &&TARGET_MATCH_LEN_GE, + &&TARGET_MATCH_SEQ_SLICE, + &&TARGET_MATCH_SEQ_ITEM, + &&TARGET_MATCH_SEQ_ITEM_END, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, diff --git a/Python/peephole.c b/Python/peephole.c index ee1665c4fc8122..491c8b2b1b04f5 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -202,8 +202,6 @@ markblocks(_Py_CODEUNIT *code, Py_ssize_t len) case MATCH: case OLD_MATCH_MAP: case OLD_MATCH_MAP_STAR: - case OLD_MATCH_SEQ: - case OLD_MATCH_SEQ_STAR: j = GETJUMPTGT(code, i); assert(j < len); blocks[j] = 1; @@ -511,8 +509,6 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, case MATCH: case OLD_MATCH_MAP: case OLD_MATCH_MAP_STAR: - case OLD_MATCH_SEQ: - case OLD_MATCH_SEQ_STAR: j = blocks[j / sizeof(_Py_CODEUNIT) + i + 1] - blocks[i] - 1; j *= sizeof(_Py_CODEUNIT); break; From a7e04884a23f15bbaf0329831b87fad69ae648bb Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 9 Jun 2020 09:33:14 -0700 Subject: [PATCH 068/189] OLD_MATCH_MAP_STAR -> OLD_MATCH_MAP --- Include/opcode.h | 1 - Lib/importlib/_bootstrap_external.py | 4 ++-- Lib/opcode.py | 2 +- Python/ceval.c | 9 ++------- Python/compile.c | 19 +++++++++++++------ Python/importlib_external.h | 2 +- Python/opcode_targets.h | 2 +- Python/peephole.c | 2 -- 8 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Include/opcode.h b/Include/opcode.h index 3660f3b2788c3a..23730c6a3c2447 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -132,7 +132,6 @@ extern "C" { #define DICT_UPDATE 165 #define MATCH 166 #define OLD_MATCH_MAP 167 -#define OLD_MATCH_MAP_STAR 168 #define MATCH_LEN_EQ 171 #define MATCH_LEN_GE 172 #define MATCH_SEQ_SLICE 173 diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index ccc0b32befb69c..d1815399a58dc3 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3451 (add MATCH*) +# Python 3.10a0 3453 (add MATCH*) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3451).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3453).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index 0e5a0d1ad013dc..2c4f98fab8d42d 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -220,7 +220,7 @@ def jabs_op(name, op): jrel_op('MATCH', 166) jrel_op('OLD_MATCH_MAP', 167) -jrel_op('OLD_MATCH_MAP_STAR', 168) + def_op('MATCH_LEN_EQ', 171) def_op('MATCH_LEN_GE', 172) def_op('MATCH_SEQ_SLICE', 173) diff --git a/Python/ceval.c b/Python/ceval.c index cd43dc0452c8b8..b8b5e9b3fa3b9d 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1040,6 +1040,7 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ Py_DECREF(proxy); return NULL; } + assert(PyTuple_CheckExact(_args)); if (PyTuple_GET_SIZE(_args) < nargs) { Py_DECREF(_args); Py_DECREF(proxy); @@ -3606,9 +3607,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(OLD_MATCH_MAP): - case TARGET(OLD_MATCH_MAP_STAR): { - int star = opcode == OLD_MATCH_MAP_STAR; + case TARGET(OLD_MATCH_MAP): { PyObject *keys = TOP(); PyObject *target = SECOND(); PyObject *values = match_map_items(tstate, target, keys); @@ -3622,10 +3621,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) JUMPBY(oparg); DISPATCH(); } - // TODO: This is inefficient: - if (star && PyList_Insert(values, 0, target)) { - goto error; - } STACK_SHRINK(1); SET_TOP(values); Py_DECREF(keys); diff --git a/Python/compile.c b/Python/compile.c index d8d8cfa39d3755..18573c3f242d82 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1123,7 +1123,6 @@ stack_effect(int opcode, int oparg, int jump) case MATCH: return jump > 0 ? -4 : -3; case OLD_MATCH_MAP: - case OLD_MATCH_MAP_STAR: return jump > 0 ? -2 : -1; case MATCH_LEN_EQ: case MATCH_LEN_GE: @@ -2849,7 +2848,8 @@ compiler_pattern_store(struct compiler *c, expr_ty p, int anon_ok, PyObject* nam static int compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) { - basicblock *block, *end; + basicblock *block, *block_star, *end; + CHECK(block_star = compiler_new_block(c)); CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); asdl_seq *keys = p->v.Dict.keys; @@ -2862,6 +2862,9 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje ADDOP_I(c, MATCH_LEN_GE, size - star); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); } + if (star) { + ADDOP(c, DUP_TOP); + } Py_ssize_t i; for (i = 0; i < size - star; i++) { expr_ty key = asdl_seq_GET(keys, i); @@ -2874,15 +2877,19 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje VISIT(c, expr, asdl_seq_GET(keys, i)); } ADDOP_I(c, BUILD_TUPLE, size - star); - // TODO: Just drop OLD_MATCH_MAP_STAR? - ADDOP_JREL(c, star ? OLD_MATCH_MAP_STAR : OLD_MATCH_MAP, fail); - for (i = 0; i < size; i++) { + ADDOP_JREL(c, OLD_MATCH_MAP, star ? block : fail); + for (i = 0; i < size - star; i++) { expr_ty value = asdl_seq_GET(values, i); ADDOP(c, LIST_POP); - CHECK(compiler_pattern(c, value, block, names)); + CHECK(compiler_pattern(c, value, star ? block_star : block, names)); } ADDOP(c, POP_TOP); + if (star) { + CHECK(compiler_pattern(c, asdl_seq_GET(values, size - 1), block, names)); + } ADDOP_JREL(c, JUMP_FORWARD, end); + compiler_use_next_block(c, block_star); + ADDOP(c, POP_TOP); compiler_use_next_block(c, block); ADDOP(c, POP_TOP); ADDOP_JREL(c, JUMP_FORWARD, fail); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 0843140e349fbd..50e8a2db757bff 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,123,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,125,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 339ce9aca0c292..c7fd9fa5283a39 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -167,7 +167,7 @@ static void *opcode_targets[256] = { &&TARGET_DICT_UPDATE, &&TARGET_MATCH, &&TARGET_OLD_MATCH_MAP, - &&TARGET_OLD_MATCH_MAP_STAR, + &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, &&TARGET_MATCH_LEN_EQ, diff --git a/Python/peephole.c b/Python/peephole.c index 491c8b2b1b04f5..284b3f2dc176e7 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -201,7 +201,6 @@ markblocks(_Py_CODEUNIT *code, Py_ssize_t len) case SETUP_ASYNC_WITH: case MATCH: case OLD_MATCH_MAP: - case OLD_MATCH_MAP_STAR: j = GETJUMPTGT(code, i); assert(j < len); blocks[j] = 1; @@ -508,7 +507,6 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, case SETUP_ASYNC_WITH: case MATCH: case OLD_MATCH_MAP: - case OLD_MATCH_MAP_STAR: j = blocks[j / sizeof(_Py_CODEUNIT) + i + 1] - blocks[i] - 1; j *= sizeof(_Py_CODEUNIT); break; From eb0fe262e1b10196d58c0fa8a2a1a0f55a567a54 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 9 Jun 2020 10:22:25 -0700 Subject: [PATCH 069/189] Support None/missing __match_args__ --- Python/ceval.c | 58 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index b8b5e9b3fa3b9d..f006f77a342b45 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -979,20 +979,23 @@ static PyObject * get_match_args(PyThreadState *tstate, PyObject *proxy) { if (!PyObject_HasAttrString(proxy, "__match_args__")) { - return PyTuple_New(0); + Py_RETURN_NONE; } PyObject *ma = PyObject_GetAttrString(proxy, "__match_args__"); if (!ma) { return NULL; } - if (!PyList_CheckExact(ma)) { - _PyErr_Format(tstate, PyExc_TypeError, - "__match_args__ must be a list (got %s)", - Py_TYPE(ma)->tp_name); - Py_DECREF(ma); - return NULL; + if (PyList_CheckExact(ma)) { + return PyList_AsTuple(ma); + } + if (ma == Py_None) { + return ma; } - return PyList_AsTuple(ma); + _PyErr_Format(tstate, PyExc_TypeError, + "__match_args__ must be a list or None (got %s)", + Py_TYPE(ma)->tp_name); + Py_DECREF(ma); + return NULL; } static PyObject * @@ -1040,17 +1043,30 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ Py_DECREF(proxy); return NULL; } - assert(PyTuple_CheckExact(_args)); - if (PyTuple_GET_SIZE(_args) < nargs) { + if (_args == Py_None) { + if (nargs > 1) { + Py_DECREF(_args); + Py_DECREF(proxy); + // TODO: Add expected and actual counts: + _PyErr_SetString(tstate, PyExc_TypeError, + "too many positional matches in pattern"); + return NULL; + } + args = _args; + } + else { + assert(PyTuple_CheckExact(_args)); + if (PyTuple_GET_SIZE(_args) < nargs) { + Py_DECREF(_args); + Py_DECREF(proxy); + // TODO: Add expected and actual counts: + _PyErr_SetString(tstate, PyExc_TypeError, + "too many positional matches in pattern"); + return NULL; + } + args = PyTuple_GetSlice(_args, 0, nargs); Py_DECREF(_args); - Py_DECREF(proxy); - // TODO: Add expected and actual counts: - _PyErr_SetString(tstate, PyExc_TypeError, - "too many positional matches in pattern"); - return NULL; } - args = PyTuple_GetSlice(_args, 0, nargs); - Py_DECREF(_args); } else { args = PyTuple_New(0); @@ -1059,7 +1075,7 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ Py_DECREF(proxy); return NULL; } - assert(PyTuple_CheckExact(args)); + assert(PyTuple_CheckExact(args) || args == Py_None); PyObject *attrs = PyList_New(nargs + nkwargs); if (!attrs) { Py_DECREF(proxy); @@ -1076,6 +1092,12 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ PyObject *name; for (Py_ssize_t i = 0; i < nargs + nkwargs; i++) { if (i < nargs) { + if (args == Py_None) { + assert(!i); + Py_INCREF(proxy); + PyList_SET_ITEM(attrs, nargs + nkwargs - 1, proxy); + continue; + } name = PyTuple_GET_ITEM(args, i); if (!PyUnicode_CheckExact(name)) { _PyErr_Format(tstate, PyExc_TypeError, From 90422e4ae0962e28c20d3091e476f7278a026a2d Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 9 Jun 2020 15:38:01 -0700 Subject: [PATCH 070/189] Clean up map matches --- Doc/library/dis.rst | 50 +++++++++++++--------------- Include/opcode.h | 2 +- Lib/importlib/_bootstrap_external.py | 4 +-- Lib/opcode.py | 2 +- Python/ceval.c | 21 +++++------- Python/compile.c | 18 +++++----- Python/importlib_external.h | 2 +- Python/opcode_targets.h | 4 +-- Python/peephole.c | 2 -- 9 files changed, 48 insertions(+), 57 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 7b18b2c0eec603..88e8a565577222 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -737,14 +737,6 @@ iterations of the loop. by :opcode:`CALL_FUNCTION` to construct a class. -.. opcode:: LIST_POP - - TOS is a :class:`list`. Pop the last item from it, and push it onto the - stack. - - .. versionadded:: 3.10 - - .. opcode:: SETUP_WITH (delta) This opcode performs several operations before a with block starts. First, @@ -1199,6 +1191,8 @@ All of the following opcodes use their arguments. .. opcode:: MATCH (delta) + TODO + Pop TOS, TOS1, TOS2, and TOS3. If TOS2 is an instance of :class:`type` and has a ``__match__`` method, call that method on TOS3. The returned "proxy" should be non-``None``. @@ -1216,40 +1210,44 @@ All of the following opcodes use their arguments. .. versionadded:: 3.10 -.. opcode:: MATCH_MAP (delta) +.. opcode:: MATCH_MAP - Pop TOS and TOS1. TOS is a tuple of keys. If TOS1 is an instance of - :class:`collections.abc.Mapping`, push a reversed list of values mapped from - those keys onto the stack. Otherwise, increment the bytecode counter by - ``delta``. + TODO .. versionadded:: 3.10 -.. opcode:: MATCH_MAP_STAR (delta) +.. opcode:: MATCH_MAP_KEYS - Perform the same steps as :opcode:`MATCH_MAP`, but prepend a :class:`dict` of - the remaining items to the list of values. + TODO .. versionadded:: 3.10 -.. opcode:: MATCH_SEQ (delta) +.. opcode:: MATCH_SEQ - Pop TOS. If it is an instance of :class:`collections.abc.Sequence`, is not an - :term:`iterator`, and is not an instance of - :class:`str`/:class:`bytes`/:class:`bytearray`, collect it into a reversed - list and push that onto the stack. Otherwise, increment the bytecode counter - by ``delta``. + TODO .. versionadded:: 3.10 -.. opcode:: MATCH_SEQ_STAR (delta) +.. opcode:: MATCH_SEQ_ITEM (i) + + TODO - Pop TOS, TOS1, and TOS2. TOS and TOS1 are int lengths. Perform the same - steps as :opcode:`MATCH_SEQ` on TOS2, but fold the middle items of the result - list between TOS1 and -TOS2 into another, nested list. + .. versionadded:: 3.10 + + +.. opcode:: MATCH_SEQ_ITEM_END (i) + + TODO + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_SEQ_ITEM_SLICE (ij) + + TODO .. versionadded:: 3.10 diff --git a/Include/opcode.h b/Include/opcode.h index 23730c6a3c2447..f2d25a86e2485d 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -33,6 +33,7 @@ extern "C" { #define INPLACE_TRUE_DIVIDE 29 #define MATCH_SEQ 30 #define MATCH_MAP 31 +#define MATCH_MAP_KEYS 32 #define RERAISE 48 #define WITH_EXCEPT_START 49 #define GET_AITER 50 @@ -131,7 +132,6 @@ extern "C" { #define DICT_MERGE 164 #define DICT_UPDATE 165 #define MATCH 166 -#define OLD_MATCH_MAP 167 #define MATCH_LEN_EQ 171 #define MATCH_LEN_GE 172 #define MATCH_SEQ_SLICE 173 diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 42ef38ec690985..a689784075eb0b 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3453 (add MATCH*) +# Python 3.10a0 3454 (add MATCH*) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3453).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3454).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index 2c4f98fab8d42d..2ba8631aa2b313 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -86,6 +86,7 @@ def jabs_op(name, op): def_op('MATCH_SEQ', 30) def_op('MATCH_MAP', 31) +def_op('MATCH_MAP_KEYS', 32) def_op('RERAISE', 48) def_op('WITH_EXCEPT_START', 49) @@ -219,7 +220,6 @@ def jabs_op(name, op): def_op('DICT_UPDATE', 165) jrel_op('MATCH', 166) -jrel_op('OLD_MATCH_MAP', 167) def_op('MATCH_LEN_EQ', 171) def_op('MATCH_LEN_GE', 172) diff --git a/Python/ceval.c b/Python/ceval.c index 8f5cf940f022e2..f5d4e4b94fa1cc 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -929,7 +929,7 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) goto fail; } Py_INCREF(value); - PyList_SET_ITEM(values, nkeys - 1 - i, value); + PyList_SET_ITEM(values, i, value); if (PyDict_DelItem(map, key)) { goto fail; } @@ -1828,7 +1828,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(POP_TOP): { - PREDICTED(POP_TOP); PyObject *value = POP(); Py_DECREF(value); FAST_DISPATCH(); @@ -3587,7 +3586,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(LIST_POP): { - PREDICTED(LIST_POP); PyObject *list = TOP(); assert(PyList_CheckExact(list)); Py_ssize_t size = PyList_GET_SIZE(list); @@ -3621,12 +3619,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } STACK_SHRINK(3); SET_TOP(attrs); - PREDICT(LIST_POP); - PREDICT(POP_TOP); DISPATCH(); } - case TARGET(OLD_MATCH_MAP): { + case TARGET(MATCH_MAP_KEYS): { PyObject *keys = TOP(); PyObject *target = SECOND(); PyObject *values = match_map_items(tstate, target, keys); @@ -3634,18 +3630,17 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (_PyErr_Occurred(tstate)) { goto error; } - STACK_SHRINK(2); + Py_INCREF(Py_None); + SET_TOP(Py_None); Py_DECREF(keys); - Py_DECREF(target); - JUMPBY(oparg); + Py_INCREF(Py_False); + PUSH(Py_False); DISPATCH(); } - STACK_SHRINK(1); SET_TOP(values); Py_DECREF(keys); - Py_DECREF(target); - PREDICT(LIST_POP); - PREDICT(POP_TOP); + Py_INCREF(Py_True); + PUSH(Py_True); DISPATCH(); } diff --git a/Python/compile.c b/Python/compile.c index ce74bb4e10605a..a60175e2250ce2 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1122,8 +1122,7 @@ stack_effect(int opcode, int oparg, int jump) return 1; case MATCH: return jump > 0 ? -4 : -3; - case OLD_MATCH_MAP: - return jump > 0 ? -2 : -1; + case MATCH_MAP_KEYS: case MATCH_LEN_EQ: case MATCH_LEN_GE: case MATCH_MAP: @@ -2862,9 +2861,6 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje ADDOP_I(c, MATCH_LEN_GE, size - star); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); } - if (star) { - ADDOP(c, DUP_TOP); - } Py_ssize_t i; for (i = 0; i < size - star; i++) { expr_ty key = asdl_seq_GET(keys, i); @@ -2877,15 +2873,19 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje VISIT(c, expr, asdl_seq_GET(keys, i)); } ADDOP_I(c, BUILD_TUPLE, size - star); - ADDOP_JREL(c, OLD_MATCH_MAP, star ? block : fail); + ADDOP(c, MATCH_MAP_KEYS); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block_star) for (i = 0; i < size - star; i++) { expr_ty value = asdl_seq_GET(values, i); - ADDOP(c, LIST_POP); - CHECK(compiler_pattern(c, value, star ? block_star : block, names)); + ADDOP_I(c, MATCH_SEQ_ITEM, i); + CHECK(compiler_pattern(c, value, block_star, names)); } ADDOP(c, POP_TOP); if (star) { - CHECK(compiler_pattern(c, asdl_seq_GET(values, size - 1), block, names)); + CHECK(compiler_pattern(c, asdl_seq_GET(values, size - 1), fail, names)); + } + else { + ADDOP(c, POP_TOP); } ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block_star); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 0c7ef05112283f..421fa16dd2ecac 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,125,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,126,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index c7fd9fa5283a39..901c4a6d191f3d 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -31,7 +31,7 @@ static void *opcode_targets[256] = { &&TARGET_INPLACE_TRUE_DIVIDE, &&TARGET_MATCH_SEQ, &&TARGET_MATCH_MAP, - &&_unknown_opcode, + &&TARGET_MATCH_MAP_KEYS, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, @@ -166,7 +166,7 @@ static void *opcode_targets[256] = { &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, &&TARGET_MATCH, - &&TARGET_OLD_MATCH_MAP, + &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, diff --git a/Python/peephole.c b/Python/peephole.c index 284b3f2dc176e7..61cc6a11aa752b 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -200,7 +200,6 @@ markblocks(_Py_CODEUNIT *code, Py_ssize_t len) case SETUP_WITH: case SETUP_ASYNC_WITH: case MATCH: - case OLD_MATCH_MAP: j = GETJUMPTGT(code, i); assert(j < len); blocks[j] = 1; @@ -506,7 +505,6 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, case SETUP_WITH: case SETUP_ASYNC_WITH: case MATCH: - case OLD_MATCH_MAP: j = blocks[j / sizeof(_Py_CODEUNIT) + i + 1] - blocks[i] - 1; j *= sizeof(_Py_CODEUNIT); break; From 73d4a2bf9dd1739405b2aac62bb79fa4e01f039a Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 9 Jun 2020 15:53:52 -0700 Subject: [PATCH 071/189] Get rid of LIST_POP --- Include/opcode.h | 1 - Lib/importlib/_bootstrap_external.py | 4 ++-- Lib/opcode.py | 1 - Python/ceval.c | 18 ++---------------- Python/compile.c | 6 ++---- Python/importlib_external.h | 2 +- Python/opcode_targets.h | 2 +- 7 files changed, 8 insertions(+), 26 deletions(-) diff --git a/Include/opcode.h b/Include/opcode.h index f2d25a86e2485d..956602d29ecdce 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -13,7 +13,6 @@ extern "C" { #define DUP_TOP 4 #define DUP_TOP_TWO 5 #define ROT_FOUR 6 -#define LIST_POP 7 #define NOP 9 #define UNARY_POSITIVE 10 #define UNARY_NEGATIVE 11 diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index a689784075eb0b..26e57ba3993e1d 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3454 (add MATCH*) +# Python 3.10a0 3455 (add MATCH*) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3454).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3455).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index 2ba8631aa2b313..59a31b61099102 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -60,7 +60,6 @@ def jabs_op(name, op): def_op('DUP_TOP', 4) def_op('DUP_TOP_TWO', 5) def_op('ROT_FOUR', 6) -def_op('LIST_POP', 7) def_op('NOP', 9) def_op('UNARY_POSITIVE', 10) diff --git a/Python/ceval.c b/Python/ceval.c index f5d4e4b94fa1cc..e5e5d5920846a9 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1092,7 +1092,7 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ if (args == Py_None) { assert(!i); Py_INCREF(proxy); - PyList_SET_ITEM(attrs, nargs + nkwargs - 1, proxy); + PyList_SET_ITEM(attrs, 0, proxy); continue; } name = PyTuple_GET_ITEM(args, i); @@ -1139,7 +1139,7 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ Py_DECREF(seen); return NULL; } - PyList_SET_ITEM(attrs, nargs + nkwargs - i - 1, attr); + PyList_SET_ITEM(attrs, i, attr); } // TODO: check __match_args_required__. Py_DECREF(proxy); @@ -3585,20 +3585,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) #endif } - case TARGET(LIST_POP): { - PyObject *list = TOP(); - assert(PyList_CheckExact(list)); - Py_ssize_t size = PyList_GET_SIZE(list); - assert(size > 0); - PyObject *popped = PyList_GET_ITEM(list, size - 1); - Py_INCREF(popped); - PUSH(popped); - if (PyList_SetSlice(list, size - 1, size, NULL)) { - goto error; - } - DISPATCH(); - } - case TARGET(MATCH): { PyObject *count = TOP(); PyObject *names = SECOND(); diff --git a/Python/compile.c b/Python/compile.c index a60175e2250ce2..abcfc89ccee976 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1118,8 +1118,6 @@ stack_effect(int opcode, int oparg, int jump) case DICT_MERGE: case DICT_UPDATE: return -1; - case LIST_POP: - return 1; case MATCH: return jump > 0 ? -4 : -3; case MATCH_MAP_KEYS: @@ -2808,12 +2806,12 @@ compiler_pattern_call(struct compiler *c, expr_ty p, basicblock *fail, PyObject* ADDOP_JREL(c, MATCH, fail); for (i = 0; i < nargs; i++) { expr_ty arg = asdl_seq_GET(args, i); - ADDOP(c, LIST_POP); + ADDOP_I(c, MATCH_SEQ_ITEM, i); CHECK(compiler_pattern(c, arg, block, names)); } for (i = 0; i < nkwargs; i++) { keyword_ty kwarg = asdl_seq_GET(kwargs, i); - ADDOP(c, LIST_POP); + ADDOP_I(c, MATCH_SEQ_ITEM, nargs + i); CHECK(compiler_pattern(c, kwarg->value, block, names)); } ADDOP(c, POP_TOP); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 421fa16dd2ecac..ecdd6258ac5510 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,126,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,127,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 901c4a6d191f3d..b13933d5377b25 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -6,7 +6,7 @@ static void *opcode_targets[256] = { &&TARGET_DUP_TOP, &&TARGET_DUP_TOP_TWO, &&TARGET_ROT_FOUR, - &&TARGET_LIST_POP, + &&_unknown_opcode, &&_unknown_opcode, &&TARGET_NOP, &&TARGET_UNARY_POSITIVE, From 2c5226aaceb31cb7f395c102c035bcf93198da33 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 9 Jun 2020 17:31:06 -0700 Subject: [PATCH 072/189] Validate missing attributes with __match_args__ --- Python/ceval.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index e5e5d5920846a9..3c51d055de8c45 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -998,11 +998,12 @@ get_match_args(PyThreadState *tstate, PyObject *proxy) static PyObject * do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *type, PyObject *target) { + // TODO: Break this up: assert(PyLong_CheckExact(count)); assert(PyTuple_CheckExact(kwargs)); if (!PyType_Check(type)) { _PyErr_Format(tstate, PyExc_TypeError, - "called match pattern must be a type; did you mean '%s'?", + "called match pattern must be a type; did you mean '%s(...)'?", Py_TYPE(type)->tp_name); return NULL; } @@ -1123,16 +1124,19 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ } return NULL; } - if (!PyObject_HasAttr(proxy, name)) { - // TODO: typo checking using __match_args__? - Py_DECREF(proxy); - Py_DECREF(args); - Py_DECREF(attrs); - Py_DECREF(seen); - return NULL; - } PyObject *attr = PyObject_GetAttr(proxy, name); if (!attr) { + _PyErr_Clear(tstate); + PyObject *_args = get_match_args(tstate, proxy); + if (_args) { + // TODO: iterate manually (and check for strings) + if (_args == Py_None || !PySequence_Contains(_args, name)) { + _PyErr_Format(tstate, PyExc_TypeError, + "match proxy %R has no attribute %R", + proxy, name); + } + Py_DECREF(_args); + } Py_DECREF(proxy); Py_DECREF(args); Py_DECREF(attrs); From f4644aabab95dea732a3e7a32b3c8f86d0e6fe83 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 9 Jun 2020 22:55:08 -0700 Subject: [PATCH 073/189] Incomplete __match_args_required__ support --- Python/ceval.c | 98 +++++++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 45 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 3c51d055de8c45..abd8433bf50103 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -998,7 +998,7 @@ get_match_args(PyThreadState *tstate, PyObject *proxy) static PyObject * do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *type, PyObject *target) { - // TODO: Break this up: + // TODO: Break this up, and better error handling ("goto error;"): assert(PyLong_CheckExact(count)); assert(PyTuple_CheckExact(kwargs)); if (!PyType_Check(type)) { @@ -1008,11 +1008,9 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ return NULL; } PyObject *method = PyObject_GetAttrString(type, "__match__"); - if (!method) { - return NULL; - } - if (method == Py_None) { - Py_DECREF(method); + if (!method || method == Py_None) { + Py_XDECREF(method); + _PyErr_Clear(tstate); _PyErr_Format(tstate, PyExc_TypeError, "type %s cannot be matched", Py_TYPE(type)->tp_name); @@ -1035,58 +1033,79 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ } nargs -= nkwargs; PyObject *args; + PyObject *match_args = get_match_args(tstate, proxy); + if (!match_args) { + Py_DECREF(proxy); + return NULL; + } + assert(PyTuple_CheckExact(match_args) || match_args == Py_None); if (nargs) { - PyObject *_args = get_match_args(tstate, proxy); - if (!_args) { - Py_DECREF(proxy); - return NULL; - } - if (_args == Py_None) { + if (match_args == Py_None) { if (nargs > 1) { - Py_DECREF(_args); + Py_DECREF(match_args); Py_DECREF(proxy); // TODO: Add expected and actual counts: _PyErr_SetString(tstate, PyExc_TypeError, "too many positional matches in pattern"); return NULL; } - args = _args; + args = match_args; } else { - assert(PyTuple_CheckExact(_args)); - if (PyTuple_GET_SIZE(_args) < nargs) { - Py_DECREF(_args); + if (PyTuple_GET_SIZE(match_args) < nargs) { + // TODO: Combine with above: + Py_DECREF(match_args); Py_DECREF(proxy); // TODO: Add expected and actual counts: _PyErr_SetString(tstate, PyExc_TypeError, "too many positional matches in pattern"); return NULL; } - args = PyTuple_GetSlice(_args, 0, nargs); - Py_DECREF(_args); + args = PyTuple_GetSlice(match_args, 0, nargs); } } else { args = PyTuple_New(0); } if (!args) { + Py_DECREF(match_args); Py_DECREF(proxy); return NULL; } assert(PyTuple_CheckExact(args) || args == Py_None); PyObject *attrs = PyList_New(nargs + nkwargs); if (!attrs) { + Py_DECREF(match_args); Py_DECREF(proxy); Py_DECREF(args); return NULL; } PyObject *seen = PySet_New(NULL); if (!seen) { + Py_DECREF(match_args); Py_DECREF(proxy); Py_DECREF(args); Py_DECREF(attrs); return NULL; } + Py_ssize_t required = get_match_args_required(tstate, proxy); + if (required < 0) { + goto error; + } + if ((match_args == Py_None ? 1 : PyTuple_GET_SIZE(match_args)) < required) { + _PyErr_Format(tstate, PyExc_TypeError, + "__match_args_required__ is larger than __match_args__", + proxy); + goto error; + } + if (required > nargs + nkwargs) { + _PyErr_Format(tstate, PyExc_TypeError, + "not enough match arguments provided"); + goto error; + } + if (required > nargs) { + // TODO: loop over names and validate (and check for strings) + } PyObject *name; for (Py_ssize_t i = 0; i < nargs + nkwargs; i++) { if (i < nargs) { @@ -1101,12 +1120,7 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ _PyErr_Format(tstate, PyExc_TypeError, "__match_args__ elements must be str (got %s)", Py_TYPE(name)->tp_name); - Py_DECREF(proxy); - Py_DECREF(args); - Py_DECREF(attrs); - Py_DECREF(seen); - Py_DECREF(name); - return NULL; + goto error; } } else { @@ -1114,42 +1128,36 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ } int dupe = PySet_Contains(seen, name); if (dupe || PySet_Add(seen, name)) { - Py_DECREF(proxy); - Py_DECREF(args); - Py_DECREF(attrs); - Py_DECREF(seen); if (!_PyErr_Occurred(tstate)) { _PyErr_Format(tstate, PyExc_TypeError, "multiple patterns bound to attribute %R", name); } - return NULL; + goto error; } PyObject *attr = PyObject_GetAttr(proxy, name); if (!attr) { _PyErr_Clear(tstate); - PyObject *_args = get_match_args(tstate, proxy); - if (_args) { - // TODO: iterate manually (and check for strings) - if (_args == Py_None || !PySequence_Contains(_args, name)) { - _PyErr_Format(tstate, PyExc_TypeError, - "match proxy %R has no attribute %R", - proxy, name); - } - Py_DECREF(_args); + // TODO: iterate manually (and check for strings) + if (match_args == Py_None || !PySequence_Contains(match_args, name)) { + _PyErr_Format(tstate, PyExc_TypeError, + "match proxy %R has no attribute %R", + proxy, name); } - Py_DECREF(proxy); - Py_DECREF(args); - Py_DECREF(attrs); - Py_DECREF(seen); - return NULL; } PyList_SET_ITEM(attrs, i, attr); } - // TODO: check __match_args_required__. + Py_DECREF(match_args); Py_DECREF(proxy); Py_DECREF(args); Py_DECREF(seen); return attrs; +error: + Py_DECREF(match_args); + Py_DECREF(proxy); + Py_DECREF(args); + Py_DECREF(seen); + Py_DECREF(attrs); + return NULL; } From ce7b0214b97853a9c6ad6b9f803e301d37841065 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 10 Jun 2020 10:06:06 -0700 Subject: [PATCH 074/189] Finish __match_args_required__ support --- Python/ceval.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index abd8433bf50103..119d682afaff60 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -982,6 +982,9 @@ get_match_args(PyThreadState *tstate, PyObject *proxy) if (!ma) { return NULL; } + // TODO: PySequence_FAST + // TODO We should probably just check for string items here + // TODO: Allow duplicate items? Hm... if (PyList_CheckExact(ma)) { return PyList_AsTuple(ma); } @@ -1046,7 +1049,7 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ Py_DECREF(proxy); // TODO: Add expected and actual counts: _PyErr_SetString(tstate, PyExc_TypeError, - "too many positional matches in pattern"); + "too many positional matches in pattern"); return NULL; } args = match_args; @@ -1058,7 +1061,7 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ Py_DECREF(proxy); // TODO: Add expected and actual counts: _PyErr_SetString(tstate, PyExc_TypeError, - "too many positional matches in pattern"); + "too many positional matches in pattern"); return NULL; } args = PyTuple_GetSlice(match_args, 0, nargs); @@ -1099,12 +1102,34 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ goto error; } if (required > nargs + nkwargs) { + // TODO: combine with below? Use name? _PyErr_Format(tstate, PyExc_TypeError, "not enough match arguments provided"); goto error; } if (required > nargs) { - // TODO: loop over names and validate (and check for strings) + if (match_args == Py_None) { + assert(required == 1); + assert(!nargs); + // TODO: combine with above? Use name? + _PyErr_Format(tstate, PyExc_TypeError, + "not enough match arguments provided"); + goto error; + } + assert(PyTuple_CheckExact(match_args)); + for (Py_ssize_t i = nargs; i < required; i++) { + PyObject *name = PyTuple_GET_ITEM(match_args, i); + int ok = PySequence_Contains(kwargs, name); + if (ok < 0) { + goto error; + } + if (!ok) { + // TODO: Combine with above? Use name? + _PyErr_Format(tstate, PyExc_TypeError, + "not enough match arguments provided"); + goto error; + } + } } PyObject *name; for (Py_ssize_t i = 0; i < nargs + nkwargs; i++) { From 6cc41286eec59cdb12f58a85fa6e1050b5659296 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 10 Jun 2020 16:52:33 -0700 Subject: [PATCH 075/189] Trivial grammar clean-ups --- Grammar/python.gram | 74 ++++------ Parser/pegen/parse.c | 318 +++++++++++++++++++++---------------------- 2 files changed, 186 insertions(+), 206 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index d4a185f617a42d..347e63eda605e3 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -198,24 +198,19 @@ match_stmt: case_block: | "case" pattern=pattern_no_comma guard=guard? ':' body=block { _Py_match_case(pattern, guard, body, p->arena) } +guard: + | 'if' guard=named_expression { guard } pattern_no_comma: - | pattern=pattern !',' { - pattern } + | pattern=pattern !',' { pattern } | pattern error=',' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "tuple displays cannot be used as patterns; did you mean '[...]'?") } pattern[expr_ty]: | target=NAME ':=' value=or_pattern { _Py_NamedExpr(CHECK(_PyPegen_set_expr_context(p, target, Store)), value, EXTRA) } - | error='(' ')' { - RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "tuple displays cannot be used as patterns; did you mean '[]'?") } | or_pattern -guard: - | 'if' guard=named_expression { - guard } - or_pattern: | value=closed_pattern '|' values='|'.closed_pattern+ { _Py_BoolOp(Or, CHECK(_PyPegen_seq_insert_in_front(p, value, values)), EXTRA) } @@ -231,84 +226,69 @@ closed_pattern: | class_pattern name_pattern: - | name=NAME !('.' | '(' | '=') { - _PyPegen_set_expr_context(p, name, Store) } + | name=NAME !('.' | '(' | '=') { _PyPegen_set_expr_context(p, name, Store) } literal_pattern: | signed_number !('+' | '-') - | real=signed_number '+' imag=NUMBER { - _Py_BinOp(real, Add, imag, EXTRA) } - | real=signed_number '-' imag=NUMBER { - _Py_BinOp(real, Sub, imag, EXTRA) } + | real=signed_number '+' imag=NUMBER { _Py_BinOp(real, Add, imag, EXTRA) } + | real=signed_number '-' imag=NUMBER { _Py_BinOp(real, Sub, imag, EXTRA) } | strings - | 'None' { - _Py_Constant(Py_None, NULL, EXTRA) } - | 'True' { - _Py_Constant(Py_True, NULL, EXTRA) } - | 'False' { - _Py_Constant(Py_False, NULL, EXTRA) } + | 'None' { _Py_Constant(Py_None, NULL, EXTRA) } + | 'True' { _Py_Constant(Py_True, NULL, EXTRA) } + | 'False' { _Py_Constant(Py_False, NULL, EXTRA) } constant_pattern: - | '.' name=NAME !('.' | '(' | '=') { - name } - | '.'? attr=attr !('.' | '(' | '=') { - attr } + | '.' name=NAME !('.' | '(' | '=') { name } + | '.'? attr=attr !('.' | '(' | '=') { attr } group_pattern: - | '(' pattern=pattern_no_comma ')' { - pattern } + | '(' pattern=pattern_no_comma ')' { pattern } + | error='(' ')' { + RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "tuple displays cannot be used as patterns; did you mean '[]'?") } sequence_pattern: - | '[' values=values_pattern? ']' { - _Py_List(values, Load, EXTRA) } + | '[' values=values_pattern? ']' { _Py_List(values, Load, EXTRA) } mapping_pattern: | '{' items=items_pattern? '}' { _Py_Dict(CHECK(_PyPegen_get_keys(p, items)), CHECK(_PyPegen_get_values(p, items)), EXTRA) } class_pattern: - | func=name_or_attr '(' ')' { - _Py_Call(func, NULL, NULL, EXTRA) } + | func=name_or_attr '(' ')' { _Py_Call(func, NULL, NULL, EXTRA) } | func=name_or_attr '(' args=','.pattern+ ','? ')' { _Py_Call(func, args, NULL, EXTRA) } | func=name_or_attr '(' keywords=','.keyword_pattern+ ','? ')' { _Py_Call(func, NULL, keywords, EXTRA) } | func=name_or_attr '(' args=','.pattern+ ',' keywords=','.keyword_pattern+ ','? ')' { _Py_Call(func, args, keywords, EXTRA) } - | func=name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' error=pattern [',' ','.argument_pattern+] ','? ')' { + | func=name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' error=pattern [',' ','.error_argument_pattern+] ','? ')' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "positional pattern follows keyword pattern") } - | func=name_or_attr '(' [','.argument_pattern+ ','] error=error_star [',' ','.(argument_pattern | error_star)+] ','? ')' { + | func=name_or_attr '(' [','.error_argument_pattern+ ','] error=error_star [',' ','.(error_argument_pattern | error_star)+] ','? ')' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "can't use starred pattern here") } signed_number: | NUMBER - | '-' number=NUMBER { - _Py_UnaryOp(USub, number, EXTRA) } + | '-' number=NUMBER { _Py_UnaryOp(USub, number, EXTRA) } attr: | value=name_or_attr '.' attr=NAME { _Py_Attribute(value, attr->v.Name.id, Load, EXTRA) } name_or_attr: | attr | NAME + values_pattern: - | values=','.value_pattern+ ','? { - values } + | values=','.value_pattern+ ','? { values } items_pattern: - | items=','.key_value_pattern+ ','? { - items } + | items=','.key_value_pattern+ ','? { items } keyword_pattern: - | arg=NAME '=' value=or_pattern { - _Py_keyword(arg->v.Name.id, value, EXTRA) } -argument_pattern: + | arg=NAME '=' value=or_pattern { _Py_keyword(arg->v.Name.id, value, EXTRA) } +error_argument_pattern: | pattern | keyword_pattern error_star[expr_ty]: - | ('*' | '**') error=NAME { - error } + | ('*' | '**') error=NAME { error } value_pattern: - | '*' value=name_pattern { - _Py_Starred(value, Store, EXTRA) } + | '*' value=name_pattern { _Py_Starred(value, Store, EXTRA) } | pattern key_value_pattern: | key=(literal_pattern | constant_pattern) ':' value=or_pattern { _PyPegen_key_value_pair(p, key, value) } - | '**' value=name_pattern { - _PyPegen_key_value_pair(p, NULL, value) } + | '**' value=name_pattern { _PyPegen_key_value_pair(p, NULL, value) } return_stmt[stmt_ty]: | 'return' a=[star_expressions] { _Py_Return(a, EXTRA) } diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index 96f2631c89d878..fa150bd470fcb6 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -115,9 +115,9 @@ static KeywordToken *reserved_keywords[] = { #define finally_block_type 1037 #define match_stmt_type 1038 #define case_block_type 1039 -#define pattern_no_comma_type 1040 -#define pattern_type 1041 -#define guard_type 1042 +#define guard_type 1040 +#define pattern_no_comma_type 1041 +#define pattern_type 1042 #define or_pattern_type 1043 #define closed_pattern_type 1044 #define name_pattern_type 1045 @@ -133,7 +133,7 @@ static KeywordToken *reserved_keywords[] = { #define values_pattern_type 1055 #define items_pattern_type 1056 #define keyword_pattern_type 1057 -#define argument_pattern_type 1058 +#define error_argument_pattern_type 1058 #define error_star_type 1059 #define value_pattern_type 1060 #define key_value_pattern_type 1061 @@ -488,9 +488,9 @@ static excepthandler_ty except_block_rule(Parser *p); static asdl_seq* finally_block_rule(Parser *p); static void *match_stmt_rule(Parser *p); static void *case_block_rule(Parser *p); +static void *guard_rule(Parser *p); static void *pattern_no_comma_rule(Parser *p); static expr_ty pattern_rule(Parser *p); -static void *guard_rule(Parser *p); static void *or_pattern_rule(Parser *p); static void *closed_pattern_rule(Parser *p); static void *name_pattern_rule(Parser *p); @@ -506,7 +506,7 @@ static void *name_or_attr_rule(Parser *p); static void *values_pattern_rule(Parser *p); static void *items_pattern_rule(Parser *p); static void *keyword_pattern_rule(Parser *p); -static void *argument_pattern_rule(Parser *p); +static void *error_argument_pattern_rule(Parser *p); static expr_ty error_star_rule(Parser *p); static void *value_pattern_rule(Parser *p); static void *key_value_pattern_rule(Parser *p); @@ -4806,6 +4806,50 @@ case_block_rule(Parser *p) return _res; } +// guard: 'if' named_expression +static void * +guard_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // 'if' named_expression + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> guard[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression")); + Token * _keyword; + expr_ty guard; + if ( + (_keyword = _PyPegen_expect_token(p, 510)) // token='if' + && + (guard = named_expression_rule(p)) // named_expression + ) + { + D(fprintf(stderr, "%*c+ guard[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression")); + _res = guard; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s guard[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + // pattern_no_comma: pattern !',' | pattern ',' static void * pattern_no_comma_rule(Parser *p) @@ -4876,7 +4920,7 @@ pattern_no_comma_rule(Parser *p) return _res; } -// pattern: NAME ':=' or_pattern | '(' ')' | or_pattern +// pattern: NAME ':=' or_pattern | or_pattern static expr_ty pattern_rule(Parser *p) { @@ -4935,33 +4979,6 @@ pattern_rule(Parser *p) D(fprintf(stderr, "%*c%s pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':=' or_pattern")); } - { // '(' ')' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' ')'")); - Token * _literal; - Token * error; - if ( - (error = _PyPegen_expect_token(p, 7)) // token='(' - && - (_literal = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' ')'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "tuple displays cannot be used as patterns; did you mean '[]'?" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' ')'")); - } { // or_pattern if (p->error_indicator) { D(p->level--); @@ -4987,50 +5004,6 @@ pattern_rule(Parser *p) return _res; } -// guard: 'if' named_expression -static void * -guard_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'if' named_expression - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> guard[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression")); - Token * _keyword; - expr_ty guard; - if ( - (_keyword = _PyPegen_expect_token(p, 510)) // token='if' - && - (guard = named_expression_rule(p)) // named_expression - ) - { - D(fprintf(stderr, "%*c+ guard[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression")); - _res = guard; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s guard[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - // or_pattern: closed_pattern '|' '|'.closed_pattern+ | closed_pattern static void * or_pattern_rule(Parser *p) @@ -5641,7 +5614,7 @@ constant_pattern_rule(Parser *p) return _res; } -// group_pattern: '(' pattern_no_comma ')' +// group_pattern: '(' pattern_no_comma ')' | '(' ')' static void * group_pattern_rule(Parser *p) { @@ -5682,6 +5655,33 @@ group_pattern_rule(Parser *p) D(fprintf(stderr, "%*c%s group_pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' pattern_no_comma ')'")); } + { // '(' ')' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> group_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' ')'")); + Token * _literal; + Token * error; + if ( + (error = _PyPegen_expect_token(p, 7)) // token='(' + && + (_literal = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ group_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' ')'")); + _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "tuple displays cannot be used as patterns; did you mean '[]'?" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s group_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' ')'")); + } _res = NULL; done: D(p->level--); @@ -5823,8 +5823,8 @@ mapping_pattern_rule(Parser *p) // | name_or_attr '(' ','.pattern+ ','? ')' // | name_or_attr '(' ','.keyword_pattern+ ','? ')' // | name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')' -// | name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.argument_pattern+] ','? ')' -// | name_or_attr '(' [','.argument_pattern+ ','] error_star [',' ','.(argument_pattern | error_star)+] ','? ')' +// | name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.error_argument_pattern+] ','? ')' +// | name_or_attr '(' [','.error_argument_pattern+ ','] error_star [',' ','.(error_argument_pattern | error_star)+] ','? ')' static void * class_pattern_rule(Parser *p) { @@ -6027,12 +6027,12 @@ class_pattern_rule(Parser *p) D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'")); } - { // name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.argument_pattern+] ','? ')' + { // name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.error_argument_pattern+] ','? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.argument_pattern+] ','? ')'")); + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.error_argument_pattern+] ','? ')'")); asdl_seq * _gather_65_var; Token * _literal; Token * _literal_1; @@ -6058,14 +6058,14 @@ class_pattern_rule(Parser *p) && (error = pattern_rule(p)) // pattern && - (_opt_var_1 = _tmp_67_rule(p), 1) // [',' ','.argument_pattern+] + (_opt_var_1 = _tmp_67_rule(p), 1) // [',' ','.error_argument_pattern+] && (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? && (_literal_2 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.argument_pattern+] ','? ')'")); + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.error_argument_pattern+] ','? ')'")); _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "positional pattern follows keyword pattern" ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -6076,14 +6076,14 @@ class_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.argument_pattern+] ','? ')'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.error_argument_pattern+] ','? ')'")); } - { // name_or_attr '(' [','.argument_pattern+ ','] error_star [',' ','.(argument_pattern | error_star)+] ','? ')' + { // name_or_attr '(' [','.error_argument_pattern+ ','] error_star [',' ','.(error_argument_pattern | error_star)+] ','? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.argument_pattern+ ','] error_star [',' ','.(argument_pattern | error_star)+] ','? ')'")); + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.error_argument_pattern+ ','] error_star [',' ','.(error_argument_pattern | error_star)+] ','? ')'")); Token * _literal; Token * _literal_1; void *_opt_var; @@ -6099,18 +6099,18 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_opt_var = _tmp_68_rule(p), 1) // [','.argument_pattern+ ','] + (_opt_var = _tmp_68_rule(p), 1) // [','.error_argument_pattern+ ','] && (error = error_star_rule(p)) // error_star && - (_opt_var_1 = _tmp_69_rule(p), 1) // [',' ','.(argument_pattern | error_star)+] + (_opt_var_1 = _tmp_69_rule(p), 1) // [',' ','.(error_argument_pattern | error_star)+] && (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.argument_pattern+ ','] error_star [',' ','.(argument_pattern | error_star)+] ','? ')'")); + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.error_argument_pattern+ ','] error_star [',' ','.(error_argument_pattern | error_star)+] ','? ')'")); _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "can't use starred pattern here" ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -6121,7 +6121,7 @@ class_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' [','.argument_pattern+ ','] error_star [',' ','.(argument_pattern | error_star)+] ','? ')'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' [','.error_argument_pattern+ ','] error_star [',' ','.(error_argument_pattern | error_star)+] ','? ')'")); } _res = NULL; done: @@ -6516,9 +6516,9 @@ keyword_pattern_rule(Parser *p) return _res; } -// argument_pattern: pattern | keyword_pattern +// error_argument_pattern: pattern | keyword_pattern static void * -argument_pattern_rule(Parser *p) +error_argument_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -6532,18 +6532,18 @@ argument_pattern_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> argument_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); + D(fprintf(stderr, "%*c> error_argument_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); expr_ty pattern_var; if ( (pattern_var = pattern_rule(p)) // pattern ) { - D(fprintf(stderr, "%*c+ argument_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); + D(fprintf(stderr, "%*c+ error_argument_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); _res = pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s argument_pattern[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s error_argument_pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); } { // keyword_pattern @@ -6551,18 +6551,18 @@ argument_pattern_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> argument_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); + D(fprintf(stderr, "%*c> error_argument_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); void *keyword_pattern_var; if ( (keyword_pattern_var = keyword_pattern_rule(p)) // keyword_pattern ) { - D(fprintf(stderr, "%*c+ argument_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); + D(fprintf(stderr, "%*c+ error_argument_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); _res = keyword_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s argument_pattern[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s error_argument_pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern")); } _res = NULL; @@ -21417,7 +21417,7 @@ _gather_65_rule(Parser *p) return _res; } -// _tmp_67: ',' ','.argument_pattern+ +// _tmp_67: ',' ','.error_argument_pattern+ static void * _tmp_67_rule(Parser *p) { @@ -21428,27 +21428,27 @@ _tmp_67_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ',' ','.argument_pattern+ + { // ',' ','.error_argument_pattern+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.argument_pattern+")); + D(fprintf(stderr, "%*c> _tmp_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.error_argument_pattern+")); asdl_seq * _gather_170_var; Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_gather_170_var = _gather_170_rule(p)) // ','.argument_pattern+ + (_gather_170_var = _gather_170_rule(p)) // ','.error_argument_pattern+ ) { - D(fprintf(stderr, "%*c+ _tmp_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.argument_pattern+")); + D(fprintf(stderr, "%*c+ _tmp_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.error_argument_pattern+")); _res = _PyPegen_dummy_name(p, _literal, _gather_170_var); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_67[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.argument_pattern+")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.error_argument_pattern+")); } _res = NULL; done: @@ -21456,7 +21456,7 @@ _tmp_67_rule(Parser *p) return _res; } -// _tmp_68: ','.argument_pattern+ ',' +// _tmp_68: ','.error_argument_pattern+ ',' static void * _tmp_68_rule(Parser *p) { @@ -21467,27 +21467,27 @@ _tmp_68_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ','.argument_pattern+ ',' + { // ','.error_argument_pattern+ ',' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.argument_pattern+ ','")); + D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.error_argument_pattern+ ','")); asdl_seq * _gather_172_var; Token * _literal; if ( - (_gather_172_var = _gather_172_rule(p)) // ','.argument_pattern+ + (_gather_172_var = _gather_172_rule(p)) // ','.error_argument_pattern+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.argument_pattern+ ','")); + D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.error_argument_pattern+ ','")); _res = _PyPegen_dummy_name(p, _gather_172_var, _literal); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.argument_pattern+ ','")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.error_argument_pattern+ ','")); } _res = NULL; done: @@ -21495,7 +21495,7 @@ _tmp_68_rule(Parser *p) return _res; } -// _tmp_69: ',' ','.(argument_pattern | error_star)+ +// _tmp_69: ',' ','.(error_argument_pattern | error_star)+ static void * _tmp_69_rule(Parser *p) { @@ -21506,27 +21506,27 @@ _tmp_69_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ',' ','.(argument_pattern | error_star)+ + { // ',' ','.(error_argument_pattern | error_star)+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); + D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(error_argument_pattern | error_star)+")); asdl_seq * _gather_174_var; Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_gather_174_var = _gather_174_rule(p)) // ','.(argument_pattern | error_star)+ + (_gather_174_var = _gather_174_rule(p)) // ','.(error_argument_pattern | error_star)+ ) { - D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); + D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(error_argument_pattern | error_star)+")); _res = _PyPegen_dummy_name(p, _literal, _gather_174_var); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_69[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.(argument_pattern | error_star)+")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.(error_argument_pattern | error_star)+")); } _res = NULL; done: @@ -27613,7 +27613,7 @@ _gather_168_rule(Parser *p) return _res; } -// _loop0_171: ',' argument_pattern +// _loop0_171: ',' error_argument_pattern static asdl_seq * _loop0_171_rule(Parser *p) { @@ -27634,18 +27634,18 @@ _loop0_171_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' argument_pattern + { // ',' error_argument_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' argument_pattern")); + D(fprintf(stderr, "%*c> _loop0_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' error_argument_pattern")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = argument_pattern_rule(p)) // argument_pattern + (elem = error_argument_pattern_rule(p)) // error_argument_pattern ) { _res = elem; @@ -27671,7 +27671,7 @@ _loop0_171_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s _loop0_171[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' argument_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' error_argument_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -27688,7 +27688,7 @@ _loop0_171_rule(Parser *p) return _seq; } -// _gather_170: argument_pattern _loop0_171 +// _gather_170: error_argument_pattern _loop0_171 static asdl_seq * _gather_170_rule(Parser *p) { @@ -27699,27 +27699,27 @@ _gather_170_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // argument_pattern _loop0_171 + { // error_argument_pattern _loop0_171 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_171")); + D(fprintf(stderr, "%*c> _gather_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_171")); void *elem; asdl_seq * seq; if ( - (elem = argument_pattern_rule(p)) // argument_pattern + (elem = error_argument_pattern_rule(p)) // error_argument_pattern && (seq = _loop0_171_rule(p)) // _loop0_171 ) { - D(fprintf(stderr, "%*c+ _gather_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_171")); + D(fprintf(stderr, "%*c+ _gather_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_171")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _gather_170[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern _loop0_171")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_argument_pattern _loop0_171")); } _res = NULL; done: @@ -27727,7 +27727,7 @@ _gather_170_rule(Parser *p) return _res; } -// _loop0_173: ',' argument_pattern +// _loop0_173: ',' error_argument_pattern static asdl_seq * _loop0_173_rule(Parser *p) { @@ -27748,18 +27748,18 @@ _loop0_173_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' argument_pattern + { // ',' error_argument_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' argument_pattern")); + D(fprintf(stderr, "%*c> _loop0_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' error_argument_pattern")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = argument_pattern_rule(p)) // argument_pattern + (elem = error_argument_pattern_rule(p)) // error_argument_pattern ) { _res = elem; @@ -27785,7 +27785,7 @@ _loop0_173_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s _loop0_173[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' argument_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' error_argument_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -27802,7 +27802,7 @@ _loop0_173_rule(Parser *p) return _seq; } -// _gather_172: argument_pattern _loop0_173 +// _gather_172: error_argument_pattern _loop0_173 static asdl_seq * _gather_172_rule(Parser *p) { @@ -27813,27 +27813,27 @@ _gather_172_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // argument_pattern _loop0_173 + { // error_argument_pattern _loop0_173 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_173")); + D(fprintf(stderr, "%*c> _gather_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_173")); void *elem; asdl_seq * seq; if ( - (elem = argument_pattern_rule(p)) // argument_pattern + (elem = error_argument_pattern_rule(p)) // error_argument_pattern && (seq = _loop0_173_rule(p)) // _loop0_173 ) { - D(fprintf(stderr, "%*c+ _gather_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern _loop0_173")); + D(fprintf(stderr, "%*c+ _gather_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_173")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _gather_172[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern _loop0_173")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_argument_pattern _loop0_173")); } _res = NULL; done: @@ -27841,7 +27841,7 @@ _gather_172_rule(Parser *p) return _res; } -// _loop0_175: ',' (argument_pattern | error_star) +// _loop0_175: ',' (error_argument_pattern | error_star) static asdl_seq * _loop0_175_rule(Parser *p) { @@ -27862,18 +27862,18 @@ _loop0_175_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' (argument_pattern | error_star) + { // ',' (error_argument_pattern | error_star) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (argument_pattern | error_star)")); + D(fprintf(stderr, "%*c> _loop0_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (error_argument_pattern | error_star)")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_190_rule(p)) // argument_pattern | error_star + (elem = _tmp_190_rule(p)) // error_argument_pattern | error_star ) { _res = elem; @@ -27899,7 +27899,7 @@ _loop0_175_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s _loop0_175[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (argument_pattern | error_star)")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (error_argument_pattern | error_star)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); if (!_seq) { @@ -27916,7 +27916,7 @@ _loop0_175_rule(Parser *p) return _seq; } -// _gather_174: (argument_pattern | error_star) _loop0_175 +// _gather_174: (error_argument_pattern | error_star) _loop0_175 static asdl_seq * _gather_174_rule(Parser *p) { @@ -27927,27 +27927,27 @@ _gather_174_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (argument_pattern | error_star) _loop0_175 + { // (error_argument_pattern | error_star) _loop0_175 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(argument_pattern | error_star) _loop0_175")); + D(fprintf(stderr, "%*c> _gather_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(error_argument_pattern | error_star) _loop0_175")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_190_rule(p)) // argument_pattern | error_star + (elem = _tmp_190_rule(p)) // error_argument_pattern | error_star && (seq = _loop0_175_rule(p)) // _loop0_175 ) { - D(fprintf(stderr, "%*c+ _gather_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(argument_pattern | error_star) _loop0_175")); + D(fprintf(stderr, "%*c+ _gather_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(error_argument_pattern | error_star) _loop0_175")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _gather_174[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(argument_pattern | error_star) _loop0_175")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(error_argument_pattern | error_star) _loop0_175")); } _res = NULL; done: @@ -28640,7 +28640,7 @@ _tmp_189_rule(Parser *p) return _res; } -// _tmp_190: argument_pattern | error_star +// _tmp_190: error_argument_pattern | error_star static void * _tmp_190_rule(Parser *p) { @@ -28651,24 +28651,24 @@ _tmp_190_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // argument_pattern + { // error_argument_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_190[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "argument_pattern")); - void *argument_pattern_var; + D(fprintf(stderr, "%*c> _tmp_190[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_argument_pattern")); + void *error_argument_pattern_var; if ( - (argument_pattern_var = argument_pattern_rule(p)) // argument_pattern + (error_argument_pattern_var = error_argument_pattern_rule(p)) // error_argument_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_190[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "argument_pattern")); - _res = argument_pattern_var; + D(fprintf(stderr, "%*c+ _tmp_190[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_argument_pattern")); + _res = error_argument_pattern_var; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_190[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "argument_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_argument_pattern")); } { // error_star if (p->error_indicator) { From 4973548d6f798b50e74c07ddf4a90a11d72dcf83 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 10 Jun 2020 17:05:45 -0700 Subject: [PATCH 076/189] Add back type annotations. --- Grammar/python.gram | 42 ++++---- Parser/pegen/parse.c | 224 +++++++++++++++++++++---------------------- 2 files changed, 133 insertions(+), 133 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 347e63eda605e3..8e43227f46fa90 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -192,16 +192,16 @@ except_block[excepthandler_ty]: | 'except' ':' b=block { _Py_ExceptHandler(NULL, NULL, b, EXTRA) } finally_block[asdl_seq*]: 'finally' ':' a=block { a } -match_stmt: +match_stmt[stmt_ty]: | "match" target=expression ':' NEWLINE INDENT cases=case_block+ DEDENT { _Py_Match(target, cases, EXTRA) } -case_block: +case_block[match_case_ty]: | "case" pattern=pattern_no_comma guard=guard? ':' body=block { _Py_match_case(pattern, guard, body, p->arena) } -guard: +guard[expr_ty]: | 'if' guard=named_expression { guard } -pattern_no_comma: +pattern_no_comma[expr_ty]: | pattern=pattern !',' { pattern } | pattern error=',' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "tuple displays cannot be used as patterns; did you mean '[...]'?") } @@ -211,12 +211,12 @@ pattern[expr_ty]: _Py_NamedExpr(CHECK(_PyPegen_set_expr_context(p, target, Store)), value, EXTRA) } | or_pattern -or_pattern: +or_pattern[expr_ty]: | value=closed_pattern '|' values='|'.closed_pattern+ { _Py_BoolOp(Or, CHECK(_PyPegen_seq_insert_in_front(p, value, values)), EXTRA) } | closed_pattern -closed_pattern: +closed_pattern[expr_ty]: | name_pattern | literal_pattern | constant_pattern @@ -225,9 +225,9 @@ closed_pattern: | mapping_pattern | class_pattern -name_pattern: +name_pattern[expr_ty]: | name=NAME !('.' | '(' | '=') { _PyPegen_set_expr_context(p, name, Store) } -literal_pattern: +literal_pattern[expr_ty]: | signed_number !('+' | '-') | real=signed_number '+' imag=NUMBER { _Py_BinOp(real, Add, imag, EXTRA) } | real=signed_number '-' imag=NUMBER { _Py_BinOp(real, Sub, imag, EXTRA) } @@ -235,19 +235,19 @@ literal_pattern: | 'None' { _Py_Constant(Py_None, NULL, EXTRA) } | 'True' { _Py_Constant(Py_True, NULL, EXTRA) } | 'False' { _Py_Constant(Py_False, NULL, EXTRA) } -constant_pattern: +constant_pattern[expr_ty]: | '.' name=NAME !('.' | '(' | '=') { name } | '.'? attr=attr !('.' | '(' | '=') { attr } -group_pattern: +group_pattern[expr_ty]: | '(' pattern=pattern_no_comma ')' { pattern } | error='(' ')' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "tuple displays cannot be used as patterns; did you mean '[]'?") } -sequence_pattern: +sequence_pattern[expr_ty]: | '[' values=values_pattern? ']' { _Py_List(values, Load, EXTRA) } -mapping_pattern: +mapping_pattern[expr_ty]: | '{' items=items_pattern? '}' { _Py_Dict(CHECK(_PyPegen_get_keys(p, items)), CHECK(_PyPegen_get_values(p, items)), EXTRA) } -class_pattern: +class_pattern[expr_ty]: | func=name_or_attr '(' ')' { _Py_Call(func, NULL, NULL, EXTRA) } | func=name_or_attr '(' args=','.pattern+ ','? ')' { _Py_Call(func, args, NULL, EXTRA) } @@ -260,21 +260,21 @@ class_pattern: | func=name_or_attr '(' [','.error_argument_pattern+ ','] error=error_star [',' ','.(error_argument_pattern | error_star)+] ','? ')' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "can't use starred pattern here") } -signed_number: +signed_number[expr_ty]: | NUMBER | '-' number=NUMBER { _Py_UnaryOp(USub, number, EXTRA) } -attr: +attr[expr_ty]: | value=name_or_attr '.' attr=NAME { _Py_Attribute(value, attr->v.Name.id, Load, EXTRA) } -name_or_attr: +name_or_attr[expr_ty]: | attr | NAME -values_pattern: +values_pattern[asdl_seq*]: | values=','.value_pattern+ ','? { values } -items_pattern: +items_pattern[asdl_seq*]: | items=','.key_value_pattern+ ','? { items } -keyword_pattern: +keyword_pattern[keyword_ty]: | arg=NAME '=' value=or_pattern { _Py_keyword(arg->v.Name.id, value, EXTRA) } error_argument_pattern: | pattern @@ -282,10 +282,10 @@ error_argument_pattern: error_star[expr_ty]: | ('*' | '**') error=NAME { error } -value_pattern: +value_pattern[expr_ty]: | '*' value=name_pattern { _Py_Starred(value, Store, EXTRA) } | pattern -key_value_pattern: +key_value_pattern[KeyValuePair*]: | key=(literal_pattern | constant_pattern) ':' value=or_pattern { _PyPegen_key_value_pair(p, key, value) } | '**' value=name_pattern { _PyPegen_key_value_pair(p, NULL, value) } diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index fa150bd470fcb6..409b9cba4728c4 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -486,30 +486,30 @@ static withitem_ty with_item_rule(Parser *p); static stmt_ty try_stmt_rule(Parser *p); static excepthandler_ty except_block_rule(Parser *p); static asdl_seq* finally_block_rule(Parser *p); -static void *match_stmt_rule(Parser *p); -static void *case_block_rule(Parser *p); -static void *guard_rule(Parser *p); -static void *pattern_no_comma_rule(Parser *p); +static stmt_ty match_stmt_rule(Parser *p); +static match_case_ty case_block_rule(Parser *p); +static expr_ty guard_rule(Parser *p); +static expr_ty pattern_no_comma_rule(Parser *p); static expr_ty pattern_rule(Parser *p); -static void *or_pattern_rule(Parser *p); -static void *closed_pattern_rule(Parser *p); -static void *name_pattern_rule(Parser *p); -static void *literal_pattern_rule(Parser *p); -static void *constant_pattern_rule(Parser *p); -static void *group_pattern_rule(Parser *p); -static void *sequence_pattern_rule(Parser *p); -static void *mapping_pattern_rule(Parser *p); -static void *class_pattern_rule(Parser *p); -static void *signed_number_rule(Parser *p); -static void *attr_rule(Parser *p); -static void *name_or_attr_rule(Parser *p); -static void *values_pattern_rule(Parser *p); -static void *items_pattern_rule(Parser *p); -static void *keyword_pattern_rule(Parser *p); +static expr_ty or_pattern_rule(Parser *p); +static expr_ty closed_pattern_rule(Parser *p); +static expr_ty name_pattern_rule(Parser *p); +static expr_ty literal_pattern_rule(Parser *p); +static expr_ty constant_pattern_rule(Parser *p); +static expr_ty group_pattern_rule(Parser *p); +static expr_ty sequence_pattern_rule(Parser *p); +static expr_ty mapping_pattern_rule(Parser *p); +static expr_ty class_pattern_rule(Parser *p); +static expr_ty signed_number_rule(Parser *p); +static expr_ty attr_rule(Parser *p); +static expr_ty name_or_attr_rule(Parser *p); +static asdl_seq* values_pattern_rule(Parser *p); +static asdl_seq* items_pattern_rule(Parser *p); +static keyword_ty keyword_pattern_rule(Parser *p); static void *error_argument_pattern_rule(Parser *p); static expr_ty error_star_rule(Parser *p); -static void *value_pattern_rule(Parser *p); -static void *key_value_pattern_rule(Parser *p); +static expr_ty value_pattern_rule(Parser *p); +static KeyValuePair* key_value_pattern_rule(Parser *p); static stmt_ty return_stmt_rule(Parser *p); static stmt_ty raise_stmt_rule(Parser *p); static stmt_ty function_def_rule(Parser *p); @@ -2132,7 +2132,7 @@ compound_stmt_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "match_stmt")); - void *match_stmt_var; + stmt_ty match_stmt_var; if ( (match_stmt_var = match_stmt_rule(p)) // match_stmt ) @@ -4677,7 +4677,7 @@ finally_block_rule(Parser *p) } // match_stmt: "match" expression ':' NEWLINE INDENT case_block+ DEDENT -static void * +static stmt_ty match_stmt_rule(Parser *p) { D(p->level++); @@ -4685,7 +4685,7 @@ match_stmt_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + stmt_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -4754,7 +4754,7 @@ match_stmt_rule(Parser *p) } // case_block: "case" pattern_no_comma guard? ':' block -static void * +static match_case_ty case_block_rule(Parser *p) { D(p->level++); @@ -4762,7 +4762,7 @@ case_block_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + match_case_ty _res = NULL; int _mark = p->mark; { // "case" pattern_no_comma guard? ':' block if (p->error_indicator) { @@ -4774,7 +4774,7 @@ case_block_rule(Parser *p) Token * _literal; asdl_seq* body; void *guard; - void *pattern; + expr_ty pattern; if ( (_keyword = _PyPegen_expect_soft_keyword(p, "case")) // soft_keyword='"case"' && @@ -4807,7 +4807,7 @@ case_block_rule(Parser *p) } // guard: 'if' named_expression -static void * +static expr_ty guard_rule(Parser *p) { D(p->level++); @@ -4815,7 +4815,7 @@ guard_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; { // 'if' named_expression if (p->error_indicator) { @@ -4851,7 +4851,7 @@ guard_rule(Parser *p) } // pattern_no_comma: pattern !',' | pattern ',' -static void * +static expr_ty pattern_no_comma_rule(Parser *p) { D(p->level++); @@ -4859,7 +4859,7 @@ pattern_no_comma_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; { // pattern !',' if (p->error_indicator) { @@ -4948,7 +4948,7 @@ pattern_rule(Parser *p) D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':=' or_pattern")); Token * _literal; expr_ty target; - void *value; + expr_ty value; if ( (target = _PyPegen_name_token(p)) // NAME && @@ -4985,7 +4985,7 @@ pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "or_pattern")); - void *or_pattern_var; + expr_ty or_pattern_var; if ( (or_pattern_var = or_pattern_rule(p)) // or_pattern ) @@ -5005,7 +5005,7 @@ pattern_rule(Parser *p) } // or_pattern: closed_pattern '|' '|'.closed_pattern+ | closed_pattern -static void * +static expr_ty or_pattern_rule(Parser *p) { D(p->level++); @@ -5013,7 +5013,7 @@ or_pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -5031,7 +5031,7 @@ or_pattern_rule(Parser *p) } D(fprintf(stderr, "%*c> or_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "closed_pattern '|' '|'.closed_pattern+")); Token * _literal; - void *value; + expr_ty value; asdl_seq * values; if ( (value = closed_pattern_rule(p)) // closed_pattern @@ -5069,7 +5069,7 @@ or_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> or_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "closed_pattern")); - void *closed_pattern_var; + expr_ty closed_pattern_var; if ( (closed_pattern_var = closed_pattern_rule(p)) // closed_pattern ) @@ -5096,7 +5096,7 @@ or_pattern_rule(Parser *p) // | sequence_pattern // | mapping_pattern // | class_pattern -static void * +static expr_ty closed_pattern_rule(Parser *p) { D(p->level++); @@ -5104,7 +5104,7 @@ closed_pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; { // name_pattern if (p->error_indicator) { @@ -5112,7 +5112,7 @@ closed_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_pattern")); - void *name_pattern_var; + expr_ty name_pattern_var; if ( (name_pattern_var = name_pattern_rule(p)) // name_pattern ) @@ -5131,7 +5131,7 @@ closed_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); - void *literal_pattern_var; + expr_ty literal_pattern_var; if ( (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern ) @@ -5150,7 +5150,7 @@ closed_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern")); - void *constant_pattern_var; + expr_ty constant_pattern_var; if ( (constant_pattern_var = constant_pattern_rule(p)) // constant_pattern ) @@ -5169,7 +5169,7 @@ closed_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group_pattern")); - void *group_pattern_var; + expr_ty group_pattern_var; if ( (group_pattern_var = group_pattern_rule(p)) // group_pattern ) @@ -5188,7 +5188,7 @@ closed_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sequence_pattern")); - void *sequence_pattern_var; + expr_ty sequence_pattern_var; if ( (sequence_pattern_var = sequence_pattern_rule(p)) // sequence_pattern ) @@ -5207,7 +5207,7 @@ closed_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "mapping_pattern")); - void *mapping_pattern_var; + expr_ty mapping_pattern_var; if ( (mapping_pattern_var = mapping_pattern_rule(p)) // mapping_pattern ) @@ -5226,7 +5226,7 @@ closed_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "class_pattern")); - void *class_pattern_var; + expr_ty class_pattern_var; if ( (class_pattern_var = class_pattern_rule(p)) // class_pattern ) @@ -5246,7 +5246,7 @@ closed_pattern_rule(Parser *p) } // name_pattern: NAME !('.' | '(' | '=') -static void * +static expr_ty name_pattern_rule(Parser *p) { D(p->level++); @@ -5254,7 +5254,7 @@ name_pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; { // NAME !('.' | '(' | '=') if (p->error_indicator) { @@ -5296,7 +5296,7 @@ name_pattern_rule(Parser *p) // | 'None' // | 'True' // | 'False' -static void * +static expr_ty literal_pattern_rule(Parser *p) { D(p->level++); @@ -5304,7 +5304,7 @@ literal_pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -5321,7 +5321,7 @@ literal_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "signed_number !('+' | '-')")); - void *signed_number_var; + expr_ty signed_number_var; if ( (signed_number_var = signed_number_rule(p)) // signed_number && @@ -5344,7 +5344,7 @@ literal_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "signed_number '+' NUMBER")); Token * _literal; expr_ty imag; - void *real; + expr_ty real; if ( (real = signed_number_rule(p)) // signed_number && @@ -5383,7 +5383,7 @@ literal_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "signed_number '-' NUMBER")); Token * _literal; expr_ty imag; - void *real; + expr_ty real; if ( (real = signed_number_rule(p)) // signed_number && @@ -5539,7 +5539,7 @@ literal_pattern_rule(Parser *p) } // constant_pattern: '.' NAME !('.' | '(' | '=') | '.'? attr !('.' | '(' | '=') -static void * +static expr_ty constant_pattern_rule(Parser *p) { D(p->level++); @@ -5547,7 +5547,7 @@ constant_pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; { // '.' NAME !('.' | '(' | '=') if (p->error_indicator) { @@ -5586,7 +5586,7 @@ constant_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> constant_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'? attr !('.' | '(' | '=')")); void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings - void *attr; + expr_ty attr; if ( (_opt_var = _PyPegen_expect_token(p, 23), 1) // '.'? && @@ -5615,7 +5615,7 @@ constant_pattern_rule(Parser *p) } // group_pattern: '(' pattern_no_comma ')' | '(' ')' -static void * +static expr_ty group_pattern_rule(Parser *p) { D(p->level++); @@ -5623,7 +5623,7 @@ group_pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; { // '(' pattern_no_comma ')' if (p->error_indicator) { @@ -5633,7 +5633,7 @@ group_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> group_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' pattern_no_comma ')'")); Token * _literal; Token * _literal_1; - void *pattern; + expr_ty pattern; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && @@ -5689,7 +5689,7 @@ group_pattern_rule(Parser *p) } // sequence_pattern: '[' values_pattern? ']' -static void * +static expr_ty sequence_pattern_rule(Parser *p) { D(p->level++); @@ -5697,7 +5697,7 @@ sequence_pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -5754,7 +5754,7 @@ sequence_pattern_rule(Parser *p) } // mapping_pattern: '{' items_pattern? '}' -static void * +static expr_ty mapping_pattern_rule(Parser *p) { D(p->level++); @@ -5762,7 +5762,7 @@ mapping_pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -5825,7 +5825,7 @@ mapping_pattern_rule(Parser *p) // | name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')' // | name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.error_argument_pattern+] ','? ')' // | name_or_attr '(' [','.error_argument_pattern+ ','] error_star [',' ','.(error_argument_pattern | error_star)+] ','? ')' -static void * +static expr_ty class_pattern_rule(Parser *p) { D(p->level++); @@ -5833,7 +5833,7 @@ class_pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -5852,7 +5852,7 @@ class_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ')'")); Token * _literal; Token * _literal_1; - void *func; + expr_ty func; if ( (func = name_or_attr_rule(p)) // name_or_attr && @@ -5894,7 +5894,7 @@ class_pattern_rule(Parser *p) void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings asdl_seq * args; - void *func; + expr_ty func; if ( (func = name_or_attr_rule(p)) // name_or_attr && @@ -5939,7 +5939,7 @@ class_pattern_rule(Parser *p) Token * _literal_1; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings - void *func; + expr_ty func; asdl_seq * keywords; if ( (func = name_or_attr_rule(p)) // name_or_attr @@ -5987,7 +5987,7 @@ class_pattern_rule(Parser *p) void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings asdl_seq * args; - void *func; + expr_ty func; asdl_seq * keywords; if ( (func = name_or_attr_rule(p)) // name_or_attr @@ -6044,7 +6044,7 @@ class_pattern_rule(Parser *p) void *_opt_var_2; UNUSED(_opt_var_2); // Silence compiler warnings expr_ty error; - void *func; + expr_ty func; if ( (func = name_or_attr_rule(p)) // name_or_attr && @@ -6093,7 +6093,7 @@ class_pattern_rule(Parser *p) void *_opt_var_2; UNUSED(_opt_var_2); // Silence compiler warnings expr_ty error; - void *func; + expr_ty func; if ( (func = name_or_attr_rule(p)) // name_or_attr && @@ -6130,7 +6130,7 @@ class_pattern_rule(Parser *p) } // signed_number: NUMBER | '-' NUMBER -static void * +static expr_ty signed_number_rule(Parser *p) { D(p->level++); @@ -6138,7 +6138,7 @@ signed_number_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -6212,12 +6212,12 @@ signed_number_rule(Parser *p) // Left-recursive // attr: name_or_attr '.' NAME -static void * attr_raw(Parser *); -static void * +static expr_ty attr_raw(Parser *); +static expr_ty attr_rule(Parser *p) { D(p->level++); - void * _res = NULL; + expr_ty _res = NULL; if (_PyPegen_is_memoized(p, attr_type, &_res)) { D(p->level--); return _res; @@ -6241,7 +6241,7 @@ attr_rule(Parser *p) D(p->level--); return _res; } -static void * +static expr_ty attr_raw(Parser *p) { D(p->level++); @@ -6249,7 +6249,7 @@ attr_raw(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -6268,7 +6268,7 @@ attr_raw(Parser *p) D(fprintf(stderr, "%*c> attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME")); Token * _literal; expr_ty attr; - void *value; + expr_ty value; if ( (value = name_or_attr_rule(p)) // name_or_attr && @@ -6307,7 +6307,7 @@ attr_raw(Parser *p) // Left-recursive // name_or_attr: attr | NAME -static void * +static expr_ty name_or_attr_rule(Parser *p) { D(p->level++); @@ -6315,7 +6315,7 @@ name_or_attr_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; { // attr if (p->error_indicator) { @@ -6323,7 +6323,7 @@ name_or_attr_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "attr")); - void *attr_var; + expr_ty attr_var; if ( (attr_var = attr_rule(p)) // attr ) @@ -6362,7 +6362,7 @@ name_or_attr_rule(Parser *p) } // values_pattern: ','.value_pattern+ ','? -static void * +static asdl_seq* values_pattern_rule(Parser *p) { D(p->level++); @@ -6370,7 +6370,7 @@ values_pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + asdl_seq* _res = NULL; int _mark = p->mark; { // ','.value_pattern+ ','? if (p->error_indicator) { @@ -6407,7 +6407,7 @@ values_pattern_rule(Parser *p) } // items_pattern: ','.key_value_pattern+ ','? -static void * +static asdl_seq* items_pattern_rule(Parser *p) { D(p->level++); @@ -6415,7 +6415,7 @@ items_pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + asdl_seq* _res = NULL; int _mark = p->mark; { // ','.key_value_pattern+ ','? if (p->error_indicator) { @@ -6452,7 +6452,7 @@ items_pattern_rule(Parser *p) } // keyword_pattern: NAME '=' or_pattern -static void * +static keyword_ty keyword_pattern_rule(Parser *p) { D(p->level++); @@ -6460,7 +6460,7 @@ keyword_pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + keyword_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -6479,7 +6479,7 @@ keyword_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> keyword_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' or_pattern")); Token * _literal; expr_ty arg; - void *value; + expr_ty value; if ( (arg = _PyPegen_name_token(p)) // NAME && @@ -6552,7 +6552,7 @@ error_argument_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> error_argument_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); - void *keyword_pattern_var; + keyword_ty keyword_pattern_var; if ( (keyword_pattern_var = keyword_pattern_rule(p)) // keyword_pattern ) @@ -6616,7 +6616,7 @@ error_star_rule(Parser *p) } // value_pattern: '*' name_pattern | pattern -static void * +static expr_ty value_pattern_rule(Parser *p) { D(p->level++); @@ -6624,7 +6624,7 @@ value_pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -6642,7 +6642,7 @@ value_pattern_rule(Parser *p) } D(fprintf(stderr, "%*c> value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' name_pattern")); Token * _literal; - void *value; + expr_ty value; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && @@ -6699,7 +6699,7 @@ value_pattern_rule(Parser *p) // key_value_pattern: // | (literal_pattern | constant_pattern) ':' or_pattern // | '**' name_pattern -static void * +static KeyValuePair* key_value_pattern_rule(Parser *p) { D(p->level++); @@ -6707,7 +6707,7 @@ key_value_pattern_rule(Parser *p) D(p->level--); return NULL; } - void * _res = NULL; + KeyValuePair* _res = NULL; int _mark = p->mark; { // (literal_pattern | constant_pattern) ':' or_pattern if (p->error_indicator) { @@ -6717,7 +6717,7 @@ key_value_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(literal_pattern | constant_pattern) ':' or_pattern")); Token * _literal; void *key; - void *value; + expr_ty value; if ( (key = _tmp_75_rule(p)) // literal_pattern | constant_pattern && @@ -6746,7 +6746,7 @@ key_value_pattern_rule(Parser *p) } D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' name_pattern")); Token * _literal; - void *value; + expr_ty value; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' && @@ -20373,7 +20373,7 @@ _loop1_49_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_49[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "case_block")); - void *case_block_var; + match_case_ty case_block_var; while ( (case_block_var = case_block_rule(p)) // case_block ) @@ -20445,7 +20445,7 @@ _loop0_51_rule(Parser *p) } D(fprintf(stderr, "%*c> _loop0_51[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|' closed_pattern")); Token * _literal; - void *elem; + expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 18)) // token='|' && @@ -20509,7 +20509,7 @@ _gather_50_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _gather_50[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "closed_pattern _loop0_51")); - void *elem; + expr_ty elem; asdl_seq * seq; if ( (elem = closed_pattern_rule(p)) // closed_pattern @@ -20950,7 +20950,7 @@ _loop0_59_rule(Parser *p) } D(fprintf(stderr, "%*c> _loop0_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; - void *elem; + keyword_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && @@ -21014,7 +21014,7 @@ _gather_58_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _gather_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_59")); - void *elem; + keyword_ty elem; asdl_seq * seq; if ( (elem = keyword_pattern_rule(p)) // keyword_pattern @@ -21178,7 +21178,7 @@ _loop0_63_rule(Parser *p) } D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; - void *elem; + keyword_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && @@ -21242,7 +21242,7 @@ _gather_62_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _gather_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_63")); - void *elem; + keyword_ty elem; asdl_seq * seq; if ( (elem = keyword_pattern_rule(p)) // keyword_pattern @@ -21331,7 +21331,7 @@ _loop0_66_rule(Parser *p) } D(fprintf(stderr, "%*c> _loop0_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; - void *elem; + keyword_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && @@ -21395,7 +21395,7 @@ _gather_65_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _gather_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_66")); - void *elem; + keyword_ty elem; asdl_seq * seq; if ( (elem = keyword_pattern_rule(p)) // keyword_pattern @@ -21562,7 +21562,7 @@ _loop0_71_rule(Parser *p) } D(fprintf(stderr, "%*c> _loop0_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' value_pattern")); Token * _literal; - void *elem; + expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && @@ -21626,7 +21626,7 @@ _gather_70_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _gather_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_71")); - void *elem; + expr_ty elem; asdl_seq * seq; if ( (elem = value_pattern_rule(p)) // value_pattern @@ -21676,7 +21676,7 @@ _loop0_73_rule(Parser *p) } D(fprintf(stderr, "%*c> _loop0_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); Token * _literal; - void *elem; + KeyValuePair* elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && @@ -21740,7 +21740,7 @@ _gather_72_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _gather_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_73")); - void *elem; + KeyValuePair* elem; asdl_seq * seq; if ( (elem = key_value_pattern_rule(p)) // key_value_pattern @@ -21834,7 +21834,7 @@ _tmp_75_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); - void *literal_pattern_var; + expr_ty literal_pattern_var; if ( (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern ) @@ -21853,7 +21853,7 @@ _tmp_75_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern")); - void *constant_pattern_var; + expr_ty constant_pattern_var; if ( (constant_pattern_var = constant_pattern_rule(p)) // constant_pattern ) From b50e40375683d2a539e9f53fc299559b15c5d6d6 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 10 Jun 2020 21:24:33 -0700 Subject: [PATCH 077/189] Simplify or-pattern parsing --- Grammar/python.gram | 5 ++--- Parser/pegen/parse.c | 37 ++++++------------------------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 8e43227f46fa90..86a6e37cc0b600 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -212,9 +212,8 @@ pattern[expr_ty]: | or_pattern or_pattern[expr_ty]: - | value=closed_pattern '|' values='|'.closed_pattern+ { - _Py_BoolOp(Or, CHECK(_PyPegen_seq_insert_in_front(p, value, values)), EXTRA) } - | closed_pattern + | values='|'.closed_pattern+ { + asdl_seq_LEN(values) == 1 ? asdl_seq_GET(values, 0) : _Py_BoolOp(Or, values, EXTRA) } closed_pattern[expr_ty]: | name_pattern diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index 409b9cba4728c4..940cda557c7741 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -5004,7 +5004,7 @@ pattern_rule(Parser *p) return _res; } -// or_pattern: closed_pattern '|' '|'.closed_pattern+ | closed_pattern +// or_pattern: '|'.closed_pattern+ static expr_ty or_pattern_rule(Parser *p) { @@ -5024,24 +5024,18 @@ or_pattern_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // closed_pattern '|' '|'.closed_pattern+ + { // '|'.closed_pattern+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> or_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "closed_pattern '|' '|'.closed_pattern+")); - Token * _literal; - expr_ty value; + D(fprintf(stderr, "%*c> or_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|'.closed_pattern+")); asdl_seq * values; if ( - (value = closed_pattern_rule(p)) // closed_pattern - && - (_literal = _PyPegen_expect_token(p, 18)) // token='|' - && (values = _gather_50_rule(p)) // '|'.closed_pattern+ ) { - D(fprintf(stderr, "%*c+ or_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "closed_pattern '|' '|'.closed_pattern+")); + D(fprintf(stderr, "%*c+ or_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'|'.closed_pattern+")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5051,7 +5045,7 @@ or_pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , value , values ) ) , EXTRA ); + _res = asdl_seq_LEN ( values ) == 1 ? asdl_seq_GET ( values , 0 ) : _Py_BoolOp ( Or , values , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5061,26 +5055,7 @@ or_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s or_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "closed_pattern '|' '|'.closed_pattern+")); - } - { // closed_pattern - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> or_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "closed_pattern")); - expr_ty closed_pattern_var; - if ( - (closed_pattern_var = closed_pattern_rule(p)) // closed_pattern - ) - { - D(fprintf(stderr, "%*c+ or_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "closed_pattern")); - _res = closed_pattern_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s or_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "closed_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|'.closed_pattern+")); } _res = NULL; done: From 1e0e35a003880e7cbcb43519eec88c164f193a75 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 11 Jun 2020 09:11:13 -0700 Subject: [PATCH 078/189] Refactor MATCH opcode. --- Doc/library/dis.rst | 16 +------ Lib/importlib/_bootstrap_external.py | 4 +- Python/ceval.c | 66 ++++++++++------------------ Python/compile.c | 8 ++-- Python/importlib_external.h | 2 +- Python/peephole.c | 2 - 6 files changed, 31 insertions(+), 67 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 88e8a565577222..7e69c8ea699e6a 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1189,24 +1189,10 @@ All of the following opcodes use their arguments. .. versionadded:: 3.6 -.. opcode:: MATCH (delta) +.. opcode:: MATCH (count) TODO - Pop TOS, TOS1, TOS2, and TOS3. If TOS2 is an instance of :class:`type` and - has a ``__match__`` method, call that method on TOS3. The returned "proxy" - should be non-``None``. - - TOS is an integer argument count, and TOS1 is a :class:`tuple` of attribute - names. Using these together with the ``__match_args__`` and - ``__match_args_required__`` attributes (if present) on the "proxy", discover - and validate the total collection of attribute names required for a - successful match. If it has all of those attributes, push a reversed - :class:`list` of their corresponsing values onto the stack. - - If any part of the above process is unsuccessful, increment the bytecode - counter by ``delta``. - .. versionadded:: 3.10 diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 26e57ba3993e1d..852c05eb14dd71 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3455 (add MATCH*) +# Python 3.10a0 3456 (add MATCH* opcodes) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3455).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3456).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Python/ceval.c b/Python/ceval.c index 119d682afaff60..a883a69a1db395 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -999,10 +999,9 @@ get_match_args(PyThreadState *tstate, PyObject *proxy) } static PyObject * -do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *type, PyObject *target) +do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *type, PyObject *target) { // TODO: Break this up, and better error handling ("goto error;"): - assert(PyLong_CheckExact(count)); assert(PyTuple_CheckExact(kwargs)); if (!PyType_Check(type)) { _PyErr_Format(tstate, PyExc_TypeError, @@ -1025,16 +1024,10 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ return NULL; } if (proxy == Py_None) { - Py_DECREF(proxy); - return NULL; + return proxy; } Py_ssize_t nkwargs = PyTuple_GET_SIZE(kwargs); - Py_ssize_t nargs = PyLong_AsSsize_t(count); - if (nargs < 0) { - Py_DECREF(proxy); - return NULL; - } - nargs -= nkwargs; + Py_ssize_t nargs = count - nkwargs; PyObject *args; PyObject *match_args = get_match_args(tstate, proxy); if (!match_args) { @@ -1076,7 +1069,7 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ return NULL; } assert(PyTuple_CheckExact(args) || args == Py_None); - PyObject *attrs = PyList_New(nargs + nkwargs); + PyObject *attrs = PyList_New(count); if (!attrs) { Py_DECREF(match_args); Py_DECREF(proxy); @@ -1101,7 +1094,7 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ proxy); goto error; } - if (required > nargs + nkwargs) { + if (required > count) { // TODO: combine with below? Use name? _PyErr_Format(tstate, PyExc_TypeError, "not enough match arguments provided"); @@ -1132,7 +1125,7 @@ do_match(PyThreadState *tstate, PyObject *count, PyObject *kwargs, PyObject *typ } } PyObject *name; - for (Py_ssize_t i = 0; i < nargs + nkwargs; i++) { + for (Py_ssize_t i = 0; i < count; i++) { if (i < nargs) { if (args == Py_None) { assert(!i); @@ -3623,25 +3616,18 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH): { - PyObject *count = TOP(); - PyObject *names = SECOND(); - PyObject *type = THIRD(); - PyObject *target = FOURTH(); - PyObject *attrs = do_match(tstate, count, names, type, target); - Py_DECREF(count); + PyObject *names = POP(); + PyObject *type = TOP(); + PyObject *target = SECOND(); + PyObject *attrs = do_match(tstate, oparg, names, type, target); Py_DECREF(names); - Py_DECREF(type); - Py_DECREF(target); if (!attrs) { - STACK_SHRINK(4); - if (_PyErr_Occurred(tstate)) { - goto error; - } - JUMPBY(oparg); - DISPATCH(); + goto error; } - STACK_SHRINK(3); - SET_TOP(attrs); + Py_DECREF(type); + Py_DECREF(target); + SET_SECOND(attrs); + SET_TOP(PyBool_FromLong(attrs != Py_None)); DISPATCH(); } @@ -3673,7 +3659,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) PyObject *item = PySequence_Fast_GET_ITEM(target, oparg); Py_INCREF(item); PUSH(item); - DISPATCH(); + FAST_DISPATCH(); } case TARGET(MATCH_SEQ_ITEM_END): { @@ -3683,7 +3669,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) PyObject *item = PySequence_Fast_GET_ITEM(target, i); Py_INCREF(item); PUSH(item); - DISPATCH(); + FAST_DISPATCH(); } case TARGET(MATCH_SEQ_SLICE): { @@ -3709,7 +3695,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) goto error; } PUSH(slice); - DISPATCH(); + FAST_DISPATCH(); } case TARGET(MATCH_LEN_EQ): { @@ -3722,9 +3708,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) assert(PyList_CheckExact(target) || PyTuple_CheckExact(target)); len = PySequence_Fast_GET_SIZE(target); } - PUSH(len == oparg ? Py_True : Py_False); - Py_INCREF(TOP()); - DISPATCH(); + PUSH(PyBool_FromLong(len == oparg)); + FAST_DISPATCH(); } case TARGET(MATCH_LEN_GE): { @@ -3737,9 +3722,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) assert(PyList_CheckExact(target) || PyTuple_CheckExact(target)); len = PySequence_Fast_GET_SIZE(target); } - PUSH(len >= oparg ? Py_True : Py_False); - Py_INCREF(TOP()); - DISPATCH(); + PUSH(PyBool_FromLong(len >= oparg)); + FAST_DISPATCH(); } case TARGET(MATCH_MAP): { @@ -3766,8 +3750,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) SET_TOP(map); Py_DECREF(target); } - PUSH(match ? Py_True : Py_False); - Py_INCREF(TOP()); + PUSH(PyBool_FromLong(match)); DISPATCH(); } @@ -3785,8 +3768,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) SET_TOP(seq); Py_DECREF(target); } - PUSH(match ? Py_True : Py_False); - Py_INCREF(TOP()); + PUSH(PyBool_FromLong(match)); DISPATCH(); } diff --git a/Python/compile.c b/Python/compile.c index abcfc89ccee976..06a55233c99049 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1119,7 +1119,7 @@ stack_effect(int opcode, int oparg, int jump) case DICT_UPDATE: return -1; case MATCH: - return jump > 0 ? -4 : -3; + return -1; case MATCH_MAP_KEYS: case MATCH_LEN_EQ: case MATCH_LEN_GE: @@ -2800,10 +2800,8 @@ compiler_pattern_call(struct compiler *c, expr_ty p, basicblock *fail, PyObject* PyTuple_SET_ITEM(kwnames, i, name); } ADDOP_LOAD_CONST_NEW(c, kwnames); - PyObject *count; - CHECK(count = PyLong_FromSsize_t(nargs + nkwargs)); - ADDOP_LOAD_CONST_NEW(c, count); - ADDOP_JREL(c, MATCH, fail); + ADDOP_I(c, MATCH, nargs + nkwargs); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); for (i = 0; i < nargs; i++) { expr_ty arg = asdl_seq_GET(args, i); ADDOP_I(c, MATCH_SEQ_ITEM, i); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index ecdd6258ac5510..c6f280a81cf625 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,127,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,128,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/peephole.c b/Python/peephole.c index 61cc6a11aa752b..84de1abc175476 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -199,7 +199,6 @@ markblocks(_Py_CODEUNIT *code, Py_ssize_t len) case SETUP_FINALLY: case SETUP_WITH: case SETUP_ASYNC_WITH: - case MATCH: j = GETJUMPTGT(code, i); assert(j < len); blocks[j] = 1; @@ -504,7 +503,6 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, case SETUP_FINALLY: case SETUP_WITH: case SETUP_ASYNC_WITH: - case MATCH: j = blocks[j / sizeof(_Py_CODEUNIT) + i + 1] - blocks[i] - 1; j *= sizeof(_Py_CODEUNIT); break; From 31301142219270ece0a5c4ff2987a2561b1ed243 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 11 Jun 2020 14:35:40 -0700 Subject: [PATCH 079/189] Tuples! --- Grammar/python.gram | 15 ++--- Parser/pegen/parse.c | 157 +++++++++++++++++++++++++------------------ Python/ast_opt.c | 3 +- Python/compile.c | 16 +++-- 4 files changed, 108 insertions(+), 83 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 5c0e764ae62a4a..e8b433658fb7f2 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -196,15 +196,15 @@ match_stmt[stmt_ty]: | "match" target=expression ':' NEWLINE INDENT cases=case_block+ DEDENT { _Py_Match(target, cases, EXTRA) } case_block[match_case_ty]: - | "case" pattern=pattern_no_comma guard=guard? ':' body=block { + | "case" pattern=patterns guard=guard? ':' body=block { _Py_match_case(pattern, guard, body, p->arena) } guard[expr_ty]: | 'if' guard=named_expression { guard } -pattern_no_comma[expr_ty]: - | pattern=pattern !',' { pattern } - | pattern error=',' { - RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "tuple displays cannot be used as patterns; did you mean '[...]'?") } +patterns[expr_ty]: + | value=value_pattern ',' values=values_pattern? { + _Py_Tuple(CHECK(_PyPegen_seq_insert_in_front(p, value, values)), Load, EXTRA) } + | pattern pattern[expr_ty]: | target=NAME ':=' value=or_pattern { @@ -238,11 +238,10 @@ constant_pattern[expr_ty]: | '.' name=NAME !('.' | '(' | '=') { name } | '.'? attr=attr !('.' | '(' | '=') { attr } group_pattern[expr_ty]: - | '(' pattern=pattern_no_comma ')' { pattern } - | error='(' ')' { - RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "tuple displays cannot be used as patterns; did you mean '[]'?") } + | '(' pattern=patterns ')' { pattern } sequence_pattern[expr_ty]: | '[' values=values_pattern? ']' { _Py_List(values, Load, EXTRA) } + | '(' ')' { _Py_Tuple(NULL, Load, EXTRA) } mapping_pattern[expr_ty]: | '{' items=items_pattern? '}' { _Py_Dict(CHECK(_PyPegen_get_keys(p, items)), CHECK(_PyPegen_get_values(p, items)), EXTRA) } diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index 1f632d3b531d8c..9cba3526a22d24 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -107,7 +107,7 @@ static KeywordToken *reserved_keywords[] = { #define match_stmt_type 1038 #define case_block_type 1039 #define guard_type 1040 -#define pattern_no_comma_type 1041 +#define patterns_type 1041 #define pattern_type 1042 #define or_pattern_type 1043 #define closed_pattern_type 1044 @@ -480,7 +480,7 @@ static asdl_seq* finally_block_rule(Parser *p); static stmt_ty match_stmt_rule(Parser *p); static match_case_ty case_block_rule(Parser *p); static expr_ty guard_rule(Parser *p); -static expr_ty pattern_no_comma_rule(Parser *p); +static expr_ty patterns_rule(Parser *p); static expr_ty pattern_rule(Parser *p); static expr_ty or_pattern_rule(Parser *p); static expr_ty closed_pattern_rule(Parser *p); @@ -4744,7 +4744,7 @@ match_stmt_rule(Parser *p) return _res; } -// case_block: "case" pattern_no_comma guard? ':' block +// case_block: "case" patterns guard? ':' block static match_case_ty case_block_rule(Parser *p) { @@ -4755,12 +4755,12 @@ case_block_rule(Parser *p) } match_case_ty _res = NULL; int _mark = p->mark; - { // "case" pattern_no_comma guard? ':' block + { // "case" patterns guard? ':' block if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> case_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" pattern_no_comma guard? ':' block")); + D(fprintf(stderr, "%*c> case_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? ':' block")); expr_ty _keyword; Token * _literal; asdl_seq* body; @@ -4769,7 +4769,7 @@ case_block_rule(Parser *p) if ( (_keyword = _PyPegen_expect_soft_keyword(p, "case")) // soft_keyword='"case"' && - (pattern = pattern_no_comma_rule(p)) // pattern_no_comma + (pattern = patterns_rule(p)) // patterns && (guard = guard_rule(p), 1) // guard? && @@ -4778,7 +4778,7 @@ case_block_rule(Parser *p) (body = block_rule(p)) // block ) { - D(fprintf(stderr, "%*c+ case_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" pattern_no_comma guard? ':' block")); + D(fprintf(stderr, "%*c+ case_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? ':' block")); _res = _Py_match_case ( pattern , guard , body , p -> arena ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -4789,7 +4789,7 @@ case_block_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s case_block[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" pattern_no_comma guard? ':' block")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" patterns guard? ':' block")); } _res = NULL; done: @@ -4841,9 +4841,9 @@ guard_rule(Parser *p) return _res; } -// pattern_no_comma: pattern !',' | pattern ',' +// patterns: value_pattern ',' values_pattern? | pattern static expr_ty -pattern_no_comma_rule(Parser *p) +patterns_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -4852,21 +4852,43 @@ pattern_no_comma_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; - { // pattern !',' + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // value_pattern ',' values_pattern? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> pattern_no_comma[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern !','")); - expr_ty pattern; + D(fprintf(stderr, "%*c> patterns[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern ',' values_pattern?")); + Token * _literal; + expr_ty value; + void *values; if ( - (pattern = pattern_rule(p)) // pattern + (value = value_pattern_rule(p)) // value_pattern && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (values = values_pattern_rule(p), 1) // values_pattern? ) { - D(fprintf(stderr, "%*c+ pattern_no_comma[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern !','")); - _res = pattern; + D(fprintf(stderr, "%*c+ patterns[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern ',' values_pattern?")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , value , values ) ) , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -4875,35 +4897,27 @@ pattern_no_comma_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s pattern_no_comma[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern !','")); + D(fprintf(stderr, "%*c%s patterns[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern ',' values_pattern?")); } - { // pattern ',' + { // pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> pattern_no_comma[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern ','")); - Token * error; + D(fprintf(stderr, "%*c> patterns[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); expr_ty pattern_var; if ( (pattern_var = pattern_rule(p)) // pattern - && - (error = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ pattern_no_comma[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern ','")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "tuple displays cannot be used as patterns; did you mean '[...]'?" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ patterns[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); + _res = pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s pattern_no_comma[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern ','")); + D(fprintf(stderr, "%*c%s patterns[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); } _res = NULL; done: @@ -5580,7 +5594,7 @@ constant_pattern_rule(Parser *p) return _res; } -// group_pattern: '(' pattern_no_comma ')' | '(' ')' +// group_pattern: '(' patterns ')' static expr_ty group_pattern_rule(Parser *p) { @@ -5591,24 +5605,24 @@ group_pattern_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; - { // '(' pattern_no_comma ')' + { // '(' patterns ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> group_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' pattern_no_comma ')'")); + D(fprintf(stderr, "%*c> group_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' patterns ')'")); Token * _literal; Token * _literal_1; expr_ty pattern; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (pattern = pattern_no_comma_rule(p)) // pattern_no_comma + (pattern = patterns_rule(p)) // patterns && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ group_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' pattern_no_comma ')'")); + D(fprintf(stderr, "%*c+ group_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' patterns ')'")); _res = pattern; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -5619,34 +5633,7 @@ group_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s group_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' pattern_no_comma ')'")); - } - { // '(' ')' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> group_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' ')'")); - Token * _literal; - Token * error; - if ( - (error = _PyPegen_expect_token(p, 7)) // token='(' - && - (_literal = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ group_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' ')'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "tuple displays cannot be used as patterns; did you mean '[]'?" ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s group_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' ')'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' patterns ')'")); } _res = NULL; done: @@ -5654,7 +5641,7 @@ group_pattern_rule(Parser *p) return _res; } -// sequence_pattern: '[' values_pattern? ']' +// sequence_pattern: '[' values_pattern? ']' | '(' ')' static expr_ty sequence_pattern_rule(Parser *p) { @@ -5713,6 +5700,42 @@ sequence_pattern_rule(Parser *p) D(fprintf(stderr, "%*c%s sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' values_pattern? ']'")); } + { // '(' ')' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' ')'")); + Token * _literal; + Token * _literal_1; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' ')'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Tuple ( NULL , Load , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' ')'")); + } _res = NULL; done: D(p->level--); diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 5079a59547d3af..bee3dc3919b4c1 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -800,7 +800,6 @@ astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) // TODO: Build out this pattern optimizer. switch (node_->kind) { case Attribute_kind: - case Constant_kind: return 1; case BinOp_kind: CALL(astfold_pattern_complex, expr_ty, node_); @@ -808,12 +807,14 @@ astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) case BoolOp_kind: // TODO: Quite a bit of potential here. case Call_kind: + case Constant_kind: case Dict_kind: // Not actually valid, but it's the complier's job to complain: case JoinedStr_kind: case List_kind: case Name_kind: case NamedExpr_kind: + case Tuple_kind: return 1; case UnaryOp_kind: CALL(astfold_pattern_negative, expr_ty, node_); diff --git a/Python/compile.c b/Python/compile.c index 06a55233c99049..2a5ad8a2418aec 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2976,8 +2976,8 @@ compiler_pattern_or(struct compiler *c, expr_ty p, basicblock *fail, PyObject* n static int compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) { - assert(p->kind == List_kind); - asdl_seq *values = p->v.List.elts; + assert(p->kind == List_kind || p->kind == Tuple_kind); + asdl_seq *values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; Py_ssize_t size = asdl_seq_LEN(values); Py_ssize_t star = -1; for (Py_ssize_t i = 0; i < size; i++) { @@ -3039,23 +3039,25 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail, PyObject* name case BinOp_kind: // Because we allow "2+2j", things like "2+2" make it this far. return compiler_error(c, "patterns cannot include operators"); + case BoolOp_kind: + return compiler_pattern_or(c, p, fail, names); case Call_kind: return compiler_pattern_call(c, p, fail, names); case Constant_kind: return compiler_pattern_load(c, p, fail); - case BoolOp_kind: - return compiler_pattern_or(c, p, fail, names); case Dict_kind: return compiler_pattern_mapping(c, p, fail, names); + case JoinedStr_kind: + // Because we allow strings, f-strings make it this far. + return compiler_error(c, "patterns cannot include f-strings"); case List_kind: return compiler_pattern_sequence(c, p, fail, names); case Name_kind: return compiler_pattern_name(c, p, fail, names); case NamedExpr_kind: return compiler_pattern_namedexpr(c, p, fail, names); - case JoinedStr_kind: - // Because we allow strings, f-strings make it this far. - return compiler_error(c, "patterns cannot include f-strings"); + case Tuple_kind: + return compiler_pattern_sequence(c, p, fail, names); default: Py_UNREACHABLE(); } From de78bc5befd5d1f81893ce1186208629aefe9b0d Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 11 Jun 2020 14:50:31 -0700 Subject: [PATCH 080/189] Fix line numbers --- Python/compile.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Python/compile.c b/Python/compile.c index 2a5ad8a2418aec..ba5e73185ddc74 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -3033,6 +3033,7 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj static int compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) { + SET_LOC(c, p); switch (p->kind) { case Attribute_kind: return compiler_pattern_load(c, p, fail); @@ -3073,6 +3074,7 @@ compiler_match(struct compiler *c, stmt_ty s) assert(cases); for (Py_ssize_t i = 0; i < cases; i++) { match_case_ty m = asdl_seq_GET(s->v.Match.cases, i); + SET_LOC(c, m->pattern); CHECK(next = compiler_new_block(c)); if (i != cases - 1) { ADDOP(c, DUP_TOP); From 07b147454feb1f755ba5e6719c79011243ec3652 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 12 Jun 2020 08:12:51 -0700 Subject: [PATCH 081/189] Improve compilation of wildcards. --- Python/compile.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 63aae0f5f0217e..26459620c1ba96 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2749,12 +2749,18 @@ compiler_if(struct compiler *c, stmt_ty s) return 1; } +// TODO: Remove Store part of check if disallowing all usage of _: +#define WILDCARD_CHECK(N) \ + ((N)->kind == Name_kind && (N)->v.Name.ctx == Store \ + && _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) + static int compiler_pattern_load(struct compiler *c, expr_ty p, basicblock *fail) { assert(p->kind == Attribute_kind || p->kind == Constant_kind || p->kind == Name_kind); assert(p->kind != Attribute_kind || p->v.Attribute.ctx == Load); assert(p->kind != Name_kind || p->v.Name.ctx == Load); + // TODO: Guard against wildcards here? VISIT(c, expr, p); ADDOP_COMPARE(c, Eq); ADDOP_JABS(c, POP_JUMP_IF_FALSE, fail); @@ -2789,11 +2795,17 @@ compiler_pattern_call(struct compiler *c, expr_ty p, basicblock *fail, PyObject* ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); for (i = 0; i < nargs; i++) { expr_ty arg = asdl_seq_GET(args, i); + if (WILDCARD_CHECK(arg)) { + continue; + } ADDOP_I(c, MATCH_SEQ_ITEM, i); CHECK(compiler_pattern(c, arg, block, names)); } for (i = 0; i < nkwargs; i++) { keyword_ty kwarg = asdl_seq_GET(kwargs, i); + if (WILDCARD_CHECK(kwarg->value)) { + continue; + } ADDOP_I(c, MATCH_SEQ_ITEM, nargs + i); CHECK(compiler_pattern(c, kwarg->value, block, names)); } @@ -2807,11 +2819,11 @@ compiler_pattern_call(struct compiler *c, expr_ty p, basicblock *fail, PyObject* } static int -compiler_pattern_store(struct compiler *c, expr_ty p, int anon_ok, PyObject* names) { +compiler_pattern_store(struct compiler *c, expr_ty p, int wildcard_ok, PyObject* names) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); - if (_PyUnicode_EqualToASCIIString(p->v.Name.id, "_")) { - if (!anon_ok) { + if (WILDCARD_CHECK(p)) { + if (!wildcard_ok) { return compiler_error(c, "can't assign to '_' here; consider removing or renaming?"); } ADDOP(c, POP_TOP); @@ -2858,12 +2870,15 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje ADDOP_JABS(c, POP_JUMP_IF_FALSE, block_star) for (i = 0; i < size - star; i++) { expr_ty value = asdl_seq_GET(values, i); + if (WILDCARD_CHECK(value)) { + continue; + } ADDOP_I(c, MATCH_SEQ_ITEM, i); CHECK(compiler_pattern(c, value, block_star, names)); } ADDOP(c, POP_TOP); if (star) { - CHECK(compiler_pattern(c, asdl_seq_GET(values, size - 1), fail, names)); + CHECK(compiler_pattern_store(c, asdl_seq_GET(values, size - 1), 0, names)); } else { ADDOP(c, POP_TOP); @@ -2992,12 +3007,18 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj } for (Py_ssize_t i = 0; i < size; i++) { expr_ty value = asdl_seq_GET(values, i); + if (WILDCARD_CHECK(value)) { + continue; + } if (star < 0 || i < star) { ADDOP_I(c, MATCH_SEQ_ITEM, i); } else if (i == star) { assert(value->kind == Starred_kind); value = value->v.Starred.value; + if (WILDCARD_CHECK(value)) { + continue; + } // TODO: ERROR CHECKING FOR THESE: ADDOP_I(c, MATCH_SEQ_SLICE, (i << 16) + (size - 1 - i)); } @@ -3023,7 +3044,7 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail, PyObject* name case Attribute_kind: return compiler_pattern_load(c, p, fail); case BinOp_kind: - // Because we allow "2+2j", things like "2+2" make it this far. + // Because we allow "2+2j", things like "2+2" make it this far: return compiler_error(c, "patterns cannot include operators"); case BoolOp_kind: return compiler_pattern_or(c, p, fail, names); @@ -3034,7 +3055,7 @@ compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail, PyObject* name case Dict_kind: return compiler_pattern_mapping(c, p, fail, names); case JoinedStr_kind: - // Because we allow strings, f-strings make it this far. + // Because we allow strings, f-strings make it this far: return compiler_error(c, "patterns cannot include f-strings"); case List_kind: return compiler_pattern_sequence(c, p, fail, names); From 18ef5771b8cbdff3d3b5aea11679c294140a11f6 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 12 Jun 2020 08:13:08 -0700 Subject: [PATCH 082/189] Better error message for bad types. --- Python/ceval.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 64852e0e3ba211..441d14d20fedb4 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1005,8 +1005,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty assert(PyTuple_CheckExact(kwargs)); if (!PyType_Check(type)) { _PyErr_Format(tstate, PyExc_TypeError, - "called match pattern must be a type; did you mean '%s(...)'?", - Py_TYPE(type)->tp_name); + "called match pattern must be a type"); return NULL; } PyObject *method = PyObject_GetAttrString(type, "__match__"); From 4106b66cab4de957d1577dfee5dde9329113f7b3 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 12 Jun 2020 08:37:59 -0700 Subject: [PATCH 083/189] Fix duplicate test --- Lib/test/test_patma.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 78d9a9867e1aaf..ce6a318172d0f0 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1187,9 +1187,9 @@ def test_patma_070(self) -> None: def test_patma_071(self) -> None: x = 0 match x: - case 0 if True: + case 0 if 1: y = 0 - case 0 if True: + case 0 if 1: y = 1 self.assertEqual(x, 0) self.assertEqual(y, 0) From 5ef4df0e3258472e2e463a94c6be2120330c0928 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 12 Jun 2020 13:00:44 -0700 Subject: [PATCH 084/189] Progress on performance improvements --- Python/ceval.c | 53 ++++++++++++++++++++++++++++++++++-------------- Python/compile.c | 3 +-- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 441d14d20fedb4..6e12296ed55eeb 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -910,7 +910,7 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) if (!seen) { goto fail; } - values = PyList_New(nkeys); + values = PyTuple_New(nkeys); if (!values) { goto fail; } @@ -929,7 +929,7 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) goto fail; } Py_INCREF(value); - PyList_SET_ITEM(values, i, value); + PyTuple_SET_ITEM(values, i, value); if (PyDict_DelItem(map, key)) { goto fail; } @@ -1068,7 +1068,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty return NULL; } assert(PyTuple_CheckExact(args) || args == Py_None); - PyObject *attrs = PyList_New(count); + PyObject *attrs = PyTuple_New(count); if (!attrs) { Py_DECREF(match_args); Py_DECREF(proxy); @@ -1129,7 +1129,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty if (args == Py_None) { assert(!i); Py_INCREF(proxy); - PyList_SET_ITEM(attrs, 0, proxy); + PyTuple_SET_ITEM(attrs, 0, proxy); continue; } name = PyTuple_GET_ITEM(args, i); @@ -1161,7 +1161,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty proxy, name); } } - PyList_SET_ITEM(attrs, i, attr); + PyTuple_SET_ITEM(attrs, i, attr); } Py_DECREF(match_args); Py_DECREF(proxy); @@ -3653,21 +3653,44 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(MATCH_SEQ_ITEM): { PyObject *target = TOP(); - assert(PyList_CheckExact(target) || PyTuple_CheckExact(target)); - PyObject *item = PySequence_Fast_GET_ITEM(target, oparg); + PyObject *item; + if (PyTuple_CheckExact(target)) { + assert(oparg < PyTuple_GET_SIZE(target)); + item = PyTuple_GET_ITEM(target, oparg); + } + else if (PyList_CheckExact(target)) { + assert(oparg < PyList_GET_SIZE(target)); + item = PyList_GET_ITEM(target, oparg); + } + else { + // TODO + Py_UNREACHABLE(); + } Py_INCREF(item); PUSH(item); - FAST_DISPATCH(); + DISPATCH(); } case TARGET(MATCH_SEQ_ITEM_END): { PyObject *target = TOP(); - assert(PyList_CheckExact(target) || PyTuple_CheckExact(target)); - Py_ssize_t i = PySequence_Fast_GET_SIZE(target) - 1 - oparg; - PyObject *item = PySequence_Fast_GET_ITEM(target, i); + PyObject *item; + if (PyTuple_CheckExact(target)) { + Py_ssize_t i = PyTuple_GET_SIZE(target) - 1 - oparg; + assert(i >= 0); + item = PyTuple_GET_ITEM(target, i); + } + else if (PyList_CheckExact(target)) { + Py_ssize_t i = PyList_GET_SIZE(target) - 1 - oparg; + assert(i >= 0); + item = PyList_GET_ITEM(target, i); + } + else { + // TODO + Py_UNREACHABLE(); + } Py_INCREF(item); PUSH(item); - FAST_DISPATCH(); + DISPATCH(); } case TARGET(MATCH_SEQ_SLICE): { @@ -3693,7 +3716,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) goto error; } PUSH(slice); - FAST_DISPATCH(); + DISPATCH(); } case TARGET(MATCH_LEN_EQ): { @@ -3707,7 +3730,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) len = PySequence_Fast_GET_SIZE(target); } PUSH(PyBool_FromLong(len == oparg)); - FAST_DISPATCH(); + DISPATCH(); } case TARGET(MATCH_LEN_GE): { @@ -3721,7 +3744,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) len = PySequence_Fast_GET_SIZE(target); } PUSH(PyBool_FromLong(len >= oparg)); - FAST_DISPATCH(); + DISPATCH(); } case TARGET(MATCH_MAP): { diff --git a/Python/compile.c b/Python/compile.c index 26459620c1ba96..b315ff232ea2e0 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2751,8 +2751,7 @@ compiler_if(struct compiler *c, stmt_ty s) // TODO: Remove Store part of check if disallowing all usage of _: #define WILDCARD_CHECK(N) \ - ((N)->kind == Name_kind && (N)->v.Name.ctx == Store \ - && _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) + ((N)->kind == Name_kind && _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) static int compiler_pattern_load(struct compiler *c, expr_ty p, basicblock *fail) From ff0c9023bacf93bbd73ed812d6ff4d312f61455a Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 12 Jun 2020 13:43:47 -0700 Subject: [PATCH 085/189] Fix segfault on missing attribute --- Python/ceval.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Python/ceval.c b/Python/ceval.c index 6e12296ed55eeb..0cd2389556e9a7 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1159,7 +1159,12 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty _PyErr_Format(tstate, PyExc_TypeError, "match proxy %R has no attribute %R", proxy, name); + goto error; } + Py_DECREF(attrs); + attrs = Py_None; + Py_INCREF(attrs); + break; } PyTuple_SET_ITEM(attrs, i, attr); } @@ -3652,13 +3657,16 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_SEQ_ITEM): { + printf("AAA\n"); PyObject *target = TOP(); PyObject *item; if (PyTuple_CheckExact(target)) { + printf("BBB\n"); assert(oparg < PyTuple_GET_SIZE(target)); item = PyTuple_GET_ITEM(target, oparg); } else if (PyList_CheckExact(target)) { + printf("CCC\n"); assert(oparg < PyList_GET_SIZE(target)); item = PyList_GET_ITEM(target, oparg); } @@ -3668,6 +3676,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } Py_INCREF(item); PUSH(item); + printf("DDD\n"); DISPATCH(); } From 38000fa995ba8543142bacf6355aaee98156daf6 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 12 Jun 2020 13:47:48 -0700 Subject: [PATCH 086/189] Cleanup --- Python/ceval.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 0cd2389556e9a7..57c7f0ba2d9312 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3657,16 +3657,13 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_SEQ_ITEM): { - printf("AAA\n"); PyObject *target = TOP(); PyObject *item; if (PyTuple_CheckExact(target)) { - printf("BBB\n"); assert(oparg < PyTuple_GET_SIZE(target)); item = PyTuple_GET_ITEM(target, oparg); } else if (PyList_CheckExact(target)) { - printf("CCC\n"); assert(oparg < PyList_GET_SIZE(target)); item = PyList_GET_ITEM(target, oparg); } @@ -3676,7 +3673,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } Py_INCREF(item); PUSH(item); - printf("DDD\n"); DISPATCH(); } From 15e8824568747cb18a3d62e9153ea187c67a651f Mon Sep 17 00:00:00 2001 From: Talin Date: Fri, 12 Jun 2020 18:49:05 -0700 Subject: [PATCH 087/189] Support for __match_args__ in dataclasses. --- Lib/dataclasses.py | 15 +++++++++++++++ Lib/test/test_dataclasses.py | 17 +++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py index fc69508354bbe8..765f0f7160a899 100644 --- a/Lib/dataclasses.py +++ b/Lib/dataclasses.py @@ -151,6 +151,16 @@ # # See _hash_action (below) for a coded version of this table. +# __match_args__ +# +# | no | yes | <--- class has __match_args__ in __dict__? +# +=======+=======+ +# | add | | <- the default +# +=======+=======+ +# __match_args__ is always added unless the class already defines it. +# __match_args__ contains the set of names of __init__ parameters. +# Non-init fields must be matched by name. + # Raised when an attempt is made to modify a frozen class. class FrozenInstanceError(AttributeError): pass @@ -992,6 +1002,11 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen): cls.__doc__ = (cls.__name__ + str(inspect.signature(cls)).replace(' -> None', '')) + match_args = cls.__dict__.get('__match_args__', MISSING) + if match_args is MISSING: + # Create a __match_args__ attribute. + _set_new_attribute(cls, '__match_args__', [f.name for f in flds if f.init]) + return cls diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index b20103bdce51cb..186f6aa3c21869 100644 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -3332,6 +3332,23 @@ class C: ## replace(c, x=5) +class TestMatchArgs(unittest.TestCase): + def test_match_args(self): + @dataclass + class B: + x: int + + o = B(4) + self.assertEqual(o.__match_args__, ['x']) + + def test_explicit_match_args(self): + @dataclass + class B: + x: int + __match_args__ = [] + + o = B(4) + self.assertEqual(o.__match_args__, []) if __name__ == '__main__': unittest.main() From 59c7a2f45625079b3ee1ff62675d7778fb3ed8e4 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 14 Jun 2020 22:03:02 -0700 Subject: [PATCH 088/189] Performance tweaks and __match__ protocol updates --- Include/opcode.h | 16 ++-- Lib/importlib/_bootstrap_external.py | 4 +- Lib/opcode.py | 20 ++-- Python/ceval.c | 131 +++++++++------------------ Python/compile.c | 8 +- Python/importlib_external.h | 2 +- Python/opcode_targets.h | 16 ++-- 7 files changed, 78 insertions(+), 119 deletions(-) diff --git a/Include/opcode.h b/Include/opcode.h index 956602d29ecdce..7bfa59812e2b80 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -30,9 +30,6 @@ extern "C" { #define BINARY_TRUE_DIVIDE 27 #define INPLACE_FLOOR_DIVIDE 28 #define INPLACE_TRUE_DIVIDE 29 -#define MATCH_SEQ 30 -#define MATCH_MAP 31 -#define MATCH_MAP_KEYS 32 #define RERAISE 48 #define WITH_EXCEPT_START 49 #define GET_AITER 50 @@ -131,11 +128,14 @@ extern "C" { #define DICT_MERGE 164 #define DICT_UPDATE 165 #define MATCH 166 -#define MATCH_LEN_EQ 171 -#define MATCH_LEN_GE 172 -#define MATCH_SEQ_SLICE 173 -#define MATCH_SEQ_ITEM 174 -#define MATCH_SEQ_ITEM_END 175 +#define MATCH_MAP 167 +#define MATCH_MAP_KEYS 168 +#define MATCH_LEN_EQ 169 +#define MATCH_LEN_GE 170 +#define MATCH_SEQ 171 +#define MATCH_SEQ_ITEM 172 +#define MATCH_SEQ_ITEM_END 173 +#define MATCH_SEQ_SLICE 174 /* EXCEPT_HANDLER is a special, implicit block type which is created when entering an except handler. It is not an opcode but we define it here diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 852c05eb14dd71..0d44b785271806 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3456 (add MATCH* opcodes) +# Python 3.10a0 3458 (add MATCH* opcodes) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3456).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3458).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index 59a31b61099102..d215002af4bec7 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -83,10 +83,6 @@ def jabs_op(name, op): def_op('INPLACE_FLOOR_DIVIDE', 28) def_op('INPLACE_TRUE_DIVIDE', 29) -def_op('MATCH_SEQ', 30) -def_op('MATCH_MAP', 31) -def_op('MATCH_MAP_KEYS', 32) - def_op('RERAISE', 48) def_op('WITH_EXCEPT_START', 49) def_op('GET_AITER', 50) @@ -218,12 +214,14 @@ def jabs_op(name, op): def_op('DICT_MERGE', 164) def_op('DICT_UPDATE', 165) -jrel_op('MATCH', 166) - -def_op('MATCH_LEN_EQ', 171) -def_op('MATCH_LEN_GE', 172) -def_op('MATCH_SEQ_SLICE', 173) -def_op('MATCH_SEQ_ITEM', 174) -def_op('MATCH_SEQ_ITEM_END', 175) +def_op('MATCH', 166) +def_op('MATCH_MAP', 167) +def_op('MATCH_MAP_KEYS', 168) +def_op('MATCH_LEN_EQ', 169) +def_op('MATCH_LEN_GE', 170) +def_op('MATCH_SEQ', 171) +def_op('MATCH_SEQ_ITEM', 172) +def_op('MATCH_SEQ_ITEM_END', 173) +def_op('MATCH_SEQ_SLICE', 174) del def_op, name_op, jrel_op, jabs_op diff --git a/Python/ceval.c b/Python/ceval.c index 57c7f0ba2d9312..80ea2c5fde0d0e 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -896,14 +896,14 @@ match_seq(PyObject *target) } static PyObject* -match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) +match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, int pop) { - assert(PyDict_CheckExact(map)); + assert(pop ? PyDict_CheckExact(map) : 1); assert(PyTuple_CheckExact(keys)); Py_ssize_t nkeys = PyTuple_GET_SIZE(keys); PyObject *seen = NULL; PyObject *values = NULL; - if (PyDict_GET_SIZE(map) < nkeys) { + if (PyMapping_Length(map) < nkeys) { goto fail; } seen = PySet_New(NULL); @@ -924,13 +924,16 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) } goto fail; } - PyObject *value = PyDict_GetItemWithError(map, key); + if (!PyMapping_HasKey(map, key)) { + goto fail; + } + PyObject *value = PyObject_GetItem(map, key); if (!value) { goto fail; } Py_INCREF(value); PyTuple_SET_ITEM(values, i, value); - if (PyDict_DelItem(map, key)) { + if (pop && PyDict_DelItem(map, key)) { goto fail; } } @@ -943,12 +946,12 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) } static Py_ssize_t -get_match_args_required(PyThreadState *tstate, PyObject *proxy) +get_match_args_required(PyThreadState *tstate, PyObject *type) { - if (!PyObject_HasAttrString(proxy, "__match_args_required__")) { + if (!PyObject_HasAttrString(type, "__match_args_required__")) { return 0; } - PyObject *mar = PyObject_GetAttrString(proxy, "__match_args_required__"); + PyObject *mar = PyObject_GetAttrString(type, "__match_args_required__"); if (!mar) { return -1; } @@ -973,26 +976,28 @@ get_match_args_required(PyThreadState *tstate, PyObject *proxy) } static PyObject * -get_match_args(PyThreadState *tstate, PyObject *proxy) +get_match_args(PyThreadState *tstate, PyObject *type) { - if (!PyObject_HasAttrString(proxy, "__match_args__")) { + if (!PyObject_HasAttrString(type, "__match_args__")) { Py_RETURN_NONE; } - PyObject *ma = PyObject_GetAttrString(proxy, "__match_args__"); + PyObject *ma = PyObject_GetAttrString(type, "__match_args__"); if (!ma) { return NULL; } // TODO: PySequence_FAST // TODO We should probably just check for string items here // TODO: Allow duplicate items? Hm... - if (PyList_CheckExact(ma)) { - return PyList_AsTuple(ma); - } - if (ma == Py_None) { + if (PyTuple_CheckExact(ma) || ma == Py_None) { return ma; } + if (PyList_CheckExact(ma)) { + PyObject *tuple = PyList_AsTuple(ma); + Py_DECREF(ma); + return tuple; + } _PyErr_Format(tstate, PyExc_TypeError, - "__match_args__ must be a list or None (got %s)", + "__match_args__ must be a list, tuple, or None (got %s)", Py_TYPE(ma)->tp_name); Py_DECREF(ma); return NULL; @@ -1028,7 +1033,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty Py_ssize_t nkwargs = PyTuple_GET_SIZE(kwargs); Py_ssize_t nargs = count - nkwargs; PyObject *args; - PyObject *match_args = get_match_args(tstate, proxy); + PyObject *match_args = get_match_args(tstate, type); if (!match_args) { Py_DECREF(proxy); return NULL; @@ -1083,7 +1088,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty Py_DECREF(attrs); return NULL; } - Py_ssize_t required = get_match_args_required(tstate, proxy); + Py_ssize_t required = get_match_args_required(tstate, type); if (required < 0) { goto error; } @@ -1135,7 +1140,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty name = PyTuple_GET_ITEM(args, i); if (!PyUnicode_CheckExact(name)) { _PyErr_Format(tstate, PyExc_TypeError, - "__match_args__ elements must be str (got %s)", + "__match_args__ elements must be strings (got %s)", Py_TYPE(name)->tp_name); goto error; } @@ -3637,7 +3642,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(MATCH_MAP_KEYS): { PyObject *keys = TOP(); PyObject *target = SECOND(); - PyObject *values = match_map_items(tstate, target, keys); + PyObject *values = match_map_items(tstate, target, keys, oparg); if (!values) { if (_PyErr_Occurred(tstate)) { goto error; @@ -3657,66 +3662,29 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_SEQ_ITEM): { - PyObject *target = TOP(); - PyObject *item; - if (PyTuple_CheckExact(target)) { - assert(oparg < PyTuple_GET_SIZE(target)); - item = PyTuple_GET_ITEM(target, oparg); - } - else if (PyList_CheckExact(target)) { - assert(oparg < PyList_GET_SIZE(target)); - item = PyList_GET_ITEM(target, oparg); - } - else { - // TODO - Py_UNREACHABLE(); + PyObject *item = PySequence_GetItem(TOP(), oparg); + if (!item) { + goto error; } - Py_INCREF(item); PUSH(item); DISPATCH(); } case TARGET(MATCH_SEQ_ITEM_END): { - PyObject *target = TOP(); - PyObject *item; - if (PyTuple_CheckExact(target)) { - Py_ssize_t i = PyTuple_GET_SIZE(target) - 1 - oparg; - assert(i >= 0); - item = PyTuple_GET_ITEM(target, i); - } - else if (PyList_CheckExact(target)) { - Py_ssize_t i = PyList_GET_SIZE(target) - 1 - oparg; - assert(i >= 0); - item = PyList_GET_ITEM(target, i); - } - else { - // TODO - Py_UNREACHABLE(); + PyObject *item = PySequence_GetItem(TOP(), -oparg - 1); + if (!item) { + goto error; } - Py_INCREF(item); PUSH(item); DISPATCH(); } case TARGET(MATCH_SEQ_SLICE): { PyObject *target = TOP(); - assert(PyList_CheckExact(target) || PyTuple_CheckExact(target)); - Py_ssize_t pre = oparg >> 16; - Py_ssize_t post = oparg & 0xFF; - PyObject *slice; - if (PyList_CheckExact(target)) { - post = PyList_GET_SIZE(target) - post; - slice = PyList_GetSlice(target, pre, post); - } - else { - post = PyTuple_GET_SIZE(target) - post; - PyObject *tslice = PyTuple_GetSlice(target, pre, post); - if (!tslice) { - goto error; - } - slice = PySequence_List(tslice); - Py_DECREF(tslice); - } + assert(PyList_CheckExact(target)); + Py_ssize_t start = oparg >> 16; + Py_ssize_t stop = PyList_GET_SIZE(target) - (oparg & 0xFF); + PyObject *slice = PyList_GetSlice(target, start, stop); if (!slice) { goto error; } @@ -3725,28 +3693,18 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_LEN_EQ): { - PyObject *target = TOP(); - Py_ssize_t len; - if (PyDict_CheckExact(target)) { - len = PyDict_GET_SIZE(target); - } - else { - assert(PyList_CheckExact(target) || PyTuple_CheckExact(target)); - len = PySequence_Fast_GET_SIZE(target); + Py_ssize_t len = PyObject_Length(TOP()); + if (len < 0) { + goto error; } PUSH(PyBool_FromLong(len == oparg)); DISPATCH(); } case TARGET(MATCH_LEN_GE): { - PyObject *target = TOP(); - Py_ssize_t len; - if (PyDict_CheckExact(target)) { - len = PyDict_GET_SIZE(target); - } - else { - assert(PyList_CheckExact(target) || PyTuple_CheckExact(target)); - len = PySequence_Fast_GET_SIZE(target); + Py_ssize_t len = PyObject_Length(TOP()); + if (len < 0) { + goto error; } PUSH(PyBool_FromLong(len >= oparg)); DISPATCH(); @@ -3758,7 +3716,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (match < 0) { goto error; } - if (match) { + if (match && oparg) { PyObject *map; if (PyDict_CheckExact(target)) { map = PyDict_Copy(target); @@ -3786,8 +3744,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (match < 0) { goto error; } - if (match) { - PyObject *seq = PySequence_Fast(target, "TODO"); // TODO + // TODO: Really needed? + if (match && oparg && !PyList_CheckExact(target)) { + PyObject *seq = PySequence_List(target); if (!seq) { goto error; } diff --git a/Python/compile.c b/Python/compile.c index b315ff232ea2e0..c402be9bd6428c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2847,7 +2847,7 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje asdl_seq *values = p->v.Dict.values; Py_ssize_t size = asdl_seq_LEN(values); int star = size ? !asdl_seq_GET(keys, size - 1) : 0; - ADDOP(c, MATCH_MAP); + ADDOP_I(c, MATCH_MAP, star); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); if (size - star) { ADDOP_I(c, MATCH_LEN_GE, size - star); @@ -2865,7 +2865,7 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje VISIT(c, expr, asdl_seq_GET(keys, i)); } ADDOP_I(c, BUILD_TUPLE, size - star); - ADDOP(c, MATCH_MAP_KEYS); + ADDOP_I(c, MATCH_MAP_KEYS, star); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block_star) for (i = 0; i < size - star; i++) { expr_ty value = asdl_seq_GET(values, i); @@ -2979,6 +2979,7 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj asdl_seq *values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; Py_ssize_t size = asdl_seq_LEN(values); Py_ssize_t star = -1; + int copy = 0; for (Py_ssize_t i = 0; i < size; i++) { expr_ty value = asdl_seq_GET(values, i); if (value->kind != Starred_kind) { @@ -2988,11 +2989,12 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj return compiler_error(c, "multiple starred names in pattern"); } star = i; + copy = !WILDCARD_CHECK(value->v.Starred.value); } basicblock *block, *end; CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); - ADDOP(c, MATCH_SEQ); + ADDOP_I(c, MATCH_SEQ, copy); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); if (star >= 0) { if (size) { diff --git a/Python/importlib_external.h b/Python/importlib_external.h index c6f280a81cf625..e6832dacfafacc 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,128,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,130,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index b13933d5377b25..7ae6c1f20d17bf 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -29,9 +29,9 @@ static void *opcode_targets[256] = { &&TARGET_BINARY_TRUE_DIVIDE, &&TARGET_INPLACE_FLOOR_DIVIDE, &&TARGET_INPLACE_TRUE_DIVIDE, - &&TARGET_MATCH_SEQ, - &&TARGET_MATCH_MAP, - &&TARGET_MATCH_MAP_KEYS, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, @@ -166,15 +166,15 @@ static void *opcode_targets[256] = { &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, &&TARGET_MATCH, - &&_unknown_opcode, - &&_unknown_opcode, - &&_unknown_opcode, - &&_unknown_opcode, + &&TARGET_MATCH_MAP, + &&TARGET_MATCH_MAP_KEYS, &&TARGET_MATCH_LEN_EQ, &&TARGET_MATCH_LEN_GE, - &&TARGET_MATCH_SEQ_SLICE, + &&TARGET_MATCH_SEQ, &&TARGET_MATCH_SEQ_ITEM, &&TARGET_MATCH_SEQ_ITEM_END, + &&TARGET_MATCH_SEQ_SLICE, + &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From db054a6c33f56371a703fe6df0f958f4814f5830 Mon Sep 17 00:00:00 2001 From: Talin Date: Wed, 17 Jun 2020 20:55:50 -0700 Subject: [PATCH 089/189] Match support for namedtuple. --- Lib/collections/__init__.py | 1 + Lib/test/test_collections.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index 42d0ec777c3f75..f692a4afbb1d15 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -489,6 +489,7 @@ def __getnewargs__(self): '__repr__': __repr__, '_asdict': _asdict, '__getnewargs__': __getnewargs__, + '__match_args__': field_names, } for index, name in enumerate(field_names): doc = _sys.intern(f'Alias for field number {index}') diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 7c7f8655b0fbdd..a1fc42ae1e8f53 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -665,6 +665,10 @@ class NewPoint(tuple): self.assertEqual(np.x, 1) self.assertEqual(np.y, 2) + def test_match_args(self): + Point = namedtuple('Point', 'x y') + self.assertEqual(Point.__match_args__, ('x', 'y')) # matches a real tuple + ################################################################################ ### Abstract Base Classes From db4a9b07cd070c66e0f1bae163b112faf8418d48 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 22 Jun 2020 09:38:35 -0700 Subject: [PATCH 090/189] Lose __match_args_required__, speed up MATCH_SEQ --- Python/ceval.c | 76 ++------------------------------------------------ 1 file changed, 3 insertions(+), 73 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 80ea2c5fde0d0e..4cde34b3be9cac 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -887,11 +887,11 @@ match_seq(PyObject *target) } } return ( - PyObject_IsInstance(target, interp->seq_abc) + !PyType_FastSubclass(Py_TYPE(target), + Py_TPFLAGS_UNICODE_SUBCLASS | Py_TPFLAGS_BYTES_SUBCLASS) && !PyIter_Check(target) - && !PyUnicode_Check(target) - && !PyBytes_Check(target) && !PyByteArray_Check(target) + && PyObject_IsInstance(target, interp->seq_abc) ); } @@ -945,36 +945,6 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, int pop) return NULL; } -static Py_ssize_t -get_match_args_required(PyThreadState *tstate, PyObject *type) -{ - if (!PyObject_HasAttrString(type, "__match_args_required__")) { - return 0; - } - PyObject *mar = PyObject_GetAttrString(type, "__match_args_required__"); - if (!mar) { - return -1; - } - if (!PyLong_CheckExact(mar)) { - _PyErr_Format(tstate, PyExc_TypeError, - "__match_args_required__ must be an int (got %s)", - Py_TYPE(mar)->tp_name); - Py_DECREF(mar); - return -1; - } - Py_ssize_t required = PyLong_AsSsize_t(mar); - Py_DECREF(mar); - if (required < 0) { - if (!_PyErr_Occurred(tstate)) { - _PyErr_Format(tstate, PyExc_TypeError, - "__match_args_required__ must be nonnegative (got %d)", - required); - } - return -1; - } - return required; -} - static PyObject * get_match_args(PyThreadState *tstate, PyObject *type) { @@ -1088,46 +1058,6 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty Py_DECREF(attrs); return NULL; } - Py_ssize_t required = get_match_args_required(tstate, type); - if (required < 0) { - goto error; - } - if ((match_args == Py_None ? 1 : PyTuple_GET_SIZE(match_args)) < required) { - _PyErr_Format(tstate, PyExc_TypeError, - "__match_args_required__ is larger than __match_args__", - proxy); - goto error; - } - if (required > count) { - // TODO: combine with below? Use name? - _PyErr_Format(tstate, PyExc_TypeError, - "not enough match arguments provided"); - goto error; - } - if (required > nargs) { - if (match_args == Py_None) { - assert(required == 1); - assert(!nargs); - // TODO: combine with above? Use name? - _PyErr_Format(tstate, PyExc_TypeError, - "not enough match arguments provided"); - goto error; - } - assert(PyTuple_CheckExact(match_args)); - for (Py_ssize_t i = nargs; i < required; i++) { - PyObject *name = PyTuple_GET_ITEM(match_args, i); - int ok = PySequence_Contains(kwargs, name); - if (ok < 0) { - goto error; - } - if (!ok) { - // TODO: Combine with above? Use name? - _PyErr_Format(tstate, PyExc_TypeError, - "not enough match arguments provided"); - goto error; - } - } - } PyObject *name; for (Py_ssize_t i = 0; i < count; i++) { if (i < nargs) { From 48f18ebdfc9b1d0adc2e86e110bfc605834eaf31 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 22 Jun 2020 14:05:43 -0700 Subject: [PATCH 091/189] Remove a bunch of new opcodes --- Doc/library/dis.rst | 30 +------------- Include/opcode.h | 8 +--- Lib/importlib/_bootstrap_external.py | 4 +- Lib/opcode.py | 8 +--- Python/ceval.c | 57 ++++--------------------- Python/compile.c | 62 ++++++++++++++++++++-------- Python/importlib_external.h | 2 +- Python/opcode_targets.h | 12 +++--- 8 files changed, 65 insertions(+), 118 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 7e69c8ea699e6a..de0e91d42605bf 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1217,35 +1217,7 @@ All of the following opcodes use their arguments. .. versionadded:: 3.10 -.. opcode:: MATCH_SEQ_ITEM (i) - - TODO - - .. versionadded:: 3.10 - - -.. opcode:: MATCH_SEQ_ITEM_END (i) - - TODO - - .. versionadded:: 3.10 - - -.. opcode:: MATCH_SEQ_ITEM_SLICE (ij) - - TODO - - .. versionadded:: 3.10 - - -.. opcode:: MATCH_LEN_EQ (size) - - TODO - - .. versionadded:: 3.10 - - -.. opcode:: MATCH_LEN_GE (size) +.. opcode:: GET_LEN TODO diff --git a/Include/opcode.h b/Include/opcode.h index 7bfa59812e2b80..20cc909cab98fe 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -13,6 +13,7 @@ extern "C" { #define DUP_TOP 4 #define DUP_TOP_TWO 5 #define ROT_FOUR 6 +#define GET_LEN 7 #define NOP 9 #define UNARY_POSITIVE 10 #define UNARY_NEGATIVE 11 @@ -130,12 +131,7 @@ extern "C" { #define MATCH 166 #define MATCH_MAP 167 #define MATCH_MAP_KEYS 168 -#define MATCH_LEN_EQ 169 -#define MATCH_LEN_GE 170 -#define MATCH_SEQ 171 -#define MATCH_SEQ_ITEM 172 -#define MATCH_SEQ_ITEM_END 173 -#define MATCH_SEQ_SLICE 174 +#define MATCH_SEQ 169 /* EXCEPT_HANDLER is a special, implicit block type which is created when entering an except handler. It is not an opcode but we define it here diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 0d44b785271806..dd7465108bbd4d 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3458 (add MATCH* opcodes) +# Python 3.10a0 3460 (add structural pattern matching) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3458).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3461).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index d215002af4bec7..1f0b2283afdc44 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -60,6 +60,7 @@ def jabs_op(name, op): def_op('DUP_TOP', 4) def_op('DUP_TOP_TWO', 5) def_op('ROT_FOUR', 6) +def_op('GET_LEN', 7) def_op('NOP', 9) def_op('UNARY_POSITIVE', 10) @@ -217,11 +218,6 @@ def jabs_op(name, op): def_op('MATCH', 166) def_op('MATCH_MAP', 167) def_op('MATCH_MAP_KEYS', 168) -def_op('MATCH_LEN_EQ', 169) -def_op('MATCH_LEN_GE', 170) -def_op('MATCH_SEQ', 171) -def_op('MATCH_SEQ_ITEM', 172) -def_op('MATCH_SEQ_ITEM_END', 173) -def_op('MATCH_SEQ_SLICE', 174) +def_op('MATCH_SEQ', 169) del def_op, name_op, jrel_op, jabs_op diff --git a/Python/ceval.c b/Python/ceval.c index 4cde34b3be9cac..f32438561a396b 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3591,52 +3591,17 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(MATCH_SEQ_ITEM): { - PyObject *item = PySequence_GetItem(TOP(), oparg); - if (!item) { - goto error; - } - PUSH(item); - DISPATCH(); - } - - case TARGET(MATCH_SEQ_ITEM_END): { - PyObject *item = PySequence_GetItem(TOP(), -oparg - 1); - if (!item) { - goto error; - } - PUSH(item); - DISPATCH(); - } - - case TARGET(MATCH_SEQ_SLICE): { + case TARGET(GET_LEN): { PyObject *target = TOP(); - assert(PyList_CheckExact(target)); - Py_ssize_t start = oparg >> 16; - Py_ssize_t stop = PyList_GET_SIZE(target) - (oparg & 0xFF); - PyObject *slice = PyList_GetSlice(target, start, stop); - if (!slice) { - goto error; - } - PUSH(slice); - DISPATCH(); - } - - case TARGET(MATCH_LEN_EQ): { - Py_ssize_t len = PyObject_Length(TOP()); - if (len < 0) { + Py_ssize_t l = PyObject_Length(target); + if (l < 0) { goto error; } - PUSH(PyBool_FromLong(len == oparg)); - DISPATCH(); - } - - case TARGET(MATCH_LEN_GE): { - Py_ssize_t len = PyObject_Length(TOP()); - if (len < 0) { + PyObject *len = PyLong_FromSsize_t(l); + if (!len) { goto error; } - PUSH(PyBool_FromLong(len >= oparg)); + PUSH(len); DISPATCH(); } @@ -3646,6 +3611,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (match < 0) { goto error; } + // TODO: Move to MATCH_MAP_ITEMS: if (match && oparg) { PyObject *map; if (PyDict_CheckExact(target)) { @@ -3674,15 +3640,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (match < 0) { goto error; } - // TODO: Really needed? - if (match && oparg && !PyList_CheckExact(target)) { - PyObject *seq = PySequence_List(target); - if (!seq) { - goto error; - } - SET_TOP(seq); - Py_DECREF(target); - } PUSH(PyBool_FromLong(match)); DISPATCH(); } diff --git a/Python/compile.c b/Python/compile.c index c402be9bd6428c..90a7bd35d74ea5 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1106,13 +1106,9 @@ stack_effect(int opcode, int oparg, int jump) case MATCH: return -1; case MATCH_MAP_KEYS: - case MATCH_LEN_EQ: - case MATCH_LEN_GE: + case GET_LEN: case MATCH_MAP: case MATCH_SEQ: - case MATCH_SEQ_ITEM: - case MATCH_SEQ_ITEM_END: - case MATCH_SEQ_SLICE: return 1; default: return PY_INVALID_STACK_EFFECT; @@ -2797,7 +2793,9 @@ compiler_pattern_call(struct compiler *c, expr_ty p, basicblock *fail, PyObject* if (WILDCARD_CHECK(arg)) { continue; } - ADDOP_I(c, MATCH_SEQ_ITEM, i); + ADDOP(c, DUP_TOP); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); + ADDOP(c, BINARY_SUBSCR); CHECK(compiler_pattern(c, arg, block, names)); } for (i = 0; i < nkwargs; i++) { @@ -2805,7 +2803,9 @@ compiler_pattern_call(struct compiler *c, expr_ty p, basicblock *fail, PyObject* if (WILDCARD_CHECK(kwarg->value)) { continue; } - ADDOP_I(c, MATCH_SEQ_ITEM, nargs + i); + ADDOP(c, DUP_TOP); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(nargs + i)); + ADDOP(c, BINARY_SUBSCR); CHECK(compiler_pattern(c, kwarg->value, block, names)); } ADDOP(c, POP_TOP); @@ -2850,7 +2850,9 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje ADDOP_I(c, MATCH_MAP, star); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); if (size - star) { - ADDOP_I(c, MATCH_LEN_GE, size - star); + ADDOP(c, GET_LEN); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - star)); + ADDOP_COMPARE(c, GtE); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); } Py_ssize_t i; @@ -2872,7 +2874,9 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje if (WILDCARD_CHECK(value)) { continue; } - ADDOP_I(c, MATCH_SEQ_ITEM, i); + ADDOP(c, DUP_TOP); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); + ADDOP(c, BINARY_SUBSCR); CHECK(compiler_pattern(c, value, block_star, names)); } ADDOP(c, POP_TOP); @@ -2979,7 +2983,6 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj asdl_seq *values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; Py_ssize_t size = asdl_seq_LEN(values); Py_ssize_t star = -1; - int copy = 0; for (Py_ssize_t i = 0; i < size; i++) { expr_ty value = asdl_seq_GET(values, i); if (value->kind != Starred_kind) { @@ -2989,21 +2992,24 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj return compiler_error(c, "multiple starred names in pattern"); } star = i; - copy = !WILDCARD_CHECK(value->v.Starred.value); } basicblock *block, *end; CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); - ADDOP_I(c, MATCH_SEQ, copy); + ADDOP_I(c, MATCH_SEQ, 0); // TODO: No arg ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); if (star >= 0) { if (size) { - ADDOP_I(c, MATCH_LEN_GE, size - 1); + ADDOP(c, GET_LEN); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - 1)); + ADDOP_COMPARE(c, GtE); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); } } else { - ADDOP_I(c, MATCH_LEN_EQ, size); + ADDOP(c, GET_LEN); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)); + ADDOP_COMPARE(c, Eq); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); } for (Py_ssize_t i = 0; i < size; i++) { @@ -3012,7 +3018,9 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj continue; } if (star < 0 || i < star) { - ADDOP_I(c, MATCH_SEQ_ITEM, i); + ADDOP(c, DUP_TOP); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); + ADDOP(c, BINARY_SUBSCR); } else if (i == star) { assert(value->kind == Starred_kind); @@ -3020,11 +3028,29 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj if (WILDCARD_CHECK(value)) { continue; } - // TODO: ERROR CHECKING FOR THESE: - ADDOP_I(c, MATCH_SEQ_SLICE, (i << 16) + (size - 1 - i)); + ADDOP(c, DUP_TOP); + ADDOP_I(c, BUILD_LIST, 0); + ADDOP(c, ROT_TWO); + if (i) { + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); + } + else { + ADDOP_LOAD_CONST(c, Py_None); + } + if (i != size - 1) { + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(-(size - 1 - i))); + } + else { + ADDOP_LOAD_CONST(c, Py_None); + } + ADDOP_I(c, BUILD_SLICE, 2); + ADDOP(c, BINARY_SUBSCR); + ADDOP_I(c, LIST_EXTEND, 1); } else { - ADDOP_I(c, MATCH_SEQ_ITEM_END, size - 1 - i); + ADDOP(c, DUP_TOP); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(-(size - i))); + ADDOP(c, BINARY_SUBSCR); } CHECK(compiler_pattern(c, value, block, names)); } diff --git a/Python/importlib_external.h b/Python/importlib_external.h index e6832dacfafacc..9535776c479e66 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,130,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,133,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 7ae6c1f20d17bf..c662fe1f6b38de 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -6,7 +6,7 @@ static void *opcode_targets[256] = { &&TARGET_DUP_TOP, &&TARGET_DUP_TOP_TWO, &&TARGET_ROT_FOUR, - &&_unknown_opcode, + &&TARGET_GET_LEN, &&_unknown_opcode, &&TARGET_NOP, &&TARGET_UNARY_POSITIVE, @@ -168,12 +168,12 @@ static void *opcode_targets[256] = { &&TARGET_MATCH, &&TARGET_MATCH_MAP, &&TARGET_MATCH_MAP_KEYS, - &&TARGET_MATCH_LEN_EQ, - &&TARGET_MATCH_LEN_GE, &&TARGET_MATCH_SEQ, - &&TARGET_MATCH_SEQ_ITEM, - &&TARGET_MATCH_SEQ_ITEM_END, - &&TARGET_MATCH_SEQ_SLICE, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From 0c8265502b6e2cfb118498f8496821d1d7530dba Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 22 Jun 2020 15:56:34 -0700 Subject: [PATCH 092/189] Don't raise if no __match_args__ --- Python/ceval.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Python/ceval.c b/Python/ceval.c index f32438561a396b..22bfd92667c9f5 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1088,9 +1088,10 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty } PyObject *attr = PyObject_GetAttr(proxy, name); if (!attr) { + // TODO: Only clear AttributeError? _PyErr_Clear(tstate); // TODO: iterate manually (and check for strings) - if (match_args == Py_None || !PySequence_Contains(match_args, name)) { + if (match_args != Py_None && !PySequence_Contains(match_args, name)) { _PyErr_Format(tstate, PyExc_TypeError, "match proxy %R has no attribute %R", proxy, name); From ef35201334c1158f42959acda96a0bd360e82953 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 23 Jun 2020 08:07:44 -0700 Subject: [PATCH 093/189] Add ImpossibleMatchError --- Doc/c-api/exceptions.rst | 3 +++ Doc/library/exceptions.rst | 8 ++++++++ Include/pyerrors.h | 1 + Lib/test/exception_hierarchy.txt | 1 + Objects/exceptions.c | 9 +++++++++ Python/ceval.c | 12 ++++++------ 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index e7805ba143c584..59b363f2fbd2d8 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -796,6 +796,7 @@ the variables: single: PyExc_FloatingPointError single: PyExc_GeneratorExit single: PyExc_ImportError + single: PyExc_ImpossibleMatchError single: PyExc_IndentationError single: PyExc_IndexError single: PyExc_InterruptedError @@ -872,6 +873,8 @@ the variables: +-----------------------------------------+---------------------------------+----------+ | :c:data:`PyExc_ImportError` | :exc:`ImportError` | | +-----------------------------------------+---------------------------------+----------+ +| :c:data:`PyExc_ImpossibleMatchError` | :exc:`ImpossibleMatchError` | | ++-----------------------------------------+---------------------------------+----------+ | :c:data:`PyExc_IndentationError` | :exc:`IndentationError` | | +-----------------------------------------+---------------------------------+----------+ | :c:data:`PyExc_IndexError` | :exc:`IndexError` | | diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index df2cda9d67ad15..70c84a382204e0 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -179,6 +179,14 @@ The following exceptions are the exceptions that are usually raised. .. versionchanged:: 3.3 Added the :attr:`name` and :attr:`path` attributes. + +.. exception:: ImpossibleMatchError + + TODO + + .. versionadded:: 3.10 + + .. exception:: ModuleNotFoundError A subclass of :exc:`ImportError` which is raised by :keyword:`import` diff --git a/Include/pyerrors.h b/Include/pyerrors.h index 979a26ba68a033..4a47d774a2c615 100644 --- a/Include/pyerrors.h +++ b/Include/pyerrors.h @@ -107,6 +107,7 @@ PyAPI_DATA(PyObject *) PyExc_ReferenceError; PyAPI_DATA(PyObject *) PyExc_SystemError; PyAPI_DATA(PyObject *) PyExc_SystemExit; PyAPI_DATA(PyObject *) PyExc_TypeError; +PyAPI_DATA(PyObject *) PyExc_ImpossibleMatchError; PyAPI_DATA(PyObject *) PyExc_UnboundLocalError; PyAPI_DATA(PyObject *) PyExc_UnicodeError; PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError; diff --git a/Lib/test/exception_hierarchy.txt b/Lib/test/exception_hierarchy.txt index 763a6c899b48eb..ac349aadea63fa 100644 --- a/Lib/test/exception_hierarchy.txt +++ b/Lib/test/exception_hierarchy.txt @@ -46,6 +46,7 @@ BaseException | +-- TabError +-- SystemError +-- TypeError + | +-- ImpossibleMatchError +-- ValueError | +-- UnicodeError | +-- UnicodeDecodeError diff --git a/Objects/exceptions.c b/Objects/exceptions.c index db5e3da12b00f3..4c2e2cc863c2ff 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -487,6 +487,13 @@ SimpleExtendsException(PyExc_Exception, TypeError, "Inappropriate argument type."); +/* + * ImpossibleMatchError extends TypeError + */ +SimpleExtendsException(PyExc_TypeError, ImpossibleMatchError, + "Incorrect use of a match-case statement."); + + /* * StopAsyncIteration extends Exception */ @@ -2529,6 +2536,7 @@ _PyExc_Init(void) PRE_INIT(BaseException); PRE_INIT(Exception); PRE_INIT(TypeError); + PRE_INIT(ImpossibleMatchError); PRE_INIT(StopAsyncIteration); PRE_INIT(StopIteration); PRE_INIT(GeneratorExit); @@ -2664,6 +2672,7 @@ _PyBuiltins_AddExceptions(PyObject *bltinmod) POST_INIT(BaseException); POST_INIT(Exception); POST_INIT(TypeError); + POST_INIT(ImpossibleMatchError); POST_INIT(StopAsyncIteration); POST_INIT(StopIteration); POST_INIT(GeneratorExit); diff --git a/Python/ceval.c b/Python/ceval.c index 245f11905fefdc..397440eaf357b5 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -919,7 +919,7 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, int pop) int dupe = PySet_Contains(seen, key); if (dupe || PySet_Add(seen, key)) { if (!_PyErr_Occurred(tstate)) { - _PyErr_Format(tstate, PyExc_ValueError, + _PyErr_Format(tstate, PyExc_ImpossibleMatchError, "mapping pattern checks duplicate key (%R)", key); } goto fail; @@ -987,7 +987,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty if (!method || method == Py_None) { Py_XDECREF(method); _PyErr_Clear(tstate); - _PyErr_Format(tstate, PyExc_TypeError, + _PyErr_Format(tstate, PyExc_ImpossibleMatchError, "type %s cannot be matched", Py_TYPE(type)->tp_name); return NULL; @@ -1015,7 +1015,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty Py_DECREF(match_args); Py_DECREF(proxy); // TODO: Add expected and actual counts: - _PyErr_SetString(tstate, PyExc_TypeError, + _PyErr_SetString(tstate, PyExc_ImpossibleMatchError, "too many positional matches in pattern"); return NULL; } @@ -1027,7 +1027,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty Py_DECREF(match_args); Py_DECREF(proxy); // TODO: Add expected and actual counts: - _PyErr_SetString(tstate, PyExc_TypeError, + _PyErr_SetString(tstate, PyExc_ImpossibleMatchError, "too many positional matches in pattern"); return NULL; } @@ -1081,7 +1081,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty int dupe = PySet_Contains(seen, name); if (dupe || PySet_Add(seen, name)) { if (!_PyErr_Occurred(tstate)) { - _PyErr_Format(tstate, PyExc_TypeError, + _PyErr_Format(tstate, PyExc_ImpossibleMatchError, "multiple patterns bound to attribute %R", name); } goto error; @@ -1092,7 +1092,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty _PyErr_Clear(tstate); // TODO: iterate manually (and check for strings) if (match_args != Py_None && !PySequence_Contains(match_args, name)) { - _PyErr_Format(tstate, PyExc_TypeError, + _PyErr_Format(tstate, PyExc_ImpossibleMatchError, "match proxy %R has no attribute %R", proxy, name); goto error; From 276c2b08270861f939f79b6ceec995effe83073f Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 23 Jun 2020 09:28:55 -0700 Subject: [PATCH 094/189] Clean up opcodes and fix pickle tests --- Doc/library/dis.rst | 44 +++++++-------- Include/opcode.h | 10 ++-- Lib/_compat_pickle.py | 9 +++ Lib/importlib/_bootstrap_external.py | 4 +- Lib/opcode.py | 29 +++------- Lib/test/test_pickle.py | 8 +++ Python/ceval.c | 84 +++++++++++++++------------- Python/compile.c | 4 +- Python/importlib_external.h | 2 +- Python/opcode_targets.h | 20 +++---- 10 files changed, 112 insertions(+), 102 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index de0e91d42605bf..dabfbab8fda89f 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -751,6 +751,27 @@ iterations of the loop. .. versionadded:: 3.2 +.. opcode:: GET_LEN + + TODO + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_MAP + + TODO + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_SEQ + + TODO + + .. versionadded:: 3.10 + + All of the following opcodes use their arguments. .. opcode:: STORE_NAME (namei) @@ -1196,28 +1217,7 @@ All of the following opcodes use their arguments. .. versionadded:: 3.10 -.. opcode:: MATCH_MAP - - TODO - - .. versionadded:: 3.10 - - -.. opcode:: MATCH_MAP_KEYS - - TODO - - .. versionadded:: 3.10 - - -.. opcode:: MATCH_SEQ - - TODO - - .. versionadded:: 3.10 - - -.. opcode:: GET_LEN +.. opcode:: MATCH_MAP_KEYS (copy) TODO diff --git a/Include/opcode.h b/Include/opcode.h index 20cc909cab98fe..2ed13d455ccc70 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -13,7 +13,6 @@ extern "C" { #define DUP_TOP 4 #define DUP_TOP_TWO 5 #define ROT_FOUR 6 -#define GET_LEN 7 #define NOP 9 #define UNARY_POSITIVE 10 #define UNARY_NEGATIVE 11 @@ -31,6 +30,9 @@ extern "C" { #define BINARY_TRUE_DIVIDE 27 #define INPLACE_FLOOR_DIVIDE 28 #define INPLACE_TRUE_DIVIDE 29 +#define GET_LEN 30 +#define MATCH_MAP 31 +#define MATCH_SEQ 32 #define RERAISE 48 #define WITH_EXCEPT_START 49 #define GET_AITER 50 @@ -97,6 +99,8 @@ extern "C" { #define LOAD_GLOBAL 116 #define IS_OP 117 #define CONTAINS_OP 118 +#define MATCH 119 +#define MATCH_MAP_KEYS 120 #define JUMP_IF_NOT_EXC_MATCH 121 #define SETUP_FINALLY 122 #define LOAD_FAST 124 @@ -128,10 +132,6 @@ extern "C" { #define SET_UPDATE 163 #define DICT_MERGE 164 #define DICT_UPDATE 165 -#define MATCH 166 -#define MATCH_MAP 167 -#define MATCH_MAP_KEYS 168 -#define MATCH_SEQ 169 /* EXCEPT_HANDLER is a special, implicit block type which is created when entering an except handler. It is not an opcode but we define it here diff --git a/Lib/_compat_pickle.py b/Lib/_compat_pickle.py index f68496ae639f5f..44aa00b15333fe 100644 --- a/Lib/_compat_pickle.py +++ b/Lib/_compat_pickle.py @@ -249,3 +249,12 @@ for excname in PYTHON3_IMPORTERROR_EXCEPTIONS: REVERSE_NAME_MAPPING[('builtins', excname)] = ('exceptions', 'ImportError') + + + +PYTHON3_TYPEERROR_EXCEPTIONS = ( + 'ImpossibleMatchError', +) + +for excname in PYTHON3_TYPEERROR_EXCEPTIONS: + REVERSE_NAME_MAPPING[('builtins', excname)] = ('exceptions', 'TypeError') diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index dd7465108bbd4d..a4fe050512f5ca 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3460 (add structural pattern matching) +# Python 3.10a0 3462 (add structural pattern matching) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3461).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3462).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index 1f0b2283afdc44..1922a4a24af61f 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -60,7 +60,6 @@ def jabs_op(name, op): def_op('DUP_TOP', 4) def_op('DUP_TOP_TWO', 5) def_op('ROT_FOUR', 6) -def_op('GET_LEN', 7) def_op('NOP', 9) def_op('UNARY_POSITIVE', 10) @@ -68,7 +67,6 @@ def jabs_op(name, op): def_op('UNARY_NOT', 12) def_op('UNARY_INVERT', 15) - def_op('BINARY_MATRIX_MULTIPLY', 16) def_op('INPLACE_MATRIX_MULTIPLY', 17) @@ -83,6 +81,9 @@ def jabs_op(name, op): def_op('BINARY_TRUE_DIVIDE', 27) def_op('INPLACE_FLOOR_DIVIDE', 28) def_op('INPLACE_TRUE_DIVIDE', 29) +def_op('GET_LEN', 30) +def_op('MATCH_MAP', 31) +def_op('MATCH_SEQ', 32) def_op('RERAISE', 48) def_op('WITH_EXCEPT_START', 49) @@ -106,7 +107,6 @@ def jabs_op(name, op): def_op('INPLACE_POWER', 67) def_op('GET_ITER', 68) def_op('GET_YIELD_FROM_ITER', 69) - def_op('PRINT_EXPR', 70) def_op('LOAD_BUILD_CLASS', 71) def_op('YIELD_FROM', 72) @@ -138,6 +138,7 @@ def jabs_op(name, op): name_op('DELETE_ATTR', 96) # "" name_op('STORE_GLOBAL', 97) # "" name_op('DELETE_GLOBAL', 98) # "" + def_op('LOAD_CONST', 100) # Index in const list hasconst.append(100) name_op('LOAD_NAME', 101) # Index in name list @@ -150,19 +151,17 @@ def jabs_op(name, op): hascompare.append(107) name_op('IMPORT_NAME', 108) # Index in name list name_op('IMPORT_FROM', 109) # Index in name list - jrel_op('JUMP_FORWARD', 110) # Number of bytes to skip jabs_op('JUMP_IF_FALSE_OR_POP', 111) # Target byte offset from beginning of code jabs_op('JUMP_IF_TRUE_OR_POP', 112) # "" jabs_op('JUMP_ABSOLUTE', 113) # "" jabs_op('POP_JUMP_IF_FALSE', 114) # "" jabs_op('POP_JUMP_IF_TRUE', 115) # "" - name_op('LOAD_GLOBAL', 116) # Index in name list - def_op('IS_OP', 117) def_op('CONTAINS_OP', 118) - +def_op('MATCH', 119) +def_op('MATCH_MAP_KEYS', 120) jabs_op('JUMP_IF_NOT_EXC_MATCH', 121) jrel_op('SETUP_FINALLY', 122) # Distance to target address @@ -177,6 +176,7 @@ def jabs_op(name, op): def_op('CALL_FUNCTION', 131) # #args def_op('MAKE_FUNCTION', 132) # Flags def_op('BUILD_SLICE', 133) # Number of items + def_op('LOAD_CLOSURE', 135) hasfree.append(135) def_op('LOAD_DEREF', 136) @@ -188,36 +188,25 @@ def jabs_op(name, op): def_op('CALL_FUNCTION_KW', 141) # #args + #kwargs def_op('CALL_FUNCTION_EX', 142) # Flags - jrel_op('SETUP_WITH', 143) - +def_op('EXTENDED_ARG', 144) +EXTENDED_ARG = 144 def_op('LIST_APPEND', 145) def_op('SET_ADD', 146) def_op('MAP_ADD', 147) - def_op('LOAD_CLASSDEREF', 148) hasfree.append(148) -def_op('EXTENDED_ARG', 144) -EXTENDED_ARG = 144 - jrel_op('SETUP_ASYNC_WITH', 154) - def_op('FORMAT_VALUE', 155) def_op('BUILD_CONST_KEY_MAP', 156) def_op('BUILD_STRING', 157) name_op('LOAD_METHOD', 160) def_op('CALL_METHOD', 161) - def_op('LIST_EXTEND', 162) def_op('SET_UPDATE', 163) def_op('DICT_MERGE', 164) def_op('DICT_UPDATE', 165) -def_op('MATCH', 166) -def_op('MATCH_MAP', 167) -def_op('MATCH_MAP_KEYS', 168) -def_op('MATCH_SEQ', 169) - del def_op, name_op, jrel_op, jabs_op diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py index 2307b133dbd0d5..15da43d45d5d39 100644 --- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -421,6 +421,9 @@ def test_name_mapping(self): elif (module2, name2) == ('exceptions', 'ImportError'): attr = getattribute(module3, name3) self.assertTrue(issubclass(attr, ImportError)) + elif (module2, name2) == ('exceptions', 'TypeError'): + attr = getattribute(module3, name3) + self.assertTrue(issubclass(attr, TypeError)) else: module, name = mapping(module2, name2) if module3[:1] != '_': @@ -492,6 +495,11 @@ def test_exceptions(self): ('exceptions', 'ImportError')) self.assertEqual(mapping('exceptions', name), ('exceptions', name)) + elif exc is not TypeError and issubclass(exc, TypeError): + self.assertEqual(reverse_mapping('builtins', name), + ('exceptions', 'TypeError')) + self.assertEqual(mapping('exceptions', name), + ('exceptions', name)) else: self.assertEqual(reverse_mapping('builtins', name), ('exceptions', name)) diff --git a/Python/ceval.c b/Python/ceval.c index 397440eaf357b5..a76d2b0037345b 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -898,7 +898,26 @@ match_seq(PyObject *target) static PyObject* match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, int pop) { - assert(pop ? PyDict_CheckExact(map) : 1); + if (pop) { + PyObject *copy; + if (PyDict_CheckExact(map)) { + copy = PyDict_Copy(map); + if (!copy) { + return NULL; + } + } + else { + copy = PyDict_New(); + if (!copy || PyDict_Update(copy, map)) { + Py_XDECREF(copy); + return NULL; + } + } + map = copy; + } + else { + Py_INCREF(map); + } assert(PyTuple_CheckExact(keys)); Py_ssize_t nkeys = PyTuple_GET_SIZE(keys); PyObject *seen = NULL; @@ -938,10 +957,12 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, int pop) } } Py_DECREF(seen); + Py_DECREF(map); return values; fail: Py_XDECREF(seen); Py_XDECREF(values); + Py_DECREF(map); return NULL; } @@ -3570,6 +3591,28 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } + case TARGET(MATCH_MAP): { + PyObject *target = TOP(); + // TODO: Just move the body of this function here: + int match = match_map(target); + if (match < 0) { + goto error; + } + PUSH(PyBool_FromLong(match)); + DISPATCH(); + } + + case TARGET(MATCH_SEQ): { + PyObject *target = TOP(); + // TODO: Just move the body of this function here: + int match = match_seq(target); + if (match < 0) { + goto error; + } + PUSH(PyBool_FromLong(match)); + DISPATCH(); + } + case TARGET(MATCH_MAP_KEYS): { PyObject *keys = TOP(); PyObject *target = SECOND(); @@ -3606,45 +3649,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(MATCH_MAP): { - PyObject *target = TOP(); - int match = match_map(target); - if (match < 0) { - goto error; - } - // TODO: Move to MATCH_MAP_ITEMS: - if (match && oparg) { - PyObject *map; - if (PyDict_CheckExact(target)) { - map = PyDict_Copy(target); - if (!map) { - goto error; - } - } - else { - map = PyDict_New(); - if (!map || PyDict_Update(map, target)) { - Py_XDECREF(map); - goto error; - } - } - SET_TOP(map); - Py_DECREF(target); - } - PUSH(PyBool_FromLong(match)); - DISPATCH(); - } - - case TARGET(MATCH_SEQ): { - PyObject *target = TOP(); - int match = match_seq(target); - if (match < 0) { - goto error; - } - PUSH(PyBool_FromLong(match)); - DISPATCH(); - } - case TARGET(GET_ITER): { /* before: [obj]; after [getiter(obj)] */ PyObject *iterable = TOP(); diff --git a/Python/compile.c b/Python/compile.c index 90a7bd35d74ea5..5c4649d17ad97c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2847,7 +2847,7 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje asdl_seq *values = p->v.Dict.values; Py_ssize_t size = asdl_seq_LEN(values); int star = size ? !asdl_seq_GET(keys, size - 1) : 0; - ADDOP_I(c, MATCH_MAP, star); + ADDOP(c, MATCH_MAP); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); if (size - star) { ADDOP(c, GET_LEN); @@ -2996,7 +2996,7 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj basicblock *block, *end; CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); - ADDOP_I(c, MATCH_SEQ, 0); // TODO: No arg + ADDOP(c, MATCH_SEQ); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); if (star >= 0) { if (size) { diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 9535776c479e66..8b838f587516b9 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,133,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,134,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index c662fe1f6b38de..ca2af205f3f261 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -6,7 +6,7 @@ static void *opcode_targets[256] = { &&TARGET_DUP_TOP, &&TARGET_DUP_TOP_TWO, &&TARGET_ROT_FOUR, - &&TARGET_GET_LEN, + &&_unknown_opcode, &&_unknown_opcode, &&TARGET_NOP, &&TARGET_UNARY_POSITIVE, @@ -29,9 +29,9 @@ static void *opcode_targets[256] = { &&TARGET_BINARY_TRUE_DIVIDE, &&TARGET_INPLACE_FLOOR_DIVIDE, &&TARGET_INPLACE_TRUE_DIVIDE, - &&_unknown_opcode, - &&_unknown_opcode, - &&_unknown_opcode, + &&TARGET_GET_LEN, + &&TARGET_MATCH_MAP, + &&TARGET_MATCH_SEQ, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, @@ -118,8 +118,8 @@ static void *opcode_targets[256] = { &&TARGET_LOAD_GLOBAL, &&TARGET_IS_OP, &&TARGET_CONTAINS_OP, - &&_unknown_opcode, - &&_unknown_opcode, + &&TARGET_MATCH, + &&TARGET_MATCH_MAP_KEYS, &&TARGET_JUMP_IF_NOT_EXC_MATCH, &&TARGET_SETUP_FINALLY, &&_unknown_opcode, @@ -165,10 +165,10 @@ static void *opcode_targets[256] = { &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, - &&TARGET_MATCH, - &&TARGET_MATCH_MAP, - &&TARGET_MATCH_MAP_KEYS, - &&TARGET_MATCH_SEQ, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, + &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From 14be5cf8c752dcf4e79bcd952b45c3ffba7704bd Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 24 Jun 2020 15:07:22 -0700 Subject: [PATCH 095/189] Clean up ceval --- Lib/_compat_pickle.py | 2 - Python/ceval.c | 113 ++++++++++++++++++------------------------ 2 files changed, 49 insertions(+), 66 deletions(-) diff --git a/Lib/_compat_pickle.py b/Lib/_compat_pickle.py index 44aa00b15333fe..9038eea46c08c3 100644 --- a/Lib/_compat_pickle.py +++ b/Lib/_compat_pickle.py @@ -250,8 +250,6 @@ for excname in PYTHON3_IMPORTERROR_EXCEPTIONS: REVERSE_NAME_MAPPING[('builtins', excname)] = ('exceptions', 'ImportError') - - PYTHON3_TYPEERROR_EXCEPTIONS = ( 'ImpossibleMatchError', ) diff --git a/Python/ceval.c b/Python/ceval.c index a76d2b0037345b..767e96e2b29486 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -847,59 +847,11 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) // Need these for pattern matching: -static int -match_map(PyObject *target) -{ - PyInterpreterState *interp = PyInterpreterState_Get(); - if (!interp) { - return -1; - } - if (!interp->map_abc) { - PyObject *abc = PyImport_ImportModule("_collections_abc"); - if (!abc) { - return -1; - } - interp->map_abc = PyObject_GetAttrString(abc, "Mapping"); - Py_DECREF(abc); - if (!interp->map_abc) { - return -1; - } - } - return PyObject_IsInstance(target, interp->map_abc); -} - -static int -match_seq(PyObject *target) -{ - PyInterpreterState *interp = PyInterpreterState_Get(); - if (!interp) { - return -1; - } - if (!interp->seq_abc) { - PyObject *abc = PyImport_ImportModule("_collections_abc"); - if (!abc) { - return -1; - } - interp->seq_abc = PyObject_GetAttrString(abc, "Sequence"); - Py_DECREF(abc); - if (!interp->seq_abc) { - return -1; - } - } - return ( - !PyType_FastSubclass(Py_TYPE(target), - Py_TPFLAGS_UNICODE_SUBCLASS | Py_TPFLAGS_BYTES_SUBCLASS) - && !PyIter_Check(target) - && !PyByteArray_Check(target) - && PyObject_IsInstance(target, interp->seq_abc) - ); -} - static PyObject* match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, int pop) { + PyObject *copy = NULL; if (pop) { - PyObject *copy; if (PyDict_CheckExact(map)) { copy = PyDict_Copy(map); if (!copy) { @@ -913,10 +865,6 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, int pop) return NULL; } } - map = copy; - } - else { - Py_INCREF(map); } assert(PyTuple_CheckExact(keys)); Py_ssize_t nkeys = PyTuple_GET_SIZE(keys); @@ -943,7 +891,7 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, int pop) } goto fail; } - if (!PyMapping_HasKey(map, key)) { + if (!PySequence_Contains(map, key)) { goto fail; } PyObject *value = PyObject_GetItem(map, key); @@ -953,16 +901,19 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, int pop) Py_INCREF(value); PyTuple_SET_ITEM(values, i, value); if (pop && PyDict_DelItem(map, key)) { - goto fail; + if (!PyErr_ExceptionMatches(PyExc_KeyError)) { + goto fail; + } + PyErr_Clear(); } } + Py_XDECREF(copy); Py_DECREF(seen); - Py_DECREF(map); return values; fail: + Py_XDECREF(copy); Py_XDECREF(seen); Py_XDECREF(values); - Py_DECREF(map); return NULL; } @@ -977,8 +928,6 @@ get_match_args(PyThreadState *tstate, PyObject *type) return NULL; } // TODO: PySequence_FAST - // TODO We should probably just check for string items here - // TODO: Allow duplicate items? Hm... if (PyTuple_CheckExact(ma) || ma == Py_None) { return ma; } @@ -3592,9 +3541,22 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_MAP): { - PyObject *target = TOP(); - // TODO: Just move the body of this function here: - int match = match_map(target); + PyInterpreterState *interp = PyInterpreterState_Get(); + if (!interp) { + goto error; + } + if (!interp->map_abc) { + PyObject *abc = PyImport_ImportModule("_collections_abc"); + if (!abc) { + goto error; + } + interp->map_abc = PyObject_GetAttrString(abc, "Mapping"); + Py_DECREF(abc); + if (!interp->map_abc) { + goto error; + } + } + int match = PyObject_IsInstance(TOP(), interp->map_abc); if (match < 0) { goto error; } @@ -3604,8 +3566,31 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(MATCH_SEQ): { PyObject *target = TOP(); - // TODO: Just move the body of this function here: - int match = match_seq(target); + if (PyType_FastSubclass(Py_TYPE(target), + Py_TPFLAGS_UNICODE_SUBCLASS | Py_TPFLAGS_BYTES_SUBCLASS) + || PyIter_Check(target) + || PyByteArray_Check(target)) + { + Py_INCREF(Py_False); + PUSH(Py_False); + DISPATCH(); + } + PyInterpreterState *interp = PyInterpreterState_Get(); + if (!interp) { + goto error; + } + if (!interp->seq_abc) { + PyObject *abc = PyImport_ImportModule("_collections_abc"); + if (!abc) { + goto error; + } + interp->seq_abc = PyObject_GetAttrString(abc, "Sequence"); + Py_DECREF(abc); + if (!interp->seq_abc) { + goto error; + } + } + int match = PyObject_IsInstance(target, interp->seq_abc); if (match < 0) { goto error; } From 23dc88b426522feb1c59c9bf4fbb3ebef479179b Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 24 Jun 2020 18:13:44 -0700 Subject: [PATCH 096/189] Add typing.sealed --- Lib/test/test_typing.py | 12 ++++++++++++ Lib/typing.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index f429e883b59538..de8ed578d7386b 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -23,6 +23,7 @@ from typing import IO, TextIO, BinaryIO from typing import Pattern, Match from typing import Annotated, ForwardRef +from typing import sealed import abc import typing import weakref @@ -2302,6 +2303,17 @@ def test_final_unmodified(self): def func(x): ... self.assertIs(func, final(func)) + def test_sealed_unmodified(self): + class C: ... + self.assertIs(C, sealed(C)) + + def test_sealed_type(self): + def f(): ... + with self.assertRaises(TypeError): + sealed(f) + with self.assertRaises(TypeError): + sealed(42) + class CastTests(BaseTestCase): diff --git a/Lib/typing.py b/Lib/typing.py index f94996daebd6ed..5bd9444c860a82 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -109,6 +109,7 @@ 'NoReturn', 'overload', 'runtime_checkable', + 'sealed', 'Text', 'TYPE_CHECKING', ] @@ -1562,6 +1563,42 @@ class Other(Leaf): # Error reported by type checker return f +def sealed(cls): + """A decorator to indicate sealed classes. + + Use this decorator to indicate to type checkers that all subclasses of this + class must be defined in the current module. The type checker can then treat + the sealed base class as a union of all its known subclasses, allowing for + static exhaustiveness checks. For example: + + @sealed + class Parent: + ... + + class Child(Parent): + ... + + class X(Child): + ... + + class Y(Child): + ... + + class Z(Parent): + ... + + With this definition: + + - Child can be treated as Union[X, Y] + - Parent can be treated as Union[X, Y, Z] + + There is no runtime-checking of this property. + """ + if not isinstance(cls, type): + raise TypeError("only classes can be @sealed") + return cls + + # Some unconstrained type variables. These are used by the container types. # (These are not for export.) T = TypeVar('T') # Any type. From 6fa3eb3462f4bbb708e3c1aff8791550d6dbd3ae Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 25 Jun 2020 08:24:00 -0700 Subject: [PATCH 097/189] Allow unparenthesized tuples as targets --- Grammar/python.gram | 2 +- Parser/parser.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index baa29d9bcd2aaa..120df193150d0f 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -197,7 +197,7 @@ except_block[excepthandler_ty]: finally_block[asdl_seq*]: 'finally' ':' a=block { a } match_stmt[stmt_ty]: - | "match" target=expression ':' NEWLINE INDENT cases=case_block+ DEDENT { + | "match" target=star_expressions ':' NEWLINE INDENT cases=case_block+ DEDENT { _Py_Match(target, cases, EXTRA) } case_block[match_case_ty]: | "case" pattern=patterns guard=guard? ':' body=block { diff --git a/Parser/parser.c b/Parser/parser.c index 0985d1929c544e..424b3a736a24bf 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -4783,7 +4783,7 @@ finally_block_rule(Parser *p) return _res; } -// match_stmt: "match" expression ':' NEWLINE INDENT case_block+ DEDENT +// match_stmt: "match" star_expressions ':' NEWLINE INDENT case_block+ DEDENT static stmt_ty match_stmt_rule(Parser *p) { @@ -4803,12 +4803,12 @@ match_stmt_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // "match" expression ':' NEWLINE INDENT case_block+ DEDENT + { // "match" star_expressions ':' NEWLINE INDENT case_block+ DEDENT if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"match\" expression ':' NEWLINE INDENT case_block+ DEDENT")); + D(fprintf(stderr, "%*c> match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"match\" star_expressions ':' NEWLINE INDENT case_block+ DEDENT")); expr_ty _keyword; Token * _literal; asdl_seq * cases; @@ -4819,7 +4819,7 @@ match_stmt_rule(Parser *p) if ( (_keyword = _PyPegen_expect_soft_keyword(p, "match")) // soft_keyword='"match"' && - (target = expression_rule(p)) // expression + (target = star_expressions_rule(p)) // star_expressions && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -4832,7 +4832,7 @@ match_stmt_rule(Parser *p) (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' ) { - D(fprintf(stderr, "%*c+ match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"match\" expression ':' NEWLINE INDENT case_block+ DEDENT")); + D(fprintf(stderr, "%*c+ match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"match\" star_expressions ':' NEWLINE INDENT case_block+ DEDENT")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -4852,7 +4852,7 @@ match_stmt_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s match_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"match\" expression ':' NEWLINE INDENT case_block+ DEDENT")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"match\" star_expressions ':' NEWLINE INDENT case_block+ DEDENT")); } _res = NULL; done: From 67146a38b34985b8a8ca8b603186ea34ca59cad6 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 25 Jun 2020 08:24:30 -0700 Subject: [PATCH 098/189] Fix handling of copied mappings --- Python/ceval.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 767e96e2b29486..416ade0e33da49 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -848,24 +848,8 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) // Need these for pattern matching: static PyObject* -match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, int pop) +match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, PyObject *copy) { - PyObject *copy = NULL; - if (pop) { - if (PyDict_CheckExact(map)) { - copy = PyDict_Copy(map); - if (!copy) { - return NULL; - } - } - else { - copy = PyDict_New(); - if (!copy || PyDict_Update(copy, map)) { - Py_XDECREF(copy); - return NULL; - } - } - } assert(PyTuple_CheckExact(keys)); Py_ssize_t nkeys = PyTuple_GET_SIZE(keys); PyObject *seen = NULL; @@ -900,18 +884,16 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, int pop) } Py_INCREF(value); PyTuple_SET_ITEM(values, i, value); - if (pop && PyDict_DelItem(map, key)) { + if (copy && PyDict_DelItem(copy, key)) { if (!PyErr_ExceptionMatches(PyExc_KeyError)) { goto fail; } PyErr_Clear(); } } - Py_XDECREF(copy); Py_DECREF(seen); return values; fail: - Py_XDECREF(copy); Py_XDECREF(seen); Py_XDECREF(values); return NULL; @@ -3601,11 +3583,28 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(MATCH_MAP_KEYS): { PyObject *keys = TOP(); PyObject *target = SECOND(); - PyObject *values = match_map_items(tstate, target, keys, oparg); + PyObject *copy = NULL; + if (oparg) { + if (PyDict_CheckExact(target)) { + copy = PyDict_Copy(target); + if (!copy) { + return NULL; + } + } + else { + copy = PyDict_New(); + if (!copy || PyDict_Update(copy, target)) { + Py_XDECREF(copy); + return NULL; + } + } + } + PyObject *values = match_map_items(tstate, target, keys, copy); if (!values) { if (_PyErr_Occurred(tstate)) { goto error; } + Py_XDECREF(copy); Py_INCREF(Py_None); SET_TOP(Py_None); Py_DECREF(keys); @@ -3615,6 +3614,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } SET_TOP(values); Py_DECREF(keys); + if (oparg) { + SET_SECOND(copy); + Py_DECREF(target); + } Py_INCREF(Py_True); PUSH(Py_True); DISPATCH(); From d7bb7ee167beb9dc5c59983347f21ae00aab673b Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 25 Jun 2020 08:24:39 -0700 Subject: [PATCH 099/189] Add tests --- Lib/test/test_patma.py | 128 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 124 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index ce6a318172d0f0..d1f57b17f2a8d5 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1,4 +1,5 @@ import ast +import collections import types import typing import unittest @@ -1646,8 +1647,7 @@ def test_patma_118(self) -> None: self.assertEqual(y, 1) def test_patma_119(self) -> None: - from collections import defaultdict - x = defaultdict(int) + x = collections.defaultdict(int) match x: case {0: 0}: y = 0 @@ -1657,8 +1657,7 @@ def test_patma_119(self) -> None: self.assertEqual(y, 1) def test_patma_120(self) -> None: - from collections import defaultdict - x = defaultdict(int) + x = collections.defaultdict(int) match x: case {0: 0}: y = 0 @@ -1668,6 +1667,127 @@ def test_patma_120(self) -> None: self.assertEqual(y, 1) self.assertEqual(z, {}) + def test_patma_121(self) -> None: + match (): + case (): + x = 0 + self.assertEqual(x, 0) + + def test_patma_122(self) -> None: + match (0, 1, 2): + case (*x,): + y = 0 + self.assertEqual(x, [0, 1, 2]) + self.assertEqual(y, 0) + + def test_patma_123(self) -> None: + match (0, 1, 2): + case 0, *x: + y = 0 + self.assertEqual(x, [1, 2]) + self.assertEqual(y, 0) + + def test_patma_124(self) -> None: + match (0, 1, 2): + case (0, 1, *x,): + y = 0 + self.assertEqual(x, [2]) + self.assertEqual(y, 0) + + def test_patma_125(self) -> None: + match (0, 1, 2): + case 0, 1, 2, *x: + y = 0 + self.assertEqual(x, []) + self.assertEqual(y, 0) + + def test_patma_126(self) -> None: + match (0, 1, 2): + case *x, 2,: + y = 0 + self.assertEqual(x, [0, 1]) + self.assertEqual(y, 0) + + def test_patma_127(self) -> None: + match (0, 1, 2): + case (*x, 1, 2): + y = 0 + self.assertEqual(x, [0]) + self.assertEqual(y, 0) + + def test_patma_128(self) -> None: + match (0, 1, 2): + case *x, 0, 1, 2,: + y = 0 + self.assertEqual(x, []) + self.assertEqual(y, 0) + + def test_patma_129(self) -> None: + match (0, 1, 2): + case (0, *x, 2): + y = 0 + self.assertEqual(x, [1]) + self.assertEqual(y, 0) + + def test_patma_130(self) -> None: + match (0, 1, 2): + case 0, 1, *x, 2,: + y = 0 + self.assertEqual(x, []) + self.assertEqual(y, 0) + + def test_patma_131(self) -> None: + match (0, 1, 2): + case (0, *x, 1, 2): + y = 0 + self.assertEqual(x, []) + self.assertEqual(y, 0) + + def test_patma_132(self) -> None: + match (0, 1, 2): + case *x,: + y = 0 + self.assertEqual(x, [0, 1, 2]) + self.assertEqual(y, 0) + + def test_patma_133(self) -> None: + x = collections.defaultdict(int, {0: 1}) + match x: + case {1: 0}: + y = 0 + case {0: 0}: + y = 0 + case {}: + y = 1 + self.assertEqual(x, {0: 1}) + self.assertEqual(y, 1) + + def test_patma_134(self) -> None: + x = collections.defaultdict(int, {0: 1}) + match x: + case {1: 0}: + y = 0 + case {0: 0}: + y = 0 + case {**z}: + y = 1 + self.assertEqual(x, {0: 1}) + self.assertEqual(y, 1) + self.assertEqual(z, {0: 1}) + + def test_patma_135(self) -> None: + x = collections.defaultdict(int, {0: 1}) + match x: + case {1: 0}: + y = 0 + case {0: 0}: + y = 0 + case {0: _, **z}: + y = 1 + self.assertEqual(x, {0: 1}) + self.assertEqual(y, 1) + self.assertEqual(z, {}) + if __name__ == "__main__": # XXX: For quick test debugging... import dis From 574593c75994980ea23de4f8657f8aa4b567d94d Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 25 Jun 2020 11:07:35 -0700 Subject: [PATCH 100/189] Fix match target parsing --- Grammar/python.gram | 7 +- Parser/parser.c | 772 ++++++++++++++++++++++++-------------------- 2 files changed, 435 insertions(+), 344 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 120df193150d0f..b6e7219147c5a2 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -196,8 +196,13 @@ except_block[excepthandler_ty]: | 'except' ':' b=block { _Py_ExceptHandler(NULL, NULL, b, EXTRA) } finally_block[asdl_seq*]: 'finally' ':' a=block { a } +match_expr[expr_ty]: + | value=star_named_expression ',' values=star_named_expressions? { + _Py_Tuple(CHECK(_PyPegen_seq_insert_in_front(p, value, values)), Load, EXTRA) } + | named_expression + match_stmt[stmt_ty]: - | "match" target=star_expressions ':' NEWLINE INDENT cases=case_block+ DEDENT { + | "match" target=match_expr ':' NEWLINE INDENT cases=case_block+ DEDENT { _Py_Match(target, cases, EXTRA) } case_block[match_case_ty]: | "case" pattern=patterns guard=guard? ':' body=block { diff --git a/Parser/parser.c b/Parser/parser.c index 424b3a736a24bf..08ac9e7fe4995e 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -104,343 +104,344 @@ static KeywordToken *reserved_keywords[] = { #define try_stmt_type 1035 #define except_block_type 1036 #define finally_block_type 1037 -#define match_stmt_type 1038 -#define case_block_type 1039 -#define guard_type 1040 -#define patterns_type 1041 -#define pattern_type 1042 -#define or_pattern_type 1043 -#define closed_pattern_type 1044 -#define name_pattern_type 1045 -#define literal_pattern_type 1046 -#define constant_pattern_type 1047 -#define group_pattern_type 1048 -#define sequence_pattern_type 1049 -#define mapping_pattern_type 1050 -#define class_pattern_type 1051 -#define signed_number_type 1052 -#define attr_type 1053 // Left-recursive -#define name_or_attr_type 1054 // Left-recursive -#define values_pattern_type 1055 -#define items_pattern_type 1056 -#define keyword_pattern_type 1057 -#define error_argument_pattern_type 1058 -#define error_star_type 1059 -#define value_pattern_type 1060 -#define key_value_pattern_type 1061 -#define return_stmt_type 1062 -#define raise_stmt_type 1063 -#define function_def_type 1064 -#define function_def_raw_type 1065 -#define func_type_comment_type 1066 -#define params_type 1067 -#define parameters_type 1068 -#define slash_no_default_type 1069 -#define slash_with_default_type 1070 -#define star_etc_type 1071 -#define kwds_type 1072 -#define param_no_default_type 1073 -#define param_with_default_type 1074 -#define param_maybe_default_type 1075 -#define param_type 1076 -#define annotation_type 1077 -#define default_type 1078 -#define decorators_type 1079 -#define class_def_type 1080 -#define class_def_raw_type 1081 -#define block_type 1082 -#define expressions_list_type 1083 -#define star_expressions_type 1084 -#define star_expression_type 1085 -#define star_named_expressions_type 1086 -#define star_named_expression_type 1087 -#define named_expression_type 1088 -#define annotated_rhs_type 1089 -#define expressions_type 1090 -#define expression_type 1091 -#define lambdef_type 1092 -#define lambda_params_type 1093 -#define lambda_parameters_type 1094 -#define lambda_slash_no_default_type 1095 -#define lambda_slash_with_default_type 1096 -#define lambda_star_etc_type 1097 -#define lambda_kwds_type 1098 -#define lambda_param_no_default_type 1099 -#define lambda_param_with_default_type 1100 -#define lambda_param_maybe_default_type 1101 -#define lambda_param_type 1102 -#define disjunction_type 1103 -#define conjunction_type 1104 -#define inversion_type 1105 -#define comparison_type 1106 -#define compare_op_bitwise_or_pair_type 1107 -#define eq_bitwise_or_type 1108 -#define noteq_bitwise_or_type 1109 -#define lte_bitwise_or_type 1110 -#define lt_bitwise_or_type 1111 -#define gte_bitwise_or_type 1112 -#define gt_bitwise_or_type 1113 -#define notin_bitwise_or_type 1114 -#define in_bitwise_or_type 1115 -#define isnot_bitwise_or_type 1116 -#define is_bitwise_or_type 1117 -#define bitwise_or_type 1118 // Left-recursive -#define bitwise_xor_type 1119 // Left-recursive -#define bitwise_and_type 1120 // Left-recursive -#define shift_expr_type 1121 // Left-recursive -#define sum_type 1122 // Left-recursive -#define term_type 1123 // Left-recursive -#define factor_type 1124 -#define power_type 1125 -#define await_primary_type 1126 -#define primary_type 1127 // Left-recursive -#define slices_type 1128 -#define slice_type 1129 -#define atom_type 1130 -#define strings_type 1131 -#define list_type 1132 -#define listcomp_type 1133 -#define tuple_type 1134 -#define group_type 1135 -#define genexp_type 1136 -#define set_type 1137 -#define setcomp_type 1138 -#define dict_type 1139 -#define dictcomp_type 1140 -#define double_starred_kvpairs_type 1141 -#define double_starred_kvpair_type 1142 -#define kvpair_type 1143 -#define for_if_clauses_type 1144 -#define for_if_clause_type 1145 -#define yield_expr_type 1146 -#define arguments_type 1147 -#define args_type 1148 -#define kwargs_type 1149 -#define starred_expression_type 1150 -#define kwarg_or_starred_type 1151 -#define kwarg_or_double_starred_type 1152 -#define star_targets_type 1153 -#define star_targets_seq_type 1154 -#define star_target_type 1155 -#define star_atom_type 1156 -#define single_target_type 1157 -#define single_subscript_attribute_target_type 1158 -#define del_targets_type 1159 -#define del_target_type 1160 -#define del_t_atom_type 1161 -#define targets_type 1162 -#define target_type 1163 -#define t_primary_type 1164 // Left-recursive -#define t_lookahead_type 1165 -#define t_atom_type 1166 -#define incorrect_arguments_type 1167 -#define invalid_kwarg_type 1168 -#define invalid_named_expression_type 1169 -#define invalid_assignment_type 1170 -#define invalid_del_stmt_type 1171 -#define invalid_block_type 1172 -#define invalid_comprehension_type 1173 -#define invalid_dict_comprehension_type 1174 -#define invalid_parameters_type 1175 -#define invalid_lambda_parameters_type 1176 -#define invalid_star_etc_type 1177 -#define invalid_lambda_star_etc_type 1178 -#define invalid_double_type_comments_type 1179 -#define invalid_with_item_type 1180 -#define invalid_for_target_type 1181 -#define invalid_group_type 1182 -#define invalid_import_from_targets_type 1183 -#define _loop0_1_type 1184 -#define _loop0_2_type 1185 -#define _loop0_4_type 1186 -#define _gather_3_type 1187 -#define _loop0_6_type 1188 -#define _gather_5_type 1189 -#define _loop0_8_type 1190 -#define _gather_7_type 1191 -#define _loop0_10_type 1192 -#define _gather_9_type 1193 -#define _loop1_11_type 1194 -#define _loop0_13_type 1195 -#define _gather_12_type 1196 -#define _tmp_14_type 1197 -#define _tmp_15_type 1198 -#define _tmp_16_type 1199 -#define _tmp_17_type 1200 -#define _tmp_18_type 1201 -#define _tmp_19_type 1202 -#define _tmp_20_type 1203 -#define _tmp_21_type 1204 -#define _loop1_22_type 1205 -#define _tmp_23_type 1206 -#define _tmp_24_type 1207 -#define _loop0_26_type 1208 -#define _gather_25_type 1209 -#define _loop0_28_type 1210 -#define _gather_27_type 1211 -#define _tmp_29_type 1212 -#define _tmp_30_type 1213 -#define _loop0_31_type 1214 -#define _loop1_32_type 1215 -#define _loop0_34_type 1216 -#define _gather_33_type 1217 -#define _tmp_35_type 1218 -#define _loop0_37_type 1219 -#define _gather_36_type 1220 -#define _tmp_38_type 1221 -#define _loop0_40_type 1222 -#define _gather_39_type 1223 -#define _loop0_42_type 1224 -#define _gather_41_type 1225 -#define _loop0_44_type 1226 -#define _gather_43_type 1227 -#define _loop0_46_type 1228 -#define _gather_45_type 1229 -#define _tmp_47_type 1230 -#define _loop1_48_type 1231 -#define _tmp_49_type 1232 -#define _loop1_50_type 1233 -#define _loop0_52_type 1234 -#define _gather_51_type 1235 -#define _tmp_53_type 1236 -#define _tmp_54_type 1237 -#define _tmp_55_type 1238 -#define _tmp_56_type 1239 -#define _loop0_58_type 1240 -#define _gather_57_type 1241 -#define _loop0_60_type 1242 -#define _gather_59_type 1243 -#define _loop0_62_type 1244 -#define _gather_61_type 1245 -#define _loop0_64_type 1246 -#define _gather_63_type 1247 -#define _tmp_65_type 1248 -#define _loop0_67_type 1249 -#define _gather_66_type 1250 -#define _tmp_68_type 1251 -#define _tmp_69_type 1252 -#define _tmp_70_type 1253 -#define _loop0_72_type 1254 -#define _gather_71_type 1255 -#define _loop0_74_type 1256 -#define _gather_73_type 1257 -#define _tmp_75_type 1258 -#define _tmp_76_type 1259 -#define _tmp_77_type 1260 -#define _tmp_78_type 1261 -#define _tmp_79_type 1262 -#define _tmp_80_type 1263 -#define _loop0_81_type 1264 -#define _loop0_82_type 1265 -#define _loop0_83_type 1266 -#define _loop1_84_type 1267 -#define _loop0_85_type 1268 -#define _loop1_86_type 1269 -#define _loop1_87_type 1270 -#define _loop1_88_type 1271 -#define _loop0_89_type 1272 -#define _loop1_90_type 1273 -#define _loop0_91_type 1274 -#define _loop1_92_type 1275 -#define _loop0_93_type 1276 -#define _loop1_94_type 1277 -#define _loop1_95_type 1278 -#define _tmp_96_type 1279 -#define _loop0_98_type 1280 -#define _gather_97_type 1281 -#define _loop1_99_type 1282 -#define _loop0_101_type 1283 -#define _gather_100_type 1284 -#define _loop1_102_type 1285 -#define _loop0_103_type 1286 -#define _loop0_104_type 1287 -#define _loop0_105_type 1288 -#define _loop1_106_type 1289 -#define _loop0_107_type 1290 -#define _loop1_108_type 1291 -#define _loop1_109_type 1292 -#define _loop1_110_type 1293 -#define _loop0_111_type 1294 -#define _loop1_112_type 1295 -#define _loop0_113_type 1296 -#define _loop1_114_type 1297 -#define _loop0_115_type 1298 -#define _loop1_116_type 1299 -#define _loop1_117_type 1300 -#define _loop1_118_type 1301 -#define _loop1_119_type 1302 -#define _tmp_120_type 1303 -#define _loop0_122_type 1304 -#define _gather_121_type 1305 -#define _tmp_123_type 1306 -#define _tmp_124_type 1307 -#define _tmp_125_type 1308 -#define _tmp_126_type 1309 -#define _loop1_127_type 1310 -#define _tmp_128_type 1311 -#define _tmp_129_type 1312 -#define _loop0_131_type 1313 -#define _gather_130_type 1314 -#define _loop1_132_type 1315 -#define _loop0_133_type 1316 -#define _loop0_134_type 1317 -#define _tmp_135_type 1318 -#define _tmp_136_type 1319 -#define _loop0_138_type 1320 -#define _gather_137_type 1321 -#define _loop0_140_type 1322 -#define _gather_139_type 1323 -#define _loop0_142_type 1324 -#define _gather_141_type 1325 -#define _loop0_144_type 1326 -#define _gather_143_type 1327 -#define _loop0_145_type 1328 -#define _loop0_147_type 1329 -#define _gather_146_type 1330 -#define _tmp_148_type 1331 -#define _loop0_150_type 1332 -#define _gather_149_type 1333 -#define _loop0_152_type 1334 -#define _gather_151_type 1335 -#define _tmp_153_type 1336 -#define _loop0_154_type 1337 -#define _tmp_155_type 1338 -#define _loop0_156_type 1339 -#define _loop0_157_type 1340 -#define _tmp_158_type 1341 -#define _tmp_159_type 1342 -#define _loop0_160_type 1343 -#define _tmp_161_type 1344 -#define _loop0_162_type 1345 -#define _tmp_163_type 1346 -#define _tmp_164_type 1347 -#define _tmp_165_type 1348 -#define _tmp_166_type 1349 -#define _tmp_167_type 1350 -#define _tmp_168_type 1351 -#define _loop0_170_type 1352 -#define _gather_169_type 1353 -#define _loop0_172_type 1354 -#define _gather_171_type 1355 -#define _loop0_174_type 1356 -#define _gather_173_type 1357 -#define _loop0_176_type 1358 -#define _gather_175_type 1359 -#define _tmp_177_type 1360 -#define _tmp_178_type 1361 -#define _tmp_179_type 1362 -#define _tmp_180_type 1363 -#define _tmp_181_type 1364 -#define _tmp_182_type 1365 -#define _tmp_183_type 1366 -#define _tmp_184_type 1367 -#define _tmp_185_type 1368 -#define _tmp_186_type 1369 -#define _loop1_187_type 1370 -#define _loop1_188_type 1371 -#define _tmp_189_type 1372 -#define _tmp_190_type 1373 -#define _tmp_191_type 1374 +#define match_expr_type 1038 +#define match_stmt_type 1039 +#define case_block_type 1040 +#define guard_type 1041 +#define patterns_type 1042 +#define pattern_type 1043 +#define or_pattern_type 1044 +#define closed_pattern_type 1045 +#define name_pattern_type 1046 +#define literal_pattern_type 1047 +#define constant_pattern_type 1048 +#define group_pattern_type 1049 +#define sequence_pattern_type 1050 +#define mapping_pattern_type 1051 +#define class_pattern_type 1052 +#define signed_number_type 1053 +#define attr_type 1054 // Left-recursive +#define name_or_attr_type 1055 // Left-recursive +#define values_pattern_type 1056 +#define items_pattern_type 1057 +#define keyword_pattern_type 1058 +#define error_argument_pattern_type 1059 +#define error_star_type 1060 +#define value_pattern_type 1061 +#define key_value_pattern_type 1062 +#define return_stmt_type 1063 +#define raise_stmt_type 1064 +#define function_def_type 1065 +#define function_def_raw_type 1066 +#define func_type_comment_type 1067 +#define params_type 1068 +#define parameters_type 1069 +#define slash_no_default_type 1070 +#define slash_with_default_type 1071 +#define star_etc_type 1072 +#define kwds_type 1073 +#define param_no_default_type 1074 +#define param_with_default_type 1075 +#define param_maybe_default_type 1076 +#define param_type 1077 +#define annotation_type 1078 +#define default_type 1079 +#define decorators_type 1080 +#define class_def_type 1081 +#define class_def_raw_type 1082 +#define block_type 1083 +#define expressions_list_type 1084 +#define star_expressions_type 1085 +#define star_expression_type 1086 +#define star_named_expressions_type 1087 +#define star_named_expression_type 1088 +#define named_expression_type 1089 +#define annotated_rhs_type 1090 +#define expressions_type 1091 +#define expression_type 1092 +#define lambdef_type 1093 +#define lambda_params_type 1094 +#define lambda_parameters_type 1095 +#define lambda_slash_no_default_type 1096 +#define lambda_slash_with_default_type 1097 +#define lambda_star_etc_type 1098 +#define lambda_kwds_type 1099 +#define lambda_param_no_default_type 1100 +#define lambda_param_with_default_type 1101 +#define lambda_param_maybe_default_type 1102 +#define lambda_param_type 1103 +#define disjunction_type 1104 +#define conjunction_type 1105 +#define inversion_type 1106 +#define comparison_type 1107 +#define compare_op_bitwise_or_pair_type 1108 +#define eq_bitwise_or_type 1109 +#define noteq_bitwise_or_type 1110 +#define lte_bitwise_or_type 1111 +#define lt_bitwise_or_type 1112 +#define gte_bitwise_or_type 1113 +#define gt_bitwise_or_type 1114 +#define notin_bitwise_or_type 1115 +#define in_bitwise_or_type 1116 +#define isnot_bitwise_or_type 1117 +#define is_bitwise_or_type 1118 +#define bitwise_or_type 1119 // Left-recursive +#define bitwise_xor_type 1120 // Left-recursive +#define bitwise_and_type 1121 // Left-recursive +#define shift_expr_type 1122 // Left-recursive +#define sum_type 1123 // Left-recursive +#define term_type 1124 // Left-recursive +#define factor_type 1125 +#define power_type 1126 +#define await_primary_type 1127 +#define primary_type 1128 // Left-recursive +#define slices_type 1129 +#define slice_type 1130 +#define atom_type 1131 +#define strings_type 1132 +#define list_type 1133 +#define listcomp_type 1134 +#define tuple_type 1135 +#define group_type 1136 +#define genexp_type 1137 +#define set_type 1138 +#define setcomp_type 1139 +#define dict_type 1140 +#define dictcomp_type 1141 +#define double_starred_kvpairs_type 1142 +#define double_starred_kvpair_type 1143 +#define kvpair_type 1144 +#define for_if_clauses_type 1145 +#define for_if_clause_type 1146 +#define yield_expr_type 1147 +#define arguments_type 1148 +#define args_type 1149 +#define kwargs_type 1150 +#define starred_expression_type 1151 +#define kwarg_or_starred_type 1152 +#define kwarg_or_double_starred_type 1153 +#define star_targets_type 1154 +#define star_targets_seq_type 1155 +#define star_target_type 1156 +#define star_atom_type 1157 +#define single_target_type 1158 +#define single_subscript_attribute_target_type 1159 +#define del_targets_type 1160 +#define del_target_type 1161 +#define del_t_atom_type 1162 +#define targets_type 1163 +#define target_type 1164 +#define t_primary_type 1165 // Left-recursive +#define t_lookahead_type 1166 +#define t_atom_type 1167 +#define incorrect_arguments_type 1168 +#define invalid_kwarg_type 1169 +#define invalid_named_expression_type 1170 +#define invalid_assignment_type 1171 +#define invalid_del_stmt_type 1172 +#define invalid_block_type 1173 +#define invalid_comprehension_type 1174 +#define invalid_dict_comprehension_type 1175 +#define invalid_parameters_type 1176 +#define invalid_lambda_parameters_type 1177 +#define invalid_star_etc_type 1178 +#define invalid_lambda_star_etc_type 1179 +#define invalid_double_type_comments_type 1180 +#define invalid_with_item_type 1181 +#define invalid_for_target_type 1182 +#define invalid_group_type 1183 +#define invalid_import_from_targets_type 1184 +#define _loop0_1_type 1185 +#define _loop0_2_type 1186 +#define _loop0_4_type 1187 +#define _gather_3_type 1188 +#define _loop0_6_type 1189 +#define _gather_5_type 1190 +#define _loop0_8_type 1191 +#define _gather_7_type 1192 +#define _loop0_10_type 1193 +#define _gather_9_type 1194 +#define _loop1_11_type 1195 +#define _loop0_13_type 1196 +#define _gather_12_type 1197 +#define _tmp_14_type 1198 +#define _tmp_15_type 1199 +#define _tmp_16_type 1200 +#define _tmp_17_type 1201 +#define _tmp_18_type 1202 +#define _tmp_19_type 1203 +#define _tmp_20_type 1204 +#define _tmp_21_type 1205 +#define _loop1_22_type 1206 +#define _tmp_23_type 1207 +#define _tmp_24_type 1208 +#define _loop0_26_type 1209 +#define _gather_25_type 1210 +#define _loop0_28_type 1211 +#define _gather_27_type 1212 +#define _tmp_29_type 1213 +#define _tmp_30_type 1214 +#define _loop0_31_type 1215 +#define _loop1_32_type 1216 +#define _loop0_34_type 1217 +#define _gather_33_type 1218 +#define _tmp_35_type 1219 +#define _loop0_37_type 1220 +#define _gather_36_type 1221 +#define _tmp_38_type 1222 +#define _loop0_40_type 1223 +#define _gather_39_type 1224 +#define _loop0_42_type 1225 +#define _gather_41_type 1226 +#define _loop0_44_type 1227 +#define _gather_43_type 1228 +#define _loop0_46_type 1229 +#define _gather_45_type 1230 +#define _tmp_47_type 1231 +#define _loop1_48_type 1232 +#define _tmp_49_type 1233 +#define _loop1_50_type 1234 +#define _loop0_52_type 1235 +#define _gather_51_type 1236 +#define _tmp_53_type 1237 +#define _tmp_54_type 1238 +#define _tmp_55_type 1239 +#define _tmp_56_type 1240 +#define _loop0_58_type 1241 +#define _gather_57_type 1242 +#define _loop0_60_type 1243 +#define _gather_59_type 1244 +#define _loop0_62_type 1245 +#define _gather_61_type 1246 +#define _loop0_64_type 1247 +#define _gather_63_type 1248 +#define _tmp_65_type 1249 +#define _loop0_67_type 1250 +#define _gather_66_type 1251 +#define _tmp_68_type 1252 +#define _tmp_69_type 1253 +#define _tmp_70_type 1254 +#define _loop0_72_type 1255 +#define _gather_71_type 1256 +#define _loop0_74_type 1257 +#define _gather_73_type 1258 +#define _tmp_75_type 1259 +#define _tmp_76_type 1260 +#define _tmp_77_type 1261 +#define _tmp_78_type 1262 +#define _tmp_79_type 1263 +#define _tmp_80_type 1264 +#define _loop0_81_type 1265 +#define _loop0_82_type 1266 +#define _loop0_83_type 1267 +#define _loop1_84_type 1268 +#define _loop0_85_type 1269 +#define _loop1_86_type 1270 +#define _loop1_87_type 1271 +#define _loop1_88_type 1272 +#define _loop0_89_type 1273 +#define _loop1_90_type 1274 +#define _loop0_91_type 1275 +#define _loop1_92_type 1276 +#define _loop0_93_type 1277 +#define _loop1_94_type 1278 +#define _loop1_95_type 1279 +#define _tmp_96_type 1280 +#define _loop0_98_type 1281 +#define _gather_97_type 1282 +#define _loop1_99_type 1283 +#define _loop0_101_type 1284 +#define _gather_100_type 1285 +#define _loop1_102_type 1286 +#define _loop0_103_type 1287 +#define _loop0_104_type 1288 +#define _loop0_105_type 1289 +#define _loop1_106_type 1290 +#define _loop0_107_type 1291 +#define _loop1_108_type 1292 +#define _loop1_109_type 1293 +#define _loop1_110_type 1294 +#define _loop0_111_type 1295 +#define _loop1_112_type 1296 +#define _loop0_113_type 1297 +#define _loop1_114_type 1298 +#define _loop0_115_type 1299 +#define _loop1_116_type 1300 +#define _loop1_117_type 1301 +#define _loop1_118_type 1302 +#define _loop1_119_type 1303 +#define _tmp_120_type 1304 +#define _loop0_122_type 1305 +#define _gather_121_type 1306 +#define _tmp_123_type 1307 +#define _tmp_124_type 1308 +#define _tmp_125_type 1309 +#define _tmp_126_type 1310 +#define _loop1_127_type 1311 +#define _tmp_128_type 1312 +#define _tmp_129_type 1313 +#define _loop0_131_type 1314 +#define _gather_130_type 1315 +#define _loop1_132_type 1316 +#define _loop0_133_type 1317 +#define _loop0_134_type 1318 +#define _tmp_135_type 1319 +#define _tmp_136_type 1320 +#define _loop0_138_type 1321 +#define _gather_137_type 1322 +#define _loop0_140_type 1323 +#define _gather_139_type 1324 +#define _loop0_142_type 1325 +#define _gather_141_type 1326 +#define _loop0_144_type 1327 +#define _gather_143_type 1328 +#define _loop0_145_type 1329 +#define _loop0_147_type 1330 +#define _gather_146_type 1331 +#define _tmp_148_type 1332 +#define _loop0_150_type 1333 +#define _gather_149_type 1334 +#define _loop0_152_type 1335 +#define _gather_151_type 1336 +#define _tmp_153_type 1337 +#define _loop0_154_type 1338 +#define _tmp_155_type 1339 +#define _loop0_156_type 1340 +#define _loop0_157_type 1341 +#define _tmp_158_type 1342 +#define _tmp_159_type 1343 +#define _loop0_160_type 1344 +#define _tmp_161_type 1345 +#define _loop0_162_type 1346 +#define _tmp_163_type 1347 +#define _tmp_164_type 1348 +#define _tmp_165_type 1349 +#define _tmp_166_type 1350 +#define _tmp_167_type 1351 +#define _tmp_168_type 1352 +#define _loop0_170_type 1353 +#define _gather_169_type 1354 +#define _loop0_172_type 1355 +#define _gather_171_type 1356 +#define _loop0_174_type 1357 +#define _gather_173_type 1358 +#define _loop0_176_type 1359 +#define _gather_175_type 1360 +#define _tmp_177_type 1361 +#define _tmp_178_type 1362 +#define _tmp_179_type 1363 +#define _tmp_180_type 1364 +#define _tmp_181_type 1365 +#define _tmp_182_type 1366 +#define _tmp_183_type 1367 +#define _tmp_184_type 1368 +#define _tmp_185_type 1369 +#define _tmp_186_type 1370 +#define _loop1_187_type 1371 +#define _loop1_188_type 1372 +#define _tmp_189_type 1373 +#define _tmp_190_type 1374 +#define _tmp_191_type 1375 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -480,6 +481,7 @@ static withitem_ty with_item_rule(Parser *p); static stmt_ty try_stmt_rule(Parser *p); static excepthandler_ty except_block_rule(Parser *p); static asdl_seq* finally_block_rule(Parser *p); +static expr_ty match_expr_rule(Parser *p); static stmt_ty match_stmt_rule(Parser *p); static match_case_ty case_block_rule(Parser *p); static expr_ty guard_rule(Parser *p); @@ -4783,7 +4785,91 @@ finally_block_rule(Parser *p) return _res; } -// match_stmt: "match" star_expressions ':' NEWLINE INDENT case_block+ DEDENT +// match_expr: star_named_expression ',' star_named_expressions? | named_expression +static expr_ty +match_expr_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // star_named_expression ',' star_named_expressions? + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> match_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + Token * _literal; + expr_ty value; + void *values; + if ( + (value = star_named_expression_rule(p)) // star_named_expression + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (values = star_named_expressions_rule(p), 1) // star_named_expressions? + ) + { + D(fprintf(stderr, "%*c+ match_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , value , values ) ) , Load , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s match_expr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + } + { // named_expression + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> match_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); + expr_ty named_expression_var; + if ( + (named_expression_var = named_expression_rule(p)) // named_expression + ) + { + D(fprintf(stderr, "%*c+ match_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + _res = named_expression_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s match_expr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// match_stmt: "match" match_expr ':' NEWLINE INDENT case_block+ DEDENT static stmt_ty match_stmt_rule(Parser *p) { @@ -4803,12 +4889,12 @@ match_stmt_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // "match" star_expressions ':' NEWLINE INDENT case_block+ DEDENT + { // "match" match_expr ':' NEWLINE INDENT case_block+ DEDENT if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"match\" star_expressions ':' NEWLINE INDENT case_block+ DEDENT")); + D(fprintf(stderr, "%*c> match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"match\" match_expr ':' NEWLINE INDENT case_block+ DEDENT")); expr_ty _keyword; Token * _literal; asdl_seq * cases; @@ -4819,7 +4905,7 @@ match_stmt_rule(Parser *p) if ( (_keyword = _PyPegen_expect_soft_keyword(p, "match")) // soft_keyword='"match"' && - (target = star_expressions_rule(p)) // star_expressions + (target = match_expr_rule(p)) // match_expr && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -4832,7 +4918,7 @@ match_stmt_rule(Parser *p) (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' ) { - D(fprintf(stderr, "%*c+ match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"match\" star_expressions ':' NEWLINE INDENT case_block+ DEDENT")); + D(fprintf(stderr, "%*c+ match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"match\" match_expr ':' NEWLINE INDENT case_block+ DEDENT")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -4852,7 +4938,7 @@ match_stmt_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s match_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"match\" star_expressions ':' NEWLINE INDENT case_block+ DEDENT")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"match\" match_expr ':' NEWLINE INDENT case_block+ DEDENT")); } _res = NULL; done: From 340d66feb86d0f0ad40d6aba116e5a8206e3fd16 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 26 Jun 2020 09:08:45 -0700 Subject: [PATCH 101/189] Add more mapping tests and a performance utility --- Lib/test/test_patma.py | 54 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index d1f57b17f2a8d5..f1374b1da9d297 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1788,11 +1788,53 @@ def test_patma_135(self) -> None: self.assertEqual(y, 1) self.assertEqual(z, {}) + def test_patma_136(self) -> None: + x = {0: 1} + match x: + case {1: 0}: + y = 0 + case {0: 0}: + y = 0 + case {}: + y = 1 + self.assertEqual(x, {0: 1}) + self.assertEqual(y, 1) -if __name__ == "__main__": # XXX: For quick test debugging... - import dis + def test_patma_137(self) -> None: + x = {0: 1} + match x: + case {1: 0}: + y = 0 + case {0: 0}: + y = 0 + case {**z}: + y = 1 + self.assertEqual(x, {0: 1}) + self.assertEqual(y, 1) + self.assertEqual(z, {0: 1}) + + def test_patma_138(self) -> None: + x = {0: 1} + match x: + case {1: 0}: + y = 0 + case {0: 0}: + y = 0 + case {0: _, **z}: + y = 1 + self.assertEqual(x, {0: 1}) + self.assertEqual(y, 1) + self.assertEqual(z, {}) - match_cases = [ - MatchCase("([0, 1]) or {'XXX': (1 or (z := 2))} or (0, q, [[[{}]]])", "pass") - ] - dis.dis(TestAST.compile_match("", "x", match_cases, "")) + def run_perf(self): + # ./python -m pyperf timeit -s 'from test.test_patma import TestMatch; t = TestMatch()' 't.run_perf()' + attrs = vars(type(self)).items() + tests = [attr for name, attr in attrs if name.startswith("test_")] + assert_equal = self.assertEqual + try: + self.assertEqual = lambda *_: None + for _ in range(1 << 10): + for test in tests: + test(self) + finally: + self.assertEqual = assert_equal From ca58086a17a41ae94b1a9a8260fe385c8ad20714 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sat, 27 Jun 2020 15:41:16 -0700 Subject: [PATCH 102/189] More cleanup --- Doc/library/dis.rst | 35 +++++++++++++++------------- Include/opcode.h | 8 +++---- Lib/importlib/_bootstrap_external.py | 4 ++-- Lib/opcode.py | 9 +++---- Python/ast_opt.c | 4 ---- Python/ceval.c | 13 +++++++---- Python/compile.c | 13 +++++------ Python/importlib_external.h | 2 +- Python/opcode_targets.h | 16 ++++++------- Python/peephole.c | 4 ++++ 10 files changed, 57 insertions(+), 51 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index dabfbab8fda89f..777ec49e142baf 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -753,21 +753,7 @@ iterations of the loop. .. opcode:: GET_LEN - TODO - - .. versionadded:: 3.10 - - -.. opcode:: MATCH_MAP - - TODO - - .. versionadded:: 3.10 - - -.. opcode:: MATCH_SEQ - - TODO + Pushes ``len(TOS)`` onto the stack. .. versionadded:: 3.10 @@ -1210,13 +1196,30 @@ All of the following opcodes use their arguments. .. versionadded:: 3.6 -.. opcode:: MATCH (count) +.. opcode:: MATCH_CLS (count) TODO .. versionadded:: 3.10 +.. opcode:: MATCH_MAP (delta) + + If TOS is not a subclass of :class:`collections.abc.Mapping`, increment the + bytecode counter by *delta*. + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_SEQ (delta) + + If TOS is a subclass of :class:`string`/:class:`bytes`/:class:`bytearray`, is + an :term:`iterator`, or is not a subclass of + :class:`collections.abc.Sequence`, increment the bytecode counter by *delta*. + + .. versionadded:: 3.10 + + .. opcode:: MATCH_MAP_KEYS (copy) TODO diff --git a/Include/opcode.h b/Include/opcode.h index 2ed13d455ccc70..cd6158ea0e11a0 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -31,8 +31,6 @@ extern "C" { #define INPLACE_FLOOR_DIVIDE 28 #define INPLACE_TRUE_DIVIDE 29 #define GET_LEN 30 -#define MATCH_MAP 31 -#define MATCH_SEQ 32 #define RERAISE 48 #define WITH_EXCEPT_START 49 #define GET_AITER 50 @@ -99,8 +97,6 @@ extern "C" { #define LOAD_GLOBAL 116 #define IS_OP 117 #define CONTAINS_OP 118 -#define MATCH 119 -#define MATCH_MAP_KEYS 120 #define JUMP_IF_NOT_EXC_MATCH 121 #define SETUP_FINALLY 122 #define LOAD_FAST 124 @@ -122,6 +118,10 @@ extern "C" { #define SET_ADD 146 #define MAP_ADD 147 #define LOAD_CLASSDEREF 148 +#define MATCH_CLS 149 +#define MATCH_MAP_KEYS 150 +#define MATCH_MAP 151 +#define MATCH_SEQ 152 #define SETUP_ASYNC_WITH 154 #define FORMAT_VALUE 155 #define BUILD_CONST_KEY_MAP 156 diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index a4fe050512f5ca..3f01712bd665d8 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3462 (add structural pattern matching) +# Python 3.10a0 3463 (add structural pattern matching) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3462).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3463).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index 1922a4a24af61f..b19be82e14b526 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -82,8 +82,6 @@ def jabs_op(name, op): def_op('INPLACE_FLOOR_DIVIDE', 28) def_op('INPLACE_TRUE_DIVIDE', 29) def_op('GET_LEN', 30) -def_op('MATCH_MAP', 31) -def_op('MATCH_SEQ', 32) def_op('RERAISE', 48) def_op('WITH_EXCEPT_START', 49) @@ -160,8 +158,7 @@ def jabs_op(name, op): name_op('LOAD_GLOBAL', 116) # Index in name list def_op('IS_OP', 117) def_op('CONTAINS_OP', 118) -def_op('MATCH', 119) -def_op('MATCH_MAP_KEYS', 120) + jabs_op('JUMP_IF_NOT_EXC_MATCH', 121) jrel_op('SETUP_FINALLY', 122) # Distance to target address @@ -196,6 +193,10 @@ def jabs_op(name, op): def_op('MAP_ADD', 147) def_op('LOAD_CLASSDEREF', 148) hasfree.append(148) +def_op('MATCH_CLS', 149) +def_op('MATCH_MAP_KEYS', 150) +jrel_op('MATCH_MAP', 151) +jrel_op('MATCH_SEQ', 152) jrel_op('SETUP_ASYNC_WITH', 154) def_op('FORMAT_VALUE', 155) diff --git a/Python/ast_opt.c b/Python/ast_opt.c index bee3dc3919b4c1..265d80aca0f529 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -715,8 +715,6 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) case Match_kind: CALL(astfold_expr, expr_ty, node_->v.Match.target); CALL_SEQ(astfold_match_case, match_case_ty, node_->v.Match.cases); - // TODO: Mark unreachable cases for removal? Maybe pattern == NULL? - // TODO: We can even optimize patterns across cases... break; default: break; @@ -797,7 +795,6 @@ static int astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) { // Don't blindly optimize the pattern as an expr; it plays by its own rules! - // TODO: Build out this pattern optimizer. switch (node_->kind) { case Attribute_kind: return 1; @@ -805,7 +802,6 @@ astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) CALL(astfold_pattern_complex, expr_ty, node_); return 1; case BoolOp_kind: - // TODO: Quite a bit of potential here. case Call_kind: case Constant_kind: case Dict_kind: diff --git a/Python/ceval.c b/Python/ceval.c index 416ade0e33da49..74a572d5ea855d 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3506,7 +3506,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) #endif } - case TARGET(MATCH): { + case TARGET(MATCH_CLS): { PyObject *names = POP(); PyObject *type = TOP(); PyObject *target = SECOND(); @@ -3542,7 +3542,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (match < 0) { goto error; } - PUSH(PyBool_FromLong(match)); + if (!match) { + JUMPBY(oparg); + } DISPATCH(); } @@ -3553,8 +3555,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) || PyIter_Check(target) || PyByteArray_Check(target)) { - Py_INCREF(Py_False); - PUSH(Py_False); + JUMPBY(oparg); DISPATCH(); } PyInterpreterState *interp = PyInterpreterState_Get(); @@ -3576,7 +3577,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (match < 0) { goto error; } - PUSH(PyBool_FromLong(match)); + if (!match) { + JUMPBY(oparg); + } DISPATCH(); } diff --git a/Python/compile.c b/Python/compile.c index 5c4649d17ad97c..333f9ab868bd21 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1103,13 +1103,14 @@ stack_effect(int opcode, int oparg, int jump) case DICT_MERGE: case DICT_UPDATE: return -1; - case MATCH: + case MATCH_CLS: return -1; case MATCH_MAP_KEYS: case GET_LEN: + return 1; case MATCH_MAP: case MATCH_SEQ: - return 1; + return 0; default: return PY_INVALID_STACK_EFFECT; } @@ -2786,7 +2787,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, basicblock *fail, PyObject* PyTuple_SET_ITEM(kwnames, i, name); } ADDOP_LOAD_CONST_NEW(c, kwnames); - ADDOP_I(c, MATCH, nargs + nkwargs); + ADDOP_I(c, MATCH_CLS, nargs + nkwargs); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); for (i = 0; i < nargs; i++) { expr_ty arg = asdl_seq_GET(args, i); @@ -2847,8 +2848,7 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje asdl_seq *values = p->v.Dict.values; Py_ssize_t size = asdl_seq_LEN(values); int star = size ? !asdl_seq_GET(keys, size - 1) : 0; - ADDOP(c, MATCH_MAP); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + ADDOP_JREL(c, MATCH_MAP, block); if (size - star) { ADDOP(c, GET_LEN); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - star)); @@ -2996,8 +2996,7 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj basicblock *block, *end; CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); - ADDOP(c, MATCH_SEQ); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + ADDOP_JREL(c, MATCH_SEQ, block); if (star >= 0) { if (size) { ADDOP(c, GET_LEN); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 8b838f587516b9..4b3fb946d4bb31 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,134,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,135,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index ca2af205f3f261..6c15c9d771f370 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -30,8 +30,8 @@ static void *opcode_targets[256] = { &&TARGET_INPLACE_FLOOR_DIVIDE, &&TARGET_INPLACE_TRUE_DIVIDE, &&TARGET_GET_LEN, - &&TARGET_MATCH_MAP, - &&TARGET_MATCH_SEQ, + &&_unknown_opcode, + &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, @@ -118,8 +118,8 @@ static void *opcode_targets[256] = { &&TARGET_LOAD_GLOBAL, &&TARGET_IS_OP, &&TARGET_CONTAINS_OP, - &&TARGET_MATCH, - &&TARGET_MATCH_MAP_KEYS, + &&_unknown_opcode, + &&_unknown_opcode, &&TARGET_JUMP_IF_NOT_EXC_MATCH, &&TARGET_SETUP_FINALLY, &&_unknown_opcode, @@ -148,10 +148,10 @@ static void *opcode_targets[256] = { &&TARGET_SET_ADD, &&TARGET_MAP_ADD, &&TARGET_LOAD_CLASSDEREF, - &&_unknown_opcode, - &&_unknown_opcode, - &&_unknown_opcode, - &&_unknown_opcode, + &&TARGET_MATCH_CLS, + &&TARGET_MATCH_MAP_KEYS, + &&TARGET_MATCH_MAP, + &&TARGET_MATCH_SEQ, &&_unknown_opcode, &&TARGET_SETUP_ASYNC_WITH, &&TARGET_FORMAT_VALUE, diff --git a/Python/peephole.c b/Python/peephole.c index fe67de42227b5b..8e95760c12a045 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -198,6 +198,8 @@ markblocks(_Py_CODEUNIT *code, Py_ssize_t len) case SETUP_FINALLY: case SETUP_WITH: case SETUP_ASYNC_WITH: + case MATCH_MAP: + case MATCH_SEQ: j = GETJUMPTGT(code, i); assert(j < len); blocks[j] = 1; @@ -502,6 +504,8 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, case SETUP_FINALLY: case SETUP_WITH: case SETUP_ASYNC_WITH: + case MATCH_MAP: + case MATCH_SEQ: j = blocks[j / sizeof(_Py_CODEUNIT) + i + 1] - blocks[i] - 1; j *= sizeof(_Py_CODEUNIT); break; From 3ec5802797df857a6a766fb48a647eb255c72d17 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sat, 27 Jun 2020 23:36:39 -0700 Subject: [PATCH 103/189] Rough revision of __match__ protocol --- Include/object.h | 5 ++ Objects/bytearrayobject.c | 3 +- Objects/bytesobject.c | 3 +- Objects/dictobject.c | 3 +- Objects/floatobject.c | 3 +- Objects/listobject.c | 3 +- Objects/longobject.c | 3 +- Objects/setobject.c | 10 +-- Objects/tupleobject.c | 3 +- Objects/typeobject.c | 4 ++ Objects/unicodeobject.c | 3 +- Python/ceval.c | 136 ++++++++++++++++++-------------------- 12 files changed, 94 insertions(+), 85 deletions(-) diff --git a/Include/object.h b/Include/object.h index 537567040f9871..bf8df522af5e57 100644 --- a/Include/object.h +++ b/Include/object.h @@ -356,6 +356,11 @@ given type object has a specified feature. /* Type is abstract and cannot be instantiated */ #define Py_TPFLAGS_IS_ABSTRACT (1UL << 20) +// This undocumented flag gives certain built-ins their unique pattern-matching +// behavior, which allows a single positional subpattern to match against the +// match proxy itself (rather than a mapped attribute on it): +#define _Py_TPFLAGS_SIMPLE_MATCH (1UL << 21) + /* These flags are used to determine if a type is a subclass. */ #define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24) #define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25) diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 5a803be6277c88..82993dedf3e5c8 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -2343,7 +2343,8 @@ PyTypeObject PyByteArray_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ &bytearray_as_buffer, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | + _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ bytearray_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index d39721428634fc..5d417f227b0cd0 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2908,7 +2908,8 @@ PyTypeObject PyBytes_Type = { 0, /* tp_setattro */ &bytes_as_buffer, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_BYTES_SUBCLASS, /* tp_flags */ + Py_TPFLAGS_BYTES_SUBCLASS | + _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ bytes_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 55bf4aefbbeacf..a3471040198c15 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -3439,7 +3439,8 @@ PyTypeObject PyDict_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE | Py_TPFLAGS_DICT_SUBCLASS, /* tp_flags */ + Py_TPFLAGS_BASETYPE | Py_TPFLAGS_DICT_SUBCLASS | + _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ dictionary_doc, /* tp_doc */ dict_traverse, /* tp_traverse */ dict_tp_clear, /* tp_clear */ diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 7ffd7eebe5a45c..e63f9d5e64a115 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -1910,7 +1910,8 @@ PyTypeObject PyFloat_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | + _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ float_new__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Objects/listobject.c b/Objects/listobject.c index 261a0fdfffae0d..d9d92a9b88184d 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3046,7 +3046,8 @@ PyTypeObject PyList_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE | Py_TPFLAGS_LIST_SUBCLASS, /* tp_flags */ + Py_TPFLAGS_BASETYPE | Py_TPFLAGS_LIST_SUBCLASS | + _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ list___init____doc__, /* tp_doc */ (traverseproc)list_traverse, /* tp_traverse */ (inquiry)_list_clear, /* tp_clear */ diff --git a/Objects/longobject.c b/Objects/longobject.c index d00a7a048ddce2..89194277da41e6 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -5650,7 +5650,8 @@ PyTypeObject PyLong_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_LONG_SUBCLASS, /* tp_flags */ + Py_TPFLAGS_LONG_SUBCLASS | + _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ long_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Objects/setobject.c b/Objects/setobject.c index 76b1944db45588..549f09c87de0fd 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -2109,8 +2109,10 @@ PyTypeObject PySet_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_BASETYPE | + _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ set_doc, /* tp_doc */ (traverseproc)set_traverse, /* tp_traverse */ (inquiry)set_clear_internal, /* tp_clear */ @@ -2210,7 +2212,8 @@ PyTypeObject PyFrozenSet_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_BASETYPE | + _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ frozenset_doc, /* tp_doc */ (traverseproc)set_traverse, /* tp_traverse */ (inquiry)set_clear_internal, /* tp_clear */ @@ -2527,4 +2530,3 @@ static PyObject _dummy_struct = { _PyObject_EXTRA_INIT 2, &_PySetDummy_Type }; - diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 2ff4c48111fe0b..f96c64b41ee23a 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -878,7 +878,8 @@ PyTypeObject PyTuple_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TUPLE_SUBCLASS, /* tp_flags */ + Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TUPLE_SUBCLASS | + _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ tuple_new__doc__, /* tp_doc */ (traverseproc)tupletraverse, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 9fbca40daf5ddc..b13e9e82e53f95 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -5180,6 +5180,10 @@ inherit_special(PyTypeObject *type, PyTypeObject *base) type->tp_flags |= Py_TPFLAGS_LIST_SUBCLASS; else if (PyType_IsSubtype(base, &PyDict_Type)) type->tp_flags |= Py_TPFLAGS_DICT_SUBCLASS; + + if (PyType_HasFeature(base, _Py_TPFLAGS_SIMPLE_MATCH)) { + type->tp_flags |= _Py_TPFLAGS_SIMPLE_MATCH; + } } static int diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 1433848c81f8e1..b646fdb81ffb7a 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -15513,7 +15513,8 @@ PyTypeObject PyUnicode_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_UNICODE_SUBCLASS, /* tp_flags */ + Py_TPFLAGS_UNICODE_SUBCLASS | + _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ unicode_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Python/ceval.c b/Python/ceval.c index 74a572d5ea855d..1a97b12c2802ce 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -885,10 +885,10 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, PyObject * Py_INCREF(value); PyTuple_SET_ITEM(values, i, value); if (copy && PyDict_DelItem(copy, key)) { - if (!PyErr_ExceptionMatches(PyExc_KeyError)) { + if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { goto fail; } - PyErr_Clear(); + _PyErr_Clear(tstate); } } Py_DECREF(seen); @@ -902,33 +902,31 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, PyObject * static PyObject * get_match_args(PyThreadState *tstate, PyObject *type) { - if (!PyObject_HasAttrString(type, "__match_args__")) { - Py_RETURN_NONE; - } - PyObject *ma = PyObject_GetAttrString(type, "__match_args__"); - if (!ma) { + PyObject *match_args = PyObject_GetAttrString(type, "__match_args__"); + if (!match_args) { + if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { + _PyErr_Clear(tstate); + } return NULL; } - // TODO: PySequence_FAST - if (PyTuple_CheckExact(ma) || ma == Py_None) { - return ma; - } - if (PyList_CheckExact(ma)) { - PyObject *tuple = PyList_AsTuple(ma); - Py_DECREF(ma); - return tuple; + if (PyList_CheckExact(match_args) || PyTuple_CheckExact(match_args)) { + return match_args; } _PyErr_Format(tstate, PyExc_TypeError, - "__match_args__ must be a list, tuple, or None (got %s)", - Py_TYPE(ma)->tp_name); - Py_DECREF(ma); + "__match_args__ must be a list or tuple (got %s)", + Py_TYPE(match_args)->tp_name); + Py_DECREF(match_args); return NULL; } static PyObject * do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *type, PyObject *target) { - // TODO: Break this up, and better error handling ("goto error;"): + // TODO: Break this up! + PyObject *match_args = NULL; + PyObject *args = NULL; + PyObject *attrs = NULL; + PyObject *seen = NULL; assert(PyTuple_CheckExact(kwargs)); if (!PyType_Check(type)) { _PyErr_Format(tstate, PyExc_TypeError, @@ -954,66 +952,60 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty } Py_ssize_t nkwargs = PyTuple_GET_SIZE(kwargs); Py_ssize_t nargs = count - nkwargs; - PyObject *args; - PyObject *match_args = get_match_args(tstate, type); - if (!match_args) { - Py_DECREF(proxy); - return NULL; + match_args = get_match_args(tstate, type); + assert(!match_args || PyList_CheckExact(match_args) || PyTuple_CheckExact(match_args)); + if (!match_args && _PyErr_Occurred(tstate)) { + goto error; + } + if (!nargs) { + args = PyTuple_New(0); + if (!args) { + goto error; + } } - assert(PyTuple_CheckExact(match_args) || match_args == Py_None); - if (nargs) { - if (match_args == Py_None) { + else if (!match_args) { + if (PyType_HasFeature((PyTypeObject *)type, _Py_TPFLAGS_SIMPLE_MATCH)) { if (nargs > 1) { - Py_DECREF(match_args); - Py_DECREF(proxy); - // TODO: Add expected and actual counts: - _PyErr_SetString(tstate, PyExc_ImpossibleMatchError, - "too many positional matches in pattern"); - return NULL; + _PyErr_Format(tstate, PyExc_ImpossibleMatchError, + "too many positional matches in pattern (expected at most 1, got %d)", + nargs); + goto error; } - args = match_args; } else { - if (PyTuple_GET_SIZE(match_args) < nargs) { - // TODO: Combine with above: - Py_DECREF(match_args); - Py_DECREF(proxy); - // TODO: Add expected and actual counts: - _PyErr_SetString(tstate, PyExc_ImpossibleMatchError, - "too many positional matches in pattern"); - return NULL; - } - args = PyTuple_GetSlice(match_args, 0, nargs); + _PyErr_Format(tstate, PyExc_ImpossibleMatchError, + "too many positional matches in pattern (expected none, got %d)", + nargs); + goto error; } } else { - args = PyTuple_New(0); - } - if (!args) { - Py_DECREF(match_args); - Py_DECREF(proxy); - return NULL; + Py_ssize_t nmatch_args = PySequence_Fast_GET_SIZE(match_args); + if (nmatch_args < nargs) { + // TODO: Combine with above: + _PyErr_Format(tstate, PyExc_ImpossibleMatchError, + "too many positional matches in pattern (expected at most %d, got %d)", + nmatch_args, nargs); + return NULL; + } + args = PyList_CheckExact(match_args) ? PyList_GetSlice(match_args, 0, nargs) : PyTuple_GetSlice(match_args, 0, nargs); + if (!args) { + goto error; + } } - assert(PyTuple_CheckExact(args) || args == Py_None); - PyObject *attrs = PyTuple_New(count); + assert(!args || PyList_CheckExact(args) || PyTuple_CheckExact(args)); + attrs = PyTuple_New(count); if (!attrs) { - Py_DECREF(match_args); - Py_DECREF(proxy); - Py_DECREF(args); - return NULL; + goto error; } - PyObject *seen = PySet_New(NULL); + seen = PySet_New(NULL); if (!seen) { - Py_DECREF(match_args); - Py_DECREF(proxy); - Py_DECREF(args); - Py_DECREF(attrs); - return NULL; + goto error; } PyObject *name; for (Py_ssize_t i = 0; i < count; i++) { if (i < nargs) { - if (args == Py_None) { + if (!args) { assert(!i); Py_INCREF(proxy); PyTuple_SET_ITEM(attrs, 0, proxy); @@ -1043,30 +1035,28 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty // TODO: Only clear AttributeError? _PyErr_Clear(tstate); // TODO: iterate manually (and check for strings) - if (match_args != Py_None && !PySequence_Contains(match_args, name)) { + if (match_args && !PySequence_Contains(match_args, name)) { _PyErr_Format(tstate, PyExc_ImpossibleMatchError, "match proxy %R has no attribute %R", proxy, name); goto error; } - Py_DECREF(attrs); - attrs = Py_None; - Py_INCREF(attrs); + Py_SETREF(attrs, Py_None); break; } PyTuple_SET_ITEM(attrs, i, attr); } - Py_DECREF(match_args); Py_DECREF(proxy); - Py_DECREF(args); + Py_XDECREF(match_args); + Py_XDECREF(args); Py_DECREF(seen); return attrs; error: - Py_DECREF(match_args); Py_DECREF(proxy); - Py_DECREF(args); - Py_DECREF(seen); - Py_DECREF(attrs); + Py_XDECREF(match_args); + Py_XDECREF(args); + Py_XDECREF(seen); + Py_XDECREF(attrs); return NULL; } From 0d99af4e6ddc895f0ebb5b5c1b24e0482a399db0 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 28 Jun 2020 12:19:49 -0700 Subject: [PATCH 104/189] Remove old AST tests and add "simple" match tests --- Lib/test/test_patma.py | 656 +++++++---------------------------------- 1 file changed, 111 insertions(+), 545 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index f1374b1da9d297..e998cede3b7370 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1,549 +1,7 @@ -import ast import collections -import types -import typing import unittest -FILENAME = "" - - -class MatchCase(typing.NamedTuple): - pattern: str - body: str - guard: typing.Optional[str] = None - - -class TestAST(unittest.TestCase): - """Tests that predate parser support, and just execute ASTs instead. - - No tests for name loads/stores, since these need a patma parser to - disambiguate. - - Note that we use "or" for "|" here, since the parser gives us a BoolOp-Or, - not a BinOp-BitOr. - """ - - @staticmethod - def parse_stmts(stmts: str) -> typing.List[ast.stmt]: - return ast.parse(stmts, FILENAME, "exec").body - - @staticmethod - def parse_expr(expr: str) -> ast.expr: - return ast.parse(expr, FILENAME, "eval").body - - @classmethod - def parse_match_case(cls, match_case: MatchCase) -> ast.expr: - pattern = cls.parse_expr(match_case.pattern) - guard = None if match_case.guard is None else cls.parse_expr(match_case.guard) - body = cls.parse_stmts(match_case.body) - return ast.match_case(pattern=pattern, guard=guard, body=body) - - @classmethod - def compile_match( - cls, pre: str, target: str, match_cases: typing.Iterable[MatchCase], post: str - ) -> types.CodeType: - cases = [cls.parse_match_case(case) for case in match_cases] - match = ast.Match(target=cls.parse_expr(target), cases=cases) - body = [*cls.parse_stmts(pre), match, *cls.parse_stmts(post)] - tree = ast.fix_missing_locations(ast.Module(body=body, type_ignores=[])) - return compile(tree, FILENAME, "exec") - - @classmethod - def execute_match( - cls, pre: str, target: str, match_cases: typing.Iterable[MatchCase], post: str - ) -> typing.Dict[str, typing.Any]: - namespace = {} - exec(cls.compile_match(pre, target, match_cases, post), None, namespace) - return namespace - - def test_patma_ast_00(self) -> None: - match_cases = [MatchCase("0", "y = 0")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_01(self) -> None: - match_cases = [MatchCase("False", "y = 0")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_02(self) -> None: - match_cases = [MatchCase("1", "y = 0")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertNotIn("y", namespace) - - def test_patma_ast_03(self) -> None: - match_cases = [MatchCase("None", "y = 0")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertNotIn("y", namespace) - - def test_patma_ast_04(self) -> None: - match_cases = [MatchCase("0", "y = 0"), MatchCase("0", "y = 1")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_05(self) -> None: - match_cases = [MatchCase("1", "y = 0"), MatchCase("1", "y = 1")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertNotIn("y", namespace) - - def test_patma_ast_06(self) -> None: - match_cases = [MatchCase("'x'", "y = 0"), MatchCase("'y'", "y = 1")] - namespace = self.execute_match("x = 'x'", "x", match_cases, "") - self.assertEqual(namespace.get("x"), "x") - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_07(self) -> None: - match_cases = [MatchCase("'y'", "y = 0"), MatchCase("'x'", "y = 1")] - namespace = self.execute_match("x = 'x'", "x", match_cases, "") - self.assertEqual(namespace.get("x"), "x") - self.assertEqual(namespace.get("y"), 1) - - def test_patma_ast_08(self) -> None: - match_cases = [MatchCase("'x'", "y = 0"), MatchCase("'y'", "y = 1")] - namespace = self.execute_match("x = 'x'", "x", match_cases, "") - self.assertEqual(namespace.get("x"), "x") - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_09(self) -> None: - match_cases = [MatchCase("b'y'", "y = 0"), MatchCase("b'x'", "y = 1")] - namespace = self.execute_match("x = b'x'", "x", match_cases, "") - self.assertEqual(namespace.get("x"), b"x") - self.assertEqual(namespace.get("y"), 1) - - def test_patma_ast_10(self) -> None: - match_cases = [MatchCase("0", "y = 0", "False"), MatchCase("0", "y = 1")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertEqual(namespace.get("y"), 1) - - def test_patma_ast_11(self) -> None: - match_cases = [MatchCase("0", "y = 0", "0"), MatchCase("0", "y = 1", "0")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertNotIn("y", namespace) - - def test_patma_ast_12(self) -> None: - match_cases = [MatchCase("0", "y = 0", "True"), MatchCase("0", "y = 1", "True")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_13(self) -> None: - match_cases = [MatchCase("0", "y = 0", "True"), MatchCase("0", "y = 1", "True")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_14(self) -> None: - match_cases = [MatchCase("0", "y = 0", "True"), MatchCase("0", "y = 1", "True")] - namespace = self.execute_match("x = 0", "x", match_cases, "y = 2") - self.assertEqual(namespace.get("x"), 0) - self.assertEqual(namespace.get("y"), 2) - - def test_patma_ast_15(self) -> None: - match_cases = [MatchCase("0", "y = 0", "0"), MatchCase("0", "y = 1", "1")] - namespace = self.execute_match("x = 0", "x", match_cases, "y = 2") - self.assertEqual(namespace.get("x"), 0) - self.assertEqual(namespace.get("y"), 2) - - def test_patma_ast_16(self) -> None: - match_cases = [MatchCase("0", "y = 0", "not (x := 1)"), MatchCase("1", "y = 1")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 1) - self.assertNotIn("y", namespace) - - def test_patma_ast_17(self) -> None: - match_cases = [ - MatchCase("0", "y = 0", "not (x := 1)"), - MatchCase("(z := 0)", "y = 1"), - ] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 1) - self.assertEqual(namespace.get("y"), 1) - self.assertEqual(namespace.get("z"), 0) - - def test_patma_ast_18(self) -> None: - match_cases = [ - MatchCase("(z := 1)", "y = 0", "not (x := 1)"), - MatchCase("0", "y = 1"), - ] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertEqual(namespace.get("y"), 1) - self.assertNotIn("z", namespace) - - def test_patma_ast_19(self) -> None: - match_cases = [MatchCase("(z := 0)", "y = 0")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertEqual(namespace.get("y"), 0) - self.assertEqual(namespace.get("z"), 0) - - def test_patma_ast_20(self) -> None: - match_cases = [MatchCase("(z := 1)", "y = 0")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertNotIn("y", namespace) - self.assertNotIn("z", namespace) - - def test_patma_ast_21(self) -> None: - match_cases = [MatchCase("(z := 0)", "y = 0", "(w := 0)")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("w"), 0) - self.assertEqual(namespace.get("x"), 0) - self.assertNotIn("y", namespace) - self.assertEqual(namespace.get("z"), 0) - - def test_patma_ast_22(self) -> None: - match_cases = [MatchCase("(z := (w := 0))", "y = 0")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("w"), 0) - self.assertEqual(namespace.get("x"), 0) - self.assertEqual(namespace.get("y"), 0) - self.assertEqual(namespace.get("z"), 0) - - def test_patma_ast_23(self) -> None: - match_cases = [MatchCase("0 or 1 or 2", "y = 0")] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_24(self) -> None: - match_cases = [MatchCase("0 or 1 or 2", "y = 0")] - namespace = self.execute_match("x = 1", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 1) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_25(self) -> None: - match_cases = [MatchCase("0 or 1 or 2", "y = 0")] - namespace = self.execute_match("x = 2", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 2) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_26(self) -> None: - match_cases = [MatchCase("0 or 1 or 2", "y = 0")] - namespace = self.execute_match("x = 3", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 3) - self.assertNotIn("y", namespace) - - def test_patma_ast_27(self) -> None: - match_cases = [ - MatchCase("(z := 0) or (z := 1) or (z := 2)", "y = 0", "z == x % 2") - ] - namespace = self.execute_match("x = 0", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 0) - self.assertEqual(namespace.get("y"), 0) - self.assertEqual(namespace.get("z"), 0) - - def test_patma_ast_28(self) -> None: - match_cases = [ - MatchCase("(z := 0) or (z := 1) or (z := 2)", "y = 0", "z == x % 2") - ] - namespace = self.execute_match("x = 1", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 1) - self.assertEqual(namespace.get("y"), 0) - self.assertEqual(namespace.get("z"), 1) - - def test_patma_ast_29(self) -> None: - match_cases = [ - MatchCase("(z := 0) or (z := 1) or (z := 2)", "y = 0", "z == x % 2") - ] - namespace = self.execute_match("x = 2", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 2) - self.assertNotIn("y", namespace) - self.assertEqual(namespace.get("z"), 2) - - def test_patma_ast_30(self) -> None: - match_cases = [ - MatchCase("(z := 0) or (z := 1) or (z := 2)", "y = 0", "z == x % 2") - ] - namespace = self.execute_match("x = 3", "x", match_cases, "") - self.assertEqual(namespace.get("x"), 3) - self.assertNotIn("y", namespace) - self.assertNotIn("z", namespace) - - def test_patma_ast_31(self) -> None: - match_cases = [MatchCase("[]", "y = 0")] - namespace = self.execute_match("x = ()", "x", match_cases, "") - self.assertEqual(namespace.get("x"), ()) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_32(self) -> None: - match_cases = [MatchCase("[]", "y = 0")] - namespace = self.execute_match("x = ()", "x", match_cases, "") - self.assertEqual(namespace.get("x"), ()) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_33(self) -> None: - match_cases = [MatchCase("[0]", "y = 0")] - namespace = self.execute_match("x = (0,)", "x", match_cases, "") - self.assertEqual(namespace.get("x"), (0,)) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_34(self) -> None: - match_cases = [MatchCase("[[]]", "y = 0")] - namespace = self.execute_match("x = ((),)", "x", match_cases, "") - self.assertEqual(namespace.get("x"), ((),)) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_35(self) -> None: - match_cases = [MatchCase("[0, 1] or [1, 0]", "y = 0")] - namespace = self.execute_match("x = [0, 1]", "x", match_cases, "") - self.assertEqual(namespace.get("x"), [0, 1]) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_36(self) -> None: - match_cases = [MatchCase("[0, 1] or [1, 0]", "y = 0")] - namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") - self.assertEqual(namespace.get("x"), [1, 0]) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_37(self) -> None: - match_cases = [MatchCase("[0, 1] or [1, 0]", "y = 0")] - namespace = self.execute_match("x = [0, 0]", "x", match_cases, "") - self.assertEqual(namespace.get("x"), [0, 0]) - self.assertNotIn("y", namespace) - - def test_patma_ast_38(self) -> None: - match_cases = [ - MatchCase("[w := 0,]", "y = 0"), - MatchCase("[z := 0] or [1, z := (0 or 1)] or [z := 0]", "y = 1"), - ] - namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") - self.assertNotIn("w", namespace) - self.assertEqual(namespace.get("x"), [1, 0]) - self.assertEqual(namespace.get("y"), 1) - self.assertEqual(namespace.get("z"), 0) - - def test_patma_ast_39(self) -> None: - match_cases = [ - MatchCase("[0,]", "y = 0"), - MatchCase("[1, 0]", "y = 1", "(x := x[:0])"), - MatchCase("[1, 0]", "y = 2"), - ] - namespace = self.execute_match("x = [1, 0]", "x", match_cases, "") - self.assertEqual(namespace.get("x"), []) - self.assertEqual(namespace.get("y"), 2) - - def test_patma_ast_40(self) -> None: - match_cases = [MatchCase("[0]", "y = 0")] - namespace = self.execute_match("x = {0}", "x", match_cases, "") - self.assertEqual(namespace.get("x"), {0}) - self.assertNotIn("y", namespace) - - def test_patma_ast_41(self) -> None: - match_cases = [MatchCase("[]", "y = 0")] - namespace = self.execute_match("x = set()", "x", match_cases, "") - self.assertEqual(namespace.get("x"), set()) - self.assertNotIn("y", namespace) - - def test_patma_ast_42(self) -> None: - match_cases = [MatchCase("[]", "y = 0")] - namespace = self.execute_match("x = iter([1,2,3])", "x", match_cases, "") - self.assertEqual(list(namespace.get("x")), [1, 2, 3]) - self.assertNotIn("y", namespace) - - def test_patma_ast_43(self) -> None: - match_cases = [MatchCase("[]", "y = 0")] - namespace = self.execute_match("x = {}", "x", match_cases, "") - self.assertEqual(namespace.get("x"), {}) - self.assertNotIn("y", namespace) - - def test_patma_ast_44(self) -> None: - match_cases = [MatchCase("[0, 1]", "y = 0")] - namespace = self.execute_match("x = {0: False, 1: True}", "x", match_cases, "") - self.assertEqual(namespace.get("x"), {0: False, 1: True}) - self.assertNotIn("y", namespace) - - def test_patma_ast_45(self) -> None: - match_cases = [MatchCase("['x']", "y = 0"), MatchCase("'x'", "y = 1")] - namespace = self.execute_match("x = 'x'", "x", match_cases, "") - self.assertEqual(namespace.get("x"), "x") - self.assertEqual(namespace.get("y"), 1) - - def test_patma_ast_46(self) -> None: - match_cases = [ - MatchCase("[b'x']", "y = 0"), - MatchCase("['x']", "y = 1"), - MatchCase("[120]", "y = 2"), - MatchCase("b'x'", "y = 4"), - ] - namespace = self.execute_match("x = b'x'", "x", match_cases, "") - self.assertEqual(namespace.get("x"), b"x") - self.assertEqual(namespace.get("y"), 4) - - def test_patma_ast_47(self) -> None: - match_cases = [MatchCase("[120]", "y = 0"), MatchCase("120", "y = 1")] - namespace = self.execute_match("x = bytearray(b'x')", "x", match_cases, "") - self.assertEqual(namespace.get("x"), b"x") - self.assertNotIn("y", namespace) - - def test_patma_ast_48(self) -> None: - match_cases = [ - MatchCase("[]", "y = 0"), - MatchCase("['']", "y = 1"), - MatchCase("''", "y = 2"), - ] - namespace = self.execute_match("x = ''", "x", match_cases, "") - self.assertEqual(namespace.get("x"), "") - self.assertEqual(namespace.get("y"), 2) - - def test_patma_ast_49(self) -> None: - match_cases = [ - MatchCase("['x', 'x', 'x']", "y = 0"), - MatchCase("['xxx']", "y = 1"), - MatchCase("'xxx'", "y = 2"), - ] - namespace = self.execute_match("x = 'xxx'", "x", match_cases, "") - self.assertEqual(namespace.get("x"), "xxx") - self.assertEqual(namespace.get("y"), 2) - - def test_patma_ast_50(self) -> None: - match_cases = [ - MatchCase("[120, 120, 120]", "y = 0"), - MatchCase("[b'xxx']", "y = 1"), - MatchCase("b'xxx'", "y = 2"), - ] - namespace = self.execute_match("x = b'xxx'", "x", match_cases, "") - self.assertEqual(namespace.get("x"), b"xxx") - self.assertEqual(namespace.get("y"), 2) - - def test_patma_ast_51(self) -> None: - match_cases = [MatchCase("{}", "y = 0")] - namespace = self.execute_match("x = {}", "x", match_cases, "") - self.assertEqual(namespace.get("x"), {}) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_52(self) -> None: - match_cases = [MatchCase("{}", "y = 0")] - namespace = self.execute_match("x = {0: 0}", "x", match_cases, "") - self.assertEqual(namespace.get("x"), {0: 0}) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_53(self) -> None: - match_cases = [MatchCase("{0: 0}", "y = 0")] - namespace = self.execute_match("x = {}", "x", match_cases, "") - self.assertEqual(namespace.get("x"), {}) - self.assertNotIn("y", namespace) - - def test_patma_ast_54(self) -> None: - match_cases = [MatchCase("{0: (z := (0 or 1 or 2))}", "y = 0")] - namespace = self.execute_match("x = {0: 0}", "x", match_cases, "") - self.assertEqual(namespace.get("x"), {0: 0}) - self.assertEqual(namespace.get("y"), 0) - self.assertEqual(namespace.get("z"), 0) - - def test_patma_ast_55(self) -> None: - match_cases = [MatchCase("{0: (z := (0 or 1 or 2))}", "y = 0")] - namespace = self.execute_match("x = {0: 1}", "x", match_cases, "") - self.assertEqual(namespace.get("x"), {0: 1}) - self.assertEqual(namespace.get("y"), 0) - self.assertEqual(namespace.get("z"), 1) - - def test_patma_ast_56(self) -> None: - match_cases = [MatchCase("{0: (z := (0 or 1 or 2))}", "y = 0")] - namespace = self.execute_match("x = {0: 2}", "x", match_cases, "") - self.assertEqual(namespace.get("x"), {0: 2}) - self.assertEqual(namespace.get("y"), 0) - self.assertEqual(namespace.get("z"), 2) - - def test_patma_ast_57(self) -> None: - match_cases = [MatchCase("{0: (z := (0 or 1 or 2))}", "y = 0")] - namespace = self.execute_match("x = {0: 3}", "x", match_cases, "") - self.assertEqual(namespace.get("x"), {0: 3}) - self.assertNotIn("y", namespace) - self.assertNotIn("z", namespace) - - def test_patma_ast_58(self) -> None: - match_cases = [ - MatchCase("{0: [1, 2, {}]}", "y = 0"), - MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), - MatchCase("[]", "y = 2"), - ] - namespace = self.execute_match("x = {}", "x", match_cases, "") - self.assertEqual(namespace.get("x"), {}) - self.assertNotIn("y", namespace) - - def test_patma_ast_59(self) -> None: - match_cases = [ - MatchCase("{0: [1, 2, {}]}", "y = 0"), - MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), - MatchCase("[]", "y = 2"), - ] - namespace = self.execute_match( - "x = {False: (True, 2.0, {})}", "x", match_cases, "" - ) - self.assertEqual(namespace.get("x"), {False: (True, 2.0, {})}) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_60(self) -> None: - match_cases = [ - MatchCase("{0: [1, 2, {}]}", "y = 0"), - MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), - MatchCase("[]", "y = 2"), - ] - namespace = self.execute_match( - "x = {False: (True, 2.0, {}), 1: [[]], 2: 0}", "x", match_cases, "" - ) - self.assertEqual(namespace.get("x"), {False: (True, 2.0, {}), 1: [[]], 2: 0}) - self.assertEqual(namespace.get("y"), 0) - - def test_patma_ast_61(self) -> None: - match_cases = [ - MatchCase("{0: [1, 2]}", "y = 0"), - MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), - MatchCase("[]", "y = 2"), - ] - namespace = self.execute_match( - "x = {False: (True, 2.0, {}), 1: [[]], 2: 0}", "x", match_cases, "" - ) - self.assertEqual(namespace.get("x"), {False: (True, 2.0, {}), 1: [[]], 2: 0}) - self.assertEqual(namespace.get("y"), 1) - - def test_patma_ast_62(self) -> None: - match_cases = [ - MatchCase("{0: [1, 2, {}]}", "y = 0"), - MatchCase("{0: [1, 2, {}], 1: [[]]}", "y = 1"), - MatchCase("[]", "y = 2"), - ] - namespace = self.execute_match("x = []", "x", match_cases, "") - self.assertEqual(namespace.get("x"), []) - self.assertEqual(namespace.get("y"), 2) - - def test_patma_ast_63(self) -> None: - match_cases = [ - MatchCase("{0: [1, 2, {}]}", "y = 0"), - MatchCase( - "{0: [1, 2, {}] or False} or {1: [[]]} or {0: [1, 2, {}]} or [] or 'X' or {}", - "y = 1", - ), - MatchCase("[]", "y = 2"), - ] - namespace = self.execute_match("x = {0: 0}", "x", match_cases, "") - self.assertEqual(namespace.get("x"), {0: 0}) - self.assertEqual(namespace.get("y"), 1) - - def test_patma_ast_64(self) -> None: - match_cases = [ - MatchCase("{0: [1, 2, {}]}", "y = 0"), - MatchCase( - "{0: [1, 2, {}] or True} or {1: [[]]} or {0: [1, 2, {}]} or [] or 'X' or {}", - "y = 1", - ), - MatchCase("[]", "y = 2"), - ] - namespace = self.execute_match("x = {0: 0}", "x", match_cases, "") - self.assertEqual(namespace.get("x"), {0: 0}) - self.assertEqual(namespace.get("y"), 1) - - class TestMatch(unittest.TestCase): def test_patma_000(self) -> None: @@ -1826,15 +1284,123 @@ def test_patma_138(self) -> None: self.assertEqual(y, 1) self.assertEqual(z, {}) + def test_patma_139(self) -> None: + x = False + match x: + case bool(z): + y = 0 + self.assertIs(x, False) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_140(self) -> None: + x = True + match x: + case bool(z): + y = 0 + self.assertIs(x, True) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_141(self) -> None: + x = bytearray() + match x: + case bytearray(z): + y = 0 + self.assertEqual(x, bytearray()) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_142(self) -> None: + x = b"" + match x: + case bytes(z): + y = 0 + self.assertEqual(x, b"") + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_143(self) -> None: + x = {} + match x: + case dict(z): + y = 0 + self.assertEqual(x, {}) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_144(self) -> None: + x = 0.0 + match x: + case float(z): + y = 0 + self.assertEqual(x, 0.0) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_145(self) -> None: + x = frozenset() + match x: + case frozenset(z): + y = 0 + self.assertEqual(x, frozenset()) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_146(self) -> None: + x = 0 + match x: + case int(z): + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_147(self) -> None: + x = [] + match x: + case list(z): + y = 0 + self.assertEqual(x, []) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_148(self) -> None: + x = set() + match x: + case set(z): + y = 0 + self.assertEqual(x, set()) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_149(self) -> None: + x = "" + match x: + case str(z): + y = 0 + self.assertEqual(x, "") + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_150(self) -> None: + x = () + match x: + case tuple(z): + y = 0 + self.assertEqual(x, ()) + self.assertEqual(y, 0) + self.assertIs(z, x) + def run_perf(self): # ./python -m pyperf timeit -s 'from test.test_patma import TestMatch; t = TestMatch()' 't.run_perf()' attrs = vars(type(self)).items() tests = [attr for name, attr in attrs if name.startswith("test_")] - assert_equal = self.assertEqual + assert_equal, assert_is = self.assertEqual, self.assertIs try: - self.assertEqual = lambda *_: None + self.assertEqual = self.assertIs = lambda *_: None for _ in range(1 << 10): for test in tests: test(self) finally: - self.assertEqual = assert_equal + self.assertEqual, self.assertIs = assert_equal, assert_is From 018e6ab26fe528371b5fda17c1deb978bce66921 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 28 Jun 2020 13:52:43 -0700 Subject: [PATCH 105/189] Cleanup --- Doc/library/dis.rst | 14 +++---- Include/opcode.h | 8 ++-- Lib/ast.py | 7 ++++ Lib/opcode.py | 8 ++-- Lib/test/test_patma.py | 86 ++++++++++++++++++++--------------------- Python/ast.c | 4 +- Python/ceval.c | 52 +++++++++++++------------ Python/compile.c | 16 ++++---- Python/opcode_targets.h | 8 ++-- Python/peephole.c | 8 ++-- 10 files changed, 112 insertions(+), 99 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 777ec49e142baf..86d999006f4e49 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1196,31 +1196,31 @@ All of the following opcodes use their arguments. .. versionadded:: 3.6 -.. opcode:: MATCH_CLS (count) +.. opcode:: MATCH_TYPE (count) TODO .. versionadded:: 3.10 -.. opcode:: MATCH_MAP (delta) +.. opcode:: JUMP_IF_NOT_MAP (delta) - If TOS is not a subclass of :class:`collections.abc.Mapping`, increment the + If TOS is not an instance of :class:`collections.abc.Mapping`, increment the bytecode counter by *delta*. .. versionadded:: 3.10 -.. opcode:: MATCH_SEQ (delta) +.. opcode:: JUMP_IF_NOT_SEQ (delta) - If TOS is a subclass of :class:`string`/:class:`bytes`/:class:`bytearray`, is - an :term:`iterator`, or is not a subclass of + If TOS is an instance of :class:`string`/:class:`bytes`/:class:`bytearray`, + is an :term:`iterator`, or is not an instance of :class:`collections.abc.Sequence`, increment the bytecode counter by *delta*. .. versionadded:: 3.10 -.. opcode:: MATCH_MAP_KEYS (copy) +.. opcode:: MATCH_KEYS (copy) TODO diff --git a/Include/opcode.h b/Include/opcode.h index cd6158ea0e11a0..af7fe4afc22201 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -118,10 +118,10 @@ extern "C" { #define SET_ADD 146 #define MAP_ADD 147 #define LOAD_CLASSDEREF 148 -#define MATCH_CLS 149 -#define MATCH_MAP_KEYS 150 -#define MATCH_MAP 151 -#define MATCH_SEQ 152 +#define MATCH_TYPE 149 +#define MATCH_KEYS 150 +#define JUMP_IF_NOT_MAP 151 +#define JUMP_IF_NOT_SEQ 152 #define SETUP_ASYNC_WITH 154 #define FORMAT_VALUE 155 #define BUILD_CONST_KEY_MAP 156 diff --git a/Lib/ast.py b/Lib/ast.py index d10852b45d06c4..abb9ffc5cfdf41 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -1367,7 +1367,14 @@ def visit_Attribute(self, node): def visit_Call(self, node): self.set_precedence(_Precedence.ATOM, node.func) + # We need to surround self.traverse(node.func) like this because + # ".xxx()" isn't legal in patterns (but visit_Name will try to include + # the leading dot if we're in a pattern). Temporary, as it's likely the + # pattern name load/store syntax will change... + _pattern = self.in_pattern() + self._pattern = False self.traverse(node.func) + self._pattern = _pattern with self.delimit("(", ")"): comma = False for e in node.args: diff --git a/Lib/opcode.py b/Lib/opcode.py index b19be82e14b526..751d56a4ca6f29 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -193,10 +193,10 @@ def jabs_op(name, op): def_op('MAP_ADD', 147) def_op('LOAD_CLASSDEREF', 148) hasfree.append(148) -def_op('MATCH_CLS', 149) -def_op('MATCH_MAP_KEYS', 150) -jrel_op('MATCH_MAP', 151) -jrel_op('MATCH_SEQ', 152) +def_op('MATCH_TYPE', 149) +def_op('MATCH_KEYS', 150) +jrel_op('JUMP_IF_NOT_MAP', 151) +jrel_op('JUMP_IF_NOT_SEQ', 152) jrel_op('SETUP_ASYNC_WITH', 154) def_op('FORMAT_VALUE', 155) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index e998cede3b7370..7c25c06c25404d 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -299,7 +299,7 @@ def test_patma_034(self) -> None: match x: case {0: [1, 2, {}]}: y = 0 - case {0: ([1, 2, {}] | False)} | {1: [[]]} | {0: [1, 2, {}]} | [] | 'X' | {}: + case {0: ([1, 2, {}] | False)} | {1: [[]]} | {0: [1, 2, {}]} | [] | "X" | {}: y = 1 case []: y = 2 @@ -311,7 +311,7 @@ def test_patma_035(self) -> None: match x: case {0: [1, 2, {}]}: y = 0 - case {0: [1, 2, {}] | True} | {1: [[]]} | {0: [1, 2, {}]} | [] | 'X' | {}: + case {0: [1, 2, {}] | True} | {1: [[]]} | {0: [1, 2, {}]} | [] | "X" | {}: y = 1 case []: y = 2 @@ -573,43 +573,43 @@ def test_patma_063(self) -> None: self.assertEqual(y, None) def test_patma_064(self) -> None: - x = 'x' + x = "x" match x: - case 'x': + case "x": y = 0 - case 'y': + case "y": y = 1 - self.assertEqual(x, 'x') + self.assertEqual(x, "x") self.assertEqual(y, 0) def test_patma_065(self) -> None: - x = 'x' + x = "x" match x: - case 'y': + case "y": y = 0 - case 'x': + case "x": y = 1 - self.assertEqual(x, 'x') + self.assertEqual(x, "x") self.assertEqual(y, 1) def test_patma_066(self) -> None: - x = 'x' + x = "x" match x: - case 'x': + case "x": y = 0 - case 'y': + case "y": y = 1 - self.assertEqual(x, 'x') + self.assertEqual(x, "x") self.assertEqual(y, 0) def test_patma_067(self) -> None: - x = b'x' + x = b"x" match x: - case b'y': + case b"y": y = 0 - case b'x': + case b"x": y = 1 - self.assertEqual(x, b'x') + self.assertEqual(x, b"x") self.assertEqual(y, 1) def test_patma_068(self) -> None: @@ -687,74 +687,74 @@ def test_patma_074(self) -> None: self.assertEqual(y, None) def test_patma_075(self) -> None: - x = 'x' + x = "x" match x: - case ['x']: + case ["x"]: y = 0 - case 'x': + case "x": y = 1 - self.assertEqual(x, 'x') + self.assertEqual(x, "x") self.assertEqual(y, 1) def test_patma_076(self) -> None: - x = b'x' + x = b"x" match x: - case [b'x']: + case [b"x"]: y = 0 - case ['x']: + case ["x"]: y = 1 case [120]: y = 2 - case b'x': + case b"x": y = 4 - self.assertEqual(x, b'x') + self.assertEqual(x, b"x") self.assertEqual(y, 4) def test_patma_077(self) -> None: - x = bytearray(b'x') + x = bytearray(b"x") y = None match x: case [120]: y = 0 case 120: y = 1 - self.assertEqual(x, b'x') + self.assertEqual(x, b"x") self.assertEqual(y, None) def test_patma_078(self) -> None: - x = '' + x = "" match x: case []: y = 0 - case ['']: + case [""]: y = 1 - case '': + case "": y = 2 - self.assertEqual(x, '') + self.assertEqual(x, "") self.assertEqual(y, 2) def test_patma_079(self) -> None: - x = 'xxx' + x = "xxx" match x: - case ['x', 'x', 'x']: + case ["x", "x", "x"]: y = 0 - case ['xxx']: + case ["xxx"]: y = 1 - case 'xxx': + case "xxx": y = 2 - self.assertEqual(x, 'xxx') + self.assertEqual(x, "xxx") self.assertEqual(y, 2) def test_patma_080(self) -> None: - x = b'xxx' + x = b"xxx" match x: case [120, 120, 120]: y = 0 - case [b'xxx']: + case [b"xxx"]: y = 1 - case b'xxx': + case b"xxx": y = 2 - self.assertEqual(x, b'xxx') + self.assertEqual(x, b"xxx") self.assertEqual(y, 2) def test_patma_081(self) -> None: @@ -1393,7 +1393,7 @@ def test_patma_150(self) -> None: self.assertIs(z, x) def run_perf(self): - # ./python -m pyperf timeit -s 'from test.test_patma import TestMatch; t = TestMatch()' 't.run_perf()' + # ./python -m pyperf timeit -s "from test.test_patma import TestMatch; t = TestMatch()" "t.run_perf()" attrs = vars(type(self)).items() tests = [attr for name, attr in attrs if name.startswith("test_")] assert_equal, assert_is = self.assertEqual, self.assertIs diff --git a/Python/ast.c b/Python/ast.c index 22a90ff42007e3..90e6e9b4313605 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -402,7 +402,8 @@ validate_pattern(expr_ty p) } return 1; case List_kind: - values = p->v.List.elts; + case Tuple_kind: + values = p->kind == List_kind ? p->v.List.elts : p->v.Tuple.elts; size = asdl_seq_LEN(values); for (i = 0; i < size; i++) { value = asdl_seq_GET(values, i); @@ -431,6 +432,7 @@ validate_pattern(expr_ty p) return (validate_pattern(p->v.NamedExpr.value) && validate_expr(p->v.NamedExpr.target, Store)); case UnaryOp_kind: + // TODO return 1; default: PyErr_SetString(PyExc_ValueError, "invalid Match pattern"); diff --git a/Python/ceval.c b/Python/ceval.c index 1a97b12c2802ce..8225f3bb91c8f2 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -857,7 +857,7 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, PyObject * if (PyMapping_Length(map) < nkeys) { goto fail; } - seen = PySet_New(NULL); + seen = PyList_New(0); if (!seen) { goto fail; } @@ -867,8 +867,8 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, PyObject * } for (Py_ssize_t i = 0; i < nkeys; i++) { PyObject *key = PyTuple_GET_ITEM(keys, i); - int dupe = PySet_Contains(seen, key); - if (dupe || PySet_Add(seen, key)) { + int dupe = PySequence_Contains(seen, key); + if (dupe || PyList_Append(seen, key)) { if (!_PyErr_Occurred(tstate)) { _PyErr_Format(tstate, PyExc_ImpossibleMatchError, "mapping pattern checks duplicate key (%R)", key); @@ -913,8 +913,8 @@ get_match_args(PyThreadState *tstate, PyObject *type) return match_args; } _PyErr_Format(tstate, PyExc_TypeError, - "__match_args__ must be a list or tuple (got %s)", - Py_TYPE(match_args)->tp_name); + "%s.__match_args__ must be a list or tuple (got %s)", + ((PyTypeObject *)type)->tp_name, Py_TYPE(match_args)->tp_name); Py_DECREF(match_args); return NULL; } @@ -939,7 +939,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty _PyErr_Clear(tstate); _PyErr_Format(tstate, PyExc_ImpossibleMatchError, "type %s cannot be matched", - Py_TYPE(type)->tp_name); + ((PyTypeObject *)type)->tp_name); return NULL; } PyObject *proxy = PyObject_CallOneArg(method, target); @@ -957,6 +957,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty if (!match_args && _PyErr_Occurred(tstate)) { goto error; } + Py_ssize_t nmatch_args; if (!nargs) { args = PyTuple_New(0); if (!args) { @@ -964,28 +965,30 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty } } else if (!match_args) { - if (PyType_HasFeature((PyTypeObject *)type, _Py_TPFLAGS_SIMPLE_MATCH)) { - if (nargs > 1) { - _PyErr_Format(tstate, PyExc_ImpossibleMatchError, - "too many positional matches in pattern (expected at most 1, got %d)", - nargs); - goto error; - } + if (!PyType_HasFeature((PyTypeObject *)type, _Py_TPFLAGS_SIMPLE_MATCH)) { + nmatch_args = 0; + // TODO: Combine with below (and reword for 0): + _PyErr_Format(tstate, PyExc_ImpossibleMatchError, + "%s() takes at most %d positional sub-patterns (%d given)", + ((PyTypeObject *)type)->tp_name, nmatch_args, nargs); + goto error; } - else { + nmatch_args = 1; + if (nargs > 1) { + // TODO: Combine with above (and reword for 0): _PyErr_Format(tstate, PyExc_ImpossibleMatchError, - "too many positional matches in pattern (expected none, got %d)", - nargs); + "%s() takes at most %d positional sub-patterns (%d given)", + ((PyTypeObject *)type)->tp_name, nmatch_args, nargs); goto error; } } else { Py_ssize_t nmatch_args = PySequence_Fast_GET_SIZE(match_args); if (nmatch_args < nargs) { - // TODO: Combine with above: + // TODO: Combine with above (and reword for 0): _PyErr_Format(tstate, PyExc_ImpossibleMatchError, - "too many positional matches in pattern (expected at most %d, got %d)", - nmatch_args, nargs); + "%s() takes at most %d positional sub-patterns (%d given)", + ((PyTypeObject *)type)->tp_name, nmatch_args, nargs); return NULL; } args = PyList_CheckExact(match_args) ? PyList_GetSlice(match_args, 0, nargs) : PyTuple_GetSlice(match_args, 0, nargs); @@ -1026,7 +1029,8 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty if (dupe || PySet_Add(seen, name)) { if (!_PyErr_Occurred(tstate)) { _PyErr_Format(tstate, PyExc_ImpossibleMatchError, - "multiple patterns bound to attribute %R", name); + "%s() got multiple sub-patterns for attribute %R", + ((PyTypeObject *)type)->tp_name, name); } goto error; } @@ -3496,7 +3500,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) #endif } - case TARGET(MATCH_CLS): { + case TARGET(MATCH_TYPE): { PyObject *names = POP(); PyObject *type = TOP(); PyObject *target = SECOND(); @@ -3512,7 +3516,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(MATCH_MAP): { + case TARGET(JUMP_IF_NOT_MAP): { PyInterpreterState *interp = PyInterpreterState_Get(); if (!interp) { goto error; @@ -3538,7 +3542,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(MATCH_SEQ): { + case TARGET(JUMP_IF_NOT_SEQ): { PyObject *target = TOP(); if (PyType_FastSubclass(Py_TYPE(target), Py_TPFLAGS_UNICODE_SUBCLASS | Py_TPFLAGS_BYTES_SUBCLASS) @@ -3573,7 +3577,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(MATCH_MAP_KEYS): { + case TARGET(MATCH_KEYS): { PyObject *keys = TOP(); PyObject *target = SECOND(); PyObject *copy = NULL; diff --git a/Python/compile.c b/Python/compile.c index 333f9ab868bd21..f566a948105dac 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1103,13 +1103,13 @@ stack_effect(int opcode, int oparg, int jump) case DICT_MERGE: case DICT_UPDATE: return -1; - case MATCH_CLS: + case MATCH_TYPE: return -1; - case MATCH_MAP_KEYS: + case MATCH_KEYS: case GET_LEN: return 1; - case MATCH_MAP: - case MATCH_SEQ: + case JUMP_IF_NOT_MAP: + case JUMP_IF_NOT_SEQ: return 0; default: return PY_INVALID_STACK_EFFECT; @@ -2787,7 +2787,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, basicblock *fail, PyObject* PyTuple_SET_ITEM(kwnames, i, name); } ADDOP_LOAD_CONST_NEW(c, kwnames); - ADDOP_I(c, MATCH_CLS, nargs + nkwargs); + ADDOP_I(c, MATCH_TYPE, nargs + nkwargs); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); for (i = 0; i < nargs; i++) { expr_ty arg = asdl_seq_GET(args, i); @@ -2848,7 +2848,7 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje asdl_seq *values = p->v.Dict.values; Py_ssize_t size = asdl_seq_LEN(values); int star = size ? !asdl_seq_GET(keys, size - 1) : 0; - ADDOP_JREL(c, MATCH_MAP, block); + ADDOP_JREL(c, JUMP_IF_NOT_MAP, block); if (size - star) { ADDOP(c, GET_LEN); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - star)); @@ -2867,7 +2867,7 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje VISIT(c, expr, asdl_seq_GET(keys, i)); } ADDOP_I(c, BUILD_TUPLE, size - star); - ADDOP_I(c, MATCH_MAP_KEYS, star); + ADDOP_I(c, MATCH_KEYS, star); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block_star) for (i = 0; i < size - star; i++) { expr_ty value = asdl_seq_GET(values, i); @@ -2996,7 +2996,7 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj basicblock *block, *end; CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); - ADDOP_JREL(c, MATCH_SEQ, block); + ADDOP_JREL(c, JUMP_IF_NOT_SEQ, block); if (star >= 0) { if (size) { ADDOP(c, GET_LEN); diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 6c15c9d771f370..4c6721c6d212a2 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -148,10 +148,10 @@ static void *opcode_targets[256] = { &&TARGET_SET_ADD, &&TARGET_MAP_ADD, &&TARGET_LOAD_CLASSDEREF, - &&TARGET_MATCH_CLS, - &&TARGET_MATCH_MAP_KEYS, - &&TARGET_MATCH_MAP, - &&TARGET_MATCH_SEQ, + &&TARGET_MATCH_TYPE, + &&TARGET_MATCH_KEYS, + &&TARGET_JUMP_IF_NOT_MAP, + &&TARGET_JUMP_IF_NOT_SEQ, &&_unknown_opcode, &&TARGET_SETUP_ASYNC_WITH, &&TARGET_FORMAT_VALUE, diff --git a/Python/peephole.c b/Python/peephole.c index 8e95760c12a045..a744b2087016c3 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -198,8 +198,8 @@ markblocks(_Py_CODEUNIT *code, Py_ssize_t len) case SETUP_FINALLY: case SETUP_WITH: case SETUP_ASYNC_WITH: - case MATCH_MAP: - case MATCH_SEQ: + case JUMP_IF_NOT_MAP: + case JUMP_IF_NOT_SEQ: j = GETJUMPTGT(code, i); assert(j < len); blocks[j] = 1; @@ -504,8 +504,8 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, case SETUP_FINALLY: case SETUP_WITH: case SETUP_ASYNC_WITH: - case MATCH_MAP: - case MATCH_SEQ: + case JUMP_IF_NOT_MAP: + case JUMP_IF_NOT_SEQ: j = blocks[j / sizeof(_Py_CODEUNIT) + i + 1] - blocks[i] - 1; j *= sizeof(_Py_CODEUNIT); break; From 7a6d897433d7ae14e8cca5c24d3f418991393294 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 28 Jun 2020 14:15:21 -0700 Subject: [PATCH 106/189] Add pattern_context --- Python/compile.c | 88 +++++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index f566a948105dac..1259955b293f8f 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -177,6 +177,14 @@ struct compiler { PyArena *c_arena; /* pointer to memory allocation arena */ }; +typedef struct { + // Py_ssize_t map_len_ge; + // Py_ssize_t seq_len_ge; + // Py_ssize_t seq_len_eq; + // basicblock *success; + basicblock *failure; +} pattern_context; + static int compiler_enter_scope(struct compiler *, identifier, int, void *, int); static void compiler_free(struct compiler *); static basicblock *compiler_new_block(struct compiler *); @@ -222,7 +230,7 @@ static int compiler_async_comprehension_generator( int depth, expr_ty elt, expr_ty val, int type); -static int compiler_pattern(struct compiler *, expr_ty, basicblock *, PyObject *); +static int compiler_pattern(struct compiler *, expr_ty, pattern_context *, PyObject *); static PyCodeObject *assemble(struct compiler *, int addNone); static PyObject *__doc__, *__annotations__; @@ -2746,25 +2754,23 @@ compiler_if(struct compiler *c, stmt_ty s) return 1; } -// TODO: Remove Store part of check if disallowing all usage of _: #define WILDCARD_CHECK(N) \ - ((N)->kind == Name_kind && _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) + ((N)->kind == Name_kind && (N)->v.Name.ctx == Store && _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) static int -compiler_pattern_load(struct compiler *c, expr_ty p, basicblock *fail) +compiler_pattern_load(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Attribute_kind || p->kind == Constant_kind || p->kind == Name_kind); assert(p->kind != Attribute_kind || p->v.Attribute.ctx == Load); assert(p->kind != Name_kind || p->v.Name.ctx == Load); - // TODO: Guard against wildcards here? VISIT(c, expr, p); ADDOP_COMPARE(c, Eq); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, fail); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, pc->failure); return 1; } static int -compiler_pattern_call(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) { +compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* names) { asdl_seq *args = p->v.Call.args; asdl_seq *kwargs = p->v.Call.keywords; Py_ssize_t nargs = asdl_seq_LEN(args); @@ -2789,6 +2795,8 @@ compiler_pattern_call(struct compiler *c, expr_ty p, basicblock *fail, PyObject* ADDOP_LOAD_CONST_NEW(c, kwnames); ADDOP_I(c, MATCH_TYPE, nargs + nkwargs); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + pattern_context sub_pc = *pc; + sub_pc.failure = block; for (i = 0; i < nargs; i++) { expr_ty arg = asdl_seq_GET(args, i); if (WILDCARD_CHECK(arg)) { @@ -2797,7 +2805,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, basicblock *fail, PyObject* ADDOP(c, DUP_TOP); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); ADDOP(c, BINARY_SUBSCR); - CHECK(compiler_pattern(c, arg, block, names)); + CHECK(compiler_pattern(c, arg, &sub_pc, names)); } for (i = 0; i < nkwargs; i++) { keyword_ty kwarg = asdl_seq_GET(kwargs, i); @@ -2807,13 +2815,13 @@ compiler_pattern_call(struct compiler *c, expr_ty p, basicblock *fail, PyObject* ADDOP(c, DUP_TOP); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(nargs + i)); ADDOP(c, BINARY_SUBSCR); - CHECK(compiler_pattern(c, kwarg->value, block, names)); + CHECK(compiler_pattern(c, kwarg->value, &sub_pc, names)); } ADDOP(c, POP_TOP); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, fail); + ADDOP_JREL(c, JUMP_FORWARD, pc->failure); compiler_use_next_block(c, end); return 1; } @@ -2838,7 +2846,7 @@ compiler_pattern_store(struct compiler *c, expr_ty p, int wildcard_ok, PyObject* } static int -compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) +compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* names) { basicblock *block, *block_star, *end; CHECK(block_star = compiler_new_block(c)); @@ -2869,6 +2877,8 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje ADDOP_I(c, BUILD_TUPLE, size - star); ADDOP_I(c, MATCH_KEYS, star); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block_star) + pattern_context sub_pc = *pc; + sub_pc.failure = block_star; for (i = 0; i < size - star; i++) { expr_ty value = asdl_seq_GET(values, i); if (WILDCARD_CHECK(value)) { @@ -2877,7 +2887,7 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje ADDOP(c, DUP_TOP); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); ADDOP(c, BINARY_SUBSCR); - CHECK(compiler_pattern(c, value, block_star, names)); + CHECK(compiler_pattern(c, value, &sub_pc, names)); } ADDOP(c, POP_TOP); if (star) { @@ -2891,42 +2901,44 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, basicblock *fail, PyObje ADDOP(c, POP_TOP); compiler_use_next_block(c, block); ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, fail); + ADDOP_JREL(c, JUMP_FORWARD, pc->failure); compiler_use_next_block(c, end); return 1; } static int -compiler_pattern_name(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) +compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* names) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Load || p->v.Name.ctx == Store); if (p->v.Name.ctx == Load) { - return compiler_pattern_load(c, p, fail); + return compiler_pattern_load(c, p, pc); } return compiler_pattern_store(c, p, 1, names); } static int -compiler_pattern_namedexpr(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) +compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* names) { assert(p->kind == NamedExpr_kind); basicblock *block, *end; CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); ADDOP(c, DUP_TOP); - CHECK(compiler_pattern(c, p->v.NamedExpr.value, block, names)); + pattern_context sub_pc = *pc; + sub_pc.failure = block; + CHECK(compiler_pattern(c, p->v.NamedExpr.value, &sub_pc, names)); CHECK(compiler_pattern_store(c, p->v.NamedExpr.target, 0, names)); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, fail); + ADDOP_JREL(c, JUMP_FORWARD, pc->failure); compiler_use_next_block(c, end); return 1; } static int -compiler_pattern_or(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) +compiler_pattern_or(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* names) { assert(p->kind == BoolOp_kind); assert(p->v.BoolOp.op == Or); @@ -2940,7 +2952,9 @@ compiler_pattern_or(struct compiler *c, expr_ty p, basicblock *fail, PyObject* n CHECK(names_copy = PySet_New(names)); CHECK(block = compiler_new_block(c)); ADDOP(c, DUP_TOP); - CHECK(compiler_pattern(c, asdl_seq_GET(p->v.BoolOp.values, i), block, names_copy)); + pattern_context sub_pc = *pc; + sub_pc.failure = block; + CHECK(compiler_pattern(c, asdl_seq_GET(p->v.BoolOp.values, i), &sub_pc, names_copy)); ADDOP(c, POP_TOP); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); @@ -2971,13 +2985,13 @@ compiler_pattern_or(struct compiler *c, expr_ty p, basicblock *fail, PyObject* n assert(control); Py_DECREF(control); ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, fail); + ADDOP_JREL(c, JUMP_FORWARD, pc->failure); compiler_use_next_block(c, end); return 1; } static int -compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) +compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* names) { assert(p->kind == List_kind || p->kind == Tuple_kind); asdl_seq *values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; @@ -3011,6 +3025,8 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj ADDOP_COMPARE(c, Eq); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); } + pattern_context sub_pc = *pc; + sub_pc.failure = block; for (Py_ssize_t i = 0; i < size; i++) { expr_ty value = asdl_seq_GET(values, i); if (WILDCARD_CHECK(value)) { @@ -3051,46 +3067,46 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, basicblock *fail, PyObj ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(-(size - i))); ADDOP(c, BINARY_SUBSCR); } - CHECK(compiler_pattern(c, value, block, names)); + CHECK(compiler_pattern(c, value, &sub_pc, names)); } ADDOP(c, POP_TOP); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, fail); + ADDOP_JREL(c, JUMP_FORWARD, pc->failure); compiler_use_next_block(c, end); return 1; } static int -compiler_pattern(struct compiler *c, expr_ty p, basicblock *fail, PyObject* names) +compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* names) { SET_LOC(c, p); switch (p->kind) { case Attribute_kind: - return compiler_pattern_load(c, p, fail); + return compiler_pattern_load(c, p, pc); case BinOp_kind: // Because we allow "2+2j", things like "2+2" make it this far: return compiler_error(c, "patterns cannot include operators"); case BoolOp_kind: - return compiler_pattern_or(c, p, fail, names); + return compiler_pattern_or(c, p, pc, names); case Call_kind: - return compiler_pattern_call(c, p, fail, names); + return compiler_pattern_call(c, p, pc, names); case Constant_kind: - return compiler_pattern_load(c, p, fail); + return compiler_pattern_load(c, p, pc); case Dict_kind: - return compiler_pattern_mapping(c, p, fail, names); + return compiler_pattern_mapping(c, p, pc, names); case JoinedStr_kind: // Because we allow strings, f-strings make it this far: return compiler_error(c, "patterns cannot include f-strings"); case List_kind: - return compiler_pattern_sequence(c, p, fail, names); + return compiler_pattern_sequence(c, p, pc, names); case Name_kind: - return compiler_pattern_name(c, p, fail, names); + return compiler_pattern_name(c, p, pc, names); case NamedExpr_kind: - return compiler_pattern_namedexpr(c, p, fail, names); + return compiler_pattern_namedexpr(c, p, pc, names); case Tuple_kind: - return compiler_pattern_sequence(c, p, fail, names); + return compiler_pattern_sequence(c, p, pc, names); default: Py_UNREACHABLE(); } @@ -3115,7 +3131,9 @@ compiler_match(struct compiler *c, stmt_ty s) if (!names) { return 0; } - int result = compiler_pattern(c, m->pattern, next, names); + pattern_context pc; + pc.failure = next; + int result = compiler_pattern(c, m->pattern, &pc, names); Py_DECREF(names); CHECK(result); if (m->guard) { From 7953dee7d579af52801bcb041cd3c0d2f28e6a23 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 28 Jun 2020 15:43:37 -0700 Subject: [PATCH 107/189] Keep bound names in pattern context --- Python/compile.c | 61 +++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 1259955b293f8f..c57c2e29a1db47 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -183,6 +183,7 @@ typedef struct { // Py_ssize_t seq_len_eq; // basicblock *success; basicblock *failure; + PyObject* stores; } pattern_context; static int compiler_enter_scope(struct compiler *, identifier, int, void *, int); @@ -230,7 +231,7 @@ static int compiler_async_comprehension_generator( int depth, expr_ty elt, expr_ty val, int type); -static int compiler_pattern(struct compiler *, expr_ty, pattern_context *, PyObject *); +static int compiler_pattern(struct compiler *, expr_ty, pattern_context *); static PyCodeObject *assemble(struct compiler *, int addNone); static PyObject *__doc__, *__annotations__; @@ -2770,7 +2771,7 @@ compiler_pattern_load(struct compiler *c, expr_ty p, pattern_context *pc) } static int -compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* names) { +compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { asdl_seq *args = p->v.Call.args; asdl_seq *kwargs = p->v.Call.keywords; Py_ssize_t nargs = asdl_seq_LEN(args); @@ -2805,7 +2806,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc, PyObje ADDOP(c, DUP_TOP); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); ADDOP(c, BINARY_SUBSCR); - CHECK(compiler_pattern(c, arg, &sub_pc, names)); + CHECK(compiler_pattern(c, arg, &sub_pc)); } for (i = 0; i < nkwargs; i++) { keyword_ty kwarg = asdl_seq_GET(kwargs, i); @@ -2815,7 +2816,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc, PyObje ADDOP(c, DUP_TOP); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(nargs + i)); ADDOP(c, BINARY_SUBSCR); - CHECK(compiler_pattern(c, kwarg->value, &sub_pc, names)); + CHECK(compiler_pattern(c, kwarg->value, &sub_pc)); } ADDOP(c, POP_TOP); ADDOP_JREL(c, JUMP_FORWARD, end); @@ -2827,7 +2828,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc, PyObje } static int -compiler_pattern_store(struct compiler *c, expr_ty p, int wildcard_ok, PyObject* names) { +compiler_pattern_store(struct compiler *c, expr_ty p, pattern_context *pc, int wildcard_ok) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); if (WILDCARD_CHECK(p)) { @@ -2837,16 +2838,16 @@ compiler_pattern_store(struct compiler *c, expr_ty p, int wildcard_ok, PyObject* ADDOP(c, POP_TOP); return 1; } - if (PySet_Contains(names, p->v.Name.id)) { + if (PySet_Contains(pc->stores, p->v.Name.id)) { // TODO: Format this error message with the name. return compiler_error(c, "multiple assignments to name in pattern"); } VISIT(c, expr, p); - return !PySet_Add(names, p->v.Name.id); + return !PySet_Add(pc->stores, p->v.Name.id); } static int -compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* names) +compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc) { basicblock *block, *block_star, *end; CHECK(block_star = compiler_new_block(c)); @@ -2887,11 +2888,11 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc, PyO ADDOP(c, DUP_TOP); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); ADDOP(c, BINARY_SUBSCR); - CHECK(compiler_pattern(c, value, &sub_pc, names)); + CHECK(compiler_pattern(c, value, &sub_pc)); } ADDOP(c, POP_TOP); if (star) { - CHECK(compiler_pattern_store(c, asdl_seq_GET(values, size - 1), 0, names)); + CHECK(compiler_pattern_store(c, asdl_seq_GET(values, size - 1), pc, 0)); } else { ADDOP(c, POP_TOP); @@ -2907,18 +2908,18 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc, PyO } static int -compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* names) +compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Load || p->v.Name.ctx == Store); if (p->v.Name.ctx == Load) { return compiler_pattern_load(c, p, pc); } - return compiler_pattern_store(c, p, 1, names); + return compiler_pattern_store(c, p, pc, 1); } static int -compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* names) +compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == NamedExpr_kind); basicblock *block, *end; @@ -2927,8 +2928,8 @@ compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc, P ADDOP(c, DUP_TOP); pattern_context sub_pc = *pc; sub_pc.failure = block; - CHECK(compiler_pattern(c, p->v.NamedExpr.value, &sub_pc, names)); - CHECK(compiler_pattern_store(c, p->v.NamedExpr.target, 0, names)); + CHECK(compiler_pattern(c, p->v.NamedExpr.value, &sub_pc)); + CHECK(compiler_pattern_store(c, p->v.NamedExpr.target, pc, 0)); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); ADDOP(c, POP_TOP); @@ -2938,7 +2939,7 @@ compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc, P } static int -compiler_pattern_or(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* names) +compiler_pattern_or(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == BoolOp_kind); assert(p->v.BoolOp.op == Or); @@ -2949,12 +2950,13 @@ compiler_pattern_or(struct compiler *c, expr_ty p, pattern_context *pc, PyObject assert(size > 1); PyObject *names_copy; for (Py_ssize_t i = 0; i < size; i++) { - CHECK(names_copy = PySet_New(names)); + CHECK(names_copy = PySet_New(pc->stores)); CHECK(block = compiler_new_block(c)); ADDOP(c, DUP_TOP); pattern_context sub_pc = *pc; sub_pc.failure = block; - CHECK(compiler_pattern(c, asdl_seq_GET(p->v.BoolOp.values, i), &sub_pc, names_copy)); + sub_pc.stores = names_copy; + CHECK(compiler_pattern(c, asdl_seq_GET(p->v.BoolOp.values, i), &sub_pc)); ADDOP(c, POP_TOP); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); @@ -2991,7 +2993,7 @@ compiler_pattern_or(struct compiler *c, expr_ty p, pattern_context *pc, PyObject } static int -compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* names) +compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == List_kind || p->kind == Tuple_kind); asdl_seq *values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; @@ -3067,7 +3069,7 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context *pc, Py ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(-(size - i))); ADDOP(c, BINARY_SUBSCR); } - CHECK(compiler_pattern(c, value, &sub_pc, names)); + CHECK(compiler_pattern(c, value, &sub_pc)); } ADDOP(c, POP_TOP); ADDOP_JREL(c, JUMP_FORWARD, end); @@ -3079,7 +3081,7 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context *pc, Py } static int -compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* names) +compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc) { SET_LOC(c, p); switch (p->kind) { @@ -3089,24 +3091,24 @@ compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc, PyObject* n // Because we allow "2+2j", things like "2+2" make it this far: return compiler_error(c, "patterns cannot include operators"); case BoolOp_kind: - return compiler_pattern_or(c, p, pc, names); + return compiler_pattern_or(c, p, pc); case Call_kind: - return compiler_pattern_call(c, p, pc, names); + return compiler_pattern_call(c, p, pc); case Constant_kind: return compiler_pattern_load(c, p, pc); case Dict_kind: - return compiler_pattern_mapping(c, p, pc, names); + return compiler_pattern_mapping(c, p, pc); case JoinedStr_kind: // Because we allow strings, f-strings make it this far: return compiler_error(c, "patterns cannot include f-strings"); case List_kind: - return compiler_pattern_sequence(c, p, pc, names); + return compiler_pattern_sequence(c, p, pc); case Name_kind: - return compiler_pattern_name(c, p, pc, names); + return compiler_pattern_name(c, p, pc); case NamedExpr_kind: - return compiler_pattern_namedexpr(c, p, pc, names); + return compiler_pattern_namedexpr(c, p, pc); case Tuple_kind: - return compiler_pattern_sequence(c, p, pc, names); + return compiler_pattern_sequence(c, p, pc); default: Py_UNREACHABLE(); } @@ -3133,7 +3135,8 @@ compiler_match(struct compiler *c, stmt_ty s) } pattern_context pc; pc.failure = next; - int result = compiler_pattern(c, m->pattern, &pc, names); + pc.stores = names; + int result = compiler_pattern(c, m->pattern, &pc); Py_DECREF(names); CHECK(result); if (m->guard) { From 214101e3086199af213ce4c7475a5c52c2bc3ab8 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 29 Jun 2020 12:59:46 -0700 Subject: [PATCH 108/189] Address recent __match__ protocol changes --- Doc/c-api/exceptions.rst | 3 -- Doc/library/exceptions.rst | 7 ---- Include/pyerrors.h | 1 - Lib/_compat_pickle.py | 7 ---- Lib/test/exception_hierarchy.txt | 1 - Lib/test/test_pickle.py | 8 ---- Objects/exceptions.c | 9 ---- Python/ceval.c | 70 ++++++++++++-------------------- 8 files changed, 26 insertions(+), 80 deletions(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index 59b363f2fbd2d8..e7805ba143c584 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -796,7 +796,6 @@ the variables: single: PyExc_FloatingPointError single: PyExc_GeneratorExit single: PyExc_ImportError - single: PyExc_ImpossibleMatchError single: PyExc_IndentationError single: PyExc_IndexError single: PyExc_InterruptedError @@ -873,8 +872,6 @@ the variables: +-----------------------------------------+---------------------------------+----------+ | :c:data:`PyExc_ImportError` | :exc:`ImportError` | | +-----------------------------------------+---------------------------------+----------+ -| :c:data:`PyExc_ImpossibleMatchError` | :exc:`ImpossibleMatchError` | | -+-----------------------------------------+---------------------------------+----------+ | :c:data:`PyExc_IndentationError` | :exc:`IndentationError` | | +-----------------------------------------+---------------------------------+----------+ | :c:data:`PyExc_IndexError` | :exc:`IndexError` | | diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index 70c84a382204e0..d852ba7c688391 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -180,13 +180,6 @@ The following exceptions are the exceptions that are usually raised. Added the :attr:`name` and :attr:`path` attributes. -.. exception:: ImpossibleMatchError - - TODO - - .. versionadded:: 3.10 - - .. exception:: ModuleNotFoundError A subclass of :exc:`ImportError` which is raised by :keyword:`import` diff --git a/Include/pyerrors.h b/Include/pyerrors.h index 4a47d774a2c615..979a26ba68a033 100644 --- a/Include/pyerrors.h +++ b/Include/pyerrors.h @@ -107,7 +107,6 @@ PyAPI_DATA(PyObject *) PyExc_ReferenceError; PyAPI_DATA(PyObject *) PyExc_SystemError; PyAPI_DATA(PyObject *) PyExc_SystemExit; PyAPI_DATA(PyObject *) PyExc_TypeError; -PyAPI_DATA(PyObject *) PyExc_ImpossibleMatchError; PyAPI_DATA(PyObject *) PyExc_UnboundLocalError; PyAPI_DATA(PyObject *) PyExc_UnicodeError; PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError; diff --git a/Lib/_compat_pickle.py b/Lib/_compat_pickle.py index 9038eea46c08c3..f68496ae639f5f 100644 --- a/Lib/_compat_pickle.py +++ b/Lib/_compat_pickle.py @@ -249,10 +249,3 @@ for excname in PYTHON3_IMPORTERROR_EXCEPTIONS: REVERSE_NAME_MAPPING[('builtins', excname)] = ('exceptions', 'ImportError') - -PYTHON3_TYPEERROR_EXCEPTIONS = ( - 'ImpossibleMatchError', -) - -for excname in PYTHON3_TYPEERROR_EXCEPTIONS: - REVERSE_NAME_MAPPING[('builtins', excname)] = ('exceptions', 'TypeError') diff --git a/Lib/test/exception_hierarchy.txt b/Lib/test/exception_hierarchy.txt index ac349aadea63fa..763a6c899b48eb 100644 --- a/Lib/test/exception_hierarchy.txt +++ b/Lib/test/exception_hierarchy.txt @@ -46,7 +46,6 @@ BaseException | +-- TabError +-- SystemError +-- TypeError - | +-- ImpossibleMatchError +-- ValueError | +-- UnicodeError | +-- UnicodeDecodeError diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py index 15da43d45d5d39..2307b133dbd0d5 100644 --- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -421,9 +421,6 @@ def test_name_mapping(self): elif (module2, name2) == ('exceptions', 'ImportError'): attr = getattribute(module3, name3) self.assertTrue(issubclass(attr, ImportError)) - elif (module2, name2) == ('exceptions', 'TypeError'): - attr = getattribute(module3, name3) - self.assertTrue(issubclass(attr, TypeError)) else: module, name = mapping(module2, name2) if module3[:1] != '_': @@ -495,11 +492,6 @@ def test_exceptions(self): ('exceptions', 'ImportError')) self.assertEqual(mapping('exceptions', name), ('exceptions', name)) - elif exc is not TypeError and issubclass(exc, TypeError): - self.assertEqual(reverse_mapping('builtins', name), - ('exceptions', 'TypeError')) - self.assertEqual(mapping('exceptions', name), - ('exceptions', name)) else: self.assertEqual(reverse_mapping('builtins', name), ('exceptions', name)) diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 4c2e2cc863c2ff..db5e3da12b00f3 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -487,13 +487,6 @@ SimpleExtendsException(PyExc_Exception, TypeError, "Inappropriate argument type."); -/* - * ImpossibleMatchError extends TypeError - */ -SimpleExtendsException(PyExc_TypeError, ImpossibleMatchError, - "Incorrect use of a match-case statement."); - - /* * StopAsyncIteration extends Exception */ @@ -2536,7 +2529,6 @@ _PyExc_Init(void) PRE_INIT(BaseException); PRE_INIT(Exception); PRE_INIT(TypeError); - PRE_INIT(ImpossibleMatchError); PRE_INIT(StopAsyncIteration); PRE_INIT(StopIteration); PRE_INIT(GeneratorExit); @@ -2672,7 +2664,6 @@ _PyBuiltins_AddExceptions(PyObject *bltinmod) POST_INIT(BaseException); POST_INIT(Exception); POST_INIT(TypeError); - POST_INIT(ImpossibleMatchError); POST_INIT(StopAsyncIteration); POST_INIT(StopIteration); POST_INIT(GeneratorExit); diff --git a/Python/ceval.c b/Python/ceval.c index 8225f3bb91c8f2..b7fc613c6c2416 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -867,10 +867,9 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, PyObject * } for (Py_ssize_t i = 0; i < nkeys; i++) { PyObject *key = PyTuple_GET_ITEM(keys, i); - int dupe = PySequence_Contains(seen, key); - if (dupe || PyList_Append(seen, key)) { + if (PySequence_Contains(seen, key) || PyList_Append(seen, key)) { if (!_PyErr_Occurred(tstate)) { - _PyErr_Format(tstate, PyExc_ImpossibleMatchError, + _PyErr_Format(tstate, PyExc_ValueError, "mapping pattern checks duplicate key (%R)", key); } goto fail; @@ -937,7 +936,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty if (!method || method == Py_None) { Py_XDECREF(method); _PyErr_Clear(tstate); - _PyErr_Format(tstate, PyExc_ImpossibleMatchError, + _PyErr_Format(tstate, PyExc_TypeError, "type %s cannot be matched", ((PyTypeObject *)type)->tp_name); return NULL; @@ -959,49 +958,38 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty } Py_ssize_t nmatch_args; if (!nargs) { + nmatch_args = 0; args = PyTuple_New(0); if (!args) { goto error; } } else if (!match_args) { - if (!PyType_HasFeature((PyTypeObject *)type, _Py_TPFLAGS_SIMPLE_MATCH)) { - nmatch_args = 0; - // TODO: Combine with below (and reword for 0): - _PyErr_Format(tstate, PyExc_ImpossibleMatchError, - "%s() takes at most %d positional sub-patterns (%d given)", - ((PyTypeObject *)type)->tp_name, nmatch_args, nargs); - goto error; - } - nmatch_args = 1; - if (nargs > 1) { - // TODO: Combine with above (and reword for 0): - _PyErr_Format(tstate, PyExc_ImpossibleMatchError, - "%s() takes at most %d positional sub-patterns (%d given)", - ((PyTypeObject *)type)->tp_name, nmatch_args, nargs); - goto error; - } + nmatch_args = PyType_HasFeature((PyTypeObject *)type, + _Py_TPFLAGS_SIMPLE_MATCH); + args = NULL; } else { - Py_ssize_t nmatch_args = PySequence_Fast_GET_SIZE(match_args); - if (nmatch_args < nargs) { - // TODO: Combine with above (and reword for 0): - _PyErr_Format(tstate, PyExc_ImpossibleMatchError, - "%s() takes at most %d positional sub-patterns (%d given)", - ((PyTypeObject *)type)->tp_name, nmatch_args, nargs); - return NULL; - } - args = PyList_CheckExact(match_args) ? PyList_GetSlice(match_args, 0, nargs) : PyTuple_GetSlice(match_args, 0, nargs); + nmatch_args = PySequence_Fast_GET_SIZE(match_args); + args = PyList_CheckExact(match_args) + ? PyList_GetSlice(match_args, 0, nargs) + : PyTuple_GetSlice(match_args, 0, nargs); if (!args) { goto error; } } + if (nmatch_args < nargs) { + _PyErr_Format(tstate, PyExc_TypeError, + "%s() accepts %d positional sub-patterns (%d given)", + ((PyTypeObject *)type)->tp_name, nmatch_args, nargs); + goto error; + } assert(!args || PyList_CheckExact(args) || PyTuple_CheckExact(args)); attrs = PyTuple_New(count); if (!attrs) { goto error; } - seen = PySet_New(NULL); + seen = PyList_New(0); if (!seen) { goto error; } @@ -1025,10 +1013,9 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty else { name = PyTuple_GET_ITEM(kwargs, i - nargs); } - int dupe = PySet_Contains(seen, name); - if (dupe || PySet_Add(seen, name)) { + if (PySequence_Contains(seen, name) || PyList_Append(seen, name)) { if (!_PyErr_Occurred(tstate)) { - _PyErr_Format(tstate, PyExc_ImpossibleMatchError, + _PyErr_Format(tstate, PyExc_TypeError, "%s() got multiple sub-patterns for attribute %R", ((PyTypeObject *)type)->tp_name, name); } @@ -1036,17 +1023,12 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty } PyObject *attr = PyObject_GetAttr(proxy, name); if (!attr) { - // TODO: Only clear AttributeError? - _PyErr_Clear(tstate); - // TODO: iterate manually (and check for strings) - if (match_args && !PySequence_Contains(match_args, name)) { - _PyErr_Format(tstate, PyExc_ImpossibleMatchError, - "match proxy %R has no attribute %R", - proxy, name); - goto error; + if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { + _PyErr_Clear(tstate); + Py_SETREF(attrs, Py_None); + break; } - Py_SETREF(attrs, Py_None); - break; + goto error; } PyTuple_SET_ITEM(attrs, i, attr); } @@ -3545,7 +3527,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(JUMP_IF_NOT_SEQ): { PyObject *target = TOP(); if (PyType_FastSubclass(Py_TYPE(target), - Py_TPFLAGS_UNICODE_SUBCLASS | Py_TPFLAGS_BYTES_SUBCLASS) + Py_TPFLAGS_BYTES_SUBCLASS | Py_TPFLAGS_UNICODE_SUBCLASS) || PyIter_Check(target) || PyByteArray_Check(target)) { From 9e170bce9a9fcd0f71a3cbedd8fda4292209bc44 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 29 Jun 2020 18:49:15 -0700 Subject: [PATCH 109/189] Ditch __match__! --- Lib/test/test_descrtut.py | 1 - Lib/test/test_pydoc.py | 4 +-- Objects/clinic/typeobject.c.h | 11 +------- Objects/typeobject.c | 26 ------------------ Python/ceval.c | 51 ++++++++++++++--------------------- 5 files changed, 22 insertions(+), 71 deletions(-) diff --git a/Lib/test/test_descrtut.py b/Lib/test/test_descrtut.py index f4567880955315..8e25f58d7aa20e 100644 --- a/Lib/test/test_descrtut.py +++ b/Lib/test/test_descrtut.py @@ -188,7 +188,6 @@ def merge(self, other): '__le__', '__len__', '__lt__', - '__match__', '__mul__', '__ne__', '__new__', diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index e212eff5aed8f0..f0d7ffd562c9d9 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -773,11 +773,9 @@ def method_returning_true(self): del expected['__doc__'] del expected['__class__'] # inspect resolves descriptors on type into methods, but vars doesn't, - # so we need to update __subclasshook__, __init_subclass__, and - # __match__. + # so we need to update __subclasshook__ and __init_subclass__. expected['__subclasshook__'] = TestClass.__subclasshook__ expected['__init_subclass__'] = TestClass.__init_subclass__ - expected['__match__'] = TestClass.__match__ methods = pydoc.allmethods(TestClass) self.assertDictEqual(methods, expected) diff --git a/Objects/clinic/typeobject.c.h b/Objects/clinic/typeobject.c.h index afaec9c809e5fb..8c70d76d916db3 100644 --- a/Objects/clinic/typeobject.c.h +++ b/Objects/clinic/typeobject.c.h @@ -243,13 +243,4 @@ object___dir__(PyObject *self, PyObject *Py_UNUSED(ignored)) { return object___dir___impl(self); } - -PyDoc_STRVAR(object___match____doc__, -"__match__($type, target, /)\n" -"--\n" -"\n" -"Match all instances of this type, returning them for further destructuring."); - -#define OBJECT___MATCH___METHODDEF \ - {"__match__", (PyCFunction)object___match__, METH_O|METH_CLASS, object___match____doc__}, -/*[clinic end generated code: output=9fc91a27a50d735d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b4fb62939b08baf9 input=a9049054013a1b77]*/ diff --git a/Objects/typeobject.c b/Objects/typeobject.c index b13e9e82e53f95..e614466bcca1b7 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4906,31 +4906,6 @@ object___dir___impl(PyObject *self) return result; } -/*[clinic input] -@classmethod -object.__match__ - - target: object - / - -Match all instances of this type, returning them for further destructuring. -[clinic start generated code]*/ - -static PyObject * -object___match__(PyTypeObject *type, PyObject *target) -/*[clinic end generated code: output=bcea50777819dfeb input=493f4963453b0072]*/ -{ - int match = PyObject_IsInstance(target, (PyObject *)type); - if (match < 0) { - return NULL; - } - if (match) { - Py_INCREF(target); - return target; - } - Py_RETURN_NONE; -} - static PyMethodDef object_methods[] = { OBJECT___REDUCE_EX___METHODDEF OBJECT___REDUCE___METHODDEF @@ -4941,7 +4916,6 @@ static PyMethodDef object_methods[] = { OBJECT___FORMAT___METHODDEF OBJECT___SIZEOF___METHODDEF OBJECT___DIR___METHODDEF - OBJECT___MATCH___METHODDEF {0} }; diff --git a/Python/ceval.c b/Python/ceval.c index b7fc613c6c2416..88ca5df779492b 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -908,9 +908,14 @@ get_match_args(PyThreadState *tstate, PyObject *type) } return NULL; } - if (PyList_CheckExact(match_args) || PyTuple_CheckExact(match_args)) { + if (PyTuple_CheckExact(match_args)) { return match_args; } + if (PyList_CheckExact(match_args)) { + PyObject *tuple = PyList_AsTuple(match_args); + Py_DECREF(match_args); + return tuple; + } _PyErr_Format(tstate, PyExc_TypeError, "%s.__match_args__ must be a list or tuple (got %s)", ((PyTypeObject *)type)->tp_name, Py_TYPE(match_args)->tp_name); @@ -932,27 +937,13 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty "called match pattern must be a type"); return NULL; } - PyObject *method = PyObject_GetAttrString(type, "__match__"); - if (!method || method == Py_None) { - Py_XDECREF(method); - _PyErr_Clear(tstate); - _PyErr_Format(tstate, PyExc_TypeError, - "type %s cannot be matched", - ((PyTypeObject *)type)->tp_name); - return NULL; - } - PyObject *proxy = PyObject_CallOneArg(method, target); - Py_DECREF(method); - if (!proxy) { + if (PyObject_IsInstance(target, type) <= 0) { return NULL; } - if (proxy == Py_None) { - return proxy; - } Py_ssize_t nkwargs = PyTuple_GET_SIZE(kwargs); Py_ssize_t nargs = count - nkwargs; match_args = get_match_args(tstate, type); - assert(!match_args || PyList_CheckExact(match_args) || PyTuple_CheckExact(match_args)); + assert(!match_args || PyTuple_CheckExact(match_args)); if (!match_args && _PyErr_Occurred(tstate)) { goto error; } @@ -970,10 +961,8 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty args = NULL; } else { - nmatch_args = PySequence_Fast_GET_SIZE(match_args); - args = PyList_CheckExact(match_args) - ? PyList_GetSlice(match_args, 0, nargs) - : PyTuple_GetSlice(match_args, 0, nargs); + nmatch_args = PyTuple_GET_SIZE(match_args); + args = PyTuple_GetSlice(match_args, 0, nargs); if (!args) { goto error; } @@ -984,7 +973,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty ((PyTypeObject *)type)->tp_name, nmatch_args, nargs); goto error; } - assert(!args || PyList_CheckExact(args) || PyTuple_CheckExact(args)); + assert(!args || PyTuple_CheckExact(args)); attrs = PyTuple_New(count); if (!attrs) { goto error; @@ -998,8 +987,8 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty if (i < nargs) { if (!args) { assert(!i); - Py_INCREF(proxy); - PyTuple_SET_ITEM(attrs, 0, proxy); + Py_INCREF(target); + PyTuple_SET_ITEM(attrs, 0, target); continue; } name = PyTuple_GET_ITEM(args, i); @@ -1021,7 +1010,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty } goto error; } - PyObject *attr = PyObject_GetAttr(proxy, name); + PyObject *attr = PyObject_GetAttr(target, name); if (!attr) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { _PyErr_Clear(tstate); @@ -1032,13 +1021,11 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty } PyTuple_SET_ITEM(attrs, i, attr); } - Py_DECREF(proxy); Py_XDECREF(match_args); Py_XDECREF(args); Py_DECREF(seen); return attrs; error: - Py_DECREF(proxy); Py_XDECREF(match_args); Py_XDECREF(args); Py_XDECREF(seen); @@ -3488,13 +3475,15 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) PyObject *target = SECOND(); PyObject *attrs = do_match(tstate, oparg, names, type, target); Py_DECREF(names); - if (!attrs) { + if (attrs) { + Py_DECREF(target); + SET_SECOND(attrs); + } + else if (_PyErr_Occurred(tstate)) { goto error; } + SET_TOP(PyBool_FromLong(!!attrs)); Py_DECREF(type); - Py_DECREF(target); - SET_SECOND(attrs); - SET_TOP(PyBool_FromLong(attrs != Py_None)); DISPATCH(); } From d696de7329afaa9b2420b15add34f6bc0c7b1bf9 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 29 Jun 2020 18:57:47 -0700 Subject: [PATCH 110/189] Fix whitespace diff --- Doc/library/exceptions.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index d852ba7c688391..df2cda9d67ad15 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -179,7 +179,6 @@ The following exceptions are the exceptions that are usually raised. .. versionchanged:: 3.3 Added the :attr:`name` and :attr:`path` attributes. - .. exception:: ModuleNotFoundError A subclass of :exc:`ImportError` which is raised by :keyword:`import` From bb8fb1bf024836c84f4a1bf9a860667fabd61e47 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 30 Jun 2020 18:16:20 -0700 Subject: [PATCH 111/189] Clean up tests and fix refleak in mapping patterns --- Lib/test/test_patma.py | 18 +++++++++--------- Python/ceval.c | 1 - 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 7c25c06c25404d..2937e00da5fa61 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1214,11 +1214,11 @@ def test_patma_133(self) -> None: case {1: 0}: y = 0 case {0: 0}: - y = 0 - case {}: y = 1 + case {}: + y = 2 self.assertEqual(x, {0: 1}) - self.assertEqual(y, 1) + self.assertEqual(y, 2) def test_patma_134(self) -> None: x = collections.defaultdict(int, {0: 1}) @@ -1226,11 +1226,11 @@ def test_patma_134(self) -> None: case {1: 0}: y = 0 case {0: 0}: - y = 0 - case {**z}: y = 1 + case {**z}: + y = 2 self.assertEqual(x, {0: 1}) - self.assertEqual(y, 1) + self.assertEqual(y, 2) self.assertEqual(z, {0: 1}) def test_patma_135(self) -> None: @@ -1239,11 +1239,11 @@ def test_patma_135(self) -> None: case {1: 0}: y = 0 case {0: 0}: - y = 0 - case {0: _, **z}: y = 1 + case {0: _, **z}: + y = 2 self.assertEqual(x, {0: 1}) - self.assertEqual(y, 1) + self.assertEqual(y, 2) self.assertEqual(z, {}) def test_patma_136(self) -> None: diff --git a/Python/ceval.c b/Python/ceval.c index 88ca5df779492b..e80287770b82e1 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -881,7 +881,6 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, PyObject * if (!value) { goto fail; } - Py_INCREF(value); PyTuple_SET_ITEM(values, i, value); if (copy && PyDict_DelItem(copy, key)) { if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { From 36398b13c06c92e24d17a5c7a7315689501ddae9 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 30 Jun 2020 19:10:53 -0700 Subject: [PATCH 112/189] Minor improvements for class matches --- Python/ceval.c | 47 +++++++++++++++++++++++++---------------------- Python/compile.c | 2 +- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index e80287770b82e1..d71217b8db08f5 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -904,6 +904,7 @@ get_match_args(PyThreadState *tstate, PyObject *type) if (!match_args) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { _PyErr_Clear(tstate); + return PyTuple_New(0); } return NULL; } @@ -923,10 +924,9 @@ get_match_args(PyThreadState *tstate, PyObject *type) } static PyObject * -do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *type, PyObject *target) +do_match(PyThreadState *tstate, Py_ssize_t nargs, PyObject *kwargs, PyObject *type, PyObject *target) { // TODO: Break this up! - PyObject *match_args = NULL; PyObject *args = NULL; PyObject *attrs = NULL; PyObject *seen = NULL; @@ -940,13 +940,9 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty return NULL; } Py_ssize_t nkwargs = PyTuple_GET_SIZE(kwargs); - Py_ssize_t nargs = count - nkwargs; - match_args = get_match_args(tstate, type); - assert(!match_args || PyTuple_CheckExact(match_args)); - if (!match_args && _PyErr_Occurred(tstate)) { - goto error; - } + Py_ssize_t count = nargs + nkwargs; Py_ssize_t nmatch_args; + // TODO: Just build attrs in two passes (nargs and nkwargs) if (!nargs) { nmatch_args = 0; args = PyTuple_New(0); @@ -954,17 +950,26 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty goto error; } } - else if (!match_args) { - nmatch_args = PyType_HasFeature((PyTypeObject *)type, - _Py_TPFLAGS_SIMPLE_MATCH); - args = NULL; - } else { - nmatch_args = PyTuple_GET_SIZE(match_args); - args = PyTuple_GetSlice(match_args, 0, nargs); - if (!args) { + PyObject *match_args = get_match_args(tstate, type); + if (!match_args) { goto error; } + assert(PyTuple_CheckExact(match_args)); + nmatch_args = PyTuple_GET_SIZE(match_args); + if (!nmatch_args) { + Py_DECREF(match_args); + nmatch_args = PyType_HasFeature((PyTypeObject *)type, + _Py_TPFLAGS_SIMPLE_MATCH); + args = NULL; + } + else { + args = PyTuple_GetSlice(match_args, 0, nargs); + Py_DECREF(match_args); + if (!args) { + goto error; + } + } } if (nmatch_args < nargs) { _PyErr_Format(tstate, PyExc_TypeError, @@ -981,7 +986,7 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty if (!seen) { goto error; } - PyObject *name; + PyObject *name, *attr; for (Py_ssize_t i = 0; i < count; i++) { if (i < nargs) { if (!args) { @@ -1009,23 +1014,21 @@ do_match(PyThreadState *tstate, Py_ssize_t count, PyObject *kwargs, PyObject *ty } goto error; } - PyObject *attr = PyObject_GetAttr(target, name); + attr = PyObject_GetAttr(target, name); if (!attr) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { _PyErr_Clear(tstate); - Py_SETREF(attrs, Py_None); + Py_CLEAR(attrs); break; } goto error; } PyTuple_SET_ITEM(attrs, i, attr); } - Py_XDECREF(match_args); Py_XDECREF(args); Py_DECREF(seen); return attrs; error: - Py_XDECREF(match_args); Py_XDECREF(args); Py_XDECREF(seen); Py_XDECREF(attrs); @@ -3489,7 +3492,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(JUMP_IF_NOT_MAP): { PyInterpreterState *interp = PyInterpreterState_Get(); if (!interp) { - goto error; + goto error; } if (!interp->map_abc) { PyObject *abc = PyImport_ImportModule("_collections_abc"); diff --git a/Python/compile.c b/Python/compile.c index 5d2d4fc7726f49..855b2c4ff9c382 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2792,7 +2792,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { PyTuple_SET_ITEM(kwnames, i, name); } ADDOP_LOAD_CONST_NEW(c, kwnames); - ADDOP_I(c, MATCH_TYPE, nargs + nkwargs); + ADDOP_I(c, MATCH_TYPE, nargs); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); pattern_context sub_pc = *pc; sub_pc.failure = block; From 82055e2a492dfb4f956ab07f0324b04f2ca4e0e3 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 1 Jul 2020 08:10:44 -0700 Subject: [PATCH 113/189] Mapping destructuring improvements --- Python/ceval.c | 126 ++++++++++++++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 48 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index d71217b8db08f5..ad784d4a61f01a 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -848,14 +848,24 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) // Need these for pattern matching: static PyObject* -match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, PyObject *copy) +match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) { assert(PyTuple_CheckExact(keys)); Py_ssize_t nkeys = PyTuple_GET_SIZE(keys); - PyObject *seen = NULL; - PyObject *values = NULL; - if (PyMapping_Length(map) < nkeys) { - goto fail; + if (!nkeys) { + return PyTuple_New(0); + } + PyObject *get = NULL, *dummy = NULL, *seen = NULL, *values = NULL; + if (!PyDict_CheckExact(map)) { + _Py_IDENTIFIER(get); + get = _PyObject_GetAttrId(map, &PyId_get); + if (!get) { + return NULL; + } + dummy = _PyObject_CallNoArg((PyObject *)&PyBaseObject_Type); + if (!dummy) { + goto fail; + } } seen = PyList_New(0); if (!seen) { @@ -865,8 +875,9 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, PyObject * if (!values) { goto fail; } + PyObject *key, *value; for (Py_ssize_t i = 0; i < nkeys; i++) { - PyObject *key = PyTuple_GET_ITEM(keys, i); + key = PyTuple_GET_ITEM(keys, i); if (PySequence_Contains(seen, key) || PyList_Append(seen, key)) { if (!_PyErr_Occurred(tstate)) { _PyErr_Format(tstate, PyExc_ValueError, @@ -874,29 +885,67 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys, PyObject * } goto fail; } - if (!PySequence_Contains(map, key)) { - goto fail; - } - PyObject *value = PyObject_GetItem(map, key); - if (!value) { - goto fail; + if (!get) { + assert(PyDict_CheckExact(map)); + value = PyDict_GetItemWithError(map, key); + if (!value) { + goto fail; + } + Py_INCREF(value); } - PyTuple_SET_ITEM(values, i, value); - if (copy && PyDict_DelItem(copy, key)) { - if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + else { + assert(dummy); + value = PyObject_CallFunctionObjArgs(get, key, dummy, NULL); + if (!value || value == dummy) { + Py_XDECREF(value); goto fail; } - _PyErr_Clear(tstate); } + PyTuple_SET_ITEM(values, i, value); } + Py_XDECREF(get); + Py_XDECREF(dummy); Py_DECREF(seen); return values; fail: + Py_XDECREF(get); + Py_XDECREF(dummy); Py_XDECREF(seen); Py_XDECREF(values); return NULL; } +static PyObject * +match_map_copy(PyThreadState *tstate, PyObject *map, PyObject *keys) +{ + PyObject *copy; + if (PyDict_CheckExact(map)) { + copy = PyDict_Copy(map); + if (!copy) { + return NULL; + } + } + else { + copy = PyDict_New(); + if (!copy || PyDict_Update(copy, map)) { + Py_XDECREF(copy); + return NULL; + } + } + Py_ssize_t nkeys = PyTuple_GET_SIZE(keys); + for (Py_ssize_t i = 0; i < nkeys; i++) { + if (PyDict_DelItem(copy, PyTuple_GET_ITEM(keys, i))) { + if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + _PyErr_Clear(tstate); + continue; + } + Py_DECREF(copy); + return NULL; + } + } + return copy; +} + static PyObject * get_match_args(PyThreadState *tstate, PyObject *type) { @@ -927,18 +976,18 @@ static PyObject * do_match(PyThreadState *tstate, Py_ssize_t nargs, PyObject *kwargs, PyObject *type, PyObject *target) { // TODO: Break this up! - PyObject *args = NULL; - PyObject *attrs = NULL; - PyObject *seen = NULL; - assert(PyTuple_CheckExact(kwargs)); if (!PyType_Check(type)) { _PyErr_Format(tstate, PyExc_TypeError, - "called match pattern must be a type"); + "called match pattern must be a type"); return NULL; } + assert(PyTuple_CheckExact(kwargs)); if (PyObject_IsInstance(target, type) <= 0) { return NULL; } + PyObject *args = NULL; + PyObject *attrs = NULL; + PyObject *seen = NULL; Py_ssize_t nkwargs = PyTuple_GET_SIZE(kwargs); Py_ssize_t count = nargs + nkwargs; Py_ssize_t nmatch_args; @@ -3491,9 +3540,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(JUMP_IF_NOT_MAP): { PyInterpreterState *interp = PyInterpreterState_Get(); - if (!interp) { - goto error; - } if (!interp->map_abc) { PyObject *abc = PyImport_ImportModule("_collections_abc"); if (!abc) { @@ -3526,9 +3572,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } PyInterpreterState *interp = PyInterpreterState_Get(); - if (!interp) { - goto error; - } if (!interp->seq_abc) { PyObject *abc = PyImport_ImportModule("_collections_abc"); if (!abc) { @@ -3553,28 +3596,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(MATCH_KEYS): { PyObject *keys = TOP(); PyObject *target = SECOND(); - PyObject *copy = NULL; - if (oparg) { - if (PyDict_CheckExact(target)) { - copy = PyDict_Copy(target); - if (!copy) { - return NULL; - } - } - else { - copy = PyDict_New(); - if (!copy || PyDict_Update(copy, target)) { - Py_XDECREF(copy); - return NULL; - } - } - } - PyObject *values = match_map_items(tstate, target, keys, copy); + PyObject *values = match_map_items(tstate, target, keys); if (!values) { if (_PyErr_Occurred(tstate)) { goto error; } - Py_XDECREF(copy); Py_INCREF(Py_None); SET_TOP(Py_None); Py_DECREF(keys); @@ -3582,12 +3608,16 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) PUSH(Py_False); DISPATCH(); } - SET_TOP(values); - Py_DECREF(keys); if (oparg) { - SET_SECOND(copy); + PyObject *rest = match_map_copy(tstate, target, keys); + if (!rest) { + goto error; + } + SET_SECOND(rest); Py_DECREF(target); } + SET_TOP(values); + Py_DECREF(keys); Py_INCREF(Py_True); PUSH(Py_True); DISPATCH(); From c9b3b4e0d7991e52b2e09b296c471cac3e0c2ecc Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 2 Jul 2020 12:23:39 -0700 Subject: [PATCH 114/189] Use tuple for dataclass __match_args__ --- Lib/dataclasses.py | 2 +- Lib/test/test_dataclasses.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py index 51c5059392b145..730a6390d5424c 100644 --- a/Lib/dataclasses.py +++ b/Lib/dataclasses.py @@ -1005,7 +1005,7 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen): match_args = cls.__dict__.get('__match_args__', MISSING) if match_args is MISSING: # Create a __match_args__ attribute. - _set_new_attribute(cls, '__match_args__', [f.name for f in flds if f.init]) + _set_new_attribute(cls, '__match_args__', tuple(f.name for f in flds if f.init)) return cls diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index 186f6aa3c21869..81c3ec1e37814b 100644 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -3339,7 +3339,7 @@ class B: x: int o = B(4) - self.assertEqual(o.__match_args__, ['x']) + self.assertEqual(o.__match_args__, ('x',)) def test_explicit_match_args(self): @dataclass From 793add3911abed838c1d8cf3b0104dfe51d26e52 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 2 Jul 2020 12:24:21 -0700 Subject: [PATCH 115/189] Add tests for new match grammar --- Lib/test/test_patma.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 2937e00da5fa61..8616b1e38ba46a 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1392,6 +1392,38 @@ def test_patma_150(self) -> None: self.assertEqual(y, 0) self.assertIs(z, x) + def test_patma_151(self) -> None: + x = 0 + match x,: + case y,: + z = 0 + self.assertEqual(x, 0) + self.assertIs(y, x) + self.assertIs(z, 0) + + def test_patma_152(self) -> None: + w = 0 + x = 0 + match w, x: + case y, z: + v = 0 + self.assertEqual(w, 0) + self.assertEqual(x, 0) + self.assertIs(y, w) + self.assertIs(z, x) + self.assertEqual(v, 0) + + def test_patma_152(self) -> None: + x = 0 + match w := x,: + case v := y,: + z = 0 + self.assertEqual(x, 0) + self.assertIs(y, x) + self.assertEqual(z, 0) + self.assertIs(w, x) + self.assertIs(v, y) + def run_perf(self): # ./python -m pyperf timeit -s "from test.test_patma import TestMatch; t = TestMatch()" "t.run_perf()" attrs = vars(type(self)).items() From 4efdb9a39152d4d24da8a6dcad18c2d381aa65e1 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 2 Jul 2020 12:24:54 -0700 Subject: [PATCH 116/189] Clean up compile.c and add SyntaxWarning --- Python/compile.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 855b2c4ff9c382..5042c23acad8e9 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -176,10 +176,6 @@ struct compiler { }; typedef struct { - // Py_ssize_t map_len_ge; - // Py_ssize_t seq_len_ge; - // Py_ssize_t seq_len_eq; - // basicblock *success; basicblock *failure; PyObject* stores; } pattern_context; @@ -2754,7 +2750,8 @@ compiler_if(struct compiler *c, stmt_ty s) } #define WILDCARD_CHECK(N) \ - ((N)->kind == Name_kind && (N)->v.Name.ctx == Store && _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) + ((N)->kind == Name_kind && (N)->v.Name.ctx == Store && \ + _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) static int compiler_pattern_load(struct compiler *c, expr_ty p, pattern_context *pc) @@ -2831,7 +2828,8 @@ compiler_pattern_store(struct compiler *c, expr_ty p, pattern_context *pc, int w assert(p->v.Name.ctx == Store); if (WILDCARD_CHECK(p)) { if (!wildcard_ok) { - return compiler_error(c, "can't assign to '_' here; consider removing or renaming?"); + return compiler_error(c, + "can't assign to '_' here; consider removing or renaming?"); } ADDOP(c, POP_TOP); return 1; @@ -3084,6 +3082,7 @@ compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc) SET_LOC(c, p); switch (p->kind) { case Attribute_kind: + case Constant_kind: return compiler_pattern_load(c, p, pc); case BinOp_kind: // Because we allow "2+2j", things like "2+2" make it this far: @@ -3092,21 +3091,18 @@ compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc) return compiler_pattern_or(c, p, pc); case Call_kind: return compiler_pattern_call(c, p, pc); - case Constant_kind: - return compiler_pattern_load(c, p, pc); case Dict_kind: return compiler_pattern_mapping(c, p, pc); case JoinedStr_kind: // Because we allow strings, f-strings make it this far: return compiler_error(c, "patterns cannot include f-strings"); case List_kind: + case Tuple_kind: return compiler_pattern_sequence(c, p, pc); case Name_kind: return compiler_pattern_name(c, p, pc); case NamedExpr_kind: return compiler_pattern_namedexpr(c, p, pc); - case Tuple_kind: - return compiler_pattern_sequence(c, p, pc); default: Py_UNREACHABLE(); } @@ -3116,29 +3112,33 @@ static int compiler_match(struct compiler *c, stmt_ty s) { VISIT(c, expr, s->v.Match.target); - basicblock *next, *end; + basicblock *end; CHECK(end = compiler_new_block(c)); + int warned = 0; Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); assert(cases); + pattern_context pc; + CHECK(pc.stores = PySet_New(NULL)); for (Py_ssize_t i = 0; i < cases; i++) { match_case_ty m = asdl_seq_GET(s->v.Match.cases, i); SET_LOC(c, m->pattern); - CHECK(next = compiler_new_block(c)); + CHECK(pc.failure = compiler_new_block(c)); if (i != cases - 1) { ADDOP(c, DUP_TOP); } - PyObject* names = PySet_New(NULL); - if (!names) { - return 0; + if (!warned && i != cases - 1 && !m->guard + && m->pattern->kind == Name_kind && m->pattern->v.Name.ctx == Store) + { + warned = 1; + CHECK(compiler_warn(c, "unguarded name capture pattern makes " + "remaining cases unreachable; did you " + "forget a leading dot?")); } - pattern_context pc; - pc.failure = next; - pc.stores = names; int result = compiler_pattern(c, m->pattern, &pc); - Py_DECREF(names); + PySet_Clear(pc.stores); CHECK(result); if (m->guard) { - CHECK(compiler_jump_if(c, m->guard, next, 0)); + CHECK(compiler_jump_if(c, m->guard, pc.failure, 0)); } if (i != cases - 1) { ADDOP(c, POP_TOP); @@ -3147,8 +3147,9 @@ compiler_match(struct compiler *c, stmt_ty s) if (i != cases - 1) { ADDOP_JREL(c, JUMP_FORWARD, end); } - compiler_use_next_block(c, next); + compiler_use_next_block(c, pc.failure); } + Py_DECREF(pc.stores); compiler_use_next_block(c, end); return 1; } From 46f33506e562e39675605f8fdb01f1e0fe036194 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 2 Jul 2020 19:07:44 -0700 Subject: [PATCH 117/189] Clean up compiler --- Python/compile.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 5042c23acad8e9..0d326d3788e29b 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2781,7 +2781,6 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { VISIT(c, expr, func); PyObject *kwnames; CHECK(kwnames = PyTuple_New(nkwargs)); - // TODO: Catch colliding keywords. Py_ssize_t i; for (i = 0; i < nkwargs; i++) { PyObject *name = ((keyword_ty) asdl_seq_GET(kwargs, i))->arg; @@ -2823,16 +2822,12 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { } static int -compiler_pattern_store(struct compiler *c, expr_ty p, pattern_context *pc, int wildcard_ok) { +compiler_pattern_store(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); if (WILDCARD_CHECK(p)) { - if (!wildcard_ok) { - return compiler_error(c, - "can't assign to '_' here; consider removing or renaming?"); - } - ADDOP(c, POP_TOP); - return 1; + return compiler_error(c, "can't assign to '_' here; " + "consider removing or renaming?"); } if (PySet_Contains(pc->stores, p->v.Name.id)) { // TODO: Format this error message with the name. @@ -2888,7 +2883,7 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc) } ADDOP(c, POP_TOP); if (star) { - CHECK(compiler_pattern_store(c, asdl_seq_GET(values, size - 1), pc, 0)); + CHECK(compiler_pattern_store(c, asdl_seq_GET(values, size - 1), pc)); } else { ADDOP(c, POP_TOP); @@ -2911,7 +2906,11 @@ compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) if (p->v.Name.ctx == Load) { return compiler_pattern_load(c, p, pc); } - return compiler_pattern_store(c, p, pc, 1); + if (WILDCARD_CHECK(p)) { + ADDOP(c, POP_TOP); + return 1; + } + return compiler_pattern_store(c, p, pc); } static int @@ -2925,7 +2924,7 @@ compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc) pattern_context sub_pc = *pc; sub_pc.failure = block; CHECK(compiler_pattern(c, p->v.NamedExpr.value, &sub_pc)); - CHECK(compiler_pattern_store(c, p->v.NamedExpr.target, pc, 0)); + CHECK(compiler_pattern_store(c, p->v.NamedExpr.target, pc)); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); ADDOP(c, POP_TOP); @@ -3119,20 +3118,23 @@ compiler_match(struct compiler *c, stmt_ty s) assert(cases); pattern_context pc; CHECK(pc.stores = PySet_New(NULL)); + int last = 0; for (Py_ssize_t i = 0; i < cases; i++) { + if (i == cases - 1) { + last = 1; + } match_case_ty m = asdl_seq_GET(s->v.Match.cases, i); SET_LOC(c, m->pattern); CHECK(pc.failure = compiler_new_block(c)); - if (i != cases - 1) { + if (!last) { ADDOP(c, DUP_TOP); } - if (!warned && i != cases - 1 && !m->guard + if (!warned && !last && !m->guard && m->pattern->kind == Name_kind && m->pattern->v.Name.ctx == Store) { warned = 1; CHECK(compiler_warn(c, "unguarded name capture pattern makes " - "remaining cases unreachable; did you " - "forget a leading dot?")); + "remaining cases unreachable")); } int result = compiler_pattern(c, m->pattern, &pc); PySet_Clear(pc.stores); @@ -3140,11 +3142,11 @@ compiler_match(struct compiler *c, stmt_ty s) if (m->guard) { CHECK(compiler_jump_if(c, m->guard, pc.failure, 0)); } - if (i != cases - 1) { + if (!last) { ADDOP(c, POP_TOP); } VISIT_SEQ(c, stmt, m->body); - if (i != cases - 1) { + if (!last) { ADDOP_JREL(c, JUMP_FORWARD, end); } compiler_use_next_block(c, pc.failure); From 9b343b73cb9b4406a90afdefa97e0d25d3094608 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 3 Jul 2020 13:51:38 -0700 Subject: [PATCH 118/189] Progress on reducing the number of blocks --- Python/compile.c | 64 +++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 0d326d3788e29b..c68001e646bd80 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2761,7 +2761,6 @@ compiler_pattern_load(struct compiler *c, expr_ty p, pattern_context *pc) assert(p->kind != Name_kind || p->v.Name.ctx == Load); VISIT(c, expr, p); ADDOP_COMPARE(c, Eq); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, pc->failure); return 1; } @@ -2789,7 +2788,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { } ADDOP_LOAD_CONST_NEW(c, kwnames); ADDOP_I(c, MATCH_TYPE, nargs); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); pattern_context sub_pc = *pc; sub_pc.failure = block; for (i = 0; i < nargs; i++) { @@ -2801,6 +2800,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); ADDOP(c, BINARY_SUBSCR); CHECK(compiler_pattern(c, arg, &sub_pc)); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } for (i = 0; i < nkwargs; i++) { keyword_ty kwarg = asdl_seq_GET(kwargs, i); @@ -2811,13 +2811,12 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(nargs + i)); ADDOP(c, BINARY_SUBSCR); CHECK(compiler_pattern(c, kwarg->value, &sub_pc)); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } - ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, end); - compiler_use_next_block(c, block); - ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, pc->failure); + ADDOP_LOAD_CONST(c, Py_True); compiler_use_next_block(c, end); + ADDOP(c, ROT_TWO); + ADDOP(c, POP_TOP); return 1; } @@ -2833,13 +2832,16 @@ compiler_pattern_store(struct compiler *c, expr_ty p, pattern_context *pc) { // TODO: Format this error message with the name. return compiler_error(c, "multiple assignments to name in pattern"); } + CHECK(!PySet_Add(pc->stores, p->v.Name.id)); VISIT(c, expr, p); - return !PySet_Add(pc->stores, p->v.Name.id); + ADDOP_LOAD_CONST(c, Py_True); + return 1; } static int compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc) { + // TODO: We shouldn't need 3 cleanup blocks. Make things more uniform basicblock *block, *block_star, *end; CHECK(block_star = compiler_new_block(c)); CHECK(block = compiler_new_block(c)); @@ -2848,7 +2850,7 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc) asdl_seq *values = p->v.Dict.values; Py_ssize_t size = asdl_seq_LEN(values); int star = size ? !asdl_seq_GET(keys, size - 1) : 0; - ADDOP_JREL(c, JUMP_IF_NOT_MAP, block); + ADDOP_JREL(c, JUMP_IF_NOT_MAP, block); // TODO: Refactor to ditch block. if (size - star) { ADDOP(c, GET_LEN); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - star)); @@ -2868,7 +2870,7 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc) } ADDOP_I(c, BUILD_TUPLE, size - star); ADDOP_I(c, MATCH_KEYS, star); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, block_star) + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block_star); pattern_context sub_pc = *pc; sub_pc.failure = block_star; for (i = 0; i < size - star; i++) { @@ -2880,6 +2882,7 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); ADDOP(c, BINARY_SUBSCR); CHECK(compiler_pattern(c, value, &sub_pc)); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block_star); } ADDOP(c, POP_TOP); if (star) { @@ -2887,13 +2890,15 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc) } else { ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_True); } ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block_star); ADDOP(c, POP_TOP); compiler_use_next_block(c, block); + ADDOP_LOAD_CONST(c, Py_False); + ADDOP(c, ROT_TWO); ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, pc->failure); compiler_use_next_block(c, end); return 1; } @@ -2908,6 +2913,7 @@ compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) } if (WILDCARD_CHECK(p)) { ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_True); return 1; } return compiler_pattern_store(c, p, pc); @@ -2920,15 +2926,16 @@ compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc) basicblock *block, *end; CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); - ADDOP(c, DUP_TOP); pattern_context sub_pc = *pc; sub_pc.failure = block; + ADDOP(c, DUP_TOP); CHECK(compiler_pattern(c, p->v.NamedExpr.value, &sub_pc)); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); CHECK(compiler_pattern_store(c, p->v.NamedExpr.target, pc)); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); + ADDOP(c, ROT_TWO); ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, pc->failure); compiler_use_next_block(c, end); return 1; } @@ -2938,7 +2945,7 @@ compiler_pattern_or(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == BoolOp_kind); assert(p->v.BoolOp.op == Or); - basicblock *block, *end; + basicblock *end; PyObject *control = NULL; CHECK(end = compiler_new_block(c)); Py_ssize_t size = asdl_seq_LEN(p->v.BoolOp.values); @@ -2946,15 +2953,11 @@ compiler_pattern_or(struct compiler *c, expr_ty p, pattern_context *pc) PyObject *names_copy; for (Py_ssize_t i = 0; i < size; i++) { CHECK(names_copy = PySet_New(pc->stores)); - CHECK(block = compiler_new_block(c)); ADDOP(c, DUP_TOP); pattern_context sub_pc = *pc; - sub_pc.failure = block; sub_pc.stores = names_copy; CHECK(compiler_pattern(c, asdl_seq_GET(p->v.BoolOp.values, i), &sub_pc)); - ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, end); - compiler_use_next_block(c, block); + ADDOP_JABS(c, JUMP_IF_TRUE_OR_POP, end); // TODO: Reuse names_copy without actually building a new copy each loop? if (!i) { control = names_copy; @@ -2981,9 +2984,10 @@ compiler_pattern_or(struct compiler *c, expr_ty p, pattern_context *pc) } assert(control); Py_DECREF(control); - ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, pc->failure); + ADDOP_LOAD_CONST(c, Py_False); compiler_use_next_block(c, end); + ADDOP(c, ROT_TWO); + ADDOP(c, POP_TOP); return 1; } @@ -3007,20 +3011,20 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context *pc) basicblock *block, *end; CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); - ADDOP_JREL(c, JUMP_IF_NOT_SEQ, block); + ADDOP_JREL(c, JUMP_IF_NOT_SEQ, block); // TODO: Refactor to ditch block. if (star >= 0) { if (size) { ADDOP(c, GET_LEN); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - 1)); ADDOP_COMPARE(c, GtE); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } } else { ADDOP(c, GET_LEN); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)); ADDOP_COMPARE(c, Eq); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } pattern_context sub_pc = *pc; sub_pc.failure = block; @@ -3065,13 +3069,15 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP(c, BINARY_SUBSCR); } CHECK(compiler_pattern(c, value, &sub_pc)); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } - ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_True); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); - ADDOP(c, POP_TOP); - ADDOP_JREL(c, JUMP_FORWARD, pc->failure); + ADDOP_LOAD_CONST(c, Py_False); compiler_use_next_block(c, end); + ADDOP(c, ROT_TWO); + ADDOP(c, POP_TOP); return 1; } @@ -3119,11 +3125,12 @@ compiler_match(struct compiler *c, stmt_ty s) pattern_context pc; CHECK(pc.stores = PySet_New(NULL)); int last = 0; + match_case_ty m; for (Py_ssize_t i = 0; i < cases; i++) { if (i == cases - 1) { last = 1; } - match_case_ty m = asdl_seq_GET(s->v.Match.cases, i); + m = asdl_seq_GET(s->v.Match.cases, i); SET_LOC(c, m->pattern); CHECK(pc.failure = compiler_new_block(c)); if (!last) { @@ -3139,6 +3146,7 @@ compiler_match(struct compiler *c, stmt_ty s) int result = compiler_pattern(c, m->pattern, &pc); PySet_Clear(pc.stores); CHECK(result); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, pc.failure); if (m->guard) { CHECK(compiler_jump_if(c, m->guard, pc.failure, 0)); } From a4fd8a32ff8e6935bed083f22db628bbbff27300 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 3 Jul 2020 16:25:40 -0700 Subject: [PATCH 119/189] Simplify emitted bytecode --- Doc/library/dis.rst | 38 ++++----- Include/opcode.h | 6 +- Lib/importlib/_bootstrap_external.py | 4 +- Lib/opcode.py | 6 +- Python/ceval.c | 45 +++++----- Python/compile.c | 121 ++++++++++++--------------- Python/importlib_external.h | 2 +- Python/opcode_targets.h | 10 +-- Python/peephole.c | 4 - 9 files changed, 107 insertions(+), 129 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 86d999006f4e49..361eec0a5696f9 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -753,7 +753,24 @@ iterations of the loop. .. opcode:: GET_LEN - Pushes ``len(TOS)`` onto the stack. + Push ``len(TOS)`` onto the stack. + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_MAPPING + + If TOS is an instance of :class:`collections.abc.Mapping`, push ``True`` onto + the stack. Otherwise, push ``False``. + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_SEQUENCE + + If TOS is an instance of :class:`collections.abc.Sequence`, is not an + instance of :class:`string`/:class:`bytes`/:class:`bytearray`, and is not an + :term:`iterator`, push ``True`` onto the stack. Otherwise, push ``False``. .. versionadded:: 3.10 @@ -1196,30 +1213,13 @@ All of the following opcodes use their arguments. .. versionadded:: 3.6 -.. opcode:: MATCH_TYPE (count) +.. opcode:: MATCH_CLASS (count) TODO .. versionadded:: 3.10 -.. opcode:: JUMP_IF_NOT_MAP (delta) - - If TOS is not an instance of :class:`collections.abc.Mapping`, increment the - bytecode counter by *delta*. - - .. versionadded:: 3.10 - - -.. opcode:: JUMP_IF_NOT_SEQ (delta) - - If TOS is an instance of :class:`string`/:class:`bytes`/:class:`bytearray`, - is an :term:`iterator`, or is not an instance of - :class:`collections.abc.Sequence`, increment the bytecode counter by *delta*. - - .. versionadded:: 3.10 - - .. opcode:: MATCH_KEYS (copy) TODO diff --git a/Include/opcode.h b/Include/opcode.h index af7fe4afc22201..24a21dc86b590a 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -31,6 +31,8 @@ extern "C" { #define INPLACE_FLOOR_DIVIDE 28 #define INPLACE_TRUE_DIVIDE 29 #define GET_LEN 30 +#define MATCH_MAPPING 31 +#define MATCH_SEQUENCE 32 #define RERAISE 48 #define WITH_EXCEPT_START 49 #define GET_AITER 50 @@ -118,10 +120,8 @@ extern "C" { #define SET_ADD 146 #define MAP_ADD 147 #define LOAD_CLASSDEREF 148 -#define MATCH_TYPE 149 +#define MATCH_CLASS 149 #define MATCH_KEYS 150 -#define JUMP_IF_NOT_MAP 151 -#define JUMP_IF_NOT_SEQ 152 #define SETUP_ASYNC_WITH 154 #define FORMAT_VALUE 155 #define BUILD_CONST_KEY_MAP 156 diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 3f01712bd665d8..17de85a43e8b39 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3463 (add structural pattern matching) +# Python 3.10a0 3464 (add structural pattern matching) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3463).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3464).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index 751d56a4ca6f29..e0ef77ea5e51f8 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -82,6 +82,8 @@ def jabs_op(name, op): def_op('INPLACE_FLOOR_DIVIDE', 28) def_op('INPLACE_TRUE_DIVIDE', 29) def_op('GET_LEN', 30) +def_op('MATCH_MAPPING', 31) +def_op('MATCH_SEQUENCE', 32) def_op('RERAISE', 48) def_op('WITH_EXCEPT_START', 49) @@ -193,10 +195,8 @@ def jabs_op(name, op): def_op('MAP_ADD', 147) def_op('LOAD_CLASSDEREF', 148) hasfree.append(148) -def_op('MATCH_TYPE', 149) +def_op('MATCH_CLASS', 149) def_op('MATCH_KEYS', 150) -jrel_op('JUMP_IF_NOT_MAP', 151) -jrel_op('JUMP_IF_NOT_SEQ', 152) jrel_op('SETUP_ASYNC_WITH', 154) def_op('FORMAT_VALUE', 155) diff --git a/Python/ceval.c b/Python/ceval.c index ad784d4a61f01a..57c6f74b1f64ee 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3520,7 +3520,21 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) #endif } - case TARGET(MATCH_TYPE): { + case TARGET(GET_LEN): { + PyObject *target = TOP(); + Py_ssize_t l = PyObject_Length(target); + if (l < 0) { + goto error; + } + PyObject *len = PyLong_FromSsize_t(l); + if (!len) { + goto error; + } + PUSH(len); + DISPATCH(); + } + + case TARGET(MATCH_CLASS): { PyObject *names = POP(); PyObject *type = TOP(); PyObject *target = SECOND(); @@ -3538,7 +3552,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(JUMP_IF_NOT_MAP): { + case TARGET(MATCH_MAPPING): { PyInterpreterState *interp = PyInterpreterState_Get(); if (!interp->map_abc) { PyObject *abc = PyImport_ImportModule("_collections_abc"); @@ -3555,20 +3569,19 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (match < 0) { goto error; } - if (!match) { - JUMPBY(oparg); - } + PUSH(PyBool_FromLong(match)); DISPATCH(); } - case TARGET(JUMP_IF_NOT_SEQ): { + case TARGET(MATCH_SEQUENCE): { PyObject *target = TOP(); if (PyType_FastSubclass(Py_TYPE(target), Py_TPFLAGS_BYTES_SUBCLASS | Py_TPFLAGS_UNICODE_SUBCLASS) || PyIter_Check(target) || PyByteArray_Check(target)) { - JUMPBY(oparg); + Py_INCREF(Py_False); + PUSH(Py_False); DISPATCH(); } PyInterpreterState *interp = PyInterpreterState_Get(); @@ -3587,9 +3600,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (match < 0) { goto error; } - if (!match) { - JUMPBY(oparg); - } + PUSH(PyBool_FromLong(match)); DISPATCH(); } @@ -3623,20 +3634,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(GET_LEN): { - PyObject *target = TOP(); - Py_ssize_t l = PyObject_Length(target); - if (l < 0) { - goto error; - } - PyObject *len = PyLong_FromSsize_t(l); - if (!len) { - goto error; - } - PUSH(len); - DISPATCH(); - } - case TARGET(GET_ITER): { /* before: [obj]; after [getiter(obj)] */ PyObject *iterable = TOP(); diff --git a/Python/compile.c b/Python/compile.c index c68001e646bd80..b12037bfd97b3c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -176,7 +176,6 @@ struct compiler { }; typedef struct { - basicblock *failure; PyObject* stores; } pattern_context; @@ -225,7 +224,7 @@ static int compiler_async_comprehension_generator( int depth, expr_ty elt, expr_ty val, int type); -static int compiler_pattern(struct compiler *, expr_ty, pattern_context *); +static int compiler_pattern(struct compiler *, expr_ty, pattern_context); static PyCodeObject *assemble(struct compiler *, int addNone); static PyObject *__doc__, *__annotations__; @@ -1106,14 +1105,14 @@ stack_effect(int opcode, int oparg, int jump) case DICT_MERGE: case DICT_UPDATE: return -1; - case MATCH_TYPE: + case GET_LEN: + return 1; + case MATCH_CLASS: return -1; case MATCH_KEYS: - case GET_LEN: + case MATCH_MAPPING: + case MATCH_SEQUENCE: return 1; - case JUMP_IF_NOT_MAP: - case JUMP_IF_NOT_SEQ: - return 0; default: return PY_INVALID_STACK_EFFECT; } @@ -2754,7 +2753,7 @@ compiler_if(struct compiler *c, stmt_ty s) _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) static int -compiler_pattern_load(struct compiler *c, expr_ty p, pattern_context *pc) +compiler_pattern_load(struct compiler *c, expr_ty p, pattern_context pc) { assert(p->kind == Attribute_kind || p->kind == Constant_kind || p->kind == Name_kind); assert(p->kind != Attribute_kind || p->v.Attribute.ctx == Load); @@ -2765,7 +2764,7 @@ compiler_pattern_load(struct compiler *c, expr_ty p, pattern_context *pc) } static int -compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { +compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context pc) { asdl_seq *args = p->v.Call.args; asdl_seq *kwargs = p->v.Call.keywords; Py_ssize_t nargs = asdl_seq_LEN(args); @@ -2787,10 +2786,8 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { PyTuple_SET_ITEM(kwnames, i, name); } ADDOP_LOAD_CONST_NEW(c, kwnames); - ADDOP_I(c, MATCH_TYPE, nargs); + ADDOP_I(c, MATCH_CLASS, nargs); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); - pattern_context sub_pc = *pc; - sub_pc.failure = block; for (i = 0; i < nargs; i++) { expr_ty arg = asdl_seq_GET(args, i); if (WILDCARD_CHECK(arg)) { @@ -2799,7 +2796,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { ADDOP(c, DUP_TOP); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); ADDOP(c, BINARY_SUBSCR); - CHECK(compiler_pattern(c, arg, &sub_pc)); + CHECK(compiler_pattern(c, arg, pc)); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } for (i = 0; i < nkwargs; i++) { @@ -2810,7 +2807,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { ADDOP(c, DUP_TOP); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(nargs + i)); ADDOP(c, BINARY_SUBSCR); - CHECK(compiler_pattern(c, kwarg->value, &sub_pc)); + CHECK(compiler_pattern(c, kwarg->value, pc)); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } ADDOP_LOAD_CONST(c, Py_True); @@ -2821,41 +2818,40 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { } static int -compiler_pattern_store(struct compiler *c, expr_ty p, pattern_context *pc) { +compiler_pattern_store(struct compiler *c, expr_ty p, pattern_context pc) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); if (WILDCARD_CHECK(p)) { return compiler_error(c, "can't assign to '_' here; " "consider removing or renaming?"); } - if (PySet_Contains(pc->stores, p->v.Name.id)) { + if (PySet_Contains(pc.stores, p->v.Name.id)) { // TODO: Format this error message with the name. return compiler_error(c, "multiple assignments to name in pattern"); } - CHECK(!PySet_Add(pc->stores, p->v.Name.id)); + CHECK(!PySet_Add(pc.stores, p->v.Name.id)); VISIT(c, expr, p); ADDOP_LOAD_CONST(c, Py_True); return 1; } static int -compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc) +compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context pc) { - // TODO: We shouldn't need 3 cleanup blocks. Make things more uniform - basicblock *block, *block_star, *end; - CHECK(block_star = compiler_new_block(c)); + basicblock *block, *end; CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); asdl_seq *keys = p->v.Dict.keys; asdl_seq *values = p->v.Dict.values; Py_ssize_t size = asdl_seq_LEN(values); int star = size ? !asdl_seq_GET(keys, size - 1) : 0; - ADDOP_JREL(c, JUMP_IF_NOT_MAP, block); // TODO: Refactor to ditch block. + ADDOP(c, MATCH_MAPPING); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); if (size - star) { ADDOP(c, GET_LEN); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - star)); ADDOP_COMPARE(c, GtE); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); } Py_ssize_t i; for (i = 0; i < size - star; i++) { @@ -2870,9 +2866,7 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc) } ADDOP_I(c, BUILD_TUPLE, size - star); ADDOP_I(c, MATCH_KEYS, star); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, block_star); - pattern_context sub_pc = *pc; - sub_pc.failure = block_star; + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); for (i = 0; i < size - star; i++) { expr_ty value = asdl_seq_GET(values, i); if (WILDCARD_CHECK(value)) { @@ -2881,8 +2875,8 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP(c, DUP_TOP); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); ADDOP(c, BINARY_SUBSCR); - CHECK(compiler_pattern(c, value, &sub_pc)); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, block_star); + CHECK(compiler_pattern(c, value, pc)); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); } ADDOP(c, POP_TOP); if (star) { @@ -2893,24 +2887,22 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP_LOAD_CONST(c, Py_True); } ADDOP_JREL(c, JUMP_FORWARD, end); - compiler_use_next_block(c, block_star); - ADDOP(c, POP_TOP); compiler_use_next_block(c, block); - ADDOP_LOAD_CONST(c, Py_False); - ADDOP(c, ROT_TWO); ADDOP(c, POP_TOP); + ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_False); compiler_use_next_block(c, end); return 1; } static int -compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) +compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context pc) { assert(p->kind == Name_kind); - assert(p->v.Name.ctx == Load || p->v.Name.ctx == Store); if (p->v.Name.ctx == Load) { return compiler_pattern_load(c, p, pc); } + assert(p->v.Name.ctx == Store); if (WILDCARD_CHECK(p)) { ADDOP(c, POP_TOP); ADDOP_LOAD_CONST(c, Py_True); @@ -2920,16 +2912,14 @@ compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) } static int -compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc) +compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context pc) { assert(p->kind == NamedExpr_kind); basicblock *block, *end; CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); - pattern_context sub_pc = *pc; - sub_pc.failure = block; ADDOP(c, DUP_TOP); - CHECK(compiler_pattern(c, p->v.NamedExpr.value, &sub_pc)); + CHECK(compiler_pattern(c, p->v.NamedExpr.value, pc)); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); CHECK(compiler_pattern_store(c, p->v.NamedExpr.target, pc)); ADDOP_JREL(c, JUMP_FORWARD, end); @@ -2941,7 +2931,7 @@ compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc) } static int -compiler_pattern_or(struct compiler *c, expr_ty p, pattern_context *pc) +compiler_pattern_or(struct compiler *c, expr_ty p, pattern_context pc) { assert(p->kind == BoolOp_kind); assert(p->v.BoolOp.op == Or); @@ -2952,11 +2942,12 @@ compiler_pattern_or(struct compiler *c, expr_ty p, pattern_context *pc) assert(size > 1); PyObject *names_copy; for (Py_ssize_t i = 0; i < size; i++) { - CHECK(names_copy = PySet_New(pc->stores)); + CHECK(names_copy = PySet_New(pc.stores)); ADDOP(c, DUP_TOP); - pattern_context sub_pc = *pc; + // TODO: Just modify pc instead. + pattern_context sub_pc = pc; sub_pc.stores = names_copy; - CHECK(compiler_pattern(c, asdl_seq_GET(p->v.BoolOp.values, i), &sub_pc)); + CHECK(compiler_pattern(c, asdl_seq_GET(p->v.BoolOp.values, i), sub_pc)); ADDOP_JABS(c, JUMP_IF_TRUE_OR_POP, end); // TODO: Reuse names_copy without actually building a new copy each loop? if (!i) { @@ -2992,7 +2983,7 @@ compiler_pattern_or(struct compiler *c, expr_ty p, pattern_context *pc) } static int -compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context *pc) +compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context pc) { assert(p->kind == List_kind || p->kind == Tuple_kind); asdl_seq *values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; @@ -3008,26 +2999,22 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context *pc) } star = i; } - basicblock *block, *end; - CHECK(block = compiler_new_block(c)); + basicblock *end; CHECK(end = compiler_new_block(c)); - ADDOP_JREL(c, JUMP_IF_NOT_SEQ, block); // TODO: Refactor to ditch block. - if (star >= 0) { - if (size) { - ADDOP(c, GET_LEN); - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - 1)); - ADDOP_COMPARE(c, GtE); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); - } - } - else { + ADDOP(c, MATCH_SEQUENCE); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); + if (star < 0) { ADDOP(c, GET_LEN); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)); ADDOP_COMPARE(c, Eq); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } - pattern_context sub_pc = *pc; - sub_pc.failure = block; + else if (size) { + ADDOP(c, GET_LEN); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - 1)); + ADDOP_COMPARE(c, GtE); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); + } for (Py_ssize_t i = 0; i < size; i++) { expr_ty value = asdl_seq_GET(values, i); if (WILDCARD_CHECK(value)) { @@ -3068,13 +3055,10 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(-(size - i))); ADDOP(c, BINARY_SUBSCR); } - CHECK(compiler_pattern(c, value, &sub_pc)); + CHECK(compiler_pattern(c, value, pc)); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } ADDOP_LOAD_CONST(c, Py_True); - ADDOP_JREL(c, JUMP_FORWARD, end); - compiler_use_next_block(c, block); - ADDOP_LOAD_CONST(c, Py_False); compiler_use_next_block(c, end); ADDOP(c, ROT_TWO); ADDOP(c, POP_TOP); @@ -3082,7 +3066,7 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context *pc) } static int -compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc) +compiler_pattern(struct compiler *c, expr_ty p, pattern_context pc) { SET_LOC(c, p); switch (p->kind) { @@ -3117,7 +3101,7 @@ static int compiler_match(struct compiler *c, stmt_ty s) { VISIT(c, expr, s->v.Match.target); - basicblock *end; + basicblock *next, *end; CHECK(end = compiler_new_block(c)); int warned = 0; Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); @@ -3126,13 +3110,14 @@ compiler_match(struct compiler *c, stmt_ty s) CHECK(pc.stores = PySet_New(NULL)); int last = 0; match_case_ty m; + // TODO: Leaks pc.stores on failure. for (Py_ssize_t i = 0; i < cases; i++) { if (i == cases - 1) { last = 1; } m = asdl_seq_GET(s->v.Match.cases, i); SET_LOC(c, m->pattern); - CHECK(pc.failure = compiler_new_block(c)); + CHECK(next = compiler_new_block(c)); if (!last) { ADDOP(c, DUP_TOP); } @@ -3143,12 +3128,12 @@ compiler_match(struct compiler *c, stmt_ty s) CHECK(compiler_warn(c, "unguarded name capture pattern makes " "remaining cases unreachable")); } - int result = compiler_pattern(c, m->pattern, &pc); + int result = compiler_pattern(c, m->pattern, pc); PySet_Clear(pc.stores); CHECK(result); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, pc.failure); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, next); if (m->guard) { - CHECK(compiler_jump_if(c, m->guard, pc.failure, 0)); + CHECK(compiler_jump_if(c, m->guard, next, 0)); } if (!last) { ADDOP(c, POP_TOP); @@ -3157,7 +3142,7 @@ compiler_match(struct compiler *c, stmt_ty s) if (!last) { ADDOP_JREL(c, JUMP_FORWARD, end); } - compiler_use_next_block(c, pc.failure); + compiler_use_next_block(c, next); } Py_DECREF(pc.stores); compiler_use_next_block(c, end); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index d09ff89aa4022b..f96f2c5d782bc6 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,135,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,136,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 4c6721c6d212a2..d877d6b0697880 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -30,8 +30,8 @@ static void *opcode_targets[256] = { &&TARGET_INPLACE_FLOOR_DIVIDE, &&TARGET_INPLACE_TRUE_DIVIDE, &&TARGET_GET_LEN, - &&_unknown_opcode, - &&_unknown_opcode, + &&TARGET_MATCH_MAPPING, + &&TARGET_MATCH_SEQUENCE, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, @@ -148,10 +148,10 @@ static void *opcode_targets[256] = { &&TARGET_SET_ADD, &&TARGET_MAP_ADD, &&TARGET_LOAD_CLASSDEREF, - &&TARGET_MATCH_TYPE, + &&TARGET_MATCH_CLASS, &&TARGET_MATCH_KEYS, - &&TARGET_JUMP_IF_NOT_MAP, - &&TARGET_JUMP_IF_NOT_SEQ, + &&_unknown_opcode, + &&_unknown_opcode, &&_unknown_opcode, &&TARGET_SETUP_ASYNC_WITH, &&TARGET_FORMAT_VALUE, diff --git a/Python/peephole.c b/Python/peephole.c index a744b2087016c3..fe67de42227b5b 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -198,8 +198,6 @@ markblocks(_Py_CODEUNIT *code, Py_ssize_t len) case SETUP_FINALLY: case SETUP_WITH: case SETUP_ASYNC_WITH: - case JUMP_IF_NOT_MAP: - case JUMP_IF_NOT_SEQ: j = GETJUMPTGT(code, i); assert(j < len); blocks[j] = 1; @@ -504,8 +502,6 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, case SETUP_FINALLY: case SETUP_WITH: case SETUP_ASYNC_WITH: - case JUMP_IF_NOT_MAP: - case JUMP_IF_NOT_SEQ: j = blocks[j / sizeof(_Py_CODEUNIT) + i + 1] - blocks[i] - 1; j *= sizeof(_Py_CODEUNIT); break; From b642e083da2d1511145abb576c17998e36e5cef1 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Sat, 4 Jul 2020 19:22:13 +0100 Subject: [PATCH 120/189] Implement __match_args__ for AST classes --- Lib/test/test_ast.py | 1 + Parser/asdl_c.py | 5 ++++- Python/Python-ast.c | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index 78e4a5653d4efd..1d97195eea82fc 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -271,6 +271,7 @@ def _assertTrueorder(self, ast_node, parent_pos): self._assertTrueorder(child, first_pos) elif value is not None: self._assertTrueorder(value, parent_pos) + self.assertEqual(ast_node._fields, ast_node.__match_args__) def test_AST_objects(self): x = ast.AST() diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index b93906ba8d45d8..9e357ddd6b72d1 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -833,9 +833,10 @@ def visitModule(self, mod): } PyTuple_SET_ITEM(fnames, i, field); } - result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOs}", + result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}", type, base, state->_fields, fnames, + state->__match_args__, fnames, state->__module__, state->ast, state->__doc__, doc); @@ -966,6 +967,7 @@ def visitModule(self, mod): empty_tuple = PyTuple_New(0); if (!empty_tuple || PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 || + PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 || PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) { Py_XDECREF(empty_tuple); return -1; @@ -1351,6 +1353,7 @@ def generate_module_def(f, mod): state_strings = { "ast", "_fields", + "__match_args__", "__doc__", "__dict__", "__module__", diff --git a/Python/Python-ast.c b/Python/Python-ast.c index f852f1eb80e7fa..44bdd80ec9f8d9 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -134,6 +134,7 @@ typedef struct { PyObject *Yield_type; PyObject *__dict__; PyObject *__doc__; + PyObject *__match_args__; PyObject *__module__; PyObject *_attributes; PyObject *_fields; @@ -389,6 +390,7 @@ static int astmodule_clear(PyObject *module) Py_CLEAR(state->Yield_type); Py_CLEAR(state->__dict__); Py_CLEAR(state->__doc__); + Py_CLEAR(state->__match_args__); Py_CLEAR(state->__module__); Py_CLEAR(state->_attributes); Py_CLEAR(state->_fields); @@ -614,6 +616,7 @@ static int astmodule_traverse(PyObject *module, visitproc visit, void* arg) Py_VISIT(state->Yield_type); Py_VISIT(state->__dict__); Py_VISIT(state->__doc__); + Py_VISIT(state->__match_args__); Py_VISIT(state->__module__); Py_VISIT(state->_attributes); Py_VISIT(state->_fields); @@ -718,6 +721,7 @@ static int init_identifiers(astmodulestate *state) { if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return 0; if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return 0; + if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return 0; if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return 0; if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return 0; if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return 0; @@ -1313,9 +1317,10 @@ make_type(astmodulestate *state, const char *type, PyObject* base, } PyTuple_SET_ITEM(fnames, i, field); } - result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOs}", + result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}", type, base, state->_fields, fnames, + state->__match_args__, fnames, state->__module__, state->ast, state->__doc__, doc); @@ -1446,6 +1451,7 @@ static int add_ast_fields(astmodulestate *state) empty_tuple = PyTuple_New(0); if (!empty_tuple || PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 || + PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 || PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) { Py_XDECREF(empty_tuple); return -1; From e39b3e2cccd63716e944516bc2bd730907700886 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sat, 4 Jul 2020 20:20:08 -0700 Subject: [PATCH 121/189] No more leading dots --- Grammar/python.gram | 3 +- Lib/test/test_patma.py | 17 +- Parser/parser.c | 2441 +++++++++++++++++++--------------------- Python/compile.c | 10 +- 4 files changed, 1179 insertions(+), 1292 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 5115c5ca0ae6f0..1b9e9fbbbfa3d7 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -244,8 +244,7 @@ literal_pattern[expr_ty]: | 'True' { _Py_Constant(Py_True, NULL, EXTRA) } | 'False' { _Py_Constant(Py_False, NULL, EXTRA) } constant_pattern[expr_ty]: - | '.' name=NAME !('.' | '(' | '=') { name } - | '.'? attr=attr !('.' | '(' | '=') { attr } + | attr=attr !('.' | '(' | '=') { attr } group_pattern[expr_ty]: | '(' pattern=patterns ')' { pattern } sequence_pattern[expr_ty]: diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 8616b1e38ba46a..75a93e8ea8ba10 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -63,13 +63,14 @@ def test_patma_007(self) -> None: def test_patma_008(self) -> None: x = 0 - y = 1 + class A: + y = 1 z = None match x: - case z := .y: + case z := A.y: pass self.assertEqual(x, 0) - self.assertEqual(y, 1) + self.assertEqual(A.y, 1) self.assertEqual(z, None) def test_patma_009(self) -> None: @@ -78,7 +79,7 @@ class A: match 0: case x if x: z = 0 - case y := .x if y: + case y := _ if y == x and y: z = 1 case A.B: z = 2 @@ -1020,7 +1021,7 @@ class A: B = 0 x = 0 match x: - case .A.B: + case A.B: y = 0 self.assertEqual(A.B, 0) self.assertEqual(x, 0) @@ -1044,7 +1045,7 @@ class B: C = 0 x = 0 match x: - case .A.B.C: + case A.B.C: y = 0 self.assertEqual(A.B.C, 0) self.assertEqual(x, 0) @@ -1057,7 +1058,7 @@ class C: D = 0 x = 0 match x: - case .A.B.C.D: + case A.B.C.D: y = 0 self.assertEqual(A.B.C.D, 0) self.assertEqual(x, 0) @@ -1070,7 +1071,7 @@ class C: D = 0 x = 0 match x: - case .A.B.C.D: + case A.B.C.D: y = 0 self.assertEqual(A.B.C.D, 0) self.assertEqual(x, 0) diff --git a/Parser/parser.c b/Parser/parser.c index af79e4f876bf9d..b71049e54ad61c 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -307,126 +307,126 @@ static KeywordToken *reserved_keywords[] = { #define _tmp_53_type 1238 #define _tmp_54_type 1239 #define _tmp_55_type 1240 -#define _tmp_56_type 1241 -#define _loop0_58_type 1242 -#define _gather_57_type 1243 -#define _loop0_60_type 1244 -#define _gather_59_type 1245 -#define _loop0_62_type 1246 -#define _gather_61_type 1247 -#define _loop0_64_type 1248 -#define _gather_63_type 1249 -#define _tmp_65_type 1250 -#define _loop0_67_type 1251 -#define _gather_66_type 1252 +#define _loop0_57_type 1241 +#define _gather_56_type 1242 +#define _loop0_59_type 1243 +#define _gather_58_type 1244 +#define _loop0_61_type 1245 +#define _gather_60_type 1246 +#define _loop0_63_type 1247 +#define _gather_62_type 1248 +#define _tmp_64_type 1249 +#define _loop0_66_type 1250 +#define _gather_65_type 1251 +#define _tmp_67_type 1252 #define _tmp_68_type 1253 #define _tmp_69_type 1254 -#define _tmp_70_type 1255 -#define _loop0_72_type 1256 -#define _gather_71_type 1257 -#define _loop0_74_type 1258 -#define _gather_73_type 1259 +#define _loop0_71_type 1255 +#define _gather_70_type 1256 +#define _loop0_73_type 1257 +#define _gather_72_type 1258 +#define _tmp_74_type 1259 #define _tmp_75_type 1260 #define _tmp_76_type 1261 #define _tmp_77_type 1262 #define _tmp_78_type 1263 #define _tmp_79_type 1264 -#define _tmp_80_type 1265 +#define _loop0_80_type 1265 #define _loop0_81_type 1266 #define _loop0_82_type 1267 -#define _loop0_83_type 1268 -#define _loop1_84_type 1269 -#define _loop0_85_type 1270 +#define _loop1_83_type 1268 +#define _loop0_84_type 1269 +#define _loop1_85_type 1270 #define _loop1_86_type 1271 #define _loop1_87_type 1272 -#define _loop1_88_type 1273 -#define _loop0_89_type 1274 -#define _loop1_90_type 1275 -#define _loop0_91_type 1276 -#define _loop1_92_type 1277 -#define _loop0_93_type 1278 +#define _loop0_88_type 1273 +#define _loop1_89_type 1274 +#define _loop0_90_type 1275 +#define _loop1_91_type 1276 +#define _loop0_92_type 1277 +#define _loop1_93_type 1278 #define _loop1_94_type 1279 -#define _loop1_95_type 1280 -#define _tmp_96_type 1281 -#define _loop0_98_type 1282 -#define _gather_97_type 1283 -#define _loop1_99_type 1284 -#define _loop0_101_type 1285 -#define _gather_100_type 1286 -#define _loop1_102_type 1287 +#define _tmp_95_type 1280 +#define _loop0_97_type 1281 +#define _gather_96_type 1282 +#define _loop1_98_type 1283 +#define _loop0_100_type 1284 +#define _gather_99_type 1285 +#define _loop1_101_type 1286 +#define _loop0_102_type 1287 #define _loop0_103_type 1288 #define _loop0_104_type 1289 -#define _loop0_105_type 1290 -#define _loop1_106_type 1291 -#define _loop0_107_type 1292 +#define _loop1_105_type 1290 +#define _loop0_106_type 1291 +#define _loop1_107_type 1292 #define _loop1_108_type 1293 #define _loop1_109_type 1294 -#define _loop1_110_type 1295 -#define _loop0_111_type 1296 -#define _loop1_112_type 1297 -#define _loop0_113_type 1298 -#define _loop1_114_type 1299 -#define _loop0_115_type 1300 +#define _loop0_110_type 1295 +#define _loop1_111_type 1296 +#define _loop0_112_type 1297 +#define _loop1_113_type 1298 +#define _loop0_114_type 1299 +#define _loop1_115_type 1300 #define _loop1_116_type 1301 #define _loop1_117_type 1302 #define _loop1_118_type 1303 -#define _loop1_119_type 1304 -#define _tmp_120_type 1305 -#define _loop0_122_type 1306 -#define _gather_121_type 1307 +#define _tmp_119_type 1304 +#define _loop0_121_type 1305 +#define _gather_120_type 1306 +#define _tmp_122_type 1307 #define _tmp_123_type 1308 #define _tmp_124_type 1309 #define _tmp_125_type 1310 -#define _tmp_126_type 1311 -#define _loop1_127_type 1312 +#define _loop1_126_type 1311 +#define _tmp_127_type 1312 #define _tmp_128_type 1313 -#define _tmp_129_type 1314 -#define _loop0_131_type 1315 -#define _gather_130_type 1316 -#define _loop1_132_type 1317 +#define _loop0_130_type 1314 +#define _gather_129_type 1315 +#define _loop1_131_type 1316 +#define _loop0_132_type 1317 #define _loop0_133_type 1318 -#define _loop0_134_type 1319 +#define _tmp_134_type 1319 #define _tmp_135_type 1320 -#define _tmp_136_type 1321 -#define _loop0_138_type 1322 -#define _gather_137_type 1323 -#define _loop0_140_type 1324 -#define _gather_139_type 1325 -#define _loop0_142_type 1326 -#define _gather_141_type 1327 -#define _loop0_144_type 1328 -#define _gather_143_type 1329 -#define _loop0_145_type 1330 -#define _loop0_147_type 1331 -#define _gather_146_type 1332 -#define _tmp_148_type 1333 -#define _loop0_150_type 1334 -#define _gather_149_type 1335 -#define _loop0_152_type 1336 -#define _gather_151_type 1337 -#define _tmp_153_type 1338 +#define _loop0_137_type 1321 +#define _gather_136_type 1322 +#define _loop0_139_type 1323 +#define _gather_138_type 1324 +#define _loop0_141_type 1325 +#define _gather_140_type 1326 +#define _loop0_143_type 1327 +#define _gather_142_type 1328 +#define _loop0_144_type 1329 +#define _loop0_146_type 1330 +#define _gather_145_type 1331 +#define _tmp_147_type 1332 +#define _loop0_149_type 1333 +#define _gather_148_type 1334 +#define _loop0_151_type 1335 +#define _gather_150_type 1336 +#define _tmp_152_type 1337 +#define _loop0_153_type 1338 #define _loop0_154_type 1339 #define _loop0_155_type 1340 -#define _loop0_156_type 1341 +#define _tmp_156_type 1341 #define _tmp_157_type 1342 -#define _tmp_158_type 1343 -#define _loop0_159_type 1344 -#define _tmp_160_type 1345 -#define _loop0_161_type 1346 +#define _loop0_158_type 1343 +#define _tmp_159_type 1344 +#define _loop0_160_type 1345 +#define _tmp_161_type 1346 #define _tmp_162_type 1347 #define _tmp_163_type 1348 #define _tmp_164_type 1349 #define _tmp_165_type 1350 #define _tmp_166_type 1351 -#define _tmp_167_type 1352 -#define _loop0_169_type 1353 -#define _gather_168_type 1354 -#define _loop0_171_type 1355 -#define _gather_170_type 1356 -#define _loop0_173_type 1357 -#define _gather_172_type 1358 -#define _loop0_175_type 1359 -#define _gather_174_type 1360 +#define _loop0_168_type 1352 +#define _gather_167_type 1353 +#define _loop0_170_type 1354 +#define _gather_169_type 1355 +#define _loop0_172_type 1356 +#define _gather_171_type 1357 +#define _loop0_174_type 1358 +#define _gather_173_type 1359 +#define _tmp_175_type 1360 #define _tmp_176_type 1361 #define _tmp_177_type 1362 #define _tmp_178_type 1363 @@ -436,12 +436,11 @@ static KeywordToken *reserved_keywords[] = { #define _tmp_182_type 1367 #define _tmp_183_type 1368 #define _tmp_184_type 1369 -#define _tmp_185_type 1370 +#define _loop1_185_type 1370 #define _loop1_186_type 1371 -#define _loop1_187_type 1372 +#define _tmp_187_type 1372 #define _tmp_188_type 1373 #define _tmp_189_type 1374 -#define _tmp_190_type 1375 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -684,126 +683,126 @@ static asdl_seq *_gather_51_rule(Parser *p); static void *_tmp_53_rule(Parser *p); static void *_tmp_54_rule(Parser *p); static void *_tmp_55_rule(Parser *p); -static void *_tmp_56_rule(Parser *p); -static asdl_seq *_loop0_58_rule(Parser *p); -static asdl_seq *_gather_57_rule(Parser *p); -static asdl_seq *_loop0_60_rule(Parser *p); -static asdl_seq *_gather_59_rule(Parser *p); -static asdl_seq *_loop0_62_rule(Parser *p); -static asdl_seq *_gather_61_rule(Parser *p); -static asdl_seq *_loop0_64_rule(Parser *p); -static asdl_seq *_gather_63_rule(Parser *p); -static void *_tmp_65_rule(Parser *p); -static asdl_seq *_loop0_67_rule(Parser *p); -static asdl_seq *_gather_66_rule(Parser *p); +static asdl_seq *_loop0_57_rule(Parser *p); +static asdl_seq *_gather_56_rule(Parser *p); +static asdl_seq *_loop0_59_rule(Parser *p); +static asdl_seq *_gather_58_rule(Parser *p); +static asdl_seq *_loop0_61_rule(Parser *p); +static asdl_seq *_gather_60_rule(Parser *p); +static asdl_seq *_loop0_63_rule(Parser *p); +static asdl_seq *_gather_62_rule(Parser *p); +static void *_tmp_64_rule(Parser *p); +static asdl_seq *_loop0_66_rule(Parser *p); +static asdl_seq *_gather_65_rule(Parser *p); +static void *_tmp_67_rule(Parser *p); static void *_tmp_68_rule(Parser *p); static void *_tmp_69_rule(Parser *p); -static void *_tmp_70_rule(Parser *p); -static asdl_seq *_loop0_72_rule(Parser *p); -static asdl_seq *_gather_71_rule(Parser *p); -static asdl_seq *_loop0_74_rule(Parser *p); -static asdl_seq *_gather_73_rule(Parser *p); +static asdl_seq *_loop0_71_rule(Parser *p); +static asdl_seq *_gather_70_rule(Parser *p); +static asdl_seq *_loop0_73_rule(Parser *p); +static asdl_seq *_gather_72_rule(Parser *p); +static void *_tmp_74_rule(Parser *p); static void *_tmp_75_rule(Parser *p); static void *_tmp_76_rule(Parser *p); static void *_tmp_77_rule(Parser *p); static void *_tmp_78_rule(Parser *p); static void *_tmp_79_rule(Parser *p); -static void *_tmp_80_rule(Parser *p); +static asdl_seq *_loop0_80_rule(Parser *p); static asdl_seq *_loop0_81_rule(Parser *p); static asdl_seq *_loop0_82_rule(Parser *p); -static asdl_seq *_loop0_83_rule(Parser *p); -static asdl_seq *_loop1_84_rule(Parser *p); -static asdl_seq *_loop0_85_rule(Parser *p); +static asdl_seq *_loop1_83_rule(Parser *p); +static asdl_seq *_loop0_84_rule(Parser *p); +static asdl_seq *_loop1_85_rule(Parser *p); static asdl_seq *_loop1_86_rule(Parser *p); static asdl_seq *_loop1_87_rule(Parser *p); -static asdl_seq *_loop1_88_rule(Parser *p); -static asdl_seq *_loop0_89_rule(Parser *p); -static asdl_seq *_loop1_90_rule(Parser *p); -static asdl_seq *_loop0_91_rule(Parser *p); -static asdl_seq *_loop1_92_rule(Parser *p); -static asdl_seq *_loop0_93_rule(Parser *p); +static asdl_seq *_loop0_88_rule(Parser *p); +static asdl_seq *_loop1_89_rule(Parser *p); +static asdl_seq *_loop0_90_rule(Parser *p); +static asdl_seq *_loop1_91_rule(Parser *p); +static asdl_seq *_loop0_92_rule(Parser *p); +static asdl_seq *_loop1_93_rule(Parser *p); static asdl_seq *_loop1_94_rule(Parser *p); -static asdl_seq *_loop1_95_rule(Parser *p); -static void *_tmp_96_rule(Parser *p); -static asdl_seq *_loop0_98_rule(Parser *p); -static asdl_seq *_gather_97_rule(Parser *p); -static asdl_seq *_loop1_99_rule(Parser *p); -static asdl_seq *_loop0_101_rule(Parser *p); -static asdl_seq *_gather_100_rule(Parser *p); -static asdl_seq *_loop1_102_rule(Parser *p); +static void *_tmp_95_rule(Parser *p); +static asdl_seq *_loop0_97_rule(Parser *p); +static asdl_seq *_gather_96_rule(Parser *p); +static asdl_seq *_loop1_98_rule(Parser *p); +static asdl_seq *_loop0_100_rule(Parser *p); +static asdl_seq *_gather_99_rule(Parser *p); +static asdl_seq *_loop1_101_rule(Parser *p); +static asdl_seq *_loop0_102_rule(Parser *p); static asdl_seq *_loop0_103_rule(Parser *p); static asdl_seq *_loop0_104_rule(Parser *p); -static asdl_seq *_loop0_105_rule(Parser *p); -static asdl_seq *_loop1_106_rule(Parser *p); -static asdl_seq *_loop0_107_rule(Parser *p); +static asdl_seq *_loop1_105_rule(Parser *p); +static asdl_seq *_loop0_106_rule(Parser *p); +static asdl_seq *_loop1_107_rule(Parser *p); static asdl_seq *_loop1_108_rule(Parser *p); static asdl_seq *_loop1_109_rule(Parser *p); -static asdl_seq *_loop1_110_rule(Parser *p); -static asdl_seq *_loop0_111_rule(Parser *p); -static asdl_seq *_loop1_112_rule(Parser *p); -static asdl_seq *_loop0_113_rule(Parser *p); -static asdl_seq *_loop1_114_rule(Parser *p); -static asdl_seq *_loop0_115_rule(Parser *p); +static asdl_seq *_loop0_110_rule(Parser *p); +static asdl_seq *_loop1_111_rule(Parser *p); +static asdl_seq *_loop0_112_rule(Parser *p); +static asdl_seq *_loop1_113_rule(Parser *p); +static asdl_seq *_loop0_114_rule(Parser *p); +static asdl_seq *_loop1_115_rule(Parser *p); static asdl_seq *_loop1_116_rule(Parser *p); static asdl_seq *_loop1_117_rule(Parser *p); static asdl_seq *_loop1_118_rule(Parser *p); -static asdl_seq *_loop1_119_rule(Parser *p); -static void *_tmp_120_rule(Parser *p); -static asdl_seq *_loop0_122_rule(Parser *p); -static asdl_seq *_gather_121_rule(Parser *p); +static void *_tmp_119_rule(Parser *p); +static asdl_seq *_loop0_121_rule(Parser *p); +static asdl_seq *_gather_120_rule(Parser *p); +static void *_tmp_122_rule(Parser *p); static void *_tmp_123_rule(Parser *p); static void *_tmp_124_rule(Parser *p); static void *_tmp_125_rule(Parser *p); -static void *_tmp_126_rule(Parser *p); -static asdl_seq *_loop1_127_rule(Parser *p); +static asdl_seq *_loop1_126_rule(Parser *p); +static void *_tmp_127_rule(Parser *p); static void *_tmp_128_rule(Parser *p); -static void *_tmp_129_rule(Parser *p); -static asdl_seq *_loop0_131_rule(Parser *p); -static asdl_seq *_gather_130_rule(Parser *p); -static asdl_seq *_loop1_132_rule(Parser *p); +static asdl_seq *_loop0_130_rule(Parser *p); +static asdl_seq *_gather_129_rule(Parser *p); +static asdl_seq *_loop1_131_rule(Parser *p); +static asdl_seq *_loop0_132_rule(Parser *p); static asdl_seq *_loop0_133_rule(Parser *p); -static asdl_seq *_loop0_134_rule(Parser *p); +static void *_tmp_134_rule(Parser *p); static void *_tmp_135_rule(Parser *p); -static void *_tmp_136_rule(Parser *p); -static asdl_seq *_loop0_138_rule(Parser *p); -static asdl_seq *_gather_137_rule(Parser *p); -static asdl_seq *_loop0_140_rule(Parser *p); -static asdl_seq *_gather_139_rule(Parser *p); -static asdl_seq *_loop0_142_rule(Parser *p); -static asdl_seq *_gather_141_rule(Parser *p); +static asdl_seq *_loop0_137_rule(Parser *p); +static asdl_seq *_gather_136_rule(Parser *p); +static asdl_seq *_loop0_139_rule(Parser *p); +static asdl_seq *_gather_138_rule(Parser *p); +static asdl_seq *_loop0_141_rule(Parser *p); +static asdl_seq *_gather_140_rule(Parser *p); +static asdl_seq *_loop0_143_rule(Parser *p); +static asdl_seq *_gather_142_rule(Parser *p); static asdl_seq *_loop0_144_rule(Parser *p); -static asdl_seq *_gather_143_rule(Parser *p); -static asdl_seq *_loop0_145_rule(Parser *p); -static asdl_seq *_loop0_147_rule(Parser *p); -static asdl_seq *_gather_146_rule(Parser *p); -static void *_tmp_148_rule(Parser *p); -static asdl_seq *_loop0_150_rule(Parser *p); -static asdl_seq *_gather_149_rule(Parser *p); -static asdl_seq *_loop0_152_rule(Parser *p); -static asdl_seq *_gather_151_rule(Parser *p); -static void *_tmp_153_rule(Parser *p); +static asdl_seq *_loop0_146_rule(Parser *p); +static asdl_seq *_gather_145_rule(Parser *p); +static void *_tmp_147_rule(Parser *p); +static asdl_seq *_loop0_149_rule(Parser *p); +static asdl_seq *_gather_148_rule(Parser *p); +static asdl_seq *_loop0_151_rule(Parser *p); +static asdl_seq *_gather_150_rule(Parser *p); +static void *_tmp_152_rule(Parser *p); +static asdl_seq *_loop0_153_rule(Parser *p); static asdl_seq *_loop0_154_rule(Parser *p); static asdl_seq *_loop0_155_rule(Parser *p); -static asdl_seq *_loop0_156_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_160_rule(Parser *p); -static asdl_seq *_loop0_161_rule(Parser *p); +static asdl_seq *_loop0_158_rule(Parser *p); +static void *_tmp_159_rule(Parser *p); +static asdl_seq *_loop0_160_rule(Parser *p); +static void *_tmp_161_rule(Parser *p); static void *_tmp_162_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 void *_tmp_167_rule(Parser *p); -static asdl_seq *_loop0_169_rule(Parser *p); -static asdl_seq *_gather_168_rule(Parser *p); -static asdl_seq *_loop0_171_rule(Parser *p); -static asdl_seq *_gather_170_rule(Parser *p); -static asdl_seq *_loop0_173_rule(Parser *p); -static asdl_seq *_gather_172_rule(Parser *p); -static asdl_seq *_loop0_175_rule(Parser *p); -static asdl_seq *_gather_174_rule(Parser *p); +static asdl_seq *_loop0_168_rule(Parser *p); +static asdl_seq *_gather_167_rule(Parser *p); +static asdl_seq *_loop0_170_rule(Parser *p); +static asdl_seq *_gather_169_rule(Parser *p); +static asdl_seq *_loop0_172_rule(Parser *p); +static asdl_seq *_gather_171_rule(Parser *p); +static asdl_seq *_loop0_174_rule(Parser *p); +static asdl_seq *_gather_173_rule(Parser *p); +static void *_tmp_175_rule(Parser *p); static void *_tmp_176_rule(Parser *p); static void *_tmp_177_rule(Parser *p); static void *_tmp_178_rule(Parser *p); @@ -813,12 +812,11 @@ static void *_tmp_181_rule(Parser *p); 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 asdl_seq *_loop1_185_rule(Parser *p); static asdl_seq *_loop1_186_rule(Parser *p); -static asdl_seq *_loop1_187_rule(Parser *p); +static void *_tmp_187_rule(Parser *p); static void *_tmp_188_rule(Parser *p); static void *_tmp_189_rule(Parser *p); -static void *_tmp_190_rule(Parser *p); // file: statements? $ @@ -5720,7 +5718,7 @@ literal_pattern_rule(Parser *p) return _res; } -// constant_pattern: '.' NAME !('.' | '(' | '=') | '.'? attr !('.' | '(' | '=') +// constant_pattern: attr !('.' | '(' | '=') static expr_ty constant_pattern_rule(Parser *p) { @@ -5731,53 +5729,20 @@ constant_pattern_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; - { // '.' NAME !('.' | '(' | '=') + { // attr !('.' | '(' | '=') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> constant_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.' NAME !('.' | '(' | '=')")); - Token * _literal; - expr_ty name; - if ( - (_literal = _PyPegen_expect_token(p, 23)) // token='.' - && - (name = _PyPegen_name_token(p)) // NAME - && - _PyPegen_lookahead(0, _tmp_55_rule, p) - ) - { - D(fprintf(stderr, "%*c+ constant_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.' NAME !('.' | '(' | '=')")); - _res = name; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s constant_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.' NAME !('.' | '(' | '=')")); - } - { // '.'? attr !('.' | '(' | '=') - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> constant_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'? attr !('.' | '(' | '=')")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings + D(fprintf(stderr, "%*c> constant_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "attr !('.' | '(' | '=')")); expr_ty attr; if ( - (_opt_var = _PyPegen_expect_token(p, 23), 1) // '.'? - && (attr = attr_rule(p)) // attr && - _PyPegen_lookahead(0, _tmp_56_rule, p) + _PyPegen_lookahead(0, _tmp_55_rule, p) ) { - D(fprintf(stderr, "%*c+ constant_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'? attr !('.' | '(' | '=')")); + D(fprintf(stderr, "%*c+ constant_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "attr !('.' | '(' | '=')")); _res = attr; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -5788,7 +5753,7 @@ constant_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s constant_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'? attr !('.' | '(' | '=')")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "attr !('.' | '(' | '=')")); } _res = NULL; done: @@ -6091,7 +6056,7 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (args = _gather_57_rule(p)) // ','.pattern+ + (args = _gather_56_rule(p)) // ','.pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -6137,7 +6102,7 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (keywords = _gather_59_rule(p)) // ','.keyword_pattern+ + (keywords = _gather_58_rule(p)) // ','.keyword_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -6185,11 +6150,11 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (args = _gather_61_rule(p)) // ','.pattern+ + (args = _gather_60_rule(p)) // ','.pattern+ && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (keywords = _gather_63_rule(p)) // ','.keyword_pattern+ + (keywords = _gather_62_rule(p)) // ','.keyword_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -6224,7 +6189,7 @@ class_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.error_argument_pattern+] ','? ')'")); - asdl_seq * _gather_66_var; + asdl_seq * _gather_65_var; Token * _literal; Token * _literal_1; Token * _literal_2; @@ -6241,15 +6206,15 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_opt_var = _tmp_65_rule(p), 1) // [','.pattern+ ','] + (_opt_var = _tmp_64_rule(p), 1) // [','.pattern+ ','] && - (_gather_66_var = _gather_66_rule(p)) // ','.keyword_pattern+ + (_gather_65_var = _gather_65_rule(p)) // ','.keyword_pattern+ && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && (error = pattern_rule(p)) // pattern && - (_opt_var_1 = _tmp_68_rule(p), 1) // [',' ','.error_argument_pattern+] + (_opt_var_1 = _tmp_67_rule(p), 1) // [',' ','.error_argument_pattern+] && (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -6290,11 +6255,11 @@ class_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_opt_var = _tmp_69_rule(p), 1) // [','.error_argument_pattern+ ','] + (_opt_var = _tmp_68_rule(p), 1) // [','.error_argument_pattern+ ','] && (error = error_star_rule(p)) // error_star && - (_opt_var_1 = _tmp_70_rule(p), 1) // [',' ','.(error_argument_pattern | error_star)+] + (_opt_var_1 = _tmp_69_rule(p), 1) // [',' ','.(error_argument_pattern | error_star)+] && (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -6573,7 +6538,7 @@ values_pattern_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * values; if ( - (values = _gather_71_rule(p)) // ','.value_pattern+ + (values = _gather_70_rule(p)) // ','.value_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -6618,7 +6583,7 @@ items_pattern_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * items; if ( - (items = _gather_73_rule(p)) // ','.key_value_pattern+ + (items = _gather_72_rule(p)) // ','.key_value_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -6779,10 +6744,10 @@ error_star_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> error_star[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('*' | '**') NAME")); - void *_tmp_75_var; + void *_tmp_74_var; expr_ty error; if ( - (_tmp_75_var = _tmp_75_rule(p)) // '*' | '**' + (_tmp_74_var = _tmp_74_rule(p)) // '*' | '**' && (error = _PyPegen_name_token(p)) // NAME ) @@ -6910,7 +6875,7 @@ key_value_pattern_rule(Parser *p) void *key; expr_ty value; if ( - (key = _tmp_76_rule(p)) // literal_pattern | constant_pattern + (key = _tmp_75_rule(p)) // literal_pattern | constant_pattern && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -7059,7 +7024,7 @@ raise_stmt_rule(Parser *p) && (a = expression_rule(p)) // expression && - (b = _tmp_77_rule(p), 1) // ['from' expression] + (b = _tmp_76_rule(p), 1) // ['from' expression] ) { D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); @@ -7234,7 +7199,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_78_rule(p), 1) // ['->' expression] + (a = _tmp_77_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -7294,7 +7259,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_79_rule(p), 1) // ['->' expression] + (a = _tmp_78_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -7358,7 +7323,7 @@ func_type_comment_rule(Parser *p) && (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' && - _PyPegen_lookahead(1, _tmp_80_rule, p) + _PyPegen_lookahead(1, _tmp_79_rule, p) ) { D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); @@ -7502,9 +7467,9 @@ parameters_rule(Parser *p) if ( (a = slash_no_default_rule(p)) // slash_no_default && - (b = _loop0_81_rule(p)) // param_no_default* + (b = _loop0_80_rule(p)) // param_no_default* && - (c = _loop0_82_rule(p)) // param_with_default* + (c = _loop0_81_rule(p)) // param_with_default* && (d = star_etc_rule(p), 1) // star_etc? ) @@ -7534,7 +7499,7 @@ parameters_rule(Parser *p) if ( (a = slash_with_default_rule(p)) // slash_with_default && - (b = _loop0_83_rule(p)) // param_with_default* + (b = _loop0_82_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -7562,9 +7527,9 @@ parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = _loop1_84_rule(p)) // param_no_default+ + (a = _loop1_83_rule(p)) // param_no_default+ && - (b = _loop0_85_rule(p)) // param_with_default* + (b = _loop0_84_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -7591,7 +7556,7 @@ parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_86_rule(p)) // param_with_default+ + (a = _loop1_85_rule(p)) // param_with_default+ && (b = star_etc_rule(p), 1) // star_etc? ) @@ -7660,7 +7625,7 @@ slash_no_default_rule(Parser *p) Token * _literal_1; asdl_seq * a; if ( - (a = _loop1_87_rule(p)) // param_no_default+ + (a = _loop1_86_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7689,7 +7654,7 @@ slash_no_default_rule(Parser *p) Token * _literal; asdl_seq * a; if ( - (a = _loop1_88_rule(p)) // param_no_default+ + (a = _loop1_87_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7739,9 +7704,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_89_rule(p)) // param_no_default* + (a = _loop0_88_rule(p)) // param_no_default* && - (b = _loop1_90_rule(p)) // param_with_default+ + (b = _loop1_89_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7771,9 +7736,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_91_rule(p)) // param_no_default* + (a = _loop0_90_rule(p)) // param_no_default* && - (b = _loop1_92_rule(p)) // param_with_default+ + (b = _loop1_91_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7829,7 +7794,7 @@ star_etc_rule(Parser *p) && (a = param_no_default_rule(p)) // param_no_default && - (b = _loop0_93_rule(p)) // param_maybe_default* + (b = _loop0_92_rule(p)) // param_maybe_default* && (c = kwds_rule(p), 1) // kwds? ) @@ -7862,7 +7827,7 @@ star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_94_rule(p)) // param_maybe_default+ + (b = _loop1_93_rule(p)) // param_maybe_default+ && (c = kwds_rule(p), 1) // kwds? ) @@ -8384,7 +8349,7 @@ decorators_rule(Parser *p) D(fprintf(stderr, "%*c> decorators[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); asdl_seq * a; if ( - (a = _loop1_95_rule(p)) // (('@' named_expression NEWLINE))+ + (a = _loop1_94_rule(p)) // (('@' named_expression NEWLINE))+ ) { D(fprintf(stderr, "%*c+ decorators[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); @@ -8505,7 +8470,7 @@ class_def_raw_rule(Parser *p) && (a = _PyPegen_name_token(p)) // NAME && - (b = _tmp_96_rule(p), 1) // ['(' arguments? ')'] + (b = _tmp_95_rule(p), 1) // ['(' arguments? ')'] && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -8654,7 +8619,7 @@ expressions_list_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_97_rule(p)) // ','.star_expression+ + (a = _gather_96_rule(p)) // ','.star_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8714,7 +8679,7 @@ star_expressions_rule(Parser *p) if ( (a = star_expression_rule(p)) // star_expression && - (b = _loop1_99_rule(p)) // ((',' star_expression))+ + (b = _loop1_98_rule(p)) // ((',' star_expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8909,7 +8874,7 @@ star_named_expressions_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_100_rule(p)) // ','.star_named_expression+ + (a = _gather_99_rule(p)) // ','.star_named_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -9214,7 +9179,7 @@ expressions_rule(Parser *p) if ( (a = expression_rule(p)) // expression && - (b = _loop1_102_rule(p)) // ((',' expression))+ + (b = _loop1_101_rule(p)) // ((',' expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -9568,9 +9533,9 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default && - (b = _loop0_103_rule(p)) // lambda_param_no_default* + (b = _loop0_102_rule(p)) // lambda_param_no_default* && - (c = _loop0_104_rule(p)) // lambda_param_with_default* + (c = _loop0_103_rule(p)) // lambda_param_with_default* && (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9600,7 +9565,7 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default && - (b = _loop0_105_rule(p)) // lambda_param_with_default* + (b = _loop0_104_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9628,9 +9593,9 @@ lambda_parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = _loop1_106_rule(p)) // lambda_param_no_default+ + (a = _loop1_105_rule(p)) // lambda_param_no_default+ && - (b = _loop0_107_rule(p)) // lambda_param_with_default* + (b = _loop0_106_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9657,7 +9622,7 @@ lambda_parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_108_rule(p)) // lambda_param_with_default+ + (a = _loop1_107_rule(p)) // lambda_param_with_default+ && (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9728,7 +9693,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal_1; asdl_seq * a; if ( - (a = _loop1_109_rule(p)) // lambda_param_no_default+ + (a = _loop1_108_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9757,7 +9722,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal; asdl_seq * a; if ( - (a = _loop1_110_rule(p)) // lambda_param_no_default+ + (a = _loop1_109_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9807,9 +9772,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_111_rule(p)) // lambda_param_no_default* + (a = _loop0_110_rule(p)) // lambda_param_no_default* && - (b = _loop1_112_rule(p)) // lambda_param_with_default+ + (b = _loop1_111_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9839,9 +9804,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_113_rule(p)) // lambda_param_no_default* + (a = _loop0_112_rule(p)) // lambda_param_no_default* && - (b = _loop1_114_rule(p)) // lambda_param_with_default+ + (b = _loop1_113_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9897,7 +9862,7 @@ lambda_star_etc_rule(Parser *p) && (a = lambda_param_no_default_rule(p)) // lambda_param_no_default && - (b = _loop0_115_rule(p)) // lambda_param_maybe_default* + (b = _loop0_114_rule(p)) // lambda_param_maybe_default* && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -9930,7 +9895,7 @@ lambda_star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_116_rule(p)) // lambda_param_maybe_default+ + (b = _loop1_115_rule(p)) // lambda_param_maybe_default+ && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -10357,7 +10322,7 @@ disjunction_rule(Parser *p) if ( (a = conjunction_rule(p)) // conjunction && - (b = _loop1_117_rule(p)) // (('or' conjunction))+ + (b = _loop1_116_rule(p)) // (('or' conjunction))+ ) { D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); @@ -10443,7 +10408,7 @@ conjunction_rule(Parser *p) if ( (a = inversion_rule(p)) // inversion && - (b = _loop1_118_rule(p)) // (('and' inversion))+ + (b = _loop1_117_rule(p)) // (('and' inversion))+ ) { D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); @@ -10611,7 +10576,7 @@ comparison_rule(Parser *p) if ( (a = bitwise_or_rule(p)) // bitwise_or && - (b = _loop1_119_rule(p)) // compare_op_bitwise_or_pair+ + (b = _loop1_118_rule(p)) // compare_op_bitwise_or_pair+ ) { D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); @@ -10939,10 +10904,10 @@ noteq_bitwise_or_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); - void *_tmp_120_var; + void *_tmp_119_var; expr_ty a; if ( - (_tmp_120_var = _tmp_120_rule(p)) // '!=' + (_tmp_119_var = _tmp_119_rule(p)) // '!=' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -12871,7 +12836,7 @@ slices_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_121_rule(p)) // ','.slice+ + (a = _gather_120_rule(p)) // ','.slice+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -12941,7 +12906,7 @@ slice_rule(Parser *p) && (b = expression_rule(p), 1) // expression? && - (c = _tmp_123_rule(p), 1) // [':' expression?] + (c = _tmp_122_rule(p), 1) // [':' expression?] ) { D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); @@ -13190,15 +13155,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - void *_tmp_124_var; + void *_tmp_123_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' && - (_tmp_124_var = _tmp_124_rule(p)) // tuple | group | genexp + (_tmp_123_var = _tmp_123_rule(p)) // tuple | group | genexp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - _res = _tmp_124_var; + _res = _tmp_123_var; goto done; } p->mark = _mark; @@ -13211,15 +13176,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - void *_tmp_125_var; + void *_tmp_124_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' && - (_tmp_125_var = _tmp_125_rule(p)) // list | listcomp + (_tmp_124_var = _tmp_124_rule(p)) // list | listcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - _res = _tmp_125_var; + _res = _tmp_124_var; goto done; } p->mark = _mark; @@ -13232,15 +13197,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - void *_tmp_126_var; + void *_tmp_125_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' && - (_tmp_126_var = _tmp_126_rule(p)) // dict | set | dictcomp | setcomp + (_tmp_125_var = _tmp_125_rule(p)) // dict | set | dictcomp | setcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - _res = _tmp_126_var; + _res = _tmp_125_var; goto done; } p->mark = _mark; @@ -13309,7 +13274,7 @@ strings_rule(Parser *p) D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+")); asdl_seq * a; if ( - (a = _loop1_127_rule(p)) // STRING+ + (a = _loop1_126_rule(p)) // STRING+ ) { D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+")); @@ -13523,7 +13488,7 @@ tuple_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_128_rule(p), 1) // [star_named_expression ',' star_named_expressions?] + (a = _tmp_127_rule(p), 1) // [star_named_expression ',' star_named_expressions?] && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -13579,7 +13544,7 @@ group_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_129_rule(p)) // yield_expr | named_expression + (a = _tmp_128_rule(p)) // yield_expr | named_expression && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -14048,7 +14013,7 @@ double_starred_kvpairs_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_130_rule(p)) // ','.double_starred_kvpair+ + (a = _gather_129_rule(p)) // ','.double_starred_kvpair+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -14199,13 +14164,13 @@ for_if_clauses_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); - asdl_seq * _loop1_132_var; + asdl_seq * _loop1_131_var; if ( - (_loop1_132_var = _loop1_132_rule(p)) // for_if_clause+ + (_loop1_131_var = _loop1_131_rule(p)) // for_if_clause+ ) { D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); - _res = _loop1_132_var; + _res = _loop1_131_var; goto done; } p->mark = _mark; @@ -14258,7 +14223,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = _loop0_133_rule(p)) // (('if' disjunction))* + (c = _loop0_132_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' ~ disjunction (('if' disjunction))*")); @@ -14301,7 +14266,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = _loop0_134_rule(p)) // (('if' disjunction))* + (c = _loop0_133_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' ~ disjunction (('if' disjunction))*")); @@ -14549,7 +14514,7 @@ args_rule(Parser *p) if ( (a = starred_expression_rule(p)) // starred_expression && - (b = _tmp_135_rule(p), 1) // [',' args] + (b = _tmp_134_rule(p), 1) // [',' args] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]")); @@ -14618,7 +14583,7 @@ args_rule(Parser *p) if ( (a = named_expression_rule(p)) // named_expression && - (b = _tmp_136_rule(p), 1) // [',' args] + (b = _tmp_135_rule(p), 1) // [',' args] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]")); @@ -14673,11 +14638,11 @@ kwargs_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _gather_137_rule(p)) // ','.kwarg_or_starred+ + (a = _gather_136_rule(p)) // ','.kwarg_or_starred+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _gather_139_rule(p)) // ','.kwarg_or_double_starred+ + (b = _gather_138_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); @@ -14699,13 +14664,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - asdl_seq * _gather_141_var; + asdl_seq * _gather_140_var; if ( - (_gather_141_var = _gather_141_rule(p)) // ','.kwarg_or_starred+ + (_gather_140_var = _gather_140_rule(p)) // ','.kwarg_or_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - _res = _gather_141_var; + _res = _gather_140_var; goto done; } p->mark = _mark; @@ -14718,13 +14683,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - asdl_seq * _gather_143_var; + asdl_seq * _gather_142_var; if ( - (_gather_143_var = _gather_143_rule(p)) // ','.kwarg_or_double_starred+ + (_gather_142_var = _gather_142_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - _res = _gather_143_var; + _res = _gather_142_var; goto done; } p->mark = _mark; @@ -15086,7 +15051,7 @@ star_targets_rule(Parser *p) if ( (a = star_target_rule(p)) // star_target && - (b = _loop0_145_rule(p)) // ((',' star_target))* + (b = _loop0_144_rule(p)) // ((',' star_target))* && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -15140,7 +15105,7 @@ star_targets_seq_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_146_rule(p)) // ','.star_target+ + (a = _gather_145_rule(p)) // ','.star_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -15203,7 +15168,7 @@ star_target_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (a = _tmp_148_rule(p)) // !'*' star_target + (a = _tmp_147_rule(p)) // !'*' star_target ) { D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); @@ -15725,7 +15690,7 @@ del_targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_149_rule(p)) // ','.del_target+ + (a = _gather_148_rule(p)) // ','.del_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -16066,7 +16031,7 @@ targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_151_rule(p)) // ','.target+ + (a = _gather_150_rule(p)) // ','.target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -16778,7 +16743,7 @@ incorrect_arguments_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_opt_var = _tmp_153_rule(p), 1) // [args | expression for_if_clauses] + (_opt_var = _tmp_152_rule(p), 1) // [args | expression for_if_clauses] ) { D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); @@ -17036,7 +17001,7 @@ invalid_assignment_rule(Parser *p) D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':' expression")); Token * _literal; Token * _literal_1; - asdl_seq * _loop0_154_var; + asdl_seq * _loop0_153_var; expr_ty a; expr_ty expression_var; if ( @@ -17044,7 +17009,7 @@ invalid_assignment_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_loop0_154_var = _loop0_154_rule(p)) // star_named_expressions* + (_loop0_153_var = _loop0_153_rule(p)) // star_named_expressions* && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -17101,10 +17066,10 @@ invalid_assignment_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='")); Token * _literal; - asdl_seq * _loop0_155_var; + asdl_seq * _loop0_154_var; expr_ty a; if ( - (_loop0_155_var = _loop0_155_rule(p)) // ((star_targets '='))* + (_loop0_154_var = _loop0_154_rule(p)) // ((star_targets '='))* && (a = star_expressions_rule(p)) // star_expressions && @@ -17131,10 +17096,10 @@ invalid_assignment_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='")); Token * _literal; - asdl_seq * _loop0_156_var; + asdl_seq * _loop0_155_var; expr_ty a; if ( - (_loop0_156_var = _loop0_156_rule(p)) // ((star_targets '='))* + (_loop0_155_var = _loop0_155_rule(p)) // ((star_targets '='))* && (a = yield_expr_rule(p)) // yield_expr && @@ -17160,7 +17125,7 @@ invalid_assignment_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); - void *_tmp_157_var; + void *_tmp_156_var; expr_ty a; AugOperator* augassign_var; if ( @@ -17168,7 +17133,7 @@ invalid_assignment_rule(Parser *p) && (augassign_var = augassign_rule(p)) // augassign && - (_tmp_157_var = _tmp_157_rule(p)) // yield_expr | star_expressions + (_tmp_156_var = _tmp_156_rule(p)) // yield_expr | star_expressions ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); @@ -17379,11 +17344,11 @@ invalid_comprehension_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); - void *_tmp_158_var; + void *_tmp_157_var; expr_ty a; asdl_seq* for_if_clauses_var; if ( - (_tmp_158_var = _tmp_158_rule(p)) // '[' | '(' | '{' + (_tmp_157_var = _tmp_157_rule(p)) // '[' | '(' | '{' && (a = starred_expression_rule(p)) // starred_expression && @@ -17480,13 +17445,13 @@ invalid_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); - asdl_seq * _loop0_159_var; - void *_tmp_160_var; + asdl_seq * _loop0_158_var; + void *_tmp_159_var; arg_ty param_no_default_var; if ( - (_loop0_159_var = _loop0_159_rule(p)) // param_no_default* + (_loop0_158_var = _loop0_158_rule(p)) // param_no_default* && - (_tmp_160_var = _tmp_160_rule(p)) // slash_with_default | param_with_default+ + (_tmp_159_var = _tmp_159_rule(p)) // slash_with_default | param_with_default+ && (param_no_default_var = param_no_default_rule(p)) // param_no_default ) @@ -17528,13 +17493,13 @@ invalid_lambda_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default")); - asdl_seq * _loop0_161_var; - void *_tmp_162_var; + asdl_seq * _loop0_160_var; + void *_tmp_161_var; arg_ty lambda_param_no_default_var; if ( - (_loop0_161_var = _loop0_161_rule(p)) // lambda_param_no_default* + (_loop0_160_var = _loop0_160_rule(p)) // lambda_param_no_default* && - (_tmp_162_var = _tmp_162_rule(p)) // lambda_slash_with_default | lambda_param_with_default+ + (_tmp_161_var = _tmp_161_rule(p)) // lambda_slash_with_default | lambda_param_with_default+ && (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default ) @@ -17576,11 +17541,11 @@ invalid_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); Token * _literal; - void *_tmp_163_var; + void *_tmp_162_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_163_var = _tmp_163_rule(p)) // ')' | ',' (')' | '**') + (_tmp_162_var = _tmp_162_rule(p)) // ')' | ',' (')' | '**') ) { D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); @@ -17650,11 +17615,11 @@ invalid_lambda_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); Token * _literal; - void *_tmp_164_var; + void *_tmp_163_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_164_var = _tmp_164_rule(p)) // ':' | ',' (':' | '**') + (_tmp_163_var = _tmp_163_rule(p)) // ':' | ',' (':' | '**') ) { D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); @@ -19163,12 +19128,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_164_var; while ( - (_tmp_165_var = _tmp_165_rule(p)) // star_targets '=' + (_tmp_164_var = _tmp_164_rule(p)) // star_targets '=' ) { - _res = _tmp_165_var; + _res = _tmp_164_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -19671,12 +19636,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_165_var; while ( - (_tmp_166_var = _tmp_166_rule(p)) // '.' | '...' + (_tmp_165_var = _tmp_165_rule(p)) // '.' | '...' ) { - _res = _tmp_166_var; + _res = _tmp_165_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -19737,12 +19702,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_166_var; while ( - (_tmp_167_var = _tmp_167_rule(p)) // '.' | '...' + (_tmp_166_var = _tmp_166_rule(p)) // '.' | '...' ) { - _res = _tmp_167_var; + _res = _tmp_166_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -21130,83 +21095,9 @@ _tmp_55_rule(Parser *p) return _res; } -// _tmp_56: '.' | '(' | '=' -static void * -_tmp_56_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_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 23)) // token='.' - ) - { - D(fprintf(stderr, "%*c+ _tmp_56[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_56[%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_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - ) - { - D(fprintf(stderr, "%*c+ _tmp_56[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_56[%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_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ _tmp_56[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_56[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _loop0_58: ',' pattern +// _loop0_57: ',' pattern static asdl_seq * -_loop0_58_rule(Parser *p) +_loop0_57_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21230,7 +21121,7 @@ _loop0_58_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; expr_ty elem; while ( @@ -21261,7 +21152,7 @@ _loop0_58_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_58[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_57[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21274,14 +21165,14 @@ _loop0_58_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_58_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_57_type, _seq); D(p->level--); return _seq; } -// _gather_57: pattern _loop0_58 +// _gather_56: pattern _loop0_57 static asdl_seq * -_gather_57_rule(Parser *p) +_gather_56_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21290,27 +21181,27 @@ _gather_57_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // pattern _loop0_58 + { // pattern _loop0_57 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_58")); + D(fprintf(stderr, "%*c> _gather_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_57")); expr_ty elem; asdl_seq * seq; if ( (elem = pattern_rule(p)) // pattern && - (seq = _loop0_58_rule(p)) // _loop0_58 + (seq = _loop0_57_rule(p)) // _loop0_57 ) { - D(fprintf(stderr, "%*c+ _gather_57[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_58")); + D(fprintf(stderr, "%*c+ _gather_56[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_57")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_57[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_58")); + D(fprintf(stderr, "%*c%s _gather_56[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_57")); } _res = NULL; done: @@ -21318,9 +21209,9 @@ _gather_57_rule(Parser *p) return _res; } -// _loop0_60: ',' keyword_pattern +// _loop0_59: ',' keyword_pattern static asdl_seq * -_loop0_60_rule(Parser *p) +_loop0_59_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21344,7 +21235,7 @@ _loop0_60_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); + D(fprintf(stderr, "%*c> _loop0_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; keyword_ty elem; while ( @@ -21375,7 +21266,7 @@ _loop0_60_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_60[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_59[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21388,14 +21279,14 @@ _loop0_60_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_60_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_59_type, _seq); D(p->level--); return _seq; } -// _gather_59: keyword_pattern _loop0_60 +// _gather_58: keyword_pattern _loop0_59 static asdl_seq * -_gather_59_rule(Parser *p) +_gather_58_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21404,27 +21295,27 @@ _gather_59_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // keyword_pattern _loop0_60 + { // keyword_pattern _loop0_59 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_60")); + D(fprintf(stderr, "%*c> _gather_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_59")); keyword_ty elem; asdl_seq * seq; if ( (elem = keyword_pattern_rule(p)) // keyword_pattern && - (seq = _loop0_60_rule(p)) // _loop0_60 + (seq = _loop0_59_rule(p)) // _loop0_59 ) { - D(fprintf(stderr, "%*c+ _gather_59[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_60")); + D(fprintf(stderr, "%*c+ _gather_58[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_59")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_59[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_60")); + D(fprintf(stderr, "%*c%s _gather_58[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_59")); } _res = NULL; done: @@ -21432,9 +21323,9 @@ _gather_59_rule(Parser *p) return _res; } -// _loop0_62: ',' pattern +// _loop0_61: ',' pattern static asdl_seq * -_loop0_62_rule(Parser *p) +_loop0_61_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21458,7 +21349,7 @@ _loop0_62_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _loop0_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; expr_ty elem; while ( @@ -21489,7 +21380,7 @@ _loop0_62_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_62[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_61[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21502,14 +21393,14 @@ _loop0_62_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_62_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_61_type, _seq); D(p->level--); return _seq; } -// _gather_61: pattern _loop0_62 +// _gather_60: pattern _loop0_61 static asdl_seq * -_gather_61_rule(Parser *p) +_gather_60_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21518,27 +21409,27 @@ _gather_61_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // pattern _loop0_62 + { // pattern _loop0_61 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_62")); + D(fprintf(stderr, "%*c> _gather_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_61")); expr_ty elem; asdl_seq * seq; if ( (elem = pattern_rule(p)) // pattern && - (seq = _loop0_62_rule(p)) // _loop0_62 + (seq = _loop0_61_rule(p)) // _loop0_61 ) { - D(fprintf(stderr, "%*c+ _gather_61[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_62")); + D(fprintf(stderr, "%*c+ _gather_60[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_61")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_61[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_62")); + D(fprintf(stderr, "%*c%s _gather_60[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_61")); } _res = NULL; done: @@ -21546,9 +21437,9 @@ _gather_61_rule(Parser *p) return _res; } -// _loop0_64: ',' keyword_pattern +// _loop0_63: ',' keyword_pattern static asdl_seq * -_loop0_64_rule(Parser *p) +_loop0_63_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21572,7 +21463,7 @@ _loop0_64_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); + D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; keyword_ty elem; while ( @@ -21603,7 +21494,7 @@ _loop0_64_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_64[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_63[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21616,14 +21507,14 @@ _loop0_64_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_64_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_63_type, _seq); D(p->level--); return _seq; } -// _gather_63: keyword_pattern _loop0_64 +// _gather_62: keyword_pattern _loop0_63 static asdl_seq * -_gather_63_rule(Parser *p) +_gather_62_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21632,27 +21523,27 @@ _gather_63_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // keyword_pattern _loop0_64 + { // keyword_pattern _loop0_63 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_64")); + D(fprintf(stderr, "%*c> _gather_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_63")); keyword_ty elem; asdl_seq * seq; if ( (elem = keyword_pattern_rule(p)) // keyword_pattern && - (seq = _loop0_64_rule(p)) // _loop0_64 + (seq = _loop0_63_rule(p)) // _loop0_63 ) { - D(fprintf(stderr, "%*c+ _gather_63[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_64")); + D(fprintf(stderr, "%*c+ _gather_62[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_63")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_63[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_64")); + D(fprintf(stderr, "%*c%s _gather_62[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_63")); } _res = NULL; done: @@ -21660,9 +21551,9 @@ _gather_63_rule(Parser *p) return _res; } -// _tmp_65: ','.pattern+ ',' +// _tmp_64: ','.pattern+ ',' static void * -_tmp_65_rule(Parser *p) +_tmp_64_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21676,21 +21567,21 @@ _tmp_65_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); - asdl_seq * _gather_168_var; + D(fprintf(stderr, "%*c> _tmp_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); + asdl_seq * _gather_167_var; Token * _literal; if ( - (_gather_168_var = _gather_168_rule(p)) // ','.pattern+ + (_gather_167_var = _gather_167_rule(p)) // ','.pattern+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); - _res = _PyPegen_dummy_name(p, _gather_168_var, _literal); + D(fprintf(stderr, "%*c+ _tmp_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); + _res = _PyPegen_dummy_name(p, _gather_167_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_65[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_64[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.pattern+ ','")); } _res = NULL; @@ -21699,9 +21590,9 @@ _tmp_65_rule(Parser *p) return _res; } -// _loop0_67: ',' keyword_pattern +// _loop0_66: ',' keyword_pattern static asdl_seq * -_loop0_67_rule(Parser *p) +_loop0_66_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21725,7 +21616,7 @@ _loop0_67_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); + D(fprintf(stderr, "%*c> _loop0_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; keyword_ty elem; while ( @@ -21756,7 +21647,7 @@ _loop0_67_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_67[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_66[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -21769,14 +21660,14 @@ _loop0_67_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_67_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_66_type, _seq); D(p->level--); return _seq; } -// _gather_66: keyword_pattern _loop0_67 +// _gather_65: keyword_pattern _loop0_66 static asdl_seq * -_gather_66_rule(Parser *p) +_gather_65_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21785,27 +21676,27 @@ _gather_66_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // keyword_pattern _loop0_67 + { // keyword_pattern _loop0_66 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_67")); + D(fprintf(stderr, "%*c> _gather_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_66")); keyword_ty elem; asdl_seq * seq; if ( (elem = keyword_pattern_rule(p)) // keyword_pattern && - (seq = _loop0_67_rule(p)) // _loop0_67 + (seq = _loop0_66_rule(p)) // _loop0_66 ) { - D(fprintf(stderr, "%*c+ _gather_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_67")); + D(fprintf(stderr, "%*c+ _gather_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_66")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_66[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_67")); + D(fprintf(stderr, "%*c%s _gather_65[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_66")); } _res = NULL; done: @@ -21813,9 +21704,9 @@ _gather_66_rule(Parser *p) return _res; } -// _tmp_68: ',' ','.error_argument_pattern+ +// _tmp_67: ',' ','.error_argument_pattern+ static void * -_tmp_68_rule(Parser *p) +_tmp_67_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21829,21 +21720,21 @@ _tmp_68_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.error_argument_pattern+")); - asdl_seq * _gather_170_var; + D(fprintf(stderr, "%*c> _tmp_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.error_argument_pattern+")); + asdl_seq * _gather_169_var; Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_gather_170_var = _gather_170_rule(p)) // ','.error_argument_pattern+ + (_gather_169_var = _gather_169_rule(p)) // ','.error_argument_pattern+ ) { - D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.error_argument_pattern+")); - _res = _PyPegen_dummy_name(p, _literal, _gather_170_var); + D(fprintf(stderr, "%*c+ _tmp_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.error_argument_pattern+")); + _res = _PyPegen_dummy_name(p, _literal, _gather_169_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_67[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.error_argument_pattern+")); } _res = NULL; @@ -21852,9 +21743,9 @@ _tmp_68_rule(Parser *p) return _res; } -// _tmp_69: ','.error_argument_pattern+ ',' +// _tmp_68: ','.error_argument_pattern+ ',' static void * -_tmp_69_rule(Parser *p) +_tmp_68_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21868,21 +21759,21 @@ _tmp_69_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.error_argument_pattern+ ','")); - asdl_seq * _gather_172_var; + D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.error_argument_pattern+ ','")); + asdl_seq * _gather_171_var; Token * _literal; if ( - (_gather_172_var = _gather_172_rule(p)) // ','.error_argument_pattern+ + (_gather_171_var = _gather_171_rule(p)) // ','.error_argument_pattern+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.error_argument_pattern+ ','")); - _res = _PyPegen_dummy_name(p, _gather_172_var, _literal); + D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.error_argument_pattern+ ','")); + _res = _PyPegen_dummy_name(p, _gather_171_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_69[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.error_argument_pattern+ ','")); } _res = NULL; @@ -21891,9 +21782,9 @@ _tmp_69_rule(Parser *p) return _res; } -// _tmp_70: ',' ','.(error_argument_pattern | error_star)+ +// _tmp_69: ',' ','.(error_argument_pattern | error_star)+ static void * -_tmp_70_rule(Parser *p) +_tmp_69_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21907,21 +21798,21 @@ _tmp_70_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(error_argument_pattern | error_star)+")); - asdl_seq * _gather_174_var; + D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(error_argument_pattern | error_star)+")); + asdl_seq * _gather_173_var; Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_gather_174_var = _gather_174_rule(p)) // ','.(error_argument_pattern | error_star)+ + (_gather_173_var = _gather_173_rule(p)) // ','.(error_argument_pattern | error_star)+ ) { - D(fprintf(stderr, "%*c+ _tmp_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(error_argument_pattern | error_star)+")); - _res = _PyPegen_dummy_name(p, _literal, _gather_174_var); + D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(error_argument_pattern | error_star)+")); + _res = _PyPegen_dummy_name(p, _literal, _gather_173_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_70[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_69[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.(error_argument_pattern | error_star)+")); } _res = NULL; @@ -21930,9 +21821,9 @@ _tmp_70_rule(Parser *p) return _res; } -// _loop0_72: ',' value_pattern +// _loop0_71: ',' value_pattern static asdl_seq * -_loop0_72_rule(Parser *p) +_loop0_71_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21956,7 +21847,7 @@ _loop0_72_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' value_pattern")); + D(fprintf(stderr, "%*c> _loop0_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' value_pattern")); Token * _literal; expr_ty elem; while ( @@ -21987,7 +21878,7 @@ _loop0_72_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_72[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_71[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' value_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22000,14 +21891,14 @@ _loop0_72_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_72_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_71_type, _seq); D(p->level--); return _seq; } -// _gather_71: value_pattern _loop0_72 +// _gather_70: value_pattern _loop0_71 static asdl_seq * -_gather_71_rule(Parser *p) +_gather_70_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22016,27 +21907,27 @@ _gather_71_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // value_pattern _loop0_72 + { // value_pattern _loop0_71 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_72")); + D(fprintf(stderr, "%*c> _gather_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_71")); expr_ty elem; asdl_seq * seq; if ( (elem = value_pattern_rule(p)) // value_pattern && - (seq = _loop0_72_rule(p)) // _loop0_72 + (seq = _loop0_71_rule(p)) // _loop0_71 ) { - D(fprintf(stderr, "%*c+ _gather_71[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_72")); + D(fprintf(stderr, "%*c+ _gather_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_71")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_71[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern _loop0_72")); + D(fprintf(stderr, "%*c%s _gather_70[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern _loop0_71")); } _res = NULL; done: @@ -22044,9 +21935,9 @@ _gather_71_rule(Parser *p) return _res; } -// _loop0_74: ',' key_value_pattern +// _loop0_73: ',' key_value_pattern static asdl_seq * -_loop0_74_rule(Parser *p) +_loop0_73_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22070,7 +21961,7 @@ _loop0_74_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); + D(fprintf(stderr, "%*c> _loop0_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); Token * _literal; KeyValuePair* elem; while ( @@ -22101,7 +21992,7 @@ _loop0_74_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_74[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_73[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' key_value_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22114,14 +22005,14 @@ _loop0_74_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_74_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_73_type, _seq); D(p->level--); return _seq; } -// _gather_73: key_value_pattern _loop0_74 +// _gather_72: key_value_pattern _loop0_73 static asdl_seq * -_gather_73_rule(Parser *p) +_gather_72_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22130,27 +22021,27 @@ _gather_73_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // key_value_pattern _loop0_74 + { // key_value_pattern _loop0_73 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_74")); + D(fprintf(stderr, "%*c> _gather_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_73")); KeyValuePair* elem; asdl_seq * seq; if ( (elem = key_value_pattern_rule(p)) // key_value_pattern && - (seq = _loop0_74_rule(p)) // _loop0_74 + (seq = _loop0_73_rule(p)) // _loop0_73 ) { - D(fprintf(stderr, "%*c+ _gather_73[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_74")); + D(fprintf(stderr, "%*c+ _gather_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_73")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_73[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_74")); + D(fprintf(stderr, "%*c%s _gather_72[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_73")); } _res = NULL; done: @@ -22158,9 +22049,9 @@ _gather_73_rule(Parser *p) return _res; } -// _tmp_75: '*' | '**' +// _tmp_74: '*' | '**' static void * -_tmp_75_rule(Parser *p) +_tmp_74_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22174,18 +22065,18 @@ _tmp_75_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); + D(fprintf(stderr, "%*c> _tmp_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' ) { - D(fprintf(stderr, "%*c+ _tmp_75[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); + D(fprintf(stderr, "%*c+ _tmp_74[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_75[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_74[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); } { // '**' @@ -22193,18 +22084,18 @@ _tmp_75_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_75[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_74[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_75[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_74[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -22213,9 +22104,9 @@ _tmp_75_rule(Parser *p) return _res; } -// _tmp_76: literal_pattern | constant_pattern +// _tmp_75: literal_pattern | constant_pattern static void * -_tmp_76_rule(Parser *p) +_tmp_75_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22229,18 +22120,18 @@ _tmp_76_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); expr_ty literal_pattern_var; if ( (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_76[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + D(fprintf(stderr, "%*c+ _tmp_75[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); _res = literal_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_76[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_75[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern")); } { // constant_pattern @@ -22248,18 +22139,18 @@ _tmp_76_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern")); + D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern")); expr_ty constant_pattern_var; if ( (constant_pattern_var = constant_pattern_rule(p)) // constant_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_76[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "constant_pattern")); + D(fprintf(stderr, "%*c+ _tmp_75[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "constant_pattern")); _res = constant_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_76[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_75[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "constant_pattern")); } _res = NULL; @@ -22268,9 +22159,9 @@ _tmp_76_rule(Parser *p) return _res; } -// _tmp_77: 'from' expression +// _tmp_76: 'from' expression static void * -_tmp_77_rule(Parser *p) +_tmp_76_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22284,7 +22175,7 @@ _tmp_77_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); + D(fprintf(stderr, "%*c> _tmp_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); Token * _keyword; expr_ty z; if ( @@ -22293,7 +22184,7 @@ _tmp_77_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_77[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); + D(fprintf(stderr, "%*c+ _tmp_76[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -22303,7 +22194,7 @@ _tmp_77_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_77[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_76[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression")); } _res = NULL; @@ -22312,9 +22203,9 @@ _tmp_77_rule(Parser *p) return _res; } -// _tmp_78: '->' expression +// _tmp_77: '->' expression static void * -_tmp_78_rule(Parser *p) +_tmp_77_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22328,7 +22219,7 @@ _tmp_78_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -22337,7 +22228,7 @@ _tmp_78_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_78[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_77[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -22347,7 +22238,7 @@ _tmp_78_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_78[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_77[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -22356,9 +22247,9 @@ _tmp_78_rule(Parser *p) return _res; } -// _tmp_79: '->' expression +// _tmp_78: '->' expression static void * -_tmp_79_rule(Parser *p) +_tmp_78_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22372,7 +22263,7 @@ _tmp_79_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -22381,7 +22272,7 @@ _tmp_79_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_79[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_78[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -22391,7 +22282,7 @@ _tmp_79_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_79[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_78[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -22400,9 +22291,9 @@ _tmp_79_rule(Parser *p) return _res; } -// _tmp_80: NEWLINE INDENT +// _tmp_79: NEWLINE INDENT static void * -_tmp_80_rule(Parser *p) +_tmp_79_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22416,7 +22307,7 @@ _tmp_80_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c> _tmp_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); Token * indent_var; Token * newline_var; if ( @@ -22425,12 +22316,12 @@ _tmp_80_rule(Parser *p) (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' ) { - D(fprintf(stderr, "%*c+ _tmp_80[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c+ _tmp_79[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); _res = _PyPegen_dummy_name(p, newline_var, indent_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_80[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_79[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); } _res = NULL; @@ -22439,9 +22330,9 @@ _tmp_80_rule(Parser *p) return _res; } -// _loop0_81: param_no_default +// _loop0_80: param_no_default static asdl_seq * -_loop0_81_rule(Parser *p) +_loop0_80_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22465,7 +22356,7 @@ _loop0_81_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_80[%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 @@ -22487,7 +22378,7 @@ _loop0_81_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_81[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_80[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22500,14 +22391,14 @@ _loop0_81_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_81_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_80_type, _seq); D(p->level--); return _seq; } -// _loop0_82: param_with_default +// _loop0_81: param_with_default static asdl_seq * -_loop0_82_rule(Parser *p) +_loop0_81_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22531,7 +22422,7 @@ _loop0_82_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -22553,7 +22444,7 @@ _loop0_82_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_82[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_81[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22566,14 +22457,14 @@ _loop0_82_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_82_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_81_type, _seq); D(p->level--); return _seq; } -// _loop0_83: param_with_default +// _loop0_82: param_with_default static asdl_seq * -_loop0_83_rule(Parser *p) +_loop0_82_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22597,7 +22488,7 @@ _loop0_83_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -22619,7 +22510,7 @@ _loop0_83_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_83[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_82[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22632,14 +22523,14 @@ _loop0_83_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_83_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_82_type, _seq); D(p->level--); return _seq; } -// _loop1_84: param_no_default +// _loop1_83: param_no_default static asdl_seq * -_loop1_84_rule(Parser *p) +_loop1_83_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22663,7 +22554,7 @@ _loop1_84_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_83[%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 @@ -22685,7 +22576,7 @@ _loop1_84_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -22703,14 +22594,14 @@ _loop1_84_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); D(p->level--); return _seq; } -// _loop0_85: param_with_default +// _loop0_84: param_with_default static asdl_seq * -_loop0_85_rule(Parser *p) +_loop0_84_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22734,7 +22625,7 @@ _loop0_85_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -22756,7 +22647,7 @@ _loop0_85_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_85[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_84[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -22769,14 +22660,14 @@ _loop0_85_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_85_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_84_type, _seq); D(p->level--); return _seq; } -// _loop1_86: param_with_default +// _loop1_85: param_with_default static asdl_seq * -_loop1_86_rule(Parser *p) +_loop1_85_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22800,7 +22691,7 @@ _loop1_86_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -22822,7 +22713,7 @@ _loop1_86_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_85[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -22840,14 +22731,14 @@ _loop1_86_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_86_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_85_type, _seq); D(p->level--); return _seq; } -// _loop1_87: param_no_default +// _loop1_86: param_no_default static asdl_seq * -_loop1_87_rule(Parser *p) +_loop1_86_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22871,7 +22762,7 @@ _loop1_87_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_86[%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 @@ -22893,7 +22784,7 @@ _loop1_87_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -22911,14 +22802,14 @@ _loop1_87_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_87_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_86_type, _seq); D(p->level--); return _seq; } -// _loop1_88: param_no_default +// _loop1_87: param_no_default static asdl_seq * -_loop1_88_rule(Parser *p) +_loop1_87_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22942,7 +22833,7 @@ _loop1_88_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_87[%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 @@ -22964,7 +22855,7 @@ _loop1_88_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_88[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -22982,14 +22873,14 @@ _loop1_88_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_88_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_87_type, _seq); D(p->level--); return _seq; } -// _loop0_89: param_no_default +// _loop0_88: param_no_default static asdl_seq * -_loop0_89_rule(Parser *p) +_loop0_88_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23013,7 +22904,7 @@ _loop0_89_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_88[%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 @@ -23035,7 +22926,7 @@ _loop0_89_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_89[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_88[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23048,14 +22939,14 @@ _loop0_89_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_89_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_88_type, _seq); D(p->level--); return _seq; } -// _loop1_90: param_with_default +// _loop1_89: param_with_default static asdl_seq * -_loop1_90_rule(Parser *p) +_loop1_89_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23079,7 +22970,7 @@ _loop1_90_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -23101,7 +22992,7 @@ _loop1_90_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_90[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -23119,14 +23010,14 @@ _loop1_90_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_90_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq); D(p->level--); return _seq; } -// _loop0_91: param_no_default +// _loop0_90: param_no_default static asdl_seq * -_loop0_91_rule(Parser *p) +_loop0_90_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23150,7 +23041,7 @@ _loop0_91_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_90[%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 @@ -23172,7 +23063,7 @@ _loop0_91_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_91[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_90[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23185,14 +23076,14 @@ _loop0_91_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_91_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_90_type, _seq); D(p->level--); return _seq; } -// _loop1_92: param_with_default +// _loop1_91: param_with_default static asdl_seq * -_loop1_92_rule(Parser *p) +_loop1_91_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23216,7 +23107,7 @@ _loop1_92_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -23238,7 +23129,7 @@ _loop1_92_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_92[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -23256,14 +23147,14 @@ _loop1_92_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_92_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq); D(p->level--); return _seq; } -// _loop0_93: param_maybe_default +// _loop0_92: param_maybe_default static asdl_seq * -_loop0_93_rule(Parser *p) +_loop0_92_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23287,7 +23178,7 @@ _loop0_93_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -23309,7 +23200,7 @@ _loop0_93_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_93[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_92[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23322,14 +23213,14 @@ _loop0_93_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_93_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_92_type, _seq); D(p->level--); return _seq; } -// _loop1_94: param_maybe_default +// _loop1_93: param_maybe_default static asdl_seq * -_loop1_94_rule(Parser *p) +_loop1_93_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23353,7 +23244,7 @@ _loop1_94_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -23375,7 +23266,7 @@ _loop1_94_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_94[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_93[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -23393,14 +23284,14 @@ _loop1_94_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_94_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_93_type, _seq); D(p->level--); return _seq; } -// _loop1_95: ('@' named_expression NEWLINE) +// _loop1_94: ('@' named_expression NEWLINE) static asdl_seq * -_loop1_95_rule(Parser *p) +_loop1_94_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23424,13 +23315,13 @@ _loop1_95_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); - void *_tmp_176_var; + D(fprintf(stderr, "%*c> _loop1_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); + void *_tmp_175_var; while ( - (_tmp_176_var = _tmp_176_rule(p)) // '@' named_expression NEWLINE + (_tmp_175_var = _tmp_175_rule(p)) // '@' named_expression NEWLINE ) { - _res = _tmp_176_var; + _res = _tmp_175_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23446,7 +23337,7 @@ _loop1_95_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_95[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_94[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)")); } if (_n == 0 || p->error_indicator) { @@ -23464,14 +23355,14 @@ _loop1_95_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_95_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_94_type, _seq); D(p->level--); return _seq; } -// _tmp_96: '(' arguments? ')' +// _tmp_95: '(' arguments? ')' static void * -_tmp_96_rule(Parser *p) +_tmp_95_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23485,7 +23376,7 @@ _tmp_96_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); Token * _literal; Token * _literal_1; void *z; @@ -23497,7 +23388,7 @@ _tmp_96_rule(Parser *p) (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -23507,7 +23398,7 @@ _tmp_96_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); } _res = NULL; @@ -23516,9 +23407,9 @@ _tmp_96_rule(Parser *p) return _res; } -// _loop0_98: ',' star_expression +// _loop0_97: ',' star_expression static asdl_seq * -_loop0_98_rule(Parser *p) +_loop0_97_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23542,7 +23433,7 @@ _loop0_98_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _loop0_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty elem; while ( @@ -23573,7 +23464,7 @@ _loop0_98_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_98[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_97[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23586,14 +23477,14 @@ _loop0_98_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_98_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_97_type, _seq); D(p->level--); return _seq; } -// _gather_97: star_expression _loop0_98 +// _gather_96: star_expression _loop0_97 static asdl_seq * -_gather_97_rule(Parser *p) +_gather_96_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23602,27 +23493,27 @@ _gather_97_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_expression _loop0_98 + { // star_expression _loop0_97 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_98")); + D(fprintf(stderr, "%*c> _gather_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_97")); expr_ty elem; asdl_seq * seq; if ( (elem = star_expression_rule(p)) // star_expression && - (seq = _loop0_98_rule(p)) // _loop0_98 + (seq = _loop0_97_rule(p)) // _loop0_97 ) { - D(fprintf(stderr, "%*c+ _gather_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_98")); + D(fprintf(stderr, "%*c+ _gather_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_97")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_97[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_98")); + D(fprintf(stderr, "%*c%s _gather_96[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_97")); } _res = NULL; done: @@ -23630,9 +23521,9 @@ _gather_97_rule(Parser *p) return _res; } -// _loop1_99: (',' star_expression) +// _loop1_98: (',' star_expression) static asdl_seq * -_loop1_99_rule(Parser *p) +_loop1_98_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23656,13 +23547,13 @@ _loop1_99_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); - void *_tmp_177_var; + D(fprintf(stderr, "%*c> _loop1_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); + void *_tmp_176_var; while ( - (_tmp_177_var = _tmp_177_rule(p)) // ',' star_expression + (_tmp_176_var = _tmp_176_rule(p)) // ',' star_expression ) { - _res = _tmp_177_var; + _res = _tmp_176_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23678,7 +23569,7 @@ _loop1_99_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_99[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_98[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); } if (_n == 0 || p->error_indicator) { @@ -23696,14 +23587,14 @@ _loop1_99_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_98_type, _seq); D(p->level--); return _seq; } -// _loop0_101: ',' star_named_expression +// _loop0_100: ',' star_named_expression static asdl_seq * -_loop0_101_rule(Parser *p) +_loop0_100_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23727,7 +23618,7 @@ _loop0_101_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); + D(fprintf(stderr, "%*c> _loop0_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); Token * _literal; expr_ty elem; while ( @@ -23758,7 +23649,7 @@ _loop0_101_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_101[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_100[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23771,14 +23662,14 @@ _loop0_101_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_101_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_100_type, _seq); D(p->level--); return _seq; } -// _gather_100: star_named_expression _loop0_101 +// _gather_99: star_named_expression _loop0_100 static asdl_seq * -_gather_100_rule(Parser *p) +_gather_99_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23787,27 +23678,27 @@ _gather_100_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_named_expression _loop0_101 + { // star_named_expression _loop0_100 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_101")); + D(fprintf(stderr, "%*c> _gather_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_100")); expr_ty elem; asdl_seq * seq; if ( (elem = star_named_expression_rule(p)) // star_named_expression && - (seq = _loop0_101_rule(p)) // _loop0_101 + (seq = _loop0_100_rule(p)) // _loop0_100 ) { - D(fprintf(stderr, "%*c+ _gather_100[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_101")); + D(fprintf(stderr, "%*c+ _gather_99[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_100")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_100[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_101")); + D(fprintf(stderr, "%*c%s _gather_99[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_100")); } _res = NULL; done: @@ -23815,9 +23706,9 @@ _gather_100_rule(Parser *p) return _res; } -// _loop1_102: (',' expression) +// _loop1_101: (',' expression) static asdl_seq * -_loop1_102_rule(Parser *p) +_loop1_101_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23841,13 +23732,13 @@ _loop1_102_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); - void *_tmp_178_var; + D(fprintf(stderr, "%*c> _loop1_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); + void *_tmp_177_var; while ( - (_tmp_178_var = _tmp_178_rule(p)) // ',' expression + (_tmp_177_var = _tmp_177_rule(p)) // ',' expression ) { - _res = _tmp_178_var; + _res = _tmp_177_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23863,7 +23754,7 @@ _loop1_102_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_102[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_101[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); } if (_n == 0 || p->error_indicator) { @@ -23881,14 +23772,14 @@ _loop1_102_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_102_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_101_type, _seq); D(p->level--); return _seq; } -// _loop0_103: lambda_param_no_default +// _loop0_102: lambda_param_no_default static asdl_seq * -_loop0_103_rule(Parser *p) +_loop0_102_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23912,7 +23803,7 @@ _loop0_103_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_102[%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 @@ -23934,7 +23825,7 @@ _loop0_103_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_102[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -23947,14 +23838,14 @@ _loop0_103_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_103_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_102_type, _seq); D(p->level--); return _seq; } -// _loop0_104: lambda_param_with_default +// _loop0_103: lambda_param_with_default static asdl_seq * -_loop0_104_rule(Parser *p) +_loop0_103_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23978,7 +23869,7 @@ _loop0_104_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -24000,7 +23891,7 @@ _loop0_104_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_104[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24013,14 +23904,14 @@ _loop0_104_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_104_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_103_type, _seq); D(p->level--); return _seq; } -// _loop0_105: lambda_param_with_default +// _loop0_104: lambda_param_with_default static asdl_seq * -_loop0_105_rule(Parser *p) +_loop0_104_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24044,7 +23935,7 @@ _loop0_105_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -24066,7 +23957,7 @@ _loop0_105_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_105[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_104[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24079,14 +23970,14 @@ _loop0_105_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_105_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_104_type, _seq); D(p->level--); return _seq; } -// _loop1_106: lambda_param_no_default +// _loop1_105: lambda_param_no_default static asdl_seq * -_loop1_106_rule(Parser *p) +_loop1_105_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24110,7 +24001,7 @@ _loop1_106_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_105[%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 @@ -24132,7 +24023,7 @@ _loop1_106_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -24150,14 +24041,14 @@ _loop1_106_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_106_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq); D(p->level--); return _seq; } -// _loop0_107: lambda_param_with_default +// _loop0_106: lambda_param_with_default static asdl_seq * -_loop0_107_rule(Parser *p) +_loop0_106_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24181,7 +24072,7 @@ _loop0_107_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -24203,7 +24094,7 @@ _loop0_107_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_107[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_106[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24216,14 +24107,14 @@ _loop0_107_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_107_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_106_type, _seq); D(p->level--); return _seq; } -// _loop1_108: lambda_param_with_default +// _loop1_107: lambda_param_with_default static asdl_seq * -_loop1_108_rule(Parser *p) +_loop1_107_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24247,7 +24138,7 @@ _loop1_108_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -24269,7 +24160,7 @@ _loop1_108_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_108[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_107[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -24287,14 +24178,14 @@ _loop1_108_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_108_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_107_type, _seq); D(p->level--); return _seq; } -// _loop1_109: lambda_param_no_default +// _loop1_108: lambda_param_no_default static asdl_seq * -_loop1_109_rule(Parser *p) +_loop1_108_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24318,7 +24209,7 @@ _loop1_109_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_108[%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 @@ -24340,7 +24231,7 @@ _loop1_109_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_109[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_108[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -24358,14 +24249,14 @@ _loop1_109_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_109_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_108_type, _seq); D(p->level--); return _seq; } -// _loop1_110: lambda_param_no_default +// _loop1_109: lambda_param_no_default static asdl_seq * -_loop1_110_rule(Parser *p) +_loop1_109_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24389,7 +24280,7 @@ _loop1_110_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_109[%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 @@ -24411,7 +24302,7 @@ _loop1_110_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_110[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_109[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -24429,14 +24320,14 @@ _loop1_110_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_110_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_109_type, _seq); D(p->level--); return _seq; } -// _loop0_111: lambda_param_no_default +// _loop0_110: lambda_param_no_default static asdl_seq * -_loop0_111_rule(Parser *p) +_loop0_110_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24460,7 +24351,7 @@ _loop0_111_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_110[%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 @@ -24482,7 +24373,7 @@ _loop0_111_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_111[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_110[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24495,14 +24386,14 @@ _loop0_111_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_111_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq); D(p->level--); return _seq; } -// _loop1_112: lambda_param_with_default +// _loop1_111: lambda_param_with_default static asdl_seq * -_loop1_112_rule(Parser *p) +_loop1_111_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24526,7 +24417,7 @@ _loop1_112_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -24548,7 +24439,7 @@ _loop1_112_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_112[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_111[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -24566,14 +24457,14 @@ _loop1_112_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_112_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_111_type, _seq); D(p->level--); return _seq; } -// _loop0_113: lambda_param_no_default +// _loop0_112: lambda_param_no_default static asdl_seq * -_loop0_113_rule(Parser *p) +_loop0_112_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24597,7 +24488,7 @@ _loop0_113_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_112[%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 @@ -24619,7 +24510,7 @@ _loop0_113_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_113[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24632,14 +24523,14 @@ _loop0_113_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_113_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq); D(p->level--); return _seq; } -// _loop1_114: lambda_param_with_default +// _loop1_113: lambda_param_with_default static asdl_seq * -_loop1_114_rule(Parser *p) +_loop1_113_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24663,7 +24554,7 @@ _loop1_114_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -24685,7 +24576,7 @@ _loop1_114_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_114[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_113[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -24703,14 +24594,14 @@ _loop1_114_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_114_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_113_type, _seq); D(p->level--); return _seq; } -// _loop0_115: lambda_param_maybe_default +// _loop0_114: lambda_param_maybe_default static asdl_seq * -_loop0_115_rule(Parser *p) +_loop0_114_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24734,7 +24625,7 @@ _loop0_115_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -24756,7 +24647,7 @@ _loop0_115_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_115[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_114[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -24769,14 +24660,14 @@ _loop0_115_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_115_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_114_type, _seq); D(p->level--); return _seq; } -// _loop1_116: lambda_param_maybe_default +// _loop1_115: lambda_param_maybe_default static asdl_seq * -_loop1_116_rule(Parser *p) +_loop1_115_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24800,7 +24691,7 @@ _loop1_116_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -24822,7 +24713,7 @@ _loop1_116_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_116[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -24840,14 +24731,14 @@ _loop1_116_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_116_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_115_type, _seq); D(p->level--); return _seq; } -// _loop1_117: ('or' conjunction) +// _loop1_116: ('or' conjunction) static asdl_seq * -_loop1_117_rule(Parser *p) +_loop1_116_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24871,13 +24762,13 @@ _loop1_117_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); - void *_tmp_179_var; + D(fprintf(stderr, "%*c> _loop1_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); + void *_tmp_178_var; while ( - (_tmp_179_var = _tmp_179_rule(p)) // 'or' conjunction + (_tmp_178_var = _tmp_178_rule(p)) // 'or' conjunction ) { - _res = _tmp_179_var; + _res = _tmp_178_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24893,7 +24784,7 @@ _loop1_117_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_117[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_116[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); } if (_n == 0 || p->error_indicator) { @@ -24911,14 +24802,14 @@ _loop1_117_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_117_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_116_type, _seq); D(p->level--); return _seq; } -// _loop1_118: ('and' inversion) +// _loop1_117: ('and' inversion) static asdl_seq * -_loop1_118_rule(Parser *p) +_loop1_117_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24942,13 +24833,13 @@ _loop1_118_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); - void *_tmp_180_var; + D(fprintf(stderr, "%*c> _loop1_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); + void *_tmp_179_var; while ( - (_tmp_180_var = _tmp_180_rule(p)) // 'and' inversion + (_tmp_179_var = _tmp_179_rule(p)) // 'and' inversion ) { - _res = _tmp_180_var; + _res = _tmp_179_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24964,7 +24855,7 @@ _loop1_118_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_118[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_117[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); } if (_n == 0 || p->error_indicator) { @@ -24982,14 +24873,14 @@ _loop1_118_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_118_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_117_type, _seq); D(p->level--); return _seq; } -// _loop1_119: compare_op_bitwise_or_pair +// _loop1_118: compare_op_bitwise_or_pair static asdl_seq * -_loop1_119_rule(Parser *p) +_loop1_118_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25013,7 +24904,7 @@ _loop1_119_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); + D(fprintf(stderr, "%*c> _loop1_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); CmpopExprPair* compare_op_bitwise_or_pair_var; while ( (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair @@ -25035,7 +24926,7 @@ _loop1_119_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_119[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_118[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); } if (_n == 0 || p->error_indicator) { @@ -25053,14 +24944,14 @@ _loop1_119_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_119_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_118_type, _seq); D(p->level--); return _seq; } -// _tmp_120: '!=' +// _tmp_119: '!=' static void * -_tmp_120_rule(Parser *p) +_tmp_119_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25074,13 +24965,13 @@ _tmp_120_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); Token * tok; if ( (tok = _PyPegen_expect_token(p, 28)) // token='!=' ) { - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25090,7 +24981,7 @@ _tmp_120_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); } _res = NULL; @@ -25099,9 +24990,9 @@ _tmp_120_rule(Parser *p) return _res; } -// _loop0_122: ',' slice +// _loop0_121: ',' slice static asdl_seq * -_loop0_122_rule(Parser *p) +_loop0_121_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25125,7 +25016,7 @@ _loop0_122_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); + D(fprintf(stderr, "%*c> _loop0_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); Token * _literal; expr_ty elem; while ( @@ -25156,7 +25047,7 @@ _loop0_122_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_122[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_121[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' slice")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25169,14 +25060,14 @@ _loop0_122_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_122_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_121_type, _seq); D(p->level--); return _seq; } -// _gather_121: slice _loop0_122 +// _gather_120: slice _loop0_121 static asdl_seq * -_gather_121_rule(Parser *p) +_gather_120_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25185,27 +25076,27 @@ _gather_121_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // slice _loop0_122 + { // slice _loop0_121 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_122")); + D(fprintf(stderr, "%*c> _gather_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_121")); expr_ty elem; asdl_seq * seq; if ( (elem = slice_rule(p)) // slice && - (seq = _loop0_122_rule(p)) // _loop0_122 + (seq = _loop0_121_rule(p)) // _loop0_121 ) { - D(fprintf(stderr, "%*c+ _gather_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_122")); + D(fprintf(stderr, "%*c+ _gather_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_121")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_121[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_122")); + D(fprintf(stderr, "%*c%s _gather_120[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_121")); } _res = NULL; done: @@ -25213,9 +25104,9 @@ _gather_121_rule(Parser *p) return _res; } -// _tmp_123: ':' expression? +// _tmp_122: ':' expression? static void * -_tmp_123_rule(Parser *p) +_tmp_122_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25229,7 +25120,7 @@ _tmp_123_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); Token * _literal; void *d; if ( @@ -25238,7 +25129,7 @@ _tmp_123_rule(Parser *p) (d = expression_rule(p), 1) // expression? ) { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); _res = d; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25248,7 +25139,7 @@ _tmp_123_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); } _res = NULL; @@ -25257,9 +25148,9 @@ _tmp_123_rule(Parser *p) return _res; } -// _tmp_124: tuple | group | genexp +// _tmp_123: tuple | group | genexp static void * -_tmp_124_rule(Parser *p) +_tmp_123_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25273,18 +25164,18 @@ _tmp_124_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); expr_ty tuple_var; if ( (tuple_var = tuple_rule(p)) // tuple ) { - D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); _res = tuple_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); } { // group @@ -25292,18 +25183,18 @@ _tmp_124_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); expr_ty group_var; if ( (group_var = group_rule(p)) // group ) { - D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); _res = group_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group")); } { // genexp @@ -25311,18 +25202,18 @@ _tmp_124_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); expr_ty genexp_var; if ( (genexp_var = genexp_rule(p)) // genexp ) { - D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); _res = genexp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); } _res = NULL; @@ -25331,9 +25222,9 @@ _tmp_124_rule(Parser *p) return _res; } -// _tmp_125: list | listcomp +// _tmp_124: list | listcomp static void * -_tmp_125_rule(Parser *p) +_tmp_124_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25347,18 +25238,18 @@ _tmp_125_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); expr_ty list_var; if ( (list_var = list_rule(p)) // list ) { - D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); _res = list_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); } { // listcomp @@ -25366,18 +25257,18 @@ _tmp_125_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); expr_ty listcomp_var; if ( (listcomp_var = listcomp_rule(p)) // listcomp ) { - D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); _res = listcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp")); } _res = NULL; @@ -25386,9 +25277,9 @@ _tmp_125_rule(Parser *p) return _res; } -// _tmp_126: dict | set | dictcomp | setcomp +// _tmp_125: dict | set | dictcomp | setcomp static void * -_tmp_126_rule(Parser *p) +_tmp_125_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25402,18 +25293,18 @@ _tmp_126_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); expr_ty dict_var; if ( (dict_var = dict_rule(p)) // dict ) { - D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); _res = dict_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict")); } { // set @@ -25421,18 +25312,18 @@ _tmp_126_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); expr_ty set_var; if ( (set_var = set_rule(p)) // set ) { - D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); _res = set_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set")); } { // dictcomp @@ -25440,18 +25331,18 @@ _tmp_126_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); expr_ty dictcomp_var; if ( (dictcomp_var = dictcomp_rule(p)) // dictcomp ) { - D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); _res = dictcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp")); } { // setcomp @@ -25459,18 +25350,18 @@ _tmp_126_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); expr_ty setcomp_var; if ( (setcomp_var = setcomp_rule(p)) // setcomp ) { - D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); _res = setcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_126[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp")); } _res = NULL; @@ -25479,9 +25370,9 @@ _tmp_126_rule(Parser *p) return _res; } -// _loop1_127: STRING +// _loop1_126: STRING static asdl_seq * -_loop1_127_rule(Parser *p) +_loop1_126_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25505,7 +25396,7 @@ _loop1_127_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); + D(fprintf(stderr, "%*c> _loop1_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); expr_ty string_var; while ( (string_var = _PyPegen_string_token(p)) // STRING @@ -25527,7 +25418,7 @@ _loop1_127_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_127[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_126[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); } if (_n == 0 || p->error_indicator) { @@ -25545,14 +25436,14 @@ _loop1_127_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_127_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_126_type, _seq); D(p->level--); return _seq; } -// _tmp_128: star_named_expression ',' star_named_expressions? +// _tmp_127: star_named_expression ',' star_named_expressions? static void * -_tmp_128_rule(Parser *p) +_tmp_127_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25566,7 +25457,7 @@ _tmp_128_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c> _tmp_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); Token * _literal; expr_ty y; void *z; @@ -25578,7 +25469,7 @@ _tmp_128_rule(Parser *p) (z = star_named_expressions_rule(p), 1) // star_named_expressions? ) { - D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c+ _tmp_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); _res = _PyPegen_seq_insert_in_front ( p , y , z ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25588,7 +25479,7 @@ _tmp_128_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_127[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); } _res = NULL; @@ -25597,9 +25488,9 @@ _tmp_128_rule(Parser *p) return _res; } -// _tmp_129: yield_expr | named_expression +// _tmp_128: yield_expr | named_expression static void * -_tmp_129_rule(Parser *p) +_tmp_128_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25613,18 +25504,18 @@ _tmp_129_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_129[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // named_expression @@ -25632,18 +25523,18 @@ _tmp_129_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); expr_ty named_expression_var; if ( (named_expression_var = named_expression_rule(p)) // named_expression ) { - D(fprintf(stderr, "%*c+ _tmp_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); _res = named_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_129[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); } _res = NULL; @@ -25652,9 +25543,9 @@ _tmp_129_rule(Parser *p) return _res; } -// _loop0_131: ',' double_starred_kvpair +// _loop0_130: ',' double_starred_kvpair static asdl_seq * -_loop0_131_rule(Parser *p) +_loop0_130_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25678,7 +25569,7 @@ _loop0_131_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); + D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); Token * _literal; KeyValuePair* elem; while ( @@ -25709,7 +25600,7 @@ _loop0_131_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_131[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25722,14 +25613,14 @@ _loop0_131_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_131_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq); D(p->level--); return _seq; } -// _gather_130: double_starred_kvpair _loop0_131 +// _gather_129: double_starred_kvpair _loop0_130 static asdl_seq * -_gather_130_rule(Parser *p) +_gather_129_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25738,27 +25629,27 @@ _gather_130_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // double_starred_kvpair _loop0_131 + { // double_starred_kvpair _loop0_130 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_131")); + D(fprintf(stderr, "%*c> _gather_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_130")); KeyValuePair* elem; asdl_seq * seq; if ( (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair && - (seq = _loop0_131_rule(p)) // _loop0_131 + (seq = _loop0_130_rule(p)) // _loop0_130 ) { - D(fprintf(stderr, "%*c+ _gather_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_131")); + D(fprintf(stderr, "%*c+ _gather_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_130")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_130[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_131")); + D(fprintf(stderr, "%*c%s _gather_129[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_130")); } _res = NULL; done: @@ -25766,9 +25657,9 @@ _gather_130_rule(Parser *p) return _res; } -// _loop1_132: for_if_clause +// _loop1_131: for_if_clause static asdl_seq * -_loop1_132_rule(Parser *p) +_loop1_131_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25792,7 +25683,7 @@ _loop1_132_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); + D(fprintf(stderr, "%*c> _loop1_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); comprehension_ty for_if_clause_var; while ( (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause @@ -25814,7 +25705,7 @@ _loop1_132_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_132[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_131[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); } if (_n == 0 || p->error_indicator) { @@ -25832,14 +25723,14 @@ _loop1_132_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_132_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_131_type, _seq); D(p->level--); return _seq; } -// _loop0_133: ('if' disjunction) +// _loop0_132: ('if' disjunction) static asdl_seq * -_loop0_133_rule(Parser *p) +_loop0_132_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25863,13 +25754,13 @@ _loop0_133_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_181_var; + D(fprintf(stderr, "%*c> _loop0_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_180_var; while ( - (_tmp_181_var = _tmp_181_rule(p)) // 'if' disjunction + (_tmp_180_var = _tmp_180_rule(p)) // 'if' disjunction ) { - _res = _tmp_181_var; + _res = _tmp_180_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -25885,7 +25776,7 @@ _loop0_133_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_133[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_132[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25898,14 +25789,14 @@ _loop0_133_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_133_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_132_type, _seq); D(p->level--); return _seq; } -// _loop0_134: ('if' disjunction) +// _loop0_133: ('if' disjunction) static asdl_seq * -_loop0_134_rule(Parser *p) +_loop0_133_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25929,13 +25820,13 @@ _loop0_134_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_182_var; + D(fprintf(stderr, "%*c> _loop0_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_181_var; while ( - (_tmp_182_var = _tmp_182_rule(p)) // 'if' disjunction + (_tmp_181_var = _tmp_181_rule(p)) // 'if' disjunction ) { - _res = _tmp_182_var; + _res = _tmp_181_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -25951,7 +25842,7 @@ _loop0_134_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_134[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_133[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -25964,14 +25855,14 @@ _loop0_134_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_134_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_133_type, _seq); D(p->level--); return _seq; } -// _tmp_135: ',' args +// _tmp_134: ',' args static void * -_tmp_135_rule(Parser *p) +_tmp_134_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25985,7 +25876,7 @@ _tmp_135_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c> _tmp_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); Token * _literal; expr_ty c; if ( @@ -25994,7 +25885,7 @@ _tmp_135_rule(Parser *p) (c = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c+ _tmp_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26004,7 +25895,7 @@ _tmp_135_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_135[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_134[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); } _res = NULL; @@ -26013,9 +25904,9 @@ _tmp_135_rule(Parser *p) return _res; } -// _tmp_136: ',' args +// _tmp_135: ',' args static void * -_tmp_136_rule(Parser *p) +_tmp_135_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26029,7 +25920,7 @@ _tmp_136_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c> _tmp_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); Token * _literal; expr_ty c; if ( @@ -26038,7 +25929,7 @@ _tmp_136_rule(Parser *p) (c = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); + D(fprintf(stderr, "%*c+ _tmp_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -26048,7 +25939,7 @@ _tmp_136_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_135[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); } _res = NULL; @@ -26057,9 +25948,9 @@ _tmp_136_rule(Parser *p) return _res; } -// _loop0_138: ',' kwarg_or_starred +// _loop0_137: ',' kwarg_or_starred static asdl_seq * -_loop0_138_rule(Parser *p) +_loop0_137_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26083,7 +25974,7 @@ _loop0_138_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -26114,7 +26005,7 @@ _loop0_138_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_138[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_137[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26127,14 +26018,14 @@ _loop0_138_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_138_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_137_type, _seq); D(p->level--); return _seq; } -// _gather_137: kwarg_or_starred _loop0_138 +// _gather_136: kwarg_or_starred _loop0_137 static asdl_seq * -_gather_137_rule(Parser *p) +_gather_136_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26143,27 +26034,27 @@ _gather_137_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_138 + { // kwarg_or_starred _loop0_137 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_138")); + D(fprintf(stderr, "%*c> _gather_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_137")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_138_rule(p)) // _loop0_138 + (seq = _loop0_137_rule(p)) // _loop0_137 ) { - D(fprintf(stderr, "%*c+ _gather_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_138")); + D(fprintf(stderr, "%*c+ _gather_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_137")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_137[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_138")); + D(fprintf(stderr, "%*c%s _gather_136[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_137")); } _res = NULL; done: @@ -26171,9 +26062,9 @@ _gather_137_rule(Parser *p) return _res; } -// _loop0_140: ',' kwarg_or_double_starred +// _loop0_139: ',' kwarg_or_double_starred static asdl_seq * -_loop0_140_rule(Parser *p) +_loop0_139_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26197,7 +26088,7 @@ _loop0_140_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -26228,7 +26119,7 @@ _loop0_140_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_140[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_139[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26241,14 +26132,14 @@ _loop0_140_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_140_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_139_type, _seq); D(p->level--); return _seq; } -// _gather_139: kwarg_or_double_starred _loop0_140 +// _gather_138: kwarg_or_double_starred _loop0_139 static asdl_seq * -_gather_139_rule(Parser *p) +_gather_138_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26257,27 +26148,27 @@ _gather_139_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_140 + { // kwarg_or_double_starred _loop0_139 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_140")); + D(fprintf(stderr, "%*c> _gather_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_139")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_140_rule(p)) // _loop0_140 + (seq = _loop0_139_rule(p)) // _loop0_139 ) { - D(fprintf(stderr, "%*c+ _gather_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_140")); + D(fprintf(stderr, "%*c+ _gather_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_139")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_139[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_140")); + D(fprintf(stderr, "%*c%s _gather_138[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_139")); } _res = NULL; done: @@ -26285,9 +26176,9 @@ _gather_139_rule(Parser *p) return _res; } -// _loop0_142: ',' kwarg_or_starred +// _loop0_141: ',' kwarg_or_starred static asdl_seq * -_loop0_142_rule(Parser *p) +_loop0_141_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26311,7 +26202,7 @@ _loop0_142_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -26342,7 +26233,7 @@ _loop0_142_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_142[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_141[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26355,14 +26246,14 @@ _loop0_142_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_142_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_141_type, _seq); D(p->level--); return _seq; } -// _gather_141: kwarg_or_starred _loop0_142 +// _gather_140: kwarg_or_starred _loop0_141 static asdl_seq * -_gather_141_rule(Parser *p) +_gather_140_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26371,27 +26262,27 @@ _gather_141_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_142 + { // kwarg_or_starred _loop0_141 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_142")); + D(fprintf(stderr, "%*c> _gather_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_141")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_142_rule(p)) // _loop0_142 + (seq = _loop0_141_rule(p)) // _loop0_141 ) { - D(fprintf(stderr, "%*c+ _gather_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_142")); + D(fprintf(stderr, "%*c+ _gather_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_141")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_141[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_142")); + D(fprintf(stderr, "%*c%s _gather_140[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_141")); } _res = NULL; done: @@ -26399,9 +26290,9 @@ _gather_141_rule(Parser *p) return _res; } -// _loop0_144: ',' kwarg_or_double_starred +// _loop0_143: ',' kwarg_or_double_starred static asdl_seq * -_loop0_144_rule(Parser *p) +_loop0_143_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26425,7 +26316,7 @@ _loop0_144_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -26456,7 +26347,7 @@ _loop0_144_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_144[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_143[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26469,14 +26360,14 @@ _loop0_144_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_144_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_143_type, _seq); D(p->level--); return _seq; } -// _gather_143: kwarg_or_double_starred _loop0_144 +// _gather_142: kwarg_or_double_starred _loop0_143 static asdl_seq * -_gather_143_rule(Parser *p) +_gather_142_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26485,27 +26376,27 @@ _gather_143_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_144 + { // kwarg_or_double_starred _loop0_143 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_144")); + D(fprintf(stderr, "%*c> _gather_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_143")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_144_rule(p)) // _loop0_144 + (seq = _loop0_143_rule(p)) // _loop0_143 ) { - D(fprintf(stderr, "%*c+ _gather_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_144")); + D(fprintf(stderr, "%*c+ _gather_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_143")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_143[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_144")); + D(fprintf(stderr, "%*c%s _gather_142[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_143")); } _res = NULL; done: @@ -26513,9 +26404,9 @@ _gather_143_rule(Parser *p) return _res; } -// _loop0_145: (',' star_target) +// _loop0_144: (',' star_target) static asdl_seq * -_loop0_145_rule(Parser *p) +_loop0_144_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26539,13 +26430,13 @@ _loop0_145_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_183_var; + D(fprintf(stderr, "%*c> _loop0_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_182_var; while ( - (_tmp_183_var = _tmp_183_rule(p)) // ',' star_target + (_tmp_182_var = _tmp_182_rule(p)) // ',' star_target ) { - _res = _tmp_183_var; + _res = _tmp_182_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -26561,7 +26452,7 @@ _loop0_145_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_145[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_144[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26574,14 +26465,14 @@ _loop0_145_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_145_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_144_type, _seq); D(p->level--); return _seq; } -// _loop0_147: ',' star_target +// _loop0_146: ',' star_target static asdl_seq * -_loop0_147_rule(Parser *p) +_loop0_146_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26605,7 +26496,7 @@ _loop0_147_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _loop0_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty elem; while ( @@ -26636,7 +26527,7 @@ _loop0_147_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_147[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_146[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26649,14 +26540,14 @@ _loop0_147_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_147_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_146_type, _seq); D(p->level--); return _seq; } -// _gather_146: star_target _loop0_147 +// _gather_145: star_target _loop0_146 static asdl_seq * -_gather_146_rule(Parser *p) +_gather_145_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26665,27 +26556,27 @@ _gather_146_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_target _loop0_147 + { // star_target _loop0_146 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_147")); + D(fprintf(stderr, "%*c> _gather_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_146")); expr_ty elem; asdl_seq * seq; if ( (elem = star_target_rule(p)) // star_target && - (seq = _loop0_147_rule(p)) // _loop0_147 + (seq = _loop0_146_rule(p)) // _loop0_146 ) { - D(fprintf(stderr, "%*c+ _gather_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_147")); + D(fprintf(stderr, "%*c+ _gather_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_146")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_146[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_147")); + D(fprintf(stderr, "%*c%s _gather_145[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_146")); } _res = NULL; done: @@ -26693,9 +26584,9 @@ _gather_146_rule(Parser *p) return _res; } -// _tmp_148: !'*' star_target +// _tmp_147: !'*' star_target static void * -_tmp_148_rule(Parser *p) +_tmp_147_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26709,7 +26600,7 @@ _tmp_148_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); expr_ty star_target_var; if ( _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' @@ -26717,12 +26608,12 @@ _tmp_148_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); _res = star_target_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); } _res = NULL; @@ -26731,9 +26622,9 @@ _tmp_148_rule(Parser *p) return _res; } -// _loop0_150: ',' del_target +// _loop0_149: ',' del_target static asdl_seq * -_loop0_150_rule(Parser *p) +_loop0_149_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26757,7 +26648,7 @@ _loop0_150_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); + D(fprintf(stderr, "%*c> _loop0_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); Token * _literal; expr_ty elem; while ( @@ -26788,7 +26679,7 @@ _loop0_150_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_150[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_149[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26801,14 +26692,14 @@ _loop0_150_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_150_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_149_type, _seq); D(p->level--); return _seq; } -// _gather_149: del_target _loop0_150 +// _gather_148: del_target _loop0_149 static asdl_seq * -_gather_149_rule(Parser *p) +_gather_148_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26817,27 +26708,27 @@ _gather_149_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // del_target _loop0_150 + { // del_target _loop0_149 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_150")); + D(fprintf(stderr, "%*c> _gather_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_149")); expr_ty elem; asdl_seq * seq; if ( (elem = del_target_rule(p)) // del_target && - (seq = _loop0_150_rule(p)) // _loop0_150 + (seq = _loop0_149_rule(p)) // _loop0_149 ) { - D(fprintf(stderr, "%*c+ _gather_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_150")); + D(fprintf(stderr, "%*c+ _gather_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_149")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_149[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_150")); + D(fprintf(stderr, "%*c%s _gather_148[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_149")); } _res = NULL; done: @@ -26845,9 +26736,9 @@ _gather_149_rule(Parser *p) return _res; } -// _loop0_152: ',' target +// _loop0_151: ',' target static asdl_seq * -_loop0_152_rule(Parser *p) +_loop0_151_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26871,7 +26762,7 @@ _loop0_152_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); + D(fprintf(stderr, "%*c> _loop0_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); Token * _literal; expr_ty elem; while ( @@ -26902,7 +26793,7 @@ _loop0_152_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_152[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_151[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' target")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -26915,14 +26806,14 @@ _loop0_152_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_152_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_151_type, _seq); D(p->level--); return _seq; } -// _gather_151: target _loop0_152 +// _gather_150: target _loop0_151 static asdl_seq * -_gather_151_rule(Parser *p) +_gather_150_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26931,27 +26822,27 @@ _gather_151_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // target _loop0_152 + { // target _loop0_151 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_152")); + D(fprintf(stderr, "%*c> _gather_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_151")); expr_ty elem; asdl_seq * seq; if ( (elem = target_rule(p)) // target && - (seq = _loop0_152_rule(p)) // _loop0_152 + (seq = _loop0_151_rule(p)) // _loop0_151 ) { - D(fprintf(stderr, "%*c+ _gather_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_152")); + D(fprintf(stderr, "%*c+ _gather_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_151")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_151[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_152")); + D(fprintf(stderr, "%*c%s _gather_150[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_151")); } _res = NULL; done: @@ -26959,9 +26850,9 @@ _gather_151_rule(Parser *p) return _res; } -// _tmp_153: args | expression for_if_clauses +// _tmp_152: args | expression for_if_clauses static void * -_tmp_153_rule(Parser *p) +_tmp_152_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26975,18 +26866,18 @@ _tmp_153_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); expr_ty args_var; if ( (args_var = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); _res = args_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); } { // expression for_if_clauses @@ -26994,7 +26885,7 @@ _tmp_153_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); expr_ty expression_var; asdl_seq* for_if_clauses_var; if ( @@ -27003,12 +26894,12 @@ _tmp_153_rule(Parser *p) (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); } _res = NULL; @@ -27017,9 +26908,9 @@ _tmp_153_rule(Parser *p) return _res; } -// _loop0_154: star_named_expressions +// _loop0_153: star_named_expressions static asdl_seq * -_loop0_154_rule(Parser *p) +_loop0_153_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27043,7 +26934,7 @@ _loop0_154_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); + D(fprintf(stderr, "%*c> _loop0_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); asdl_seq* star_named_expressions_var; while ( (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions @@ -27065,7 +26956,7 @@ _loop0_154_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_154[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -27078,14 +26969,14 @@ _loop0_154_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_154_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_153_type, _seq); D(p->level--); return _seq; } -// _loop0_155: (star_targets '=') +// _loop0_154: (star_targets '=') static asdl_seq * -_loop0_155_rule(Parser *p) +_loop0_154_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27109,13 +27000,13 @@ _loop0_155_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_184_var; + D(fprintf(stderr, "%*c> _loop0_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); + void *_tmp_183_var; while ( - (_tmp_184_var = _tmp_184_rule(p)) // star_targets '=' + (_tmp_183_var = _tmp_183_rule(p)) // star_targets '=' ) { - _res = _tmp_184_var; + _res = _tmp_183_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -27131,7 +27022,7 @@ _loop0_155_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_155[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -27144,14 +27035,14 @@ _loop0_155_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_155_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_154_type, _seq); D(p->level--); return _seq; } -// _loop0_156: (star_targets '=') +// _loop0_155: (star_targets '=') static asdl_seq * -_loop0_156_rule(Parser *p) +_loop0_155_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27175,13 +27066,13 @@ _loop0_156_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_185_var; + D(fprintf(stderr, "%*c> _loop0_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); + void *_tmp_184_var; while ( - (_tmp_185_var = _tmp_185_rule(p)) // star_targets '=' + (_tmp_184_var = _tmp_184_rule(p)) // star_targets '=' ) { - _res = _tmp_185_var; + _res = _tmp_184_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -27197,7 +27088,7 @@ _loop0_156_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_156[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -27210,14 +27101,14 @@ _loop0_156_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_156_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_155_type, _seq); D(p->level--); return _seq; } -// _tmp_157: yield_expr | star_expressions +// _tmp_156: yield_expr | star_expressions static void * -_tmp_157_rule(Parser *p) +_tmp_156_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27231,18 +27122,18 @@ _tmp_157_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -27250,18 +27141,18 @@ _tmp_157_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -27270,9 +27161,9 @@ _tmp_157_rule(Parser *p) return _res; } -// _tmp_158: '[' | '(' | '{' +// _tmp_157: '[' | '(' | '{' static void * -_tmp_158_rule(Parser *p) +_tmp_157_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27286,18 +27177,18 @@ _tmp_158_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); } { // '(' @@ -27305,18 +27196,18 @@ _tmp_158_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } { // '{' @@ -27324,18 +27215,18 @@ _tmp_158_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); } _res = NULL; @@ -27344,9 +27235,9 @@ _tmp_158_rule(Parser *p) return _res; } -// _loop0_159: param_no_default +// _loop0_158: param_no_default static asdl_seq * -_loop0_159_rule(Parser *p) +_loop0_158_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27370,7 +27261,7 @@ _loop0_159_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_158[%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 @@ -27392,7 +27283,7 @@ _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, ' ', + D(fprintf(stderr, "%*c%s _loop0_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -27405,14 +27296,14 @@ _loop0_159_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_159_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_158_type, _seq); D(p->level--); return _seq; } -// _tmp_160: slash_with_default | param_with_default+ +// _tmp_159: slash_with_default | param_with_default+ static void * -_tmp_160_rule(Parser *p) +_tmp_159_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27426,18 +27317,18 @@ _tmp_160_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + 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_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "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_160[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); } { // param_with_default+ @@ -27445,18 +27336,18 @@ _tmp_160_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - asdl_seq * _loop1_186_var; + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + asdl_seq * _loop1_185_var; if ( - (_loop1_186_var = _loop1_186_rule(p)) // param_with_default+ + (_loop1_185_var = _loop1_185_rule(p)) // param_with_default+ ) { - D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - _res = _loop1_186_var; + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + _res = _loop1_185_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+")); } _res = NULL; @@ -27465,9 +27356,9 @@ _tmp_160_rule(Parser *p) return _res; } -// _loop0_161: lambda_param_no_default +// _loop0_160: lambda_param_no_default static asdl_seq * -_loop0_161_rule(Parser *p) +_loop0_160_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27491,7 +27382,7 @@ _loop0_161_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_160[%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 @@ -27513,7 +27404,7 @@ _loop0_161_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_161[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -27526,14 +27417,14 @@ _loop0_161_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_161_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_160_type, _seq); D(p->level--); return _seq; } -// _tmp_162: lambda_slash_with_default | lambda_param_with_default+ +// _tmp_161: lambda_slash_with_default | lambda_param_with_default+ static void * -_tmp_162_rule(Parser *p) +_tmp_161_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27547,18 +27438,18 @@ _tmp_162_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); + D(fprintf(stderr, "%*c> _tmp_161[%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_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); + D(fprintf(stderr, "%*c+ _tmp_161[%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_162[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default")); } { // lambda_param_with_default+ @@ -27566,18 +27457,18 @@ _tmp_162_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); - asdl_seq * _loop1_187_var; + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); + asdl_seq * _loop1_186_var; if ( - (_loop1_187_var = _loop1_187_rule(p)) // lambda_param_with_default+ + (_loop1_186_var = _loop1_186_rule(p)) // lambda_param_with_default+ ) { - D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); - _res = _loop1_187_var; + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); + _res = _loop1_186_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+")); } _res = NULL; @@ -27586,9 +27477,9 @@ _tmp_162_rule(Parser *p) return _res; } -// _tmp_163: ')' | ',' (')' | '**') +// _tmp_162: ')' | ',' (')' | '**') static void * -_tmp_163_rule(Parser *p) +_tmp_162_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27602,18 +27493,18 @@ _tmp_163_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // ',' (')' | '**') @@ -27621,21 +27512,21 @@ _tmp_163_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); Token * _literal; - void *_tmp_188_var; + void *_tmp_187_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_188_var = _tmp_188_rule(p)) // ')' | '**' + (_tmp_187_var = _tmp_187_rule(p)) // ')' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_188_var); + D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_187_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); } _res = NULL; @@ -27644,9 +27535,9 @@ _tmp_163_rule(Parser *p) return _res; } -// _tmp_164: ':' | ',' (':' | '**') +// _tmp_163: ':' | ',' (':' | '**') static void * -_tmp_164_rule(Parser *p) +_tmp_163_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27660,18 +27551,18 @@ _tmp_164_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // ',' (':' | '**') @@ -27679,21 +27570,21 @@ _tmp_164_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); Token * _literal; - void *_tmp_189_var; + void *_tmp_188_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_189_var = _tmp_189_rule(p)) // ':' | '**' + (_tmp_188_var = _tmp_188_rule(p)) // ':' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_189_var); + D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_188_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); } _res = NULL; @@ -27702,9 +27593,9 @@ _tmp_164_rule(Parser *p) return _res; } -// _tmp_165: star_targets '=' +// _tmp_164: star_targets '=' static void * -_tmp_165_rule(Parser *p) +_tmp_164_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27718,7 +27609,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_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty z; if ( @@ -27727,7 +27618,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_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -27737,7 +27628,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_164[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -27746,9 +27637,9 @@ _tmp_165_rule(Parser *p) return _res; } -// _tmp_166: '.' | '...' +// _tmp_165: '.' | '...' static void * -_tmp_166_rule(Parser *p) +_tmp_165_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27762,18 +27653,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_165[%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_165[%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_165[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -27781,18 +27672,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_165[%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_165[%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_165[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -27801,9 +27692,9 @@ _tmp_166_rule(Parser *p) return _res; } -// _tmp_167: '.' | '...' +// _tmp_166: '.' | '...' static void * -_tmp_167_rule(Parser *p) +_tmp_166_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27817,18 +27708,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_166[%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_166[%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_166[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -27836,18 +27727,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_166[%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_166[%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_166[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -27856,9 +27747,9 @@ _tmp_167_rule(Parser *p) return _res; } -// _loop0_169: ',' pattern +// _loop0_168: ',' pattern static asdl_seq * -_loop0_169_rule(Parser *p) +_loop0_168_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27882,7 +27773,7 @@ _loop0_169_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _loop0_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; expr_ty elem; while ( @@ -27913,7 +27804,7 @@ _loop0_169_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_169[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_168[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -27926,14 +27817,14 @@ _loop0_169_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_169_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_168_type, _seq); D(p->level--); return _seq; } -// _gather_168: pattern _loop0_169 +// _gather_167: pattern _loop0_168 static asdl_seq * -_gather_168_rule(Parser *p) +_gather_167_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27942,27 +27833,27 @@ _gather_168_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // pattern _loop0_169 + { // pattern _loop0_168 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_169")); + D(fprintf(stderr, "%*c> _gather_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_168")); expr_ty elem; asdl_seq * seq; if ( (elem = pattern_rule(p)) // pattern && - (seq = _loop0_169_rule(p)) // _loop0_169 + (seq = _loop0_168_rule(p)) // _loop0_168 ) { - D(fprintf(stderr, "%*c+ _gather_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_169")); + D(fprintf(stderr, "%*c+ _gather_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_168")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_168[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_169")); + D(fprintf(stderr, "%*c%s _gather_167[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_168")); } _res = NULL; done: @@ -27970,9 +27861,9 @@ _gather_168_rule(Parser *p) return _res; } -// _loop0_171: ',' error_argument_pattern +// _loop0_170: ',' error_argument_pattern static asdl_seq * -_loop0_171_rule(Parser *p) +_loop0_170_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27996,7 +27887,7 @@ _loop0_171_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' error_argument_pattern")); + D(fprintf(stderr, "%*c> _loop0_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' error_argument_pattern")); Token * _literal; void *elem; while ( @@ -28027,7 +27918,7 @@ _loop0_171_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_171[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_170[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' error_argument_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -28040,14 +27931,14 @@ _loop0_171_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_171_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_170_type, _seq); D(p->level--); return _seq; } -// _gather_170: error_argument_pattern _loop0_171 +// _gather_169: error_argument_pattern _loop0_170 static asdl_seq * -_gather_170_rule(Parser *p) +_gather_169_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28056,27 +27947,27 @@ _gather_170_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // error_argument_pattern _loop0_171 + { // error_argument_pattern _loop0_170 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_171")); + D(fprintf(stderr, "%*c> _gather_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_170")); void *elem; asdl_seq * seq; if ( (elem = error_argument_pattern_rule(p)) // error_argument_pattern && - (seq = _loop0_171_rule(p)) // _loop0_171 + (seq = _loop0_170_rule(p)) // _loop0_170 ) { - D(fprintf(stderr, "%*c+ _gather_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_171")); + D(fprintf(stderr, "%*c+ _gather_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_170")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_170[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_argument_pattern _loop0_171")); + D(fprintf(stderr, "%*c%s _gather_169[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_argument_pattern _loop0_170")); } _res = NULL; done: @@ -28084,9 +27975,9 @@ _gather_170_rule(Parser *p) return _res; } -// _loop0_173: ',' error_argument_pattern +// _loop0_172: ',' error_argument_pattern static asdl_seq * -_loop0_173_rule(Parser *p) +_loop0_172_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28110,7 +28001,7 @@ _loop0_173_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' error_argument_pattern")); + D(fprintf(stderr, "%*c> _loop0_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' error_argument_pattern")); Token * _literal; void *elem; while ( @@ -28141,7 +28032,7 @@ _loop0_173_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_173[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_172[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' error_argument_pattern")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -28154,14 +28045,14 @@ _loop0_173_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_173_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_172_type, _seq); D(p->level--); return _seq; } -// _gather_172: error_argument_pattern _loop0_173 +// _gather_171: error_argument_pattern _loop0_172 static asdl_seq * -_gather_172_rule(Parser *p) +_gather_171_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28170,27 +28061,27 @@ _gather_172_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // error_argument_pattern _loop0_173 + { // error_argument_pattern _loop0_172 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_173")); + D(fprintf(stderr, "%*c> _gather_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_172")); void *elem; asdl_seq * seq; if ( (elem = error_argument_pattern_rule(p)) // error_argument_pattern && - (seq = _loop0_173_rule(p)) // _loop0_173 + (seq = _loop0_172_rule(p)) // _loop0_172 ) { - D(fprintf(stderr, "%*c+ _gather_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_173")); + D(fprintf(stderr, "%*c+ _gather_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_172")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_172[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_argument_pattern _loop0_173")); + D(fprintf(stderr, "%*c%s _gather_171[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_argument_pattern _loop0_172")); } _res = NULL; done: @@ -28198,9 +28089,9 @@ _gather_172_rule(Parser *p) return _res; } -// _loop0_175: ',' (error_argument_pattern | error_star) +// _loop0_174: ',' (error_argument_pattern | error_star) static asdl_seq * -_loop0_175_rule(Parser *p) +_loop0_174_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28224,13 +28115,13 @@ _loop0_175_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (error_argument_pattern | error_star)")); + D(fprintf(stderr, "%*c> _loop0_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (error_argument_pattern | error_star)")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_190_rule(p)) // error_argument_pattern | error_star + (elem = _tmp_189_rule(p)) // error_argument_pattern | error_star ) { _res = elem; @@ -28255,7 +28146,7 @@ _loop0_175_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_175[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_174[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (error_argument_pattern | error_star)")); } asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); @@ -28268,14 +28159,14 @@ _loop0_175_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop0_175_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_174_type, _seq); D(p->level--); return _seq; } -// _gather_174: (error_argument_pattern | error_star) _loop0_175 +// _gather_173: (error_argument_pattern | error_star) _loop0_174 static asdl_seq * -_gather_174_rule(Parser *p) +_gather_173_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28284,27 +28175,27 @@ _gather_174_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (error_argument_pattern | error_star) _loop0_175 + { // (error_argument_pattern | error_star) _loop0_174 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(error_argument_pattern | error_star) _loop0_175")); + D(fprintf(stderr, "%*c> _gather_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(error_argument_pattern | error_star) _loop0_174")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_190_rule(p)) // error_argument_pattern | error_star + (elem = _tmp_189_rule(p)) // error_argument_pattern | error_star && - (seq = _loop0_175_rule(p)) // _loop0_175 + (seq = _loop0_174_rule(p)) // _loop0_174 ) { - D(fprintf(stderr, "%*c+ _gather_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(error_argument_pattern | error_star) _loop0_175")); + D(fprintf(stderr, "%*c+ _gather_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(error_argument_pattern | error_star) _loop0_174")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_174[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(error_argument_pattern | error_star) _loop0_175")); + D(fprintf(stderr, "%*c%s _gather_173[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(error_argument_pattern | error_star) _loop0_174")); } _res = NULL; done: @@ -28312,9 +28203,9 @@ _gather_174_rule(Parser *p) return _res; } -// _tmp_176: '@' named_expression NEWLINE +// _tmp_175: '@' named_expression NEWLINE static void * -_tmp_176_rule(Parser *p) +_tmp_175_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28328,7 +28219,7 @@ _tmp_176_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); Token * _literal; expr_ty f; Token * newline_var; @@ -28340,7 +28231,7 @@ _tmp_176_rule(Parser *p) (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); _res = f; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28350,7 +28241,7 @@ _tmp_176_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_176[%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, "'@' named_expression NEWLINE")); } _res = NULL; @@ -28359,9 +28250,9 @@ _tmp_176_rule(Parser *p) return _res; } -// _tmp_177: ',' star_expression +// _tmp_176: ',' star_expression static void * -_tmp_177_rule(Parser *p) +_tmp_176_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28375,7 +28266,7 @@ _tmp_177_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty c; if ( @@ -28384,7 +28275,7 @@ _tmp_177_rule(Parser *p) (c = star_expression_rule(p)) // star_expression ) { - D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28394,7 +28285,7 @@ _tmp_177_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_177[%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, "',' star_expression")); } _res = NULL; @@ -28403,9 +28294,9 @@ _tmp_177_rule(Parser *p) return _res; } -// _tmp_178: ',' expression +// _tmp_177: ',' expression static void * -_tmp_178_rule(Parser *p) +_tmp_177_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28419,7 +28310,7 @@ _tmp_178_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty c; if ( @@ -28428,7 +28319,7 @@ _tmp_178_rule(Parser *p) (c = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28438,7 +28329,7 @@ _tmp_178_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_178[%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, "',' expression")); } _res = NULL; @@ -28447,9 +28338,9 @@ _tmp_178_rule(Parser *p) return _res; } -// _tmp_179: 'or' conjunction +// _tmp_178: 'or' conjunction static void * -_tmp_179_rule(Parser *p) +_tmp_178_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28463,7 +28354,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, "'or' conjunction")); + D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); Token * _keyword; expr_ty c; if ( @@ -28472,7 +28363,7 @@ _tmp_179_rule(Parser *p) (c = conjunction_rule(p)) // conjunction ) { - D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28482,7 +28373,7 @@ _tmp_179_rule(Parser *p) 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_178[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); } _res = NULL; @@ -28491,9 +28382,9 @@ _tmp_179_rule(Parser *p) return _res; } -// _tmp_180: 'and' inversion +// _tmp_179: 'and' inversion static void * -_tmp_180_rule(Parser *p) +_tmp_179_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28507,7 +28398,7 @@ _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, "'and' inversion")); + D(fprintf(stderr, "%*c> _tmp_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); Token * _keyword; expr_ty c; if ( @@ -28516,7 +28407,7 @@ _tmp_180_rule(Parser *p) (c = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28526,7 +28417,7 @@ _tmp_180_rule(Parser *p) 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_179[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); } _res = NULL; @@ -28535,9 +28426,9 @@ _tmp_180_rule(Parser *p) return _res; } -// _tmp_181: 'if' disjunction +// _tmp_180: 'if' disjunction static void * -_tmp_181_rule(Parser *p) +_tmp_180_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28551,7 +28442,7 @@ _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, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -28560,7 +28451,7 @@ _tmp_181_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28570,7 +28461,7 @@ _tmp_181_rule(Parser *p) 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_180[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -28579,9 +28470,9 @@ _tmp_181_rule(Parser *p) return _res; } -// _tmp_182: 'if' disjunction +// _tmp_181: 'if' disjunction static void * -_tmp_182_rule(Parser *p) +_tmp_181_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28595,7 +28486,7 @@ _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, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -28604,7 +28495,7 @@ _tmp_182_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28614,7 +28505,7 @@ _tmp_182_rule(Parser *p) 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_181[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -28623,9 +28514,9 @@ _tmp_182_rule(Parser *p) return _res; } -// _tmp_183: ',' star_target +// _tmp_182: ',' star_target static void * -_tmp_183_rule(Parser *p) +_tmp_182_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28639,7 +28530,7 @@ _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, "',' star_target")); + D(fprintf(stderr, "%*c> _tmp_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty c; if ( @@ -28648,7 +28539,7 @@ _tmp_183_rule(Parser *p) (c = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28658,7 +28549,7 @@ _tmp_183_rule(Parser *p) 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_182[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } _res = NULL; @@ -28667,9 +28558,9 @@ _tmp_183_rule(Parser *p) return _res; } -// _tmp_184: star_targets '=' +// _tmp_183: star_targets '=' static void * -_tmp_184_rule(Parser *p) +_tmp_183_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28683,7 +28574,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, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty star_targets_var; if ( @@ -28692,12 +28583,12 @@ _tmp_184_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_184[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_183[%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_184[%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, "star_targets '='")); } _res = NULL; @@ -28706,9 +28597,9 @@ _tmp_184_rule(Parser *p) return _res; } -// _tmp_185: star_targets '=' +// _tmp_184: star_targets '=' static void * -_tmp_185_rule(Parser *p) +_tmp_184_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28722,7 +28613,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, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty star_targets_var; if ( @@ -28731,12 +28622,12 @@ _tmp_185_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_185[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_184[%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_185[%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, "star_targets '='")); } _res = NULL; @@ -28745,9 +28636,9 @@ _tmp_185_rule(Parser *p) return _res; } -// _loop1_186: param_with_default +// _loop1_185: param_with_default static asdl_seq * -_loop1_186_rule(Parser *p) +_loop1_185_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28771,7 +28662,7 @@ _loop1_186_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_186[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_185[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -28793,7 +28684,7 @@ _loop1_186_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_186[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_185[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -28811,14 +28702,14 @@ _loop1_186_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_186_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_185_type, _seq); D(p->level--); return _seq; } -// _loop1_187: lambda_param_with_default +// _loop1_186: lambda_param_with_default static asdl_seq * -_loop1_187_rule(Parser *p) +_loop1_186_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28842,7 +28733,7 @@ _loop1_187_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_187[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_186[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -28864,7 +28755,7 @@ _loop1_187_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_187[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_186[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -28882,14 +28773,14 @@ _loop1_187_rule(Parser *p) } for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); PyMem_Free(_children); - _PyPegen_insert_memo(p, _start_mark, _loop1_187_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_186_type, _seq); D(p->level--); return _seq; } -// _tmp_188: ')' | '**' +// _tmp_187: ')' | '**' static void * -_tmp_188_rule(Parser *p) +_tmp_187_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28903,18 +28794,18 @@ _tmp_188_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_188[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_187[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_188[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_187[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_188[%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, "')'")); } { // '**' @@ -28922,18 +28813,18 @@ _tmp_188_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_188[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_187[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_188[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_187[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_188[%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, "'**'")); } _res = NULL; @@ -28942,9 +28833,9 @@ _tmp_188_rule(Parser *p) return _res; } -// _tmp_189: ':' | '**' +// _tmp_188: ':' | '**' static void * -_tmp_189_rule(Parser *p) +_tmp_188_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28958,18 +28849,18 @@ _tmp_189_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_189[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_188[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_189[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_188[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_189[%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, "':'")); } { // '**' @@ -28977,18 +28868,18 @@ _tmp_189_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_189[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_188[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_189[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_188[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_189[%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, "'**'")); } _res = NULL; @@ -28997,9 +28888,9 @@ _tmp_189_rule(Parser *p) return _res; } -// _tmp_190: error_argument_pattern | error_star +// _tmp_189: error_argument_pattern | error_star static void * -_tmp_190_rule(Parser *p) +_tmp_189_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -29013,18 +28904,18 @@ _tmp_190_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_190[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_argument_pattern")); + D(fprintf(stderr, "%*c> _tmp_189[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_argument_pattern")); void *error_argument_pattern_var; if ( (error_argument_pattern_var = error_argument_pattern_rule(p)) // error_argument_pattern ) { - D(fprintf(stderr, "%*c+ _tmp_190[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_argument_pattern")); + D(fprintf(stderr, "%*c+ _tmp_189[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_argument_pattern")); _res = error_argument_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_190[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_189[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_argument_pattern")); } { // error_star @@ -29032,18 +28923,18 @@ _tmp_190_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_190[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_star")); + D(fprintf(stderr, "%*c> _tmp_189[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_star")); expr_ty error_star_var; if ( (error_star_var = error_star_rule(p)) // error_star ) { - D(fprintf(stderr, "%*c+ _tmp_190[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_star")); + D(fprintf(stderr, "%*c+ _tmp_189[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_star")); _res = error_star_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_190[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_189[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_star")); } _res = NULL; diff --git a/Python/compile.c b/Python/compile.c index b12037bfd97b3c..246310a261ee71 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2749,15 +2749,14 @@ compiler_if(struct compiler *c, stmt_ty s) } #define WILDCARD_CHECK(N) \ - ((N)->kind == Name_kind && (N)->v.Name.ctx == Store && \ - _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) + ((N)->kind == Name_kind && \ + _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) static int compiler_pattern_load(struct compiler *c, expr_ty p, pattern_context pc) { - assert(p->kind == Attribute_kind || p->kind == Constant_kind || p->kind == Name_kind); + assert(p->kind == Attribute_kind || p->kind == Constant_kind); assert(p->kind != Attribute_kind || p->v.Attribute.ctx == Load); - assert(p->kind != Name_kind || p->v.Name.ctx == Load); VISIT(c, expr, p); ADDOP_COMPARE(c, Eq); return 1; @@ -2899,9 +2898,6 @@ static int compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context pc) { assert(p->kind == Name_kind); - if (p->v.Name.ctx == Load) { - return compiler_pattern_load(c, p, pc); - } assert(p->v.Name.ctx == Store); if (WILDCARD_CHECK(p)) { ADDOP(c, POP_TOP); From 123e15b2b6fc1176e600b01d9cc67eaf0a691257 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 5 Jul 2020 08:57:41 -0700 Subject: [PATCH 122/189] Only use nonnegative integer indices --- Doc/library/dis.rst | 21 ++++++++++++ Include/opcode.h | 3 ++ Lib/importlib/_bootstrap_external.py | 4 +-- Lib/opcode.py | 4 ++- Python/ceval.c | 49 ++++++++++++++++++++++++++++ Python/compile.c | 48 ++++++++++----------------- Python/importlib_external.h | 2 +- Python/opcode_targets.h | 6 ++-- 8 files changed, 100 insertions(+), 37 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 361eec0a5696f9..7efaf05e9ffcc9 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1227,6 +1227,27 @@ All of the following opcodes use their arguments. .. versionadded:: 3.10 +.. opcode:: MATCH_ITEM (i) + + TODO + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_ITEM_END (i) + + TODO + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_ITEM_SLICE (ij) + + TODO + + .. versionadded:: 3.10 + + .. opcode:: HAVE_ARGUMENT This is not really an opcode. It identifies the dividing line between diff --git a/Include/opcode.h b/Include/opcode.h index 24a21dc86b590a..db4da0bfad8ef5 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -122,6 +122,9 @@ extern "C" { #define LOAD_CLASSDEREF 148 #define MATCH_CLASS 149 #define MATCH_KEYS 150 +#define MATCH_ITEM 151 +#define MATCH_ITEM_END 152 +#define MATCH_ITEM_SLICE 153 #define SETUP_ASYNC_WITH 154 #define FORMAT_VALUE 155 #define BUILD_CONST_KEY_MAP 156 diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 17de85a43e8b39..05b87ea214c54c 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3464 (add structural pattern matching) +# Python 3.10a0 3465 (add structural pattern matching) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3464).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3465).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index e0ef77ea5e51f8..fb68736fa03155 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -197,7 +197,9 @@ def jabs_op(name, op): hasfree.append(148) def_op('MATCH_CLASS', 149) def_op('MATCH_KEYS', 150) - +def_op('MATCH_ITEM', 151) +def_op('MATCH_ITEM_END', 152) +def_op('MATCH_ITEM_SLICE', 153) jrel_op('SETUP_ASYNC_WITH', 154) def_op('FORMAT_VALUE', 155) def_op('BUILD_CONST_KEY_MAP', 156) diff --git a/Python/ceval.c b/Python/ceval.c index 57c6f74b1f64ee..24013dd782c9af 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3634,6 +3634,55 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } + case TARGET(MATCH_ITEM): { + PyObject *item = PySequence_GetItem(SECOND(), oparg); + if (!item) { + goto error; + } + PUSH(item); + DISPATCH(); + } + + case TARGET(MATCH_ITEM_END): { + Py_ssize_t len = PyLong_AsSsize_t(TOP()); + if (len < 0) { + goto error; + } + assert(len - 1 - oparg >= 0); + PyObject *item = PySequence_GetItem(SECOND(), len - 1 - oparg); + if (!item) { + goto error; + } + PUSH(item); + DISPATCH(); + } + + case TARGET(MATCH_ITEM_SLICE): { + Py_ssize_t len = PyLong_AsSsize_t(TOP()); + if (len < 0) { + goto error; + } + Py_ssize_t start = oparg >> 16; + Py_ssize_t stop = len - (oparg & 0xFFFF); + assert(start <= stop); + PyObject *items = PyList_New(stop - start); + if (!items) { + goto error; + } + PyObject *target = SECOND(); + PyObject *item; + for (Py_ssize_t i = start; i < stop; i++) { + item = PySequence_GetItem(target, i); + if (!item) { + Py_DECREF(items); + goto error; + } + PyList_SET_ITEM(items, i - start, item); + } + PUSH(items); + DISPATCH(); + } + case TARGET(GET_ITER): { /* before: [obj]; after [getiter(obj)] */ PyObject *iterable = TOP(); diff --git a/Python/compile.c b/Python/compile.c index 246310a261ee71..824e825bad36b5 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1109,6 +1109,9 @@ stack_effect(int opcode, int oparg, int jump) return 1; case MATCH_CLASS: return -1; + case MATCH_ITEM: + case MATCH_ITEM_END: + case MATCH_ITEM_SLICE: case MATCH_KEYS: case MATCH_MAPPING: case MATCH_SEQUENCE: @@ -2995,31 +2998,32 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context pc) } star = i; } - basicblock *end; + basicblock *block, *end; + CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); ADDOP(c, MATCH_SEQUENCE); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); + ADDOP(c, GET_LEN); if (star < 0) { - ADDOP(c, GET_LEN); + ADDOP(c, DUP_TOP); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)); ADDOP_COMPARE(c, Eq); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); } else if (size) { - ADDOP(c, GET_LEN); + ADDOP(c, DUP_TOP); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - 1)); ADDOP_COMPARE(c, GtE); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); } for (Py_ssize_t i = 0; i < size; i++) { + // TODO: Raise for invalid sizes to MATCH_ITEM* opcodes. expr_ty value = asdl_seq_GET(values, i); if (WILDCARD_CHECK(value)) { continue; } if (star < 0 || i < star) { - ADDOP(c, DUP_TOP); - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); - ADDOP(c, BINARY_SUBSCR); + ADDOP_I(c, MATCH_ITEM, i); } else if (i == star) { assert(value->kind == Starred_kind); @@ -3027,34 +3031,18 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context pc) if (WILDCARD_CHECK(value)) { continue; } - ADDOP(c, DUP_TOP); - ADDOP_I(c, BUILD_LIST, 0); - ADDOP(c, ROT_TWO); - if (i) { - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); - } - else { - ADDOP_LOAD_CONST(c, Py_None); - } - if (i != size - 1) { - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(-(size - 1 - i))); - } - else { - ADDOP_LOAD_CONST(c, Py_None); - } - ADDOP_I(c, BUILD_SLICE, 2); - ADDOP(c, BINARY_SUBSCR); - ADDOP_I(c, LIST_EXTEND, 1); + ADDOP_I(c, MATCH_ITEM_SLICE, (i << 16) + (size - 1 - i)); } else { - ADDOP(c, DUP_TOP); - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(-(size - i))); - ADDOP(c, BINARY_SUBSCR); + ADDOP_I(c, MATCH_ITEM_END, size - 1 - i); } CHECK(compiler_pattern(c, value, pc)); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); } ADDOP_LOAD_CONST(c, Py_True); + compiler_use_next_block(c, block); + ADDOP(c, ROT_TWO); + ADDOP(c, POP_TOP); compiler_use_next_block(c, end); ADDOP(c, ROT_TWO); ADDOP(c, POP_TOP); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index f96f2c5d782bc6..53148ddda84dd1 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,136,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,137,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index d877d6b0697880..4febf772d76a52 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -150,9 +150,9 @@ static void *opcode_targets[256] = { &&TARGET_LOAD_CLASSDEREF, &&TARGET_MATCH_CLASS, &&TARGET_MATCH_KEYS, - &&_unknown_opcode, - &&_unknown_opcode, - &&_unknown_opcode, + &&TARGET_MATCH_ITEM, + &&TARGET_MATCH_ITEM_END, + &&TARGET_MATCH_ITEM_SLICE, &&TARGET_SETUP_ASYNC_WITH, &&TARGET_FORMAT_VALUE, &&TARGET_BUILD_CONST_KEY_MAP, From 2f03ae0b11fe69c3fa219c0a0e0a8c0a531d2b55 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 5 Jul 2020 08:58:00 -0700 Subject: [PATCH 123/189] Remove leading dot rules from unparsing logic --- Lib/ast.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Lib/ast.py b/Lib/ast.py index abb9ffc5cfdf41..aecbd013c0af07 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -1106,8 +1106,6 @@ def _fstring_FormattedValue(self, node, write): write("}") def visit_Name(self, node): - if self.in_pattern() and isinstance(node.ctx, Load): - self.write(".") self.write(node.id) def _write_docstring(self, node): @@ -1367,14 +1365,7 @@ def visit_Attribute(self, node): def visit_Call(self, node): self.set_precedence(_Precedence.ATOM, node.func) - # We need to surround self.traverse(node.func) like this because - # ".xxx()" isn't legal in patterns (but visit_Name will try to include - # the leading dot if we're in a pattern). Temporary, as it's likely the - # pattern name load/store syntax will change... - _pattern = self.in_pattern() - self._pattern = False self.traverse(node.func) - self._pattern = _pattern with self.delimit("(", ")"): comma = False for e in node.args: From ef881fa07aea3a7f48d09bf2eba27b71b56a70d4 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 5 Jul 2020 14:38:13 -0700 Subject: [PATCH 124/189] Use MATCH_ITEM for mapping and class patterns --- Python/ceval.c | 10 +++++----- Python/compile.c | 16 +++++++--------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 24013dd782c9af..3420a1b4ba68e6 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3635,7 +3635,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_ITEM): { - PyObject *item = PySequence_GetItem(SECOND(), oparg); + PyObject *item = PySequence_GetItem(TOP(), oparg); if (!item) { goto error; } @@ -3644,12 +3644,12 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_ITEM_END): { - Py_ssize_t len = PyLong_AsSsize_t(TOP()); + Py_ssize_t len = PyLong_AsSsize_t(SECOND()); if (len < 0) { goto error; } assert(len - 1 - oparg >= 0); - PyObject *item = PySequence_GetItem(SECOND(), len - 1 - oparg); + PyObject *item = PySequence_GetItem(TOP(), len - 1 - oparg); if (!item) { goto error; } @@ -3658,7 +3658,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_ITEM_SLICE): { - Py_ssize_t len = PyLong_AsSsize_t(TOP()); + Py_ssize_t len = PyLong_AsSsize_t(SECOND()); if (len < 0) { goto error; } @@ -3669,7 +3669,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (!items) { goto error; } - PyObject *target = SECOND(); + PyObject *target = TOP(); PyObject *item; for (Py_ssize_t i = start; i < stop; i++) { item = PySequence_GetItem(target, i); diff --git a/Python/compile.c b/Python/compile.c index 824e825bad36b5..2fb98aefc4c135 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2795,9 +2795,8 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context pc) { if (WILDCARD_CHECK(arg)) { continue; } - ADDOP(c, DUP_TOP); - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); - ADDOP(c, BINARY_SUBSCR); + // TODO: Validate arg; + ADDOP_I(c, MATCH_ITEM, i); CHECK(compiler_pattern(c, arg, pc)); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } @@ -2806,9 +2805,8 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context pc) { if (WILDCARD_CHECK(kwarg->value)) { continue; } - ADDOP(c, DUP_TOP); - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(nargs + i)); - ADDOP(c, BINARY_SUBSCR); + // TODO: Validate arg; + ADDOP_I(c, MATCH_ITEM, nargs + i); CHECK(compiler_pattern(c, kwarg->value, pc)); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } @@ -2874,9 +2872,8 @@ compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context pc) if (WILDCARD_CHECK(value)) { continue; } - ADDOP(c, DUP_TOP); - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); - ADDOP(c, BINARY_SUBSCR); + // TODO: Validate arg; + ADDOP_I(c, MATCH_ITEM, i); CHECK(compiler_pattern(c, value, pc)); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); } @@ -3016,6 +3013,7 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context pc) ADDOP_COMPARE(c, GtE); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); } + ADDOP(c, ROT_TWO); for (Py_ssize_t i = 0; i < size; i++) { // TODO: Raise for invalid sizes to MATCH_ITEM* opcodes. expr_ty value = asdl_seq_GET(values, i); From eb86fa7b798dbd82e73b332d13ab266872ade9ed Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 5 Jul 2020 17:10:09 -0700 Subject: [PATCH 125/189] Reduce unnecessary EXTENDED_ARG instructions --- Lib/importlib/_bootstrap_external.py | 4 ++-- Python/ceval.c | 4 ++-- Python/compile.c | 2 +- Python/importlib_external.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 05b87ea214c54c..299583fdd5f593 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3465 (add structural pattern matching) +# Python 3.10a0 3466 (add structural pattern matching) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3465).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3466).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Python/ceval.c b/Python/ceval.c index 3420a1b4ba68e6..353b69ffa13489 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3662,8 +3662,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (len < 0) { goto error; } - Py_ssize_t start = oparg >> 16; - Py_ssize_t stop = len - (oparg & 0xFFFF); + Py_ssize_t start = oparg & 0xFF; + Py_ssize_t stop = len - (oparg >> 8); assert(start <= stop); PyObject *items = PyList_New(stop - start); if (!items) { diff --git a/Python/compile.c b/Python/compile.c index 2fb98aefc4c135..526eb4e4210c5e 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -3029,7 +3029,7 @@ compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context pc) if (WILDCARD_CHECK(value)) { continue; } - ADDOP_I(c, MATCH_ITEM_SLICE, (i << 16) + (size - 1 - i)); + ADDOP_I(c, MATCH_ITEM_SLICE, ((size - 1 - i) << 8) + i); } else { ADDOP_I(c, MATCH_ITEM_END, size - 1 - i); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 53148ddda84dd1..e52b9111c5519f 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,137,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,138,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, From f3d3d8350dec5847af149647df3628930ee2821e Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sat, 11 Jul 2020 16:56:55 -0700 Subject: [PATCH 126/189] Documentation and cleanup --- Doc/library/dis.rst | 11 +- Python/ceval.c | 3 +- Python/compile.c | 1486 ++++++++++++++++++++++--------------------- 3 files changed, 779 insertions(+), 721 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 7efaf05e9ffcc9..f07742f5c07cf4 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1229,21 +1229,24 @@ All of the following opcodes use their arguments. .. opcode:: MATCH_ITEM (i) - TODO + TOS is a sequence. Push ``TOS[i]`` onto the stack. .. versionadded:: 3.10 .. opcode:: MATCH_ITEM_END (i) - TODO + TOS is a sequence, and TOS1 is its length. Push ``TOS[TOS1 - 1 - i]`` onto + the stack. .. versionadded:: 3.10 -.. opcode:: MATCH_ITEM_SLICE (ij) +.. opcode:: MATCH_ITEM_SLICE (i) - TODO + TOS is a sequence, and TOS1 is its length. Push a list formed from + ``TOS[x:TOS1 - 1 - y]`` onto the stack, where *x* is the low byte of *i* and + *y* is the high bytes of *i*. .. versionadded:: 3.10 diff --git a/Python/ceval.c b/Python/ceval.c index 353b69ffa13489..3deac496908c80 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3521,8 +3521,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(GET_LEN): { - PyObject *target = TOP(); - Py_ssize_t l = PyObject_Length(target); + Py_ssize_t l = PyObject_Length(TOP()); if (l < 0) { goto error; } diff --git a/Python/compile.c b/Python/compile.c index 526eb4e4210c5e..aab9f514ba5577 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -225,6 +225,7 @@ static int compiler_async_comprehension_generator( expr_ty elt, expr_ty val, int type); static int compiler_pattern(struct compiler *, expr_ty, pattern_context); +static int compiler_match(struct compiler *, stmt_ty); static PyCodeObject *assemble(struct compiler *, int addNone); static PyObject *__doc__, *__annotations__; @@ -2751,563 +2752,184 @@ compiler_if(struct compiler *c, stmt_ty s) return 1; } -#define WILDCARD_CHECK(N) \ - ((N)->kind == Name_kind && \ - _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) static int -compiler_pattern_load(struct compiler *c, expr_ty p, pattern_context pc) +compiler_for(struct compiler *c, stmt_ty s) { - assert(p->kind == Attribute_kind || p->kind == Constant_kind); - assert(p->kind != Attribute_kind || p->v.Attribute.ctx == Load); - VISIT(c, expr, p); - ADDOP_COMPARE(c, Eq); - return 1; -} + basicblock *start, *cleanup, *end; -static int -compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context pc) { - asdl_seq *args = p->v.Call.args; - asdl_seq *kwargs = p->v.Call.keywords; - Py_ssize_t nargs = asdl_seq_LEN(args); - Py_ssize_t nkwargs = asdl_seq_LEN(kwargs); - basicblock *block, *end; - CHECK(block = compiler_new_block(c)); - CHECK(end = compiler_new_block(c)); - expr_ty func = p->v.Call.func; - assert(func->kind == Attribute_kind || func->kind == Name_kind); - assert(func->kind != Attribute_kind || func->v.Attribute.ctx == Load); - assert(func->kind != Name_kind || func->v.Name.ctx == Load); - VISIT(c, expr, func); - PyObject *kwnames; - CHECK(kwnames = PyTuple_New(nkwargs)); - Py_ssize_t i; - for (i = 0; i < nkwargs; i++) { - PyObject *name = ((keyword_ty) asdl_seq_GET(kwargs, i))->arg; - Py_INCREF(name); - PyTuple_SET_ITEM(kwnames, i, name); - } - ADDOP_LOAD_CONST_NEW(c, kwnames); - ADDOP_I(c, MATCH_CLASS, nargs); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); - for (i = 0; i < nargs; i++) { - expr_ty arg = asdl_seq_GET(args, i); - if (WILDCARD_CHECK(arg)) { - continue; - } - // TODO: Validate arg; - ADDOP_I(c, MATCH_ITEM, i); - CHECK(compiler_pattern(c, arg, pc)); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); + start = compiler_new_block(c); + cleanup = compiler_new_block(c); + end = compiler_new_block(c); + if (start == NULL || end == NULL || cleanup == NULL) { + return 0; } - for (i = 0; i < nkwargs; i++) { - keyword_ty kwarg = asdl_seq_GET(kwargs, i); - if (WILDCARD_CHECK(kwarg->value)) { - continue; - } - // TODO: Validate arg; - ADDOP_I(c, MATCH_ITEM, nargs + i); - CHECK(compiler_pattern(c, kwarg->value, pc)); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); + if (!compiler_push_fblock(c, FOR_LOOP, start, end, NULL)) { + return 0; } - ADDOP_LOAD_CONST(c, Py_True); + VISIT(c, expr, s->v.For.iter); + ADDOP(c, GET_ITER); + compiler_use_next_block(c, start); + ADDOP_JREL(c, FOR_ITER, cleanup); + VISIT(c, expr, s->v.For.target); + VISIT_SEQ(c, stmt, s->v.For.body); + ADDOP_JABS(c, JUMP_ABSOLUTE, start); + compiler_use_next_block(c, cleanup); + + compiler_pop_fblock(c, FOR_LOOP, start); + + VISIT_SEQ(c, stmt, s->v.For.orelse); compiler_use_next_block(c, end); - ADDOP(c, ROT_TWO); - ADDOP(c, POP_TOP); return 1; } + static int -compiler_pattern_store(struct compiler *c, expr_ty p, pattern_context pc) { - assert(p->kind == Name_kind); - assert(p->v.Name.ctx == Store); - if (WILDCARD_CHECK(p)) { - return compiler_error(c, "can't assign to '_' here; " - "consider removing or renaming?"); +compiler_async_for(struct compiler *c, stmt_ty s) +{ + basicblock *start, *except, *end; + if (IS_TOP_LEVEL_AWAIT(c)){ + c->u->u_ste->ste_coroutine = 1; + } else if (c->u->u_scope_type != COMPILER_SCOPE_ASYNC_FUNCTION) { + return compiler_error(c, "'async for' outside async function"); } - if (PySet_Contains(pc.stores, p->v.Name.id)) { - // TODO: Format this error message with the name. - return compiler_error(c, "multiple assignments to name in pattern"); + + start = compiler_new_block(c); + except = compiler_new_block(c); + end = compiler_new_block(c); + + if (start == NULL || except == NULL || end == NULL) { + return 0; } - CHECK(!PySet_Add(pc.stores, p->v.Name.id)); - VISIT(c, expr, p); - ADDOP_LOAD_CONST(c, Py_True); + VISIT(c, expr, s->v.AsyncFor.iter); + ADDOP(c, GET_AITER); + + compiler_use_next_block(c, start); + if (!compiler_push_fblock(c, FOR_LOOP, start, end, NULL)) { + return 0; + } + /* SETUP_FINALLY to guard the __anext__ call */ + ADDOP_JREL(c, SETUP_FINALLY, except); + ADDOP(c, GET_ANEXT); + ADDOP_LOAD_CONST(c, Py_None); + ADDOP(c, YIELD_FROM); + ADDOP(c, POP_BLOCK); /* for SETUP_FINALLY */ + + /* Success block for __anext__ */ + VISIT(c, expr, s->v.AsyncFor.target); + VISIT_SEQ(c, stmt, s->v.AsyncFor.body); + ADDOP_JABS(c, JUMP_ABSOLUTE, start); + + compiler_pop_fblock(c, FOR_LOOP, start); + + /* Except block for __anext__ */ + compiler_use_next_block(c, except); + ADDOP(c, END_ASYNC_FOR); + + /* `else` block */ + VISIT_SEQ(c, stmt, s->v.For.orelse); + + compiler_use_next_block(c, end); + return 1; } static int -compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context pc) +compiler_while(struct compiler *c, stmt_ty s) { - basicblock *block, *end; - CHECK(block = compiler_new_block(c)); - CHECK(end = compiler_new_block(c)); - asdl_seq *keys = p->v.Dict.keys; - asdl_seq *values = p->v.Dict.values; - Py_ssize_t size = asdl_seq_LEN(values); - int star = size ? !asdl_seq_GET(keys, size - 1) : 0; - ADDOP(c, MATCH_MAPPING); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); - if (size - star) { - ADDOP(c, GET_LEN); - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - star)); - ADDOP_COMPARE(c, GtE); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); - } - Py_ssize_t i; - for (i = 0; i < size - star; i++) { - expr_ty key = asdl_seq_GET(keys, i); - if (!key) { - return compiler_error(c, "can't use starred pattern here; consider moving to end?"); + basicblock *loop, *orelse, *end, *anchor = NULL; + int constant = expr_constant(s->v.While.test); + + if (constant == 0) { + BEGIN_DO_NOT_EMIT_BYTECODE + // Push a dummy block so the VISIT_SEQ knows that we are + // inside a while loop so it can correctly evaluate syntax + // errors. + if (!compiler_push_fblock(c, WHILE_LOOP, NULL, NULL, NULL)) { + return 0; } - assert(key->kind == Attribute_kind || key->kind == Constant_kind || key->kind == Name_kind); - assert(key->kind != Attribute_kind || key->v.Attribute.ctx == Load); - assert(key->kind != Name_kind || key->v.Name.ctx == Load); - VISIT(c, expr, asdl_seq_GET(keys, i)); - } - ADDOP_I(c, BUILD_TUPLE, size - star); - ADDOP_I(c, MATCH_KEYS, star); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); - for (i = 0; i < size - star; i++) { - expr_ty value = asdl_seq_GET(values, i); - if (WILDCARD_CHECK(value)) { - continue; + VISIT_SEQ(c, stmt, s->v.While.body); + // Remove the dummy block now that is not needed. + compiler_pop_fblock(c, WHILE_LOOP, NULL); + END_DO_NOT_EMIT_BYTECODE + if (s->v.While.orelse) { + VISIT_SEQ(c, stmt, s->v.While.orelse); } - // TODO: Validate arg; - ADDOP_I(c, MATCH_ITEM, i); - CHECK(compiler_pattern(c, value, pc)); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + return 1; } - ADDOP(c, POP_TOP); - if (star) { - CHECK(compiler_pattern_store(c, asdl_seq_GET(values, size - 1), pc)); + loop = compiler_new_block(c); + end = compiler_new_block(c); + if (constant == -1) { + anchor = compiler_new_block(c); + if (anchor == NULL) + return 0; } - else { - ADDOP(c, POP_TOP); - ADDOP_LOAD_CONST(c, Py_True); + if (loop == NULL || end == NULL) + return 0; + if (s->v.While.orelse) { + orelse = compiler_new_block(c); + if (orelse == NULL) + return 0; } - ADDOP_JREL(c, JUMP_FORWARD, end); - compiler_use_next_block(c, block); - ADDOP(c, POP_TOP); - ADDOP(c, POP_TOP); - ADDOP_LOAD_CONST(c, Py_False); + else + orelse = NULL; + + compiler_use_next_block(c, loop); + if (!compiler_push_fblock(c, WHILE_LOOP, loop, end, NULL)) + return 0; + if (constant == -1) { + if (!compiler_jump_if(c, s->v.While.test, anchor, 0)) + return 0; + } + VISIT_SEQ(c, stmt, s->v.While.body); + ADDOP_JABS(c, JUMP_ABSOLUTE, loop); + + /* XXX should the two POP instructions be in a separate block + if there is no else clause ? + */ + + if (constant == -1) + compiler_use_next_block(c, anchor); + compiler_pop_fblock(c, WHILE_LOOP, loop); + + if (orelse != NULL) /* what if orelse is just pass? */ + VISIT_SEQ(c, stmt, s->v.While.orelse); compiler_use_next_block(c, end); + return 1; } static int -compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context pc) +compiler_return(struct compiler *c, stmt_ty s) { - assert(p->kind == Name_kind); - assert(p->v.Name.ctx == Store); - if (WILDCARD_CHECK(p)) { - ADDOP(c, POP_TOP); - ADDOP_LOAD_CONST(c, Py_True); - return 1; + int preserve_tos = ((s->v.Return.value != NULL) && + (s->v.Return.value->kind != Constant_kind)); + if (c->u->u_ste->ste_type != FunctionBlock) + return compiler_error(c, "'return' outside function"); + if (s->v.Return.value != NULL && + c->u->u_ste->ste_coroutine && c->u->u_ste->ste_generator) + { + return compiler_error( + c, "'return' with value in async generator"); } - return compiler_pattern_store(c, p, pc); -} + if (preserve_tos) { + VISIT(c, expr, s->v.Return.value); + } + if (!compiler_unwind_fblock_stack(c, preserve_tos, NULL)) + return 0; + if (s->v.Return.value == NULL) { + ADDOP_LOAD_CONST(c, Py_None); + } + else if (!preserve_tos) { + VISIT(c, expr, s->v.Return.value); + } + ADDOP(c, RETURN_VALUE); -static int -compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context pc) -{ - assert(p->kind == NamedExpr_kind); - basicblock *block, *end; - CHECK(block = compiler_new_block(c)); - CHECK(end = compiler_new_block(c)); - ADDOP(c, DUP_TOP); - CHECK(compiler_pattern(c, p->v.NamedExpr.value, pc)); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); - CHECK(compiler_pattern_store(c, p->v.NamedExpr.target, pc)); - ADDOP_JREL(c, JUMP_FORWARD, end); - compiler_use_next_block(c, block); - ADDOP(c, ROT_TWO); - ADDOP(c, POP_TOP); - compiler_use_next_block(c, end); return 1; } static int -compiler_pattern_or(struct compiler *c, expr_ty p, pattern_context pc) -{ - assert(p->kind == BoolOp_kind); - assert(p->v.BoolOp.op == Or); - basicblock *end; - PyObject *control = NULL; - CHECK(end = compiler_new_block(c)); - Py_ssize_t size = asdl_seq_LEN(p->v.BoolOp.values); - assert(size > 1); - PyObject *names_copy; - for (Py_ssize_t i = 0; i < size; i++) { - CHECK(names_copy = PySet_New(pc.stores)); - ADDOP(c, DUP_TOP); - // TODO: Just modify pc instead. - pattern_context sub_pc = pc; - sub_pc.stores = names_copy; - CHECK(compiler_pattern(c, asdl_seq_GET(p->v.BoolOp.values, i), sub_pc)); - ADDOP_JABS(c, JUMP_IF_TRUE_OR_POP, end); - // TODO: Reuse names_copy without actually building a new copy each loop? - if (!i) { - control = names_copy; - } - else if (PySet_GET_SIZE(control) || PySet_GET_SIZE(names_copy)) { - PyObject *diff = PyNumber_InPlaceXor(names_copy, control); - if (!diff) { - Py_DECREF(control); - return 0; - } - Py_DECREF(names_copy); - if (PySet_GET_SIZE(diff)) { - // TODO: Format this error message with a name. - // PyObject *extra = PySet_Pop(diff); - Py_DECREF(control); - Py_DECREF(diff); - return compiler_error(c, "pattern binds different names based on target"); - } - Py_DECREF(diff); - } - else { - Py_DECREF(names_copy); - } - } - assert(control); - Py_DECREF(control); - ADDOP_LOAD_CONST(c, Py_False); - compiler_use_next_block(c, end); - ADDOP(c, ROT_TWO); - ADDOP(c, POP_TOP); - return 1; -} - -static int -compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context pc) -{ - assert(p->kind == List_kind || p->kind == Tuple_kind); - asdl_seq *values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; - Py_ssize_t size = asdl_seq_LEN(values); - Py_ssize_t star = -1; - for (Py_ssize_t i = 0; i < size; i++) { - expr_ty value = asdl_seq_GET(values, i); - if (value->kind != Starred_kind) { - continue; - } - if (star >= 0) { - return compiler_error(c, "multiple starred names in pattern"); - } - star = i; - } - basicblock *block, *end; - CHECK(block = compiler_new_block(c)); - CHECK(end = compiler_new_block(c)); - ADDOP(c, MATCH_SEQUENCE); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); - ADDOP(c, GET_LEN); - if (star < 0) { - ADDOP(c, DUP_TOP); - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)); - ADDOP_COMPARE(c, Eq); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); - } - else if (size) { - ADDOP(c, DUP_TOP); - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - 1)); - ADDOP_COMPARE(c, GtE); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); - } - ADDOP(c, ROT_TWO); - for (Py_ssize_t i = 0; i < size; i++) { - // TODO: Raise for invalid sizes to MATCH_ITEM* opcodes. - expr_ty value = asdl_seq_GET(values, i); - if (WILDCARD_CHECK(value)) { - continue; - } - if (star < 0 || i < star) { - ADDOP_I(c, MATCH_ITEM, i); - } - else if (i == star) { - assert(value->kind == Starred_kind); - value = value->v.Starred.value; - if (WILDCARD_CHECK(value)) { - continue; - } - ADDOP_I(c, MATCH_ITEM_SLICE, ((size - 1 - i) << 8) + i); - } - else { - ADDOP_I(c, MATCH_ITEM_END, size - 1 - i); - } - CHECK(compiler_pattern(c, value, pc)); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); - } - ADDOP_LOAD_CONST(c, Py_True); - compiler_use_next_block(c, block); - ADDOP(c, ROT_TWO); - ADDOP(c, POP_TOP); - compiler_use_next_block(c, end); - ADDOP(c, ROT_TWO); - ADDOP(c, POP_TOP); - return 1; -} - -static int -compiler_pattern(struct compiler *c, expr_ty p, pattern_context pc) -{ - SET_LOC(c, p); - switch (p->kind) { - case Attribute_kind: - case Constant_kind: - return compiler_pattern_load(c, p, pc); - case BinOp_kind: - // Because we allow "2+2j", things like "2+2" make it this far: - return compiler_error(c, "patterns cannot include operators"); - case BoolOp_kind: - return compiler_pattern_or(c, p, pc); - case Call_kind: - return compiler_pattern_call(c, p, pc); - case Dict_kind: - return compiler_pattern_mapping(c, p, pc); - case JoinedStr_kind: - // Because we allow strings, f-strings make it this far: - return compiler_error(c, "patterns cannot include f-strings"); - case List_kind: - case Tuple_kind: - return compiler_pattern_sequence(c, p, pc); - case Name_kind: - return compiler_pattern_name(c, p, pc); - case NamedExpr_kind: - return compiler_pattern_namedexpr(c, p, pc); - default: - Py_UNREACHABLE(); - } -} - -static int -compiler_match(struct compiler *c, stmt_ty s) -{ - VISIT(c, expr, s->v.Match.target); - basicblock *next, *end; - CHECK(end = compiler_new_block(c)); - int warned = 0; - Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); - assert(cases); - pattern_context pc; - CHECK(pc.stores = PySet_New(NULL)); - int last = 0; - match_case_ty m; - // TODO: Leaks pc.stores on failure. - for (Py_ssize_t i = 0; i < cases; i++) { - if (i == cases - 1) { - last = 1; - } - m = asdl_seq_GET(s->v.Match.cases, i); - SET_LOC(c, m->pattern); - CHECK(next = compiler_new_block(c)); - if (!last) { - ADDOP(c, DUP_TOP); - } - if (!warned && !last && !m->guard - && m->pattern->kind == Name_kind && m->pattern->v.Name.ctx == Store) - { - warned = 1; - CHECK(compiler_warn(c, "unguarded name capture pattern makes " - "remaining cases unreachable")); - } - int result = compiler_pattern(c, m->pattern, pc); - PySet_Clear(pc.stores); - CHECK(result); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, next); - if (m->guard) { - CHECK(compiler_jump_if(c, m->guard, next, 0)); - } - if (!last) { - ADDOP(c, POP_TOP); - } - VISIT_SEQ(c, stmt, m->body); - if (!last) { - ADDOP_JREL(c, JUMP_FORWARD, end); - } - compiler_use_next_block(c, next); - } - Py_DECREF(pc.stores); - compiler_use_next_block(c, end); - return 1; -} - -static int -compiler_for(struct compiler *c, stmt_ty s) -{ - basicblock *start, *cleanup, *end; - - start = compiler_new_block(c); - cleanup = compiler_new_block(c); - end = compiler_new_block(c); - if (start == NULL || end == NULL || cleanup == NULL) { - return 0; - } - if (!compiler_push_fblock(c, FOR_LOOP, start, end, NULL)) { - return 0; - } - VISIT(c, expr, s->v.For.iter); - ADDOP(c, GET_ITER); - compiler_use_next_block(c, start); - ADDOP_JREL(c, FOR_ITER, cleanup); - VISIT(c, expr, s->v.For.target); - VISIT_SEQ(c, stmt, s->v.For.body); - ADDOP_JABS(c, JUMP_ABSOLUTE, start); - compiler_use_next_block(c, cleanup); - - compiler_pop_fblock(c, FOR_LOOP, start); - - VISIT_SEQ(c, stmt, s->v.For.orelse); - compiler_use_next_block(c, end); - return 1; -} - - -static int -compiler_async_for(struct compiler *c, stmt_ty s) -{ - basicblock *start, *except, *end; - if (IS_TOP_LEVEL_AWAIT(c)){ - c->u->u_ste->ste_coroutine = 1; - } else if (c->u->u_scope_type != COMPILER_SCOPE_ASYNC_FUNCTION) { - return compiler_error(c, "'async for' outside async function"); - } - - start = compiler_new_block(c); - except = compiler_new_block(c); - end = compiler_new_block(c); - - if (start == NULL || except == NULL || end == NULL) { - return 0; - } - VISIT(c, expr, s->v.AsyncFor.iter); - ADDOP(c, GET_AITER); - - compiler_use_next_block(c, start); - if (!compiler_push_fblock(c, FOR_LOOP, start, end, NULL)) { - return 0; - } - /* SETUP_FINALLY to guard the __anext__ call */ - ADDOP_JREL(c, SETUP_FINALLY, except); - ADDOP(c, GET_ANEXT); - ADDOP_LOAD_CONST(c, Py_None); - ADDOP(c, YIELD_FROM); - ADDOP(c, POP_BLOCK); /* for SETUP_FINALLY */ - - /* Success block for __anext__ */ - VISIT(c, expr, s->v.AsyncFor.target); - VISIT_SEQ(c, stmt, s->v.AsyncFor.body); - ADDOP_JABS(c, JUMP_ABSOLUTE, start); - - compiler_pop_fblock(c, FOR_LOOP, start); - - /* Except block for __anext__ */ - compiler_use_next_block(c, except); - ADDOP(c, END_ASYNC_FOR); - - /* `else` block */ - VISIT_SEQ(c, stmt, s->v.For.orelse); - - compiler_use_next_block(c, end); - - return 1; -} - -static int -compiler_while(struct compiler *c, stmt_ty s) -{ - basicblock *loop, *orelse, *end, *anchor = NULL; - int constant = expr_constant(s->v.While.test); - - if (constant == 0) { - BEGIN_DO_NOT_EMIT_BYTECODE - // Push a dummy block so the VISIT_SEQ knows that we are - // inside a while loop so it can correctly evaluate syntax - // errors. - if (!compiler_push_fblock(c, WHILE_LOOP, NULL, NULL, NULL)) { - return 0; - } - VISIT_SEQ(c, stmt, s->v.While.body); - // Remove the dummy block now that is not needed. - compiler_pop_fblock(c, WHILE_LOOP, NULL); - END_DO_NOT_EMIT_BYTECODE - if (s->v.While.orelse) { - VISIT_SEQ(c, stmt, s->v.While.orelse); - } - return 1; - } - loop = compiler_new_block(c); - end = compiler_new_block(c); - if (constant == -1) { - anchor = compiler_new_block(c); - if (anchor == NULL) - return 0; - } - if (loop == NULL || end == NULL) - return 0; - if (s->v.While.orelse) { - orelse = compiler_new_block(c); - if (orelse == NULL) - return 0; - } - else - orelse = NULL; - - compiler_use_next_block(c, loop); - if (!compiler_push_fblock(c, WHILE_LOOP, loop, end, NULL)) - return 0; - if (constant == -1) { - if (!compiler_jump_if(c, s->v.While.test, anchor, 0)) - return 0; - } - VISIT_SEQ(c, stmt, s->v.While.body); - ADDOP_JABS(c, JUMP_ABSOLUTE, loop); - - /* XXX should the two POP instructions be in a separate block - if there is no else clause ? - */ - - if (constant == -1) - compiler_use_next_block(c, anchor); - compiler_pop_fblock(c, WHILE_LOOP, loop); - - if (orelse != NULL) /* what if orelse is just pass? */ - VISIT_SEQ(c, stmt, s->v.While.orelse); - compiler_use_next_block(c, end); - - return 1; -} - -static int -compiler_return(struct compiler *c, stmt_ty s) -{ - int preserve_tos = ((s->v.Return.value != NULL) && - (s->v.Return.value->kind != Constant_kind)); - if (c->u->u_ste->ste_type != FunctionBlock) - return compiler_error(c, "'return' outside function"); - if (s->v.Return.value != NULL && - c->u->u_ste->ste_coroutine && c->u->u_ste->ste_generator) - { - return compiler_error( - c, "'return' with value in async generator"); - } - if (preserve_tos) { - VISIT(c, expr, s->v.Return.value); - } - if (!compiler_unwind_fblock_stack(c, preserve_tos, NULL)) - return 0; - if (s->v.Return.value == NULL) { - ADDOP_LOAD_CONST(c, Py_None); - } - else if (!preserve_tos) { - VISIT(c, expr, s->v.Return.value); - } - ADDOP(c, RETURN_VALUE); - - return 1; -} - -static int -compiler_break(struct compiler *c) +compiler_break(struct compiler *c) { struct fblockinfo *loop = NULL; if (!compiler_unwind_fblock_stack(c, 0, &loop)) { @@ -5545,264 +5167,698 @@ compiler_augassign(struct compiler *c, stmt_ty s) return 0; } - c->u->u_lineno = old_lineno; - c->u->u_col_offset = old_col_offset; + c->u->u_lineno = old_lineno; + c->u->u_col_offset = old_col_offset; + + VISIT(c, expr, s->v.AugAssign.value); + ADDOP(c, inplace_binop(s->v.AugAssign.op)); + + SET_LOC(c, e); + + switch (e->kind) { + case Attribute_kind: + ADDOP(c, ROT_TWO); + ADDOP_NAME(c, STORE_ATTR, e->v.Attribute.attr, names); + break; + case Subscript_kind: + ADDOP(c, ROT_THREE); + ADDOP(c, STORE_SUBSCR); + break; + case Name_kind: + return compiler_nameop(c, e->v.Name.id, Store); + default: + Py_UNREACHABLE(); + } + return 1; +} + +static int +check_ann_expr(struct compiler *c, expr_ty e) +{ + VISIT(c, expr, e); + ADDOP(c, POP_TOP); + return 1; +} + +static int +check_annotation(struct compiler *c, stmt_ty s) +{ + /* Annotations are only evaluated in a module or class. */ + if (c->u->u_scope_type == COMPILER_SCOPE_MODULE || + c->u->u_scope_type == COMPILER_SCOPE_CLASS) { + return check_ann_expr(c, s->v.AnnAssign.annotation); + } + return 1; +} + +static int +check_ann_subscr(struct compiler *c, expr_ty e) +{ + /* We check that everything in a subscript is defined at runtime. */ + switch (e->kind) { + case Slice_kind: + if (e->v.Slice.lower && !check_ann_expr(c, e->v.Slice.lower)) { + return 0; + } + if (e->v.Slice.upper && !check_ann_expr(c, e->v.Slice.upper)) { + return 0; + } + if (e->v.Slice.step && !check_ann_expr(c, e->v.Slice.step)) { + return 0; + } + return 1; + case Tuple_kind: { + /* extended slice */ + asdl_seq *elts = e->v.Tuple.elts; + Py_ssize_t i, n = asdl_seq_LEN(elts); + for (i = 0; i < n; i++) { + if (!check_ann_subscr(c, asdl_seq_GET(elts, i))) { + return 0; + } + } + return 1; + } + default: + return check_ann_expr(c, e); + } +} + +static int +compiler_annassign(struct compiler *c, stmt_ty s) +{ + expr_ty targ = s->v.AnnAssign.target; + PyObject* mangled; + + assert(s->kind == AnnAssign_kind); + + /* We perform the actual assignment first. */ + if (s->v.AnnAssign.value) { + VISIT(c, expr, s->v.AnnAssign.value); + VISIT(c, expr, targ); + } + switch (targ->kind) { + case Name_kind: + if (forbidden_name(c, targ->v.Name.id, Store)) + return 0; + /* If we have a simple name in a module or class, store annotation. */ + if (s->v.AnnAssign.simple && + (c->u->u_scope_type == COMPILER_SCOPE_MODULE || + c->u->u_scope_type == COMPILER_SCOPE_CLASS)) { + if (c->c_future->ff_features & CO_FUTURE_ANNOTATIONS) { + VISIT(c, annexpr, s->v.AnnAssign.annotation) + } + else { + VISIT(c, expr, s->v.AnnAssign.annotation); + } + ADDOP_NAME(c, LOAD_NAME, __annotations__, names); + mangled = _Py_Mangle(c->u->u_private, targ->v.Name.id); + ADDOP_LOAD_CONST_NEW(c, mangled); + ADDOP(c, STORE_SUBSCR); + } + break; + case Attribute_kind: + if (forbidden_name(c, targ->v.Attribute.attr, Store)) + return 0; + if (!s->v.AnnAssign.value && + !check_ann_expr(c, targ->v.Attribute.value)) { + return 0; + } + break; + case Subscript_kind: + if (!s->v.AnnAssign.value && + (!check_ann_expr(c, targ->v.Subscript.value) || + !check_ann_subscr(c, targ->v.Subscript.slice))) { + return 0; + } + break; + default: + PyErr_Format(PyExc_SystemError, + "invalid node type (%d) for annotated assignment", + targ->kind); + return 0; + } + /* Annotation is evaluated last. */ + if (!s->v.AnnAssign.simple && !check_annotation(c, s)) { + return 0; + } + return 1; +} + +/* Raises a SyntaxError and returns 0. + If something goes wrong, a different exception may be raised. +*/ + +static int +compiler_error(struct compiler *c, const char *errstr) +{ + PyObject *loc; + PyObject *u = NULL, *v = NULL; + + loc = PyErr_ProgramTextObject(c->c_filename, c->u->u_lineno); + if (!loc) { + Py_INCREF(Py_None); + loc = Py_None; + } + u = Py_BuildValue("(OiiO)", c->c_filename, c->u->u_lineno, + c->u->u_col_offset + 1, loc); + if (!u) + goto exit; + v = Py_BuildValue("(zO)", errstr, u); + if (!v) + goto exit; + PyErr_SetObject(PyExc_SyntaxError, v); + exit: + Py_DECREF(loc); + Py_XDECREF(u); + Py_XDECREF(v); + return 0; +} + +/* Emits a SyntaxWarning and returns 1 on success. + If a SyntaxWarning raised as error, replaces it with a SyntaxError + and returns 0. +*/ +static int +compiler_warn(struct compiler *c, const char *format, ...) +{ + va_list vargs; +#ifdef HAVE_STDARG_PROTOTYPES + va_start(vargs, format); +#else + va_start(vargs); +#endif + PyObject *msg = PyUnicode_FromFormatV(format, vargs); + va_end(vargs); + if (msg == NULL) { + return 0; + } + if (PyErr_WarnExplicitObject(PyExc_SyntaxWarning, msg, c->c_filename, + c->u->u_lineno, NULL, NULL) < 0) + { + if (PyErr_ExceptionMatches(PyExc_SyntaxWarning)) { + /* Replace the SyntaxWarning exception with a SyntaxError + to get a more accurate error report */ + PyErr_Clear(); + assert(PyUnicode_AsUTF8(msg) != NULL); + compiler_error(c, PyUnicode_AsUTF8(msg)); + } + Py_DECREF(msg); + return 0; + } + Py_DECREF(msg); + return 1; +} + +static int +compiler_subscript(struct compiler *c, expr_ty e) +{ + expr_context_ty ctx = e->v.Subscript.ctx; + int op = 0; + + if (ctx == Load) { + if (!check_subscripter(c, e->v.Subscript.value)) { + return 0; + } + if (!check_index(c, e->v.Subscript.value, e->v.Subscript.slice)) { + return 0; + } + } + + switch (ctx) { + case Load: op = BINARY_SUBSCR; break; + case Store: op = STORE_SUBSCR; break; + case Del: op = DELETE_SUBSCR; break; + } + assert(op); + VISIT(c, expr, e->v.Subscript.value); + VISIT(c, expr, e->v.Subscript.slice); + ADDOP(c, op); + return 1; +} + +static int +compiler_slice(struct compiler *c, expr_ty s) +{ + int n = 2; + assert(s->kind == Slice_kind); + + /* only handles the cases where BUILD_SLICE is emitted */ + if (s->v.Slice.lower) { + VISIT(c, expr, s->v.Slice.lower); + } + else { + ADDOP_LOAD_CONST(c, Py_None); + } + + if (s->v.Slice.upper) { + VISIT(c, expr, s->v.Slice.upper); + } + else { + ADDOP_LOAD_CONST(c, Py_None); + } - VISIT(c, expr, s->v.AugAssign.value); - ADDOP(c, inplace_binop(s->v.AugAssign.op)); + if (s->v.Slice.step) { + n++; + VISIT(c, expr, s->v.Slice.step); + } + ADDOP_I(c, BUILD_SLICE, n); + return 1; +} - SET_LOC(c, e); - switch (e->kind) { - case Attribute_kind: - ADDOP(c, ROT_TWO); - ADDOP_NAME(c, STORE_ATTR, e->v.Attribute.attr, names); - break; - case Subscript_kind: - ADDOP(c, ROT_THREE); - ADDOP(c, STORE_SUBSCR); - break; - case Name_kind: - return compiler_nameop(c, e->v.Name.id, Store); - default: - Py_UNREACHABLE(); +// PEP 622: Structural Pattern Matching + +// To keep things simple, all compiler_pattern_* routines follow the convention +// of replacing TOS (the subject for the given pattern) with either True (match) +// or False (no match). We do this even for irrefutable patterns; the idea is +// that it's much easier to smooth out any redundant pushing, popping, and +// jumping in the peephole optimizer than to detect or predict it here. + +// Other than that, go nuts. The PEP intentionally gives us broad freedom to +// take (reasonable) shortcuts - the AST optimization pass in particular is full +// of low-hanging fruit. Please *always* document these with a comment of the +// form "OPTIM: ...", so we can track exactly when and where they're happening. + +// For now, we eschew a full decision tree in favor of a simpler pass that just +// tracks the most-recently-checked subclass and length info for the current +// subject in the pattern_context struct. More complicated strategies are +// possible, but early experimentation suggests that the current approach keeps +// most of the runtime benefits while dramatically reducing compiler complexity. + + +#define WILDCARD_CHECK(N) \ + ((N)->kind == Name_kind && \ + _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) + + +static int +pattern_load(struct compiler *c, expr_ty p, pattern_context pc) +{ + if (p->kind == Attribute_kind) { + assert(p->v.Attribute.ctx == Load); + CHECK(pattern_load(c, p->v.Attribute.value, pc)); + ADDOP_NAME(c, LOAD_ATTR, p->v.Attribute.attr, names); + } + else if (p->kind == Name_kind) { + assert(p->v.Name.ctx == Load); + CHECK(compiler_nameop(c, p->v.Name.id, Load)); + } + else { + assert(p->kind == Constant_kind); + ADDOP_LOAD_CONST(c, p->v.Constant.value); } return 1; } + static int -check_ann_expr(struct compiler *c, expr_ty e) -{ - VISIT(c, expr, e); - ADDOP(c, POP_TOP); +pattern_store(struct compiler *c, expr_ty p, pattern_context pc) { + assert(p->kind == Name_kind); + assert(p->v.Name.ctx == Store); + if (WILDCARD_CHECK(p)) { + return compiler_error(c, + "can't assign to '_' here; consider removing or renaming?"); + } + if (PySet_Contains(pc.stores, p->v.Name.id)) { + // TODO: Format this error message with the name. + return compiler_error(c, "multiple assignments to name in pattern"); + } + CHECK(!PySet_Add(pc.stores, p->v.Name.id)); + CHECK(compiler_nameop(c, p->v.Name.id, Store)); return 1; } + static int -check_annotation(struct compiler *c, stmt_ty s) +compiler_pattern_attribute(struct compiler *c, expr_ty p, pattern_context pc) { - /* Annotations are only evaluated in a module or class. */ - if (c->u->u_scope_type == COMPILER_SCOPE_MODULE || - c->u->u_scope_type == COMPILER_SCOPE_CLASS) { - return check_ann_expr(c, s->v.AnnAssign.annotation); - } + assert(p->kind == Attribute_kind); + assert(p->v.Attribute.ctx == Load); + CHECK(pattern_load(c, p, pc)); + ADDOP_COMPARE(c, Eq); return 1; } + static int -check_ann_subscr(struct compiler *c, expr_ty e) +compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context pc) { - /* We check that everything in a subscript is defined at runtime. */ - switch (e->kind) { - case Slice_kind: - if (e->v.Slice.lower && !check_ann_expr(c, e->v.Slice.lower)) { - return 0; - } - if (e->v.Slice.upper && !check_ann_expr(c, e->v.Slice.upper)) { - return 0; - } - if (e->v.Slice.step && !check_ann_expr(c, e->v.Slice.step)) { - return 0; + assert(p->kind == BoolOp_kind); + assert(p->v.BoolOp.op == Or); + basicblock *end; + PyObject *control = NULL; + CHECK(end = compiler_new_block(c)); + Py_ssize_t size = asdl_seq_LEN(p->v.BoolOp.values); + assert(size > 1); + PyObject *names_copy; + for (Py_ssize_t i = 0; i < size; i++) { + CHECK(names_copy = PySet_New(pc.stores)); + ADDOP(c, DUP_TOP); + // TODO: Just modify pc instead. + pattern_context sub_pc = pc; + sub_pc.stores = names_copy; + CHECK(compiler_pattern(c, asdl_seq_GET(p->v.BoolOp.values, i), sub_pc)); + ADDOP_JABS(c, JUMP_IF_TRUE_OR_POP, end); + // TODO: Reuse names_copy without actually building a new copy each loop? + if (!i) { + control = names_copy; } - return 1; - case Tuple_kind: { - /* extended slice */ - asdl_seq *elts = e->v.Tuple.elts; - Py_ssize_t i, n = asdl_seq_LEN(elts); - for (i = 0; i < n; i++) { - if (!check_ann_subscr(c, asdl_seq_GET(elts, i))) { + else if (PySet_GET_SIZE(control) || PySet_GET_SIZE(names_copy)) { + PyObject *diff = PyNumber_InPlaceXor(names_copy, control); + if (!diff) { + Py_DECREF(control); return 0; } + Py_DECREF(names_copy); + if (PySet_GET_SIZE(diff)) { + // TODO: Format this error message with a name. + // PyObject *extra = PySet_Pop(diff); + Py_DECREF(control); + Py_DECREF(diff); + // TODO: Catch this during store. + return compiler_error(c, "pattern binds different names based on target"); + } + Py_DECREF(diff); + } + else { + Py_DECREF(names_copy); } - return 1; } - default: - return check_ann_expr(c, e); + assert(control); + Py_DECREF(control); + ADDOP_LOAD_CONST(c, Py_False); + compiler_use_next_block(c, end); + ADDOP(c, ROT_TWO); + ADDOP(c, POP_TOP); + return 1; +} + + +static int +compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context pc) { + asdl_seq *args = p->v.Call.args; + asdl_seq *kwargs = p->v.Call.keywords; + Py_ssize_t nargs = asdl_seq_LEN(args); + Py_ssize_t nkwargs = asdl_seq_LEN(kwargs); + basicblock *block, *end; + CHECK(!validate_keywords(c, kwargs)); + CHECK(block = compiler_new_block(c)); + CHECK(end = compiler_new_block(c)); + CHECK(pattern_load(c, p->v.Call.func, pc)); + PyObject *kwnames, *name; + CHECK(kwnames = PyTuple_New(nkwargs)); + Py_ssize_t i; + for (i = 0; i < nkwargs; i++) { + name = ((keyword_ty) asdl_seq_GET(kwargs, i))->arg; + Py_INCREF(name); + PyTuple_SET_ITEM(kwnames, i, name); + } + ADDOP_LOAD_CONST_NEW(c, kwnames); + ADDOP_I(c, MATCH_CLASS, nargs); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); + expr_ty arg; + for (i = 0; i < nargs + nkwargs; i++) { + if (i < nargs) { + arg = asdl_seq_GET(args, i); + } + else { + arg = ((keyword_ty) asdl_seq_GET(kwargs, i - nargs))->value; + } + if (WILDCARD_CHECK(arg)) { + continue; + } + // TODO: Validate arg: + ADDOP_I(c, MATCH_ITEM, i); + CHECK(compiler_pattern(c, arg, pc)); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } + ADDOP_LOAD_CONST(c, Py_True); + compiler_use_next_block(c, end); + ADDOP(c, ROT_TWO); + ADDOP(c, POP_TOP); + return 1; } + static int -compiler_annassign(struct compiler *c, stmt_ty s) +compiler_pattern_constant(struct compiler *c, expr_ty p, pattern_context pc) { - expr_ty targ = s->v.AnnAssign.target; - PyObject* mangled; + assert(p->kind == Constant_kind); + ADDOP_LOAD_CONST(c, p->v.Constant.value); + ADDOP_COMPARE(c, Eq); + return 1; +} - assert(s->kind == AnnAssign_kind); - /* We perform the actual assignment first. */ - if (s->v.AnnAssign.value) { - VISIT(c, expr, s->v.AnnAssign.value); - VISIT(c, expr, targ); +static int +compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context pc) +{ + basicblock *block, *end; + CHECK(block = compiler_new_block(c)); + CHECK(end = compiler_new_block(c)); + asdl_seq *keys = p->v.Dict.keys; + asdl_seq *values = p->v.Dict.values; + Py_ssize_t size = asdl_seq_LEN(values); + int star = size ? !asdl_seq_GET(keys, size - 1) : 0; + ADDOP(c, MATCH_MAPPING); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); + if (size - star) { + ADDOP(c, GET_LEN); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - star)); + ADDOP_COMPARE(c, GtE); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); } - switch (targ->kind) { - case Name_kind: - if (forbidden_name(c, targ->v.Name.id, Store)) - return 0; - /* If we have a simple name in a module or class, store annotation. */ - if (s->v.AnnAssign.simple && - (c->u->u_scope_type == COMPILER_SCOPE_MODULE || - c->u->u_scope_type == COMPILER_SCOPE_CLASS)) { - if (c->c_future->ff_features & CO_FUTURE_ANNOTATIONS) { - VISIT(c, annexpr, s->v.AnnAssign.annotation) - } - else { - VISIT(c, expr, s->v.AnnAssign.annotation); - } - ADDOP_NAME(c, LOAD_NAME, __annotations__, names); - mangled = _Py_Mangle(c->u->u_private, targ->v.Name.id); - ADDOP_LOAD_CONST_NEW(c, mangled); - ADDOP(c, STORE_SUBSCR); - } - break; - case Attribute_kind: - if (forbidden_name(c, targ->v.Attribute.attr, Store)) - return 0; - if (!s->v.AnnAssign.value && - !check_ann_expr(c, targ->v.Attribute.value)) { - return 0; + Py_ssize_t i; + for (i = 0; i < size - star; i++) { + expr_ty key = asdl_seq_GET(keys, i); + if (!key) { + return compiler_error(c, "can't use starred pattern here; consider moving to end?"); } - break; - case Subscript_kind: - if (!s->v.AnnAssign.value && - (!check_ann_expr(c, targ->v.Subscript.value) || - !check_ann_subscr(c, targ->v.Subscript.slice))) { - return 0; + CHECK(pattern_load(c, key, pc)); + } + ADDOP_I(c, BUILD_TUPLE, size - star); + ADDOP_I(c, MATCH_KEYS, star); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + for (i = 0; i < size - star; i++) { + expr_ty value = asdl_seq_GET(values, i); + if (WILDCARD_CHECK(value)) { + continue; } - break; - default: - PyErr_Format(PyExc_SystemError, - "invalid node type (%d) for annotated assignment", - targ->kind); - return 0; + // TODO: Validate arg; + ADDOP_I(c, MATCH_ITEM, i); + CHECK(compiler_pattern(c, value, pc)); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); } - /* Annotation is evaluated last. */ - if (!s->v.AnnAssign.simple && !check_annotation(c, s)) { - return 0; + ADDOP(c, POP_TOP); + if (star) { + CHECK(pattern_store(c, asdl_seq_GET(values, size - 1), pc)); + } + else { + ADDOP(c, POP_TOP); } + ADDOP_LOAD_CONST(c, Py_True); + ADDOP_JREL(c, JUMP_FORWARD, end); + compiler_use_next_block(c, block); + ADDOP(c, POP_TOP); + ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_False); + compiler_use_next_block(c, end); return 1; } -/* Raises a SyntaxError and returns 0. - If something goes wrong, a different exception may be raised. -*/ static int -compiler_error(struct compiler *c, const char *errstr) +compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context pc) { - PyObject *loc; - PyObject *u = NULL, *v = NULL; - - loc = PyErr_ProgramTextObject(c->c_filename, c->u->u_lineno); - if (!loc) { - Py_INCREF(Py_None); - loc = Py_None; + assert(p->kind == List_kind || p->kind == Tuple_kind); + asdl_seq *values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; + Py_ssize_t size = asdl_seq_LEN(values); + Py_ssize_t star = -1; + for (Py_ssize_t i = 0; i < size; i++) { + expr_ty value = asdl_seq_GET(values, i); + if (value->kind != Starred_kind) { + continue; + } + if (star >= 0) { + return compiler_error(c, "multiple starred names in pattern"); + } + star = i; } - u = Py_BuildValue("(OiiO)", c->c_filename, c->u->u_lineno, - c->u->u_col_offset + 1, loc); - if (!u) - goto exit; - v = Py_BuildValue("(zO)", errstr, u); - if (!v) - goto exit; - PyErr_SetObject(PyExc_SyntaxError, v); - exit: - Py_DECREF(loc); - Py_XDECREF(u); - Py_XDECREF(v); - return 0; -} - -/* Emits a SyntaxWarning and returns 1 on success. - If a SyntaxWarning raised as error, replaces it with a SyntaxError - and returns 0. -*/ -static int -compiler_warn(struct compiler *c, const char *format, ...) -{ - va_list vargs; -#ifdef HAVE_STDARG_PROTOTYPES - va_start(vargs, format); -#else - va_start(vargs); -#endif - PyObject *msg = PyUnicode_FromFormatV(format, vargs); - va_end(vargs); - if (msg == NULL) { - return 0; + basicblock *block, *end; + CHECK(block = compiler_new_block(c)); + CHECK(end = compiler_new_block(c)); + ADDOP(c, MATCH_SEQUENCE); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); + ADDOP(c, GET_LEN); + if (star < 0) { + ADDOP(c, DUP_TOP); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)); + ADDOP_COMPARE(c, Eq); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); } - if (PyErr_WarnExplicitObject(PyExc_SyntaxWarning, msg, c->c_filename, - c->u->u_lineno, NULL, NULL) < 0) - { - if (PyErr_ExceptionMatches(PyExc_SyntaxWarning)) { - /* Replace the SyntaxWarning exception with a SyntaxError - to get a more accurate error report */ - PyErr_Clear(); - assert(PyUnicode_AsUTF8(msg) != NULL); - compiler_error(c, PyUnicode_AsUTF8(msg)); + else if (size) { + ADDOP(c, DUP_TOP); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - 1)); + ADDOP_COMPARE(c, GtE); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); + } + ADDOP(c, ROT_TWO); + for (Py_ssize_t i = 0; i < size; i++) { + // TODO: Raise for invalid sizes to MATCH_ITEM* opcodes. + expr_ty value = asdl_seq_GET(values, i); + if (WILDCARD_CHECK(value)) { + continue; } - Py_DECREF(msg); - return 0; + if (star < 0 || i < star) { + ADDOP_I(c, MATCH_ITEM, i); + } + else if (i == star) { + assert(value->kind == Starred_kind); + value = value->v.Starred.value; + if (WILDCARD_CHECK(value)) { + continue; + } + ADDOP_I(c, MATCH_ITEM_SLICE, ((size - 1 - i) << 8) + i); + } + else { + ADDOP_I(c, MATCH_ITEM_END, size - 1 - i); + } + CHECK(compiler_pattern(c, value, pc)); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); } - Py_DECREF(msg); + ADDOP_LOAD_CONST(c, Py_True); + compiler_use_next_block(c, block); + ADDOP(c, ROT_TWO); + ADDOP(c, POP_TOP); + compiler_use_next_block(c, end); + ADDOP(c, ROT_TWO); + ADDOP(c, POP_TOP); return 1; } + static int -compiler_subscript(struct compiler *c, expr_ty e) +compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context pc) { - expr_context_ty ctx = e->v.Subscript.ctx; - int op = 0; - - if (ctx == Load) { - if (!check_subscripter(c, e->v.Subscript.value)) { - return 0; - } - if (!check_index(c, e->v.Subscript.value, e->v.Subscript.slice)) { - return 0; - } + assert(p->kind == Name_kind); + assert(p->v.Name.ctx == Store); + if (WILDCARD_CHECK(p)) { + ADDOP(c, POP_TOP); } - - switch (ctx) { - case Load: op = BINARY_SUBSCR; break; - case Store: op = STORE_SUBSCR; break; - case Del: op = DELETE_SUBSCR; break; + else { + CHECK(pattern_store(c, p, pc)); } - assert(op); - VISIT(c, expr, e->v.Subscript.value); - VISIT(c, expr, e->v.Subscript.slice); - ADDOP(c, op); + ADDOP_LOAD_CONST(c, Py_True); return 1; } + static int -compiler_slice(struct compiler *c, expr_ty s) +compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context pc) { - int n = 2; - assert(s->kind == Slice_kind); + assert(p->kind == NamedExpr_kind); + basicblock *block, *end; + CHECK(block = compiler_new_block(c)); + CHECK(end = compiler_new_block(c)); + ADDOP(c, DUP_TOP); + CHECK(compiler_pattern(c, p->v.NamedExpr.value, pc)); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); + CHECK(pattern_store(c, p->v.NamedExpr.target, pc)); + ADDOP_LOAD_CONST(c, Py_True); + ADDOP_JREL(c, JUMP_FORWARD, end); + compiler_use_next_block(c, block); + ADDOP(c, ROT_TWO); + ADDOP(c, POP_TOP); + compiler_use_next_block(c, end); + return 1; +} - /* only handles the cases where BUILD_SLICE is emitted */ - if (s->v.Slice.lower) { - VISIT(c, expr, s->v.Slice.lower); - } - else { - ADDOP_LOAD_CONST(c, Py_None); - } - if (s->v.Slice.upper) { - VISIT(c, expr, s->v.Slice.upper); - } - else { - ADDOP_LOAD_CONST(c, Py_None); +static int +compiler_pattern(struct compiler *c, expr_ty p, pattern_context pc) +{ + SET_LOC(c, p); + switch (p->kind) { + case Attribute_kind: + return compiler_pattern_attribute(c, p, pc); + case BinOp_kind: + // Because we allow "2+2j", things like "2+2" make it this far: + return compiler_error(c, "patterns cannot include operators"); + case BoolOp_kind: + return compiler_pattern_boolop(c, p, pc); + case Call_kind: + return compiler_pattern_call(c, p, pc); + case Constant_kind: + return compiler_pattern_constant(c, p, pc); + case Dict_kind: + return compiler_pattern_dict(c, p, pc); + case JoinedStr_kind: + // Because we allow strings, f-strings make it this far: + return compiler_error(c, "patterns cannot include f-strings"); + case List_kind: + case Tuple_kind: + return compiler_pattern_list_tuple(c, p, pc); + case Name_kind: + return compiler_pattern_name(c, p, pc); + case NamedExpr_kind: + return compiler_pattern_namedexpr(c, p, pc); + default: + Py_UNREACHABLE(); } +} - if (s->v.Slice.step) { - n++; - VISIT(c, expr, s->v.Slice.step); + +static int +compiler_match(struct compiler *c, stmt_ty s) +{ + VISIT(c, expr, s->v.Match.target); + basicblock *next, *end; + CHECK(end = compiler_new_block(c)); + Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); + assert(cases); + pattern_context pc; + int last = 0, result; + match_case_ty m; + for (Py_ssize_t i = 0; i < cases; i++) { + if (i == cases - 1) { + last = 1; + } + m = asdl_seq_GET(s->v.Match.cases, i); + SET_LOC(c, m->pattern); + CHECK(next = compiler_new_block(c)); + if (!last) { + ADDOP(c, DUP_TOP); + } + // TODO: Set pc.stores lazily. + CHECK(pc.stores = PySet_New(NULL)); + result = compiler_pattern(c, m->pattern, pc); + Py_DECREF(pc.stores); + CHECK(result); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, next); + if (m->guard) { + CHECK(compiler_jump_if(c, m->guard, next, 0)); + } + if (!last) { + ADDOP(c, POP_TOP); + } + VISIT_SEQ(c, stmt, m->body); + if (!last) { + ADDOP_JREL(c, JUMP_FORWARD, end); + } + compiler_use_next_block(c, next); + if (m->pattern->kind == Name_kind && m->pattern->v.Name.ctx == Store + && !m->guard && !last) + { + CHECK(compiler_warn(c, "unguarded name capture pattern makes " + "remaining cases unreachable")); + break; + } } - ADDOP_I(c, BUILD_SLICE, n); + compiler_use_next_block(c, end); return 1; } + /* End of the compiler section, beginning of the assembler section */ /* do depth-first search of basic block graph, starting with block. From b0a02f510bbdfe1c45c670422817369874e911dc Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 12 Jul 2020 14:14:36 -0700 Subject: [PATCH 127/189] Generalize conditional jump peepholing --- Python/peephole.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Python/peephole.c b/Python/peephole.c index fe67de42227b5b..1d9c170fed367e 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -15,7 +15,12 @@ #define ABSOLUTE_JUMP(op) (op==JUMP_ABSOLUTE \ || op==POP_JUMP_IF_FALSE || op==POP_JUMP_IF_TRUE \ || op==JUMP_IF_FALSE_OR_POP || op==JUMP_IF_TRUE_OR_POP || op==JUMP_IF_NOT_EXC_MATCH) +#define JUMPS_ON_FALSE(op) (op==POP_JUMP_IF_FALSE || op==JUMP_IF_FALSE_OR_POP) #define JUMPS_ON_TRUE(op) (op==POP_JUMP_IF_TRUE || op==JUMP_IF_TRUE_OR_POP) +#define POPS_ON_FALSE(op) (op==POP_JUMP_IF_TRUE || op==POP_JUMP_IF_FALSE \ + || op==JUMP_IF_TRUE_OR_POP) +#define POPS_ON_TRUE(op) (op==POP_JUMP_IF_TRUE || op==POP_JUMP_IF_FALSE \ + || op==JUMP_IF_FALSE_OR_POP) #define GETJUMPTGT(arr, i) (get_arg(arr, i) / sizeof(_Py_CODEUNIT) + \ (ABSOLUTE_JUMP(_Py_OPCODE(arr[i])) ? 0 : i+1)) #define ISBASICBLOCK(blocks, start, end) \ @@ -299,12 +304,10 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, cumlc = 0; switch (opcode) { - /* Skip over LOAD_CONST trueconst - POP_JUMP_IF_FALSE xx. This improves - "while 1" performance. */ + // Fold LOAD_CONST followed by conditional jumping/popping: case LOAD_CONST: cumlc = lastlc + 1; - if (nextop != POP_JUMP_IF_FALSE || + if (!(JUMPS_ON_FALSE(nextop) || JUMPS_ON_TRUE(nextop)) || !ISBASICBLOCK(blocks, op_start, i + 1)) { break; } @@ -313,9 +316,11 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, if (is_true == -1) { goto exitError; } - if (is_true == 1) { - fill_nops(codestr, op_start, nexti + 1); - cumlc = 0; + int jump = JUMPS_ON_TRUE(nextop) == is_true; + int pop = is_true ? POPS_ON_TRUE(nextop) : POPS_ON_FALSE(nextop); + fill_nops(codestr, pop ? op_start : i + 1, (jump ? i : nexti) + 1); + if (jump) { + codestr[nexti] = PACKOPARG(JUMP_ABSOLUTE, _Py_OPARG(codestr[nexti])); } break; From da6ee98e817e7c6378207c9de6fe5b1ba98da20d Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 12 Jul 2020 14:14:58 -0700 Subject: [PATCH 128/189] MATCH_ITEM* -> GET_INDEX* --- Doc/library/dis.rst | 26 ++++++++++----------- Include/opcode.h | 10 ++++---- Lib/importlib/_bootstrap_external.py | 4 ++-- Lib/opcode.py | 10 ++++---- Lib/test/test_dis.py | 34 +++++++++++++--------------- Python/ceval.c | 6 ++--- Python/compile.c | 31 +++++++++++++------------ Python/importlib_external.h | 2 +- Python/opcode_targets.h | 6 ++--- 9 files changed, 65 insertions(+), 64 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index f07742f5c07cf4..6567c5a35bec14 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1213,40 +1213,40 @@ All of the following opcodes use their arguments. .. versionadded:: 3.6 -.. opcode:: MATCH_CLASS (count) +.. opcode:: GET_INDEX (i) - TODO + TOS is a sequence. Push ``TOS[i]`` onto the stack. .. versionadded:: 3.10 -.. opcode:: MATCH_KEYS (copy) +.. opcode:: GET_INDEX_END (i) - TODO + TOS is a sequence, and TOS1 is its length. Push ``TOS[TOS1 - 1 - i]`` onto + the stack. .. versionadded:: 3.10 -.. opcode:: MATCH_ITEM (i) +.. opcode:: GET_INDEX_SLICE (i) - TOS is a sequence. Push ``TOS[i]`` onto the stack. + TOS is a sequence, and TOS1 is its length. Push a list formed from + ``TOS[x:TOS1 - 1 - y]`` onto the stack, where *x* is the low byte of *i* and + *y* is the high bytes of *i*. .. versionadded:: 3.10 -.. opcode:: MATCH_ITEM_END (i) +.. opcode:: MATCH_CLASS (count) - TOS is a sequence, and TOS1 is its length. Push ``TOS[TOS1 - 1 - i]`` onto - the stack. + TODO .. versionadded:: 3.10 -.. opcode:: MATCH_ITEM_SLICE (i) +.. opcode:: MATCH_KEYS (copy) - TOS is a sequence, and TOS1 is its length. Push a list formed from - ``TOS[x:TOS1 - 1 - y]`` onto the stack, where *x* is the low byte of *i* and - *y* is the high bytes of *i*. + TODO .. versionadded:: 3.10 diff --git a/Include/opcode.h b/Include/opcode.h index db4da0bfad8ef5..2e978e25dfc9fc 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -120,11 +120,11 @@ extern "C" { #define SET_ADD 146 #define MAP_ADD 147 #define LOAD_CLASSDEREF 148 -#define MATCH_CLASS 149 -#define MATCH_KEYS 150 -#define MATCH_ITEM 151 -#define MATCH_ITEM_END 152 -#define MATCH_ITEM_SLICE 153 +#define GET_INDEX 149 +#define GET_INDEX_END 150 +#define GET_INDEX_SLICE 151 +#define MATCH_CLASS 152 +#define MATCH_KEYS 153 #define SETUP_ASYNC_WITH 154 #define FORMAT_VALUE 155 #define BUILD_CONST_KEY_MAP 156 diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 299583fdd5f593..df709f1a6ec770 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -277,7 +277,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3423 (add IS_OP, CONTAINS_OP and JUMP_IF_NOT_EXC_MATCH bytecodes #39156) # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) -# Python 3.10a0 3466 (add structural pattern matching) +# Python 3.10a0 3467 (add structural pattern matching) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -287,7 +287,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3466).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3467).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index fb68736fa03155..5a4474bb82a7b4 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -195,11 +195,11 @@ def jabs_op(name, op): def_op('MAP_ADD', 147) def_op('LOAD_CLASSDEREF', 148) hasfree.append(148) -def_op('MATCH_CLASS', 149) -def_op('MATCH_KEYS', 150) -def_op('MATCH_ITEM', 151) -def_op('MATCH_ITEM_END', 152) -def_op('MATCH_ITEM_SLICE', 153) +def_op('GET_INDEX', 149) +def_op('GET_INDEX_END', 150) +def_op('GET_INDEX_SLICE', 151) +def_op('MATCH_CLASS', 152) +def_op('MATCH_KEYS', 153) jrel_op('SETUP_ASYNC_WITH', 154) def_op('FORMAT_VALUE', 155) def_op('BUILD_CONST_KEY_MAP', 156) diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index ac5836d288978c..9c761e5a42260b 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -145,24 +145,22 @@ def bug1333982(x=[]): pass dis_bug1333982 = """\ -%3d 0 LOAD_CONST 1 (0) - 2 POP_JUMP_IF_TRUE 26 - 4 LOAD_ASSERTION_ERROR - 6 LOAD_CONST 2 ( at 0x..., file "%s", line %d>) - 8 LOAD_CONST 3 ('bug1333982..') - 10 MAKE_FUNCTION 0 - 12 LOAD_FAST 0 (x) - 14 GET_ITER - 16 CALL_FUNCTION 1 - -%3d 18 LOAD_CONST 4 (1) - -%3d 20 BINARY_ADD - 22 CALL_FUNCTION 1 - 24 RAISE_VARARGS 1 - -%3d >> 26 LOAD_CONST 0 (None) - 28 RETURN_VALUE +%3d 0 LOAD_ASSERTION_ERROR + 2 LOAD_CONST 2 ( at 0x..., file "%s", line %d>) + 4 LOAD_CONST 3 ('bug1333982..') + 6 MAKE_FUNCTION 0 + 8 LOAD_FAST 0 (x) + 10 GET_ITER + 12 CALL_FUNCTION 1 + +%3d 14 LOAD_CONST 4 (1) + +%3d 16 BINARY_ADD + 18 CALL_FUNCTION 1 + 20 RAISE_VARARGS 1 + +%3d 22 LOAD_CONST 0 (None) + 24 RETURN_VALUE """ % (bug1333982.__code__.co_firstlineno + 1, __file__, bug1333982.__code__.co_firstlineno + 1, diff --git a/Python/ceval.c b/Python/ceval.c index 3deac496908c80..91d9c00fea0f48 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3633,7 +3633,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(MATCH_ITEM): { + case TARGET(GET_INDEX): { PyObject *item = PySequence_GetItem(TOP(), oparg); if (!item) { goto error; @@ -3642,7 +3642,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(MATCH_ITEM_END): { + case TARGET(GET_INDEX_END): { Py_ssize_t len = PyLong_AsSsize_t(SECOND()); if (len < 0) { goto error; @@ -3656,7 +3656,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } - case TARGET(MATCH_ITEM_SLICE): { + case TARGET(GET_INDEX_SLICE): { Py_ssize_t len = PyLong_AsSsize_t(SECOND()); if (len < 0) { goto error; diff --git a/Python/compile.c b/Python/compile.c index aab9f514ba5577..14927170195924 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1110,9 +1110,9 @@ stack_effect(int opcode, int oparg, int jump) return 1; case MATCH_CLASS: return -1; - case MATCH_ITEM: - case MATCH_ITEM_END: - case MATCH_ITEM_SLICE: + case GET_INDEX: + case GET_INDEX_END: + case GET_INDEX_SLICE: case MATCH_KEYS: case MATCH_MAPPING: case MATCH_SEQUENCE: @@ -5441,9 +5441,9 @@ compiler_slice(struct compiler *c, expr_ty s) // For now, we eschew a full decision tree in favor of a simpler pass that just // tracks the most-recently-checked subclass and length info for the current -// subject in the pattern_context struct. More complicated strategies are -// possible, but early experimentation suggests that the current approach keeps -// most of the runtime benefits while dramatically reducing compiler complexity. +// subject in the pattern_context struct. Experimentation suggests that the +// current approach keeps most of the runtime benefits while dramatically +// reducing compiler complexity. #define WILDCARD_CHECK(N) \ @@ -5511,6 +5511,7 @@ compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context pc) Py_ssize_t size = asdl_seq_LEN(p->v.BoolOp.values); assert(size > 1); PyObject *names_copy; + // TODO: Leaks sets. for (Py_ssize_t i = 0; i < size; i++) { CHECK(names_copy = PySet_New(pc.stores)); ADDOP(c, DUP_TOP); @@ -5560,6 +5561,9 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context pc) { asdl_seq *kwargs = p->v.Call.keywords; Py_ssize_t nargs = asdl_seq_LEN(args); Py_ssize_t nkwargs = asdl_seq_LEN(kwargs); + if (nargs + nkwargs > INT_MAX) { + return compiler_error(c, "too many sub-patterns in class pattern"); + } basicblock *block, *end; CHECK(!validate_keywords(c, kwargs)); CHECK(block = compiler_new_block(c)); @@ -5587,8 +5591,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context pc) { if (WILDCARD_CHECK(arg)) { continue; } - // TODO: Validate arg: - ADDOP_I(c, MATCH_ITEM, i); + ADDOP_I(c, GET_INDEX, i); CHECK(compiler_pattern(c, arg, pc)); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } @@ -5620,6 +5623,7 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context pc) asdl_seq *values = p->v.Dict.values; Py_ssize_t size = asdl_seq_LEN(values); int star = size ? !asdl_seq_GET(keys, size - 1) : 0; + // TODO :(i >= (1 << 8)) || (n-i-1 >= (INT_MAX >> 8)) ADDOP(c, MATCH_MAPPING); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); if (size - star) { @@ -5644,8 +5648,7 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context pc) if (WILDCARD_CHECK(value)) { continue; } - // TODO: Validate arg; - ADDOP_I(c, MATCH_ITEM, i); + ADDOP_I(c, GET_INDEX, i); CHECK(compiler_pattern(c, value, pc)); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); } @@ -5704,13 +5707,13 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context pc) } ADDOP(c, ROT_TWO); for (Py_ssize_t i = 0; i < size; i++) { - // TODO: Raise for invalid sizes to MATCH_ITEM* opcodes. + // TODO :(i >= (1 << 8)) || (n-i-1 >= (INT_MAX >> 8)) expr_ty value = asdl_seq_GET(values, i); if (WILDCARD_CHECK(value)) { continue; } if (star < 0 || i < star) { - ADDOP_I(c, MATCH_ITEM, i); + ADDOP_I(c, GET_INDEX, i); } else if (i == star) { assert(value->kind == Starred_kind); @@ -5718,10 +5721,10 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context pc) if (WILDCARD_CHECK(value)) { continue; } - ADDOP_I(c, MATCH_ITEM_SLICE, ((size - 1 - i) << 8) + i); + ADDOP_I(c, GET_INDEX_SLICE, ((size - 1 - i) << 8) + i); } else { - ADDOP_I(c, MATCH_ITEM_END, size - 1 - i); + ADDOP_I(c, GET_INDEX_END, size - 1 - i); } CHECK(compiler_pattern(c, value, pc)); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); diff --git a/Python/importlib_external.h b/Python/importlib_external.h index e52b9111c5519f..23f0bb69338368 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -286,7 +286,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,97,116,111,109,105,99,120,0,0,0,115,28,0,0, 0,0,5,16,1,6,1,22,255,4,2,2,3,14,1,40, 1,16,1,12,1,2,1,14,1,12,1,6,1,114,69,0, - 0,0,105,138,13,0,0,114,28,0,0,0,114,17,0,0, + 0,0,105,139,13,0,0,114,28,0,0,0,114,17,0,0, 0,115,2,0,0,0,13,10,90,11,95,95,112,121,99,97, 99,104,101,95,95,122,4,111,112,116,45,122,3,46,112,121, 122,4,46,112,121,99,78,41,1,218,12,111,112,116,105,109, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 4febf772d76a52..70be8acaec99e0 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -148,11 +148,11 @@ static void *opcode_targets[256] = { &&TARGET_SET_ADD, &&TARGET_MAP_ADD, &&TARGET_LOAD_CLASSDEREF, + &&TARGET_GET_INDEX, + &&TARGET_GET_INDEX_END, + &&TARGET_GET_INDEX_SLICE, &&TARGET_MATCH_CLASS, &&TARGET_MATCH_KEYS, - &&TARGET_MATCH_ITEM, - &&TARGET_MATCH_ITEM_END, - &&TARGET_MATCH_ITEM_SLICE, &&TARGET_SETUP_ASYNC_WITH, &&TARGET_FORMAT_VALUE, &&TARGET_BUILD_CONST_KEY_MAP, From 3eda95e045a3a304acf8f1b6d34e715f9abaa820 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 12 Jul 2020 14:56:38 -0700 Subject: [PATCH 129/189] Revert old unparse hack --- Lib/ast.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Lib/ast.py b/Lib/ast.py index aecbd013c0af07..1085326b4a26b7 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -1350,11 +1350,8 @@ def increasing_level_traverse(node): self.interleave(lambda: self.write(s), increasing_level_traverse, node.values) def visit_Attribute(self, node): - if self.in_pattern() and isinstance(node.value, Name): - self.write(node.value.id) - else: - self.set_precedence(_Precedence.ATOM, node.value) - self.traverse(node.value) + self.set_precedence(_Precedence.ATOM, node.value) + self.traverse(node.value) # Special case: 3.__abs__() is a syntax error, so if node.value # is an integer literal then we need to either parenthesize # it or add an extra space to get 3 .__abs__(). From b3840befa23f29a6f4b5e62a2e4a277d56a55033 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 12 Jul 2020 16:24:15 -0700 Subject: [PATCH 130/189] Improve performance for wildcards --- Python/compile.c | 34 ++++++++++++++++++++-------------- Python/peephole.c | 11 +++++++++-- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 14927170195924..7777f87d5c3d3e 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5447,7 +5447,7 @@ compiler_slice(struct compiler *c, expr_ty s) #define WILDCARD_CHECK(N) \ - ((N)->kind == Name_kind && \ + ((N)->kind == Name_kind && \ _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) @@ -5607,7 +5607,7 @@ static int compiler_pattern_constant(struct compiler *c, expr_ty p, pattern_context pc) { assert(p->kind == Constant_kind); - ADDOP_LOAD_CONST(c, p->v.Constant.value); + CHECK(pattern_load(c, p, pc)); ADDOP_COMPARE(c, Eq); return 1; } @@ -5820,12 +5820,11 @@ compiler_match(struct compiler *c, stmt_ty s) Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); assert(cases); pattern_context pc; - int last = 0, result; - match_case_ty m; - for (Py_ssize_t i = 0; i < cases; i++) { - if (i == cases - 1) { - last = 1; - } + int last, result; + match_case_ty m = asdl_seq_GET(s->v.Match.cases, cases - 1); + int has_default = WILDCARD_CHECK(m->pattern); + for (Py_ssize_t i = 0; i < cases - has_default; i++) { + last = i == cases - 1 - has_default; m = asdl_seq_GET(s->v.Match.cases, i); SET_LOC(c, m->pattern); CHECK(next = compiler_new_block(c)); @@ -5845,18 +5844,25 @@ compiler_match(struct compiler *c, stmt_ty s) ADDOP(c, POP_TOP); } VISIT_SEQ(c, stmt, m->body); - if (!last) { - ADDOP_JREL(c, JUMP_FORWARD, end); - } + ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, next); - if (m->pattern->kind == Name_kind && m->pattern->v.Name.ctx == Store - && !m->guard && !last) + if (!m->guard && m->pattern->kind == Name_kind && + m->pattern->v.Name.ctx == Store && i != cases - 1) { CHECK(compiler_warn(c, "unguarded name capture pattern makes " "remaining cases unreachable")); - break; } } + if (has_default) { + if (cases == 1) { + ADDOP(c, POP_TOP); + } + m = asdl_seq_GET(s->v.Match.cases, cases - 1); + if (m->guard) { + CHECK(compiler_jump_if(c, m->guard, end, 0)); + } + VISIT_SEQ(c, stmt, m->body); + } compiler_use_next_block(c, end); return 1; } diff --git a/Python/peephole.c b/Python/peephole.c index 1d9c170fed367e..2e5c0436d5385d 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -304,9 +304,9 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, cumlc = 0; switch (opcode) { - // Fold LOAD_CONST followed by conditional jumping/popping: + // Simplify LOAD_CONST followed by conditional jumping/popping: case LOAD_CONST: - cumlc = lastlc + 1; + cumlc = lastlc + 1; // TODO? if (!(JUMPS_ON_FALSE(nextop) || JUMPS_ON_TRUE(nextop)) || !ISBASICBLOCK(blocks, op_start, i + 1)) { break; @@ -324,6 +324,13 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, } break; + // Remove DUP_TOP + POP_TOP: + case DUP_TOP: + if (nextop == POP_TOP) { + fill_nops(codestr, op_start, nexti + 1); + } + break; + /* Try to fold tuples of constants. Skip over BUILD_SEQN 1 UNPACK_SEQN 1. Replace BUILD_SEQN 2 UNPACK_SEQN 2 with ROT2. From 14e4eaabad04f55b8ba5cb87897d4da0aac2045d Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 12 Jul 2020 21:43:25 -0700 Subject: [PATCH 131/189] Add/fix tests --- Doc/library/dis.rst | 2 +- Doc/tools/susp-ignored.csv | 1 + Lib/test/test_patma.py | 548 ++++++++++++++++++++++++++----------- Python/compile.c | 12 +- 4 files changed, 393 insertions(+), 170 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 6567c5a35bec14..1ca57b53739ceb 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -769,7 +769,7 @@ iterations of the loop. .. opcode:: MATCH_SEQUENCE If TOS is an instance of :class:`collections.abc.Sequence`, is not an - instance of :class:`string`/:class:`bytes`/:class:`bytearray`, and is not an + instance of :class:`str`/:class:`bytes`/:class:`bytearray`, and is not an :term:`iterator`, push ``True`` onto the stack. Otherwise, push ``False``. .. versionadded:: 3.10 diff --git a/Doc/tools/susp-ignored.csv b/Doc/tools/susp-ignored.csv index 7be8d0abd69a57..392dd68359d23b 100644 --- a/Doc/tools/susp-ignored.csv +++ b/Doc/tools/susp-ignored.csv @@ -362,3 +362,4 @@ whatsnew/changelog,,::,default::DeprecationWarning library/importlib.metadata,,:main,"EntryPoint(name='wheel', value='wheel.cli:main', group='console_scripts')" library/importlib.metadata,,`,loading the metadata for packages for the indicated ``context``. library/re,,`,"`" +library/dis,,:TOS1,TOS[x:TOS1 - 1 - y] diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 75a93e8ea8ba10..2c14d485009339 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1,16 +1,17 @@ import collections +import contextlib import unittest class TestMatch(unittest.TestCase): - def test_patma_000(self) -> None: + def test_patma_000(self): match 0: case 0: x = True self.assertEqual(x, True) - def test_patma_001(self) -> None: + def test_patma_001(self): match 0: case 0 if False: x = False @@ -18,7 +19,7 @@ def test_patma_001(self) -> None: x = True self.assertEqual(x, True) - def test_patma_002(self) -> None: + def test_patma_002(self): match 0: case 0: x = True @@ -26,42 +27,42 @@ def test_patma_002(self) -> None: x = False self.assertEqual(x, True) - def test_patma_003(self) -> None: + def test_patma_003(self): x = False match 0: case 0 | 1 | 2 | 3: x = True self.assertEqual(x, True) - def test_patma_004(self) -> None: + def test_patma_004(self): x = False match 1: case 0 | 1 | 2 | 3: x = True self.assertEqual(x, True) - def test_patma_005(self) -> None: + def test_patma_005(self): x = False match 2: case 0 | 1 | 2 | 3: x = True self.assertEqual(x, True) - def test_patma_006(self) -> None: + def test_patma_006(self): x = False match 3: case 0 | 1 | 2 | 3: x = True self.assertEqual(x, True) - def test_patma_007(self) -> None: + def test_patma_007(self): x = False match 4: case 0 | 1 | 2 | 3: x = True self.assertEqual(x, False) - def test_patma_008(self) -> None: + def test_patma_008(self): x = 0 class A: y = 1 @@ -73,7 +74,7 @@ class A: self.assertEqual(A.y, 1) self.assertEqual(z, None) - def test_patma_009(self) -> None: + def test_patma_009(self): class A: B = 0 match 0: @@ -88,90 +89,90 @@ class A: self.assertEqual(y, 0) self.assertEqual(z, 2) - def test_patma_010(self) -> None: + def test_patma_010(self): match (): case []: x = 0 self.assertEqual(x, 0) - def test_patma_011(self) -> None: + def test_patma_011(self): match (0, 1, 2): case [*x]: y = 0 self.assertEqual(x, [0, 1, 2]) self.assertEqual(y, 0) - def test_patma_012(self) -> None: + def test_patma_012(self): match (0, 1, 2): case [0, *x]: y = 0 self.assertEqual(x, [1, 2]) self.assertEqual(y, 0) - def test_patma_013(self) -> None: + def test_patma_013(self): match (0, 1, 2): case [0, 1, *x,]: y = 0 self.assertEqual(x, [2]) self.assertEqual(y, 0) - def test_patma_014(self) -> None: + def test_patma_014(self): match (0, 1, 2): case [0, 1, 2, *x]: y = 0 self.assertEqual(x, []) self.assertEqual(y, 0) - def test_patma_015(self) -> None: + def test_patma_015(self): match (0, 1, 2): case [*x, 2,]: y = 0 self.assertEqual(x, [0, 1]) self.assertEqual(y, 0) - def test_patma_016(self) -> None: + def test_patma_016(self): match (0, 1, 2): case [*x, 1, 2]: y = 0 self.assertEqual(x, [0]) self.assertEqual(y, 0) - def test_patma_017(self) -> None: + def test_patma_017(self): match (0, 1, 2): case [*x, 0, 1, 2,]: y = 0 self.assertEqual(x, []) self.assertEqual(y, 0) - def test_patma_018(self) -> None: + def test_patma_018(self): match (0, 1, 2): case [0, *x, 2]: y = 0 self.assertEqual(x, [1]) self.assertEqual(y, 0) - def test_patma_019(self) -> None: + def test_patma_019(self): match (0, 1, 2): case [0, 1, *x, 2,]: y = 0 self.assertEqual(x, []) self.assertEqual(y, 0) - def test_patma_020(self) -> None: + def test_patma_020(self): match (0, 1, 2): case [0, *x, 1, 2]: y = 0 self.assertEqual(x, []) self.assertEqual(y, 0) - def test_patma_021(self) -> None: + def test_patma_021(self): match (0, 1, 2): case [*x,]: y = 0 self.assertEqual(x, [0, 1, 2]) self.assertEqual(y, 0) - def test_patma_022(self) -> None: + def test_patma_022(self): x = {} match x: case {}: @@ -179,7 +180,7 @@ def test_patma_022(self) -> None: self.assertEqual(x, {}) self.assertEqual(y, 0) - def test_patma_023(self) -> None: + def test_patma_023(self): x = {0: 0} match x: case {}: @@ -187,7 +188,7 @@ def test_patma_023(self) -> None: self.assertEqual(x, {0: 0}) self.assertEqual(y, 0) - def test_patma_024(self) -> None: + def test_patma_024(self): x = {} y = None match x: @@ -196,7 +197,7 @@ def test_patma_024(self) -> None: self.assertEqual(x, {}) self.assertEqual(y, None) - def test_patma_025(self) -> None: + def test_patma_025(self): x = {0: 0} match x: case {0: (z := 0 | 1 | 2)}: @@ -205,7 +206,7 @@ def test_patma_025(self) -> None: self.assertEqual(y, 0) self.assertEqual(z, 0) - def test_patma_026(self) -> None: + def test_patma_026(self): x = {0: 1} match x: case {0: (z := 0 | 1 | 2)}: @@ -214,7 +215,7 @@ def test_patma_026(self) -> None: self.assertEqual(y, 0) self.assertEqual(z, 1) - def test_patma_027(self) -> None: + def test_patma_027(self): x = {0: 2} match x: case {0: (z := 0 | 1 | 2)}: @@ -223,7 +224,7 @@ def test_patma_027(self) -> None: self.assertEqual(y, 0) self.assertEqual(z, 2) - def test_patma_028(self) -> None: + def test_patma_028(self): x = {0: 3} y = None z = None @@ -234,7 +235,7 @@ def test_patma_028(self) -> None: self.assertEqual(y, None) self.assertEqual(z, None) - def test_patma_029(self) -> None: + def test_patma_029(self): x = {} y = None match x: @@ -247,7 +248,7 @@ def test_patma_029(self) -> None: self.assertEqual(x, {}) self.assertEqual(y, None) - def test_patma_030(self) -> None: + def test_patma_030(self): x = {False: (True, 2.0, {})} match x: case {0: [1, 2, {}]}: @@ -259,7 +260,7 @@ def test_patma_030(self) -> None: self.assertEqual(x, {False: (True, 2.0, {})}) self.assertEqual(y, 0) - def test_patma_031(self) -> None: + def test_patma_031(self): x = {False: (True, 2.0, {}), 1: [[]], 2: 0} match x: case {0: [1, 2, {}]}: @@ -271,7 +272,7 @@ def test_patma_031(self) -> None: self.assertEqual(x, {False: (True, 2.0, {}), 1: [[]], 2: 0}) self.assertEqual(y, 0) - def test_patma_032(self) -> None: + def test_patma_032(self): x = {False: (True, 2.0, {}), 1: [[]], 2: 0} match x: case {0: [1, 2]}: @@ -283,7 +284,7 @@ def test_patma_032(self) -> None: self.assertEqual(x, {False: (True, 2.0, {}), 1: [[]], 2: 0}) self.assertEqual(y, 1) - def test_patma_033(self) -> None: + def test_patma_033(self): x = [] match x: case {0: [1, 2, {}]}: @@ -295,7 +296,7 @@ def test_patma_033(self) -> None: self.assertEqual(x, []) self.assertEqual(y, 2) - def test_patma_034(self) -> None: + def test_patma_034(self): x = {0: 0} match x: case {0: [1, 2, {}]}: @@ -307,7 +308,7 @@ def test_patma_034(self) -> None: self.assertEqual(x, {0: 0}) self.assertEqual(y, 1) - def test_patma_035(self) -> None: + def test_patma_035(self): x = {0: 0} match x: case {0: [1, 2, {}]}: @@ -319,7 +320,7 @@ def test_patma_035(self) -> None: self.assertEqual(x, {0: 0}) self.assertEqual(y, 1) - def test_patma_036(self) -> None: + def test_patma_036(self): x = 0 match x: case 0 | 1 | 2: @@ -327,7 +328,7 @@ def test_patma_036(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_037(self) -> None: + def test_patma_037(self): x = 1 match x: case 0 | 1 | 2: @@ -335,7 +336,7 @@ def test_patma_037(self) -> None: self.assertEqual(x, 1) self.assertEqual(y, 0) - def test_patma_038(self) -> None: + def test_patma_038(self): x = 2 match x: case 0 | 1 | 2: @@ -343,7 +344,7 @@ def test_patma_038(self) -> None: self.assertEqual(x, 2) self.assertEqual(y, 0) - def test_patma_039(self) -> None: + def test_patma_039(self): x = 3 y = None match x: @@ -352,7 +353,7 @@ def test_patma_039(self) -> None: self.assertEqual(x, 3) self.assertEqual(y, None) - def test_patma_040(self) -> None: + def test_patma_040(self): x = 0 match x: case (z := 0) | (z := 1) | (z := 2) if z == x % 2: @@ -361,7 +362,7 @@ def test_patma_040(self) -> None: self.assertEqual(y, 0) self.assertEqual(z, 0) - def test_patma_041(self) -> None: + def test_patma_041(self): x = 1 match x: case (z := 0) | (z := 1) | (z := 2) if z == x % 2: @@ -370,7 +371,7 @@ def test_patma_041(self) -> None: self.assertEqual(y, 0) self.assertEqual(z, 1) - def test_patma_042(self) -> None: + def test_patma_042(self): x = 2 y = None match x: @@ -380,7 +381,7 @@ def test_patma_042(self) -> None: self.assertEqual(y, None) self.assertEqual(z, 2) - def test_patma_043(self) -> None: + def test_patma_043(self): x = 3 y = None z = None @@ -391,7 +392,7 @@ def test_patma_043(self) -> None: self.assertEqual(y, None) self.assertEqual(z, None) - def test_patma_044(self) -> None: + def test_patma_044(self): x = () match x: case []: @@ -399,7 +400,7 @@ def test_patma_044(self) -> None: self.assertEqual(x, ()) self.assertEqual(y, 0) - def test_patma_045(self) -> None: + def test_patma_045(self): x = () match x: case []: @@ -407,7 +408,7 @@ def test_patma_045(self) -> None: self.assertEqual(x, ()) self.assertEqual(y, 0) - def test_patma_046(self) -> None: + def test_patma_046(self): x = (0,) match x: case [0]: @@ -415,7 +416,7 @@ def test_patma_046(self) -> None: self.assertEqual(x, (0,)) self.assertEqual(y, 0) - def test_patma_047(self) -> None: + def test_patma_047(self): x = ((),) match x: case [[]]: @@ -423,7 +424,7 @@ def test_patma_047(self) -> None: self.assertEqual(x, ((),)) self.assertEqual(y, 0) - def test_patma_048(self) -> None: + def test_patma_048(self): x = [0, 1] match x: case [0, 1] | [1, 0]: @@ -431,7 +432,7 @@ def test_patma_048(self) -> None: self.assertEqual(x, [0, 1]) self.assertEqual(y, 0) - def test_patma_049(self) -> None: + def test_patma_049(self): x = [1, 0] match x: case [0, 1] | [1, 0]: @@ -439,7 +440,7 @@ def test_patma_049(self) -> None: self.assertEqual(x, [1, 0]) self.assertEqual(y, 0) - def test_patma_050(self) -> None: + def test_patma_050(self): x = [0, 0] y = None match x: @@ -448,7 +449,7 @@ def test_patma_050(self) -> None: self.assertEqual(x, [0, 0]) self.assertEqual(y, None) - def test_patma_051(self) -> None: + def test_patma_051(self): w = None x = [1, 0] match x: @@ -461,7 +462,7 @@ def test_patma_051(self) -> None: self.assertEqual(y, 1) self.assertEqual(z, 0) - def test_patma_052(self) -> None: + def test_patma_052(self): x = [1, 0] match x: case [0]: @@ -473,7 +474,7 @@ def test_patma_052(self) -> None: self.assertEqual(x, []) self.assertEqual(y, 2) - def test_patma_053(self) -> None: + def test_patma_053(self): x = {0} y = None match x: @@ -482,7 +483,7 @@ def test_patma_053(self) -> None: self.assertEqual(x, {0}) self.assertEqual(y, None) - def test_patma_054(self) -> None: + def test_patma_054(self): x = set() y = None match x: @@ -491,7 +492,7 @@ def test_patma_054(self) -> None: self.assertEqual(x, set()) self.assertEqual(y, None) - def test_patma_055(self) -> None: + def test_patma_055(self): x = iter([1, 2, 3]) y = None match x: @@ -500,7 +501,7 @@ def test_patma_055(self) -> None: self.assertEqual([*x], [1, 2, 3]) self.assertEqual(y, None) - def test_patma_056(self) -> None: + def test_patma_056(self): x = {} y = None match x: @@ -509,7 +510,7 @@ def test_patma_056(self) -> None: self.assertEqual(x, {}) self.assertEqual(y, None) - def test_patma_057(self) -> None: + def test_patma_057(self): x = {0: False, 1: True} y = None match x: @@ -518,7 +519,7 @@ def test_patma_057(self) -> None: self.assertEqual(x, {0: False, 1: True}) self.assertEqual(y, None) - def test_patma_058(self) -> None: + def test_patma_058(self): x = 0 match x: case 0: @@ -526,7 +527,7 @@ def test_patma_058(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_059(self) -> None: + def test_patma_059(self): x = 0 match x: case False: @@ -534,7 +535,7 @@ def test_patma_059(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_060(self) -> None: + def test_patma_060(self): x = 0 y = None match x: @@ -543,7 +544,7 @@ def test_patma_060(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, None) - def test_patma_061(self) -> None: + def test_patma_061(self): x = 0 y = None match x: @@ -552,7 +553,7 @@ def test_patma_061(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, None) - def test_patma_062(self) -> None: + def test_patma_062(self): x = 0 match x: case 0: @@ -562,7 +563,7 @@ def test_patma_062(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_063(self) -> None: + def test_patma_063(self): x = 0 y = None match x: @@ -573,7 +574,7 @@ def test_patma_063(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, None) - def test_patma_064(self) -> None: + def test_patma_064(self): x = "x" match x: case "x": @@ -583,7 +584,7 @@ def test_patma_064(self) -> None: self.assertEqual(x, "x") self.assertEqual(y, 0) - def test_patma_065(self) -> None: + def test_patma_065(self): x = "x" match x: case "y": @@ -593,7 +594,7 @@ def test_patma_065(self) -> None: self.assertEqual(x, "x") self.assertEqual(y, 1) - def test_patma_066(self) -> None: + def test_patma_066(self): x = "x" match x: case "x": @@ -603,7 +604,7 @@ def test_patma_066(self) -> None: self.assertEqual(x, "x") self.assertEqual(y, 0) - def test_patma_067(self) -> None: + def test_patma_067(self): x = b"x" match x: case b"y": @@ -613,7 +614,7 @@ def test_patma_067(self) -> None: self.assertEqual(x, b"x") self.assertEqual(y, 1) - def test_patma_068(self) -> None: + def test_patma_068(self): x = 0 match x: case 0 if False: @@ -623,7 +624,7 @@ def test_patma_068(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 1) - def test_patma_069(self) -> None: + def test_patma_069(self): x = 0 y = None match x: @@ -634,7 +635,7 @@ def test_patma_069(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, None) - def test_patma_070(self) -> None: + def test_patma_070(self): x = 0 match x: case 0 if True: @@ -644,7 +645,7 @@ def test_patma_070(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_071(self) -> None: + def test_patma_071(self): x = 0 match x: case 0 if 1: @@ -654,7 +655,7 @@ def test_patma_071(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_072(self) -> None: + def test_patma_072(self): x = 0 match x: case 0 if True: @@ -665,7 +666,7 @@ def test_patma_072(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 2) - def test_patma_073(self) -> None: + def test_patma_073(self): x = 0 match x: case 0 if 0: @@ -676,7 +677,7 @@ def test_patma_073(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 2) - def test_patma_074(self) -> None: + def test_patma_074(self): x = 0 y = None match x: @@ -687,7 +688,7 @@ def test_patma_074(self) -> None: self.assertEqual(x, 1) self.assertEqual(y, None) - def test_patma_075(self) -> None: + def test_patma_075(self): x = "x" match x: case ["x"]: @@ -697,7 +698,7 @@ def test_patma_075(self) -> None: self.assertEqual(x, "x") self.assertEqual(y, 1) - def test_patma_076(self) -> None: + def test_patma_076(self): x = b"x" match x: case [b"x"]: @@ -711,7 +712,7 @@ def test_patma_076(self) -> None: self.assertEqual(x, b"x") self.assertEqual(y, 4) - def test_patma_077(self) -> None: + def test_patma_077(self): x = bytearray(b"x") y = None match x: @@ -722,7 +723,7 @@ def test_patma_077(self) -> None: self.assertEqual(x, b"x") self.assertEqual(y, None) - def test_patma_078(self) -> None: + def test_patma_078(self): x = "" match x: case []: @@ -734,7 +735,7 @@ def test_patma_078(self) -> None: self.assertEqual(x, "") self.assertEqual(y, 2) - def test_patma_079(self) -> None: + def test_patma_079(self): x = "xxx" match x: case ["x", "x", "x"]: @@ -746,7 +747,7 @@ def test_patma_079(self) -> None: self.assertEqual(x, "xxx") self.assertEqual(y, 2) - def test_patma_080(self) -> None: + def test_patma_080(self): x = b"xxx" match x: case [120, 120, 120]: @@ -758,7 +759,7 @@ def test_patma_080(self) -> None: self.assertEqual(x, b"xxx") self.assertEqual(y, 2) - def test_patma_081(self) -> None: + def test_patma_081(self): x = 0 match x: case 0 if not (x := 1): @@ -769,7 +770,7 @@ def test_patma_081(self) -> None: self.assertEqual(y, 1) self.assertEqual(z, 0) - def test_patma_082(self) -> None: + def test_patma_082(self): x = 0 z = None match x: @@ -781,7 +782,7 @@ def test_patma_082(self) -> None: self.assertEqual(y, 1) self.assertEqual(z, None) - def test_patma_083(self) -> None: + def test_patma_083(self): x = 0 match x: case (z := 0): @@ -790,7 +791,7 @@ def test_patma_083(self) -> None: self.assertEqual(y, 0) self.assertEqual(z, 0) - def test_patma_084(self) -> None: + def test_patma_084(self): x = 0 y = None z = None @@ -801,7 +802,7 @@ def test_patma_084(self) -> None: self.assertEqual(y, None) self.assertEqual(z, None) - def test_patma_085(self) -> None: + def test_patma_085(self): x = 0 y = None match x: @@ -812,7 +813,7 @@ def test_patma_085(self) -> None: self.assertEqual(y, None) self.assertEqual(z, 0) - def test_patma_086(self) -> None: + def test_patma_086(self): x = 0 match x: case (z := (w := 0)): @@ -822,7 +823,7 @@ def test_patma_086(self) -> None: self.assertEqual(y, 0) self.assertEqual(z, 0) - def test_patma_087(self) -> None: + def test_patma_087(self): x = 0 match x: case (0 | 1) | 2: @@ -830,7 +831,7 @@ def test_patma_087(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_088(self) -> None: + def test_patma_088(self): x = 1 match x: case (0 | 1) | 2: @@ -838,7 +839,7 @@ def test_patma_088(self) -> None: self.assertEqual(x, 1) self.assertEqual(y, 0) - def test_patma_089(self) -> None: + def test_patma_089(self): x = 2 match x: case (0 | 1) | 2: @@ -846,7 +847,7 @@ def test_patma_089(self) -> None: self.assertEqual(x, 2) self.assertEqual(y, 0) - def test_patma_090(self) -> None: + def test_patma_090(self): x = 3 y = None match x: @@ -855,7 +856,7 @@ def test_patma_090(self) -> None: self.assertEqual(x, 3) self.assertEqual(y, None) - def test_patma_091(self) -> None: + def test_patma_091(self): x = 0 match x: case 0 | (1 | 2): @@ -863,7 +864,7 @@ def test_patma_091(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_092(self) -> None: + def test_patma_092(self): x = 1 match x: case 0 | (1 | 2): @@ -871,7 +872,7 @@ def test_patma_092(self) -> None: self.assertEqual(x, 1) self.assertEqual(y, 0) - def test_patma_093(self) -> None: + def test_patma_093(self): x = 2 match x: case 0 | (1 | 2): @@ -879,7 +880,7 @@ def test_patma_093(self) -> None: self.assertEqual(x, 2) self.assertEqual(y, 0) - def test_patma_094(self) -> None: + def test_patma_094(self): x = 3 y = None match x: @@ -888,7 +889,7 @@ def test_patma_094(self) -> None: self.assertEqual(x, 3) self.assertEqual(y, None) - def test_patma_095(self) -> None: + def test_patma_095(self): x = 0 match x: case -0: @@ -896,7 +897,7 @@ def test_patma_095(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_096(self) -> None: + def test_patma_096(self): x = 0 match x: case -0.0: @@ -904,7 +905,7 @@ def test_patma_096(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_097(self) -> None: + def test_patma_097(self): x = 0 match x: case -0j: @@ -912,7 +913,7 @@ def test_patma_097(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_098(self) -> None: + def test_patma_098(self): x = 0 match x: case -0.0j: @@ -920,7 +921,7 @@ def test_patma_098(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_099(self) -> None: + def test_patma_099(self): x = -1 match x: case -1: @@ -928,7 +929,7 @@ def test_patma_099(self) -> None: self.assertEqual(x, -1) self.assertEqual(y, 0) - def test_patma_100(self) -> None: + def test_patma_100(self): x = -1.5 match x: case -1.5: @@ -936,7 +937,7 @@ def test_patma_100(self) -> None: self.assertEqual(x, -1.5) self.assertEqual(y, 0) - def test_patma_101(self) -> None: + def test_patma_101(self): x = -1j match x: case -1j: @@ -944,7 +945,7 @@ def test_patma_101(self) -> None: self.assertEqual(x, -1j) self.assertEqual(y, 0) - def test_patma_102(self) -> None: + def test_patma_102(self): x = -1.5j match x: case -1.5j: @@ -952,7 +953,7 @@ def test_patma_102(self) -> None: self.assertEqual(x, -1.5j) self.assertEqual(y, 0) - def test_patma_103(self) -> None: + def test_patma_103(self): x = 0 match x: case 0 + 0j: @@ -960,7 +961,7 @@ def test_patma_103(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_104(self) -> None: + def test_patma_104(self): x = 0 match x: case 0 - 0j: @@ -968,7 +969,7 @@ def test_patma_104(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_105(self) -> None: + def test_patma_105(self): x = 0 match x: case -0 + 0j: @@ -976,7 +977,7 @@ def test_patma_105(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_106(self) -> None: + def test_patma_106(self): x = 0 match x: case -0 - 0j: @@ -984,7 +985,7 @@ def test_patma_106(self) -> None: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_107(self) -> None: + def test_patma_107(self): x = 0.25 + 1.75j match x: case 0.25 + 1.75j: @@ -992,7 +993,7 @@ def test_patma_107(self) -> None: self.assertEqual(x, 0.25 + 1.75j) self.assertEqual(y, 0) - def test_patma_108(self) -> None: + def test_patma_108(self): x = 0.25 - 1.75j match x: case 0.25 - 1.75j: @@ -1000,7 +1001,7 @@ def test_patma_108(self) -> None: self.assertEqual(x, 0.25 - 1.75j) self.assertEqual(y, 0) - def test_patma_109(self) -> None: + def test_patma_109(self): x = -0.25 + 1.75j match x: case -0.25 + 1.75j: @@ -1008,7 +1009,7 @@ def test_patma_109(self) -> None: self.assertEqual(x, -0.25 + 1.75j) self.assertEqual(y, 0) - def test_patma_110(self) -> None: + def test_patma_110(self): x = -0.25 - 1.75j match x: case -0.25 - 1.75j: @@ -1016,7 +1017,7 @@ def test_patma_110(self) -> None: self.assertEqual(x, -0.25 - 1.75j) self.assertEqual(y, 0) - def test_patma_111(self) -> None: + def test_patma_111(self): class A: B = 0 x = 0 @@ -1027,7 +1028,7 @@ class A: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_112(self) -> None: + def test_patma_112(self): class A: class B: C = 0 @@ -1039,7 +1040,7 @@ class B: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_113(self) -> None: + def test_patma_113(self): class A: class B: C = 0 @@ -1051,7 +1052,7 @@ class B: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_114(self) -> None: + def test_patma_114(self): class A: class B: class C: @@ -1064,7 +1065,7 @@ class C: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_115(self) -> None: + def test_patma_115(self): class A: class B: class C: @@ -1077,7 +1078,7 @@ class C: self.assertEqual(x, 0) self.assertEqual(y, 0) - def test_patma_116(self) -> None: + def test_patma_116(self): match = case = 0 match match: case case: @@ -1086,7 +1087,7 @@ def test_patma_116(self) -> None: self.assertEqual(case, 0) self.assertEqual(x, 0) - def test_patma_117(self) -> None: + def test_patma_117(self): match = case = 0 match case: case match: @@ -1095,7 +1096,7 @@ def test_patma_117(self) -> None: self.assertEqual(case, 0) self.assertEqual(x, 0) - def test_patma_118(self) -> None: + def test_patma_118(self): x = [] match x: case [*_, _]: @@ -1105,7 +1106,7 @@ def test_patma_118(self) -> None: self.assertEqual(x, []) self.assertEqual(y, 1) - def test_patma_119(self) -> None: + def test_patma_119(self): x = collections.defaultdict(int) match x: case {0: 0}: @@ -1115,7 +1116,7 @@ def test_patma_119(self) -> None: self.assertEqual(x, {}) self.assertEqual(y, 1) - def test_patma_120(self) -> None: + def test_patma_120(self): x = collections.defaultdict(int) match x: case {0: 0}: @@ -1126,90 +1127,90 @@ def test_patma_120(self) -> None: self.assertEqual(y, 1) self.assertEqual(z, {}) - def test_patma_121(self) -> None: + def test_patma_121(self): match (): case (): x = 0 self.assertEqual(x, 0) - def test_patma_122(self) -> None: + def test_patma_122(self): match (0, 1, 2): case (*x,): y = 0 self.assertEqual(x, [0, 1, 2]) self.assertEqual(y, 0) - def test_patma_123(self) -> None: + def test_patma_123(self): match (0, 1, 2): case 0, *x: y = 0 self.assertEqual(x, [1, 2]) self.assertEqual(y, 0) - def test_patma_124(self) -> None: + def test_patma_124(self): match (0, 1, 2): case (0, 1, *x,): y = 0 self.assertEqual(x, [2]) self.assertEqual(y, 0) - def test_patma_125(self) -> None: + def test_patma_125(self): match (0, 1, 2): case 0, 1, 2, *x: y = 0 self.assertEqual(x, []) self.assertEqual(y, 0) - def test_patma_126(self) -> None: + def test_patma_126(self): match (0, 1, 2): case *x, 2,: y = 0 self.assertEqual(x, [0, 1]) self.assertEqual(y, 0) - def test_patma_127(self) -> None: + def test_patma_127(self): match (0, 1, 2): case (*x, 1, 2): y = 0 self.assertEqual(x, [0]) self.assertEqual(y, 0) - def test_patma_128(self) -> None: + def test_patma_128(self): match (0, 1, 2): case *x, 0, 1, 2,: y = 0 self.assertEqual(x, []) self.assertEqual(y, 0) - def test_patma_129(self) -> None: + def test_patma_129(self): match (0, 1, 2): case (0, *x, 2): y = 0 self.assertEqual(x, [1]) self.assertEqual(y, 0) - def test_patma_130(self) -> None: + def test_patma_130(self): match (0, 1, 2): case 0, 1, *x, 2,: y = 0 self.assertEqual(x, []) self.assertEqual(y, 0) - def test_patma_131(self) -> None: + def test_patma_131(self): match (0, 1, 2): case (0, *x, 1, 2): y = 0 self.assertEqual(x, []) self.assertEqual(y, 0) - def test_patma_132(self) -> None: + def test_patma_132(self): match (0, 1, 2): case *x,: y = 0 self.assertEqual(x, [0, 1, 2]) self.assertEqual(y, 0) - def test_patma_133(self) -> None: + def test_patma_133(self): x = collections.defaultdict(int, {0: 1}) match x: case {1: 0}: @@ -1221,7 +1222,7 @@ def test_patma_133(self) -> None: self.assertEqual(x, {0: 1}) self.assertEqual(y, 2) - def test_patma_134(self) -> None: + def test_patma_134(self): x = collections.defaultdict(int, {0: 1}) match x: case {1: 0}: @@ -1234,7 +1235,7 @@ def test_patma_134(self) -> None: self.assertEqual(y, 2) self.assertEqual(z, {0: 1}) - def test_patma_135(self) -> None: + def test_patma_135(self): x = collections.defaultdict(int, {0: 1}) match x: case {1: 0}: @@ -1247,7 +1248,7 @@ def test_patma_135(self) -> None: self.assertEqual(y, 2) self.assertEqual(z, {}) - def test_patma_136(self) -> None: + def test_patma_136(self): x = {0: 1} match x: case {1: 0}: @@ -1259,7 +1260,7 @@ def test_patma_136(self) -> None: self.assertEqual(x, {0: 1}) self.assertEqual(y, 1) - def test_patma_137(self) -> None: + def test_patma_137(self): x = {0: 1} match x: case {1: 0}: @@ -1272,7 +1273,7 @@ def test_patma_137(self) -> None: self.assertEqual(y, 1) self.assertEqual(z, {0: 1}) - def test_patma_138(self) -> None: + def test_patma_138(self): x = {0: 1} match x: case {1: 0}: @@ -1285,7 +1286,7 @@ def test_patma_138(self) -> None: self.assertEqual(y, 1) self.assertEqual(z, {}) - def test_patma_139(self) -> None: + def test_patma_139(self): x = False match x: case bool(z): @@ -1294,7 +1295,7 @@ def test_patma_139(self) -> None: self.assertEqual(y, 0) self.assertIs(z, x) - def test_patma_140(self) -> None: + def test_patma_140(self): x = True match x: case bool(z): @@ -1303,7 +1304,7 @@ def test_patma_140(self) -> None: self.assertEqual(y, 0) self.assertIs(z, x) - def test_patma_141(self) -> None: + def test_patma_141(self): x = bytearray() match x: case bytearray(z): @@ -1312,7 +1313,7 @@ def test_patma_141(self) -> None: self.assertEqual(y, 0) self.assertIs(z, x) - def test_patma_142(self) -> None: + def test_patma_142(self): x = b"" match x: case bytes(z): @@ -1321,7 +1322,7 @@ def test_patma_142(self) -> None: self.assertEqual(y, 0) self.assertIs(z, x) - def test_patma_143(self) -> None: + def test_patma_143(self): x = {} match x: case dict(z): @@ -1330,7 +1331,7 @@ def test_patma_143(self) -> None: self.assertEqual(y, 0) self.assertIs(z, x) - def test_patma_144(self) -> None: + def test_patma_144(self): x = 0.0 match x: case float(z): @@ -1339,7 +1340,7 @@ def test_patma_144(self) -> None: self.assertEqual(y, 0) self.assertIs(z, x) - def test_patma_145(self) -> None: + def test_patma_145(self): x = frozenset() match x: case frozenset(z): @@ -1348,7 +1349,7 @@ def test_patma_145(self) -> None: self.assertEqual(y, 0) self.assertIs(z, x) - def test_patma_146(self) -> None: + def test_patma_146(self): x = 0 match x: case int(z): @@ -1357,7 +1358,7 @@ def test_patma_146(self) -> None: self.assertEqual(y, 0) self.assertIs(z, x) - def test_patma_147(self) -> None: + def test_patma_147(self): x = [] match x: case list(z): @@ -1366,7 +1367,7 @@ def test_patma_147(self) -> None: self.assertEqual(y, 0) self.assertIs(z, x) - def test_patma_148(self) -> None: + def test_patma_148(self): x = set() match x: case set(z): @@ -1375,7 +1376,7 @@ def test_patma_148(self) -> None: self.assertEqual(y, 0) self.assertIs(z, x) - def test_patma_149(self) -> None: + def test_patma_149(self): x = "" match x: case str(z): @@ -1384,7 +1385,7 @@ def test_patma_149(self) -> None: self.assertEqual(y, 0) self.assertIs(z, x) - def test_patma_150(self) -> None: + def test_patma_150(self): x = () match x: case tuple(z): @@ -1393,7 +1394,7 @@ def test_patma_150(self) -> None: self.assertEqual(y, 0) self.assertIs(z, x) - def test_patma_151(self) -> None: + def test_patma_151(self): x = 0 match x,: case y,: @@ -1402,7 +1403,7 @@ def test_patma_151(self) -> None: self.assertIs(y, x) self.assertIs(z, 0) - def test_patma_152(self) -> None: + def test_patma_152(self): w = 0 x = 0 match w, x: @@ -1414,7 +1415,7 @@ def test_patma_152(self) -> None: self.assertIs(z, x) self.assertEqual(v, 0) - def test_patma_152(self) -> None: + def test_patma_153(self): x = 0 match w := x,: case v := y,: @@ -1425,15 +1426,236 @@ def test_patma_152(self) -> None: self.assertIs(w, x) self.assertIs(v, y) + def test_patma_154(self): + x = 0 + y = None + match x: + case 0 if x: + y = 0 + self.assertEqual(x, 0) + self.assertIs(y, None) + + def test_patma_155(self): + x = 0 + y = None + match x: + case 1: + y = 0 + self.assertEqual(x, 0) + self.assertIs(y, None) + + def test_patma_156(self): + x = 0 + match x: + case z: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_157(self): + x = 0 + y = None + match x: + case _ if x: + y = 0 + self.assertEqual(x, 0) + self.assertIs(y, None) + + def test_patma_158(self): + x = 0 + match x: + case 0: + y = 0 + case 0: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_159(self): + x = 0 + match x: + case 0 if not x: + y = 0 + case 1: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_160(self): + x = 0 + z = None + match x: + case 0: + y = 0 + case z if x: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertIs(z, None) + + def test_patma_161(self): + x = 0 + match x: + case 0: + y = 0 + case _: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_162(self): + x = 0 + match x: + case 1 if x: + y = 0 + case 0: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 1) + + def test_patma_163(self): + x = 0 + y = None + match x: + case 1: + y = 0 + case 1 if not x: + y = 1 + self.assertEqual(x, 0) + self.assertIs(y, None) + + def test_patma_164(self): + x = 0 + match x: + case 1: + y = 0 + case z: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 1) + self.assertIs(z, x) + + def test_patma_165(self): + x = 0 + match x: + case 1 if x: + y = 0 + case _: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 1) + + def test_patma_166(self): + x = 0 + match x: + case z if not z: + y = 0 + case 0 if x: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_167(self): + x = 0 + match x: + case z if not z: + y = 0 + case 1: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_168(self): + x = 0 + match x: + case z if not x: + y = 0 + case z: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_169(self): + x = 0 + match x: + case z if not z: + y = 0 + case _ if x: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_170(self): + x = 0 + match x: + case _ if not x: + y = 0 + case 0: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_171(self): + x = 0 + y = None + match x: + case _ if x: + y = 0 + case 1: + y = 1 + self.assertEqual(x, 0) + self.assertIs(y, None) + + def test_patma_172(self): + x = 0 + z = None + match x: + case _ if not x: + y = 0 + case z if not x: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertIs(z, None) + + def test_patma_173(self): + x = 0 + match x: + case _ if not x: + y = 0 + case _: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + +class PerfMatch(TestMatch): + + @staticmethod + def setUpClass(): + raise unittest.SkipTest("performance testing") + + def assertEqual(*_, **__): + pass + + def assertIs(*_, **__): + pass + def run_perf(self): - # ./python -m pyperf timeit -s "from test.test_patma import TestMatch; t = TestMatch()" "t.run_perf()" attrs = vars(type(self)).items() tests = [attr for name, attr in attrs if name.startswith("test_")] - assert_equal, assert_is = self.assertEqual, self.assertIs - try: - self.assertEqual = self.assertIs = lambda *_: None - for _ in range(1 << 10): - for test in tests: - test(self) - finally: - self.assertEqual, self.assertIs = assert_equal, assert_is + for _ in range(1 << 10): + for test in tests: + test(self) + + +""" +sudo ./python -m pyperf system tune && \ + ./python -m pyperf timeit -s "from test.test_patma import PerfMatch; p = PerfMatch()" "p.run_perf()"; \ +sudo ./python -m pyperf system reset +""" diff --git a/Python/compile.c b/Python/compile.c index 7777f87d5c3d3e..d53679296d4a7c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5827,6 +5827,12 @@ compiler_match(struct compiler *c, stmt_ty s) last = i == cases - 1 - has_default; m = asdl_seq_GET(s->v.Match.cases, i); SET_LOC(c, m->pattern); + if (!m->guard && m->pattern->kind == Name_kind && + m->pattern->v.Name.ctx == Store && i != cases - 1) + { + CHECK(compiler_warn(c, "unguarded name capture pattern makes " + "remaining cases unreachable")); + } CHECK(next = compiler_new_block(c)); if (!last) { ADDOP(c, DUP_TOP); @@ -5846,12 +5852,6 @@ compiler_match(struct compiler *c, stmt_ty s) VISIT_SEQ(c, stmt, m->body); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, next); - if (!m->guard && m->pattern->kind == Name_kind && - m->pattern->v.Name.ctx == Store && i != cases - 1) - { - CHECK(compiler_warn(c, "unguarded name capture pattern makes " - "remaining cases unreachable")); - } } if (has_default) { if (cases == 1) { From 4789bff6f36f7c9446380839ff2dde3aa8c21fb3 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 13 Jul 2020 09:00:04 -0700 Subject: [PATCH 132/189] Fix refleaks when tracking names --- Python/compile.c | 118 ++++++++++++++++++++++++++++------------------- 1 file changed, 71 insertions(+), 47 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index d53679296d4a7c..4c73dfbe37680b 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -176,7 +176,7 @@ struct compiler { }; typedef struct { - PyObject* stores; + PyObject *stores; } pattern_context; static int compiler_enter_scope(struct compiler *, identifier, int, void *, int); @@ -224,7 +224,7 @@ static int compiler_async_comprehension_generator( int depth, expr_ty elt, expr_ty val, int type); -static int compiler_pattern(struct compiler *, expr_ty, pattern_context); +static int compiler_pattern(struct compiler *, expr_ty, pattern_context *); static int compiler_match(struct compiler *, stmt_ty); static PyCodeObject *assemble(struct compiler *, int addNone); @@ -5452,7 +5452,7 @@ compiler_slice(struct compiler *c, expr_ty s) static int -pattern_load(struct compiler *c, expr_ty p, pattern_context pc) +pattern_load(struct compiler *c, expr_ty p, pattern_context *pc) { if (p->kind == Attribute_kind) { assert(p->v.Attribute.ctx == Load); @@ -5472,25 +5472,45 @@ pattern_load(struct compiler *c, expr_ty p, pattern_context pc) static int -pattern_store(struct compiler *c, expr_ty p, pattern_context pc) { +pattern_store(struct compiler *c, expr_ty p, pattern_context *pc) +{ assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); if (WILDCARD_CHECK(p)) { return compiler_error(c, "can't assign to '_' here; consider removing or renaming?"); } - if (PySet_Contains(pc.stores, p->v.Name.id)) { - // TODO: Format this error message with the name. - return compiler_error(c, "multiple assignments to name in pattern"); + if (!pc->stores) { + CHECK(pc->stores = PySet_New(NULL)); + } + else { + int dupe = PySet_Contains(pc->stores, p->v.Name.id); + if (dupe < 0) { + return 0; + } + if (dupe) { + PyObject *str = PyUnicode_FromFormat( + "multiple assignments to name %R in pattern", p->v.Name.id); + if (!str) { + return 0; + } + const char *s = PyUnicode_AsUTF8(str); + if (!s) { + return 0; + } + compiler_error(c, s); + Py_DECREF(str); + return 0; + } } - CHECK(!PySet_Add(pc.stores, p->v.Name.id)); + CHECK(!PySet_Add(pc->stores, p->v.Name.id)); CHECK(compiler_nameop(c, p->v.Name.id, Store)); return 1; } static int -compiler_pattern_attribute(struct compiler *c, expr_ty p, pattern_context pc) +compiler_pattern_attribute(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Attribute_kind); assert(p->v.Attribute.ctx == Load); @@ -5501,62 +5521,67 @@ compiler_pattern_attribute(struct compiler *c, expr_ty p, pattern_context pc) static int -compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context pc) +compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == BoolOp_kind); assert(p->v.BoolOp.op == Or); basicblock *end; PyObject *control = NULL; + PyObject *diff; CHECK(end = compiler_new_block(c)); Py_ssize_t size = asdl_seq_LEN(p->v.BoolOp.values); assert(size > 1); - PyObject *names_copy; - // TODO: Leaks sets. + PyObject *stores_init = pc->stores; + expr_ty alt; for (Py_ssize_t i = 0; i < size; i++) { - CHECK(names_copy = PySet_New(pc.stores)); - ADDOP(c, DUP_TOP); - // TODO: Just modify pc instead. - pattern_context sub_pc = pc; - sub_pc.stores = names_copy; - CHECK(compiler_pattern(c, asdl_seq_GET(p->v.BoolOp.values, i), sub_pc)); - ADDOP_JABS(c, JUMP_IF_TRUE_OR_POP, end); - // TODO: Reuse names_copy without actually building a new copy each loop? + // Can't use our helpful returning macros here (they'll leak sets): + alt = asdl_seq_GET(p->v.BoolOp.values, i); + pc->stores = PySet_New(stores_init); + SET_LOC(c, alt); + if (alt->kind == Name_kind && alt->v.Name.ctx == Store && i != size - 1) { + compiler_warn(c, "name capture pattern makes remaining alternate " + "patterns unreachable"); + } + if (!(pc->stores && compiler_addop(c, DUP_TOP) && + compiler_pattern(c, alt, pc) && + compiler_addop_j(c, JUMP_IF_TRUE_OR_POP, end, 1))) + { + goto fail; + } if (!i) { - control = names_copy; + control = pc->stores; + continue; } - else if (PySet_GET_SIZE(control) || PySet_GET_SIZE(names_copy)) { - PyObject *diff = PyNumber_InPlaceXor(names_copy, control); + if (PySet_GET_SIZE(pc->stores) || PySet_GET_SIZE(control)) { + diff = PyNumber_InPlaceXor(pc->stores, control); if (!diff) { - Py_DECREF(control); - return 0; + goto fail; } - Py_DECREF(names_copy); if (PySet_GET_SIZE(diff)) { - // TODO: Format this error message with a name. - // PyObject *extra = PySet_Pop(diff); - Py_DECREF(control); Py_DECREF(diff); - // TODO: Catch this during store. - return compiler_error(c, "pattern binds different names based on target"); + compiler_error(c, "pattern binds different names based on target"); + goto fail; } Py_DECREF(diff); } - else { - Py_DECREF(names_copy); - } + Py_DECREF(pc->stores); } - assert(control); - Py_DECREF(control); + Py_XDECREF(stores_init); + pc->stores = control; ADDOP_LOAD_CONST(c, Py_False); compiler_use_next_block(c, end); ADDOP(c, ROT_TWO); ADDOP(c, POP_TOP); return 1; +fail: + Py_XDECREF(stores_init); + Py_XDECREF(control); + return 0; } static int -compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context pc) { +compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { asdl_seq *args = p->v.Call.args; asdl_seq *kwargs = p->v.Call.keywords; Py_ssize_t nargs = asdl_seq_LEN(args); @@ -5604,7 +5629,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context pc) { static int -compiler_pattern_constant(struct compiler *c, expr_ty p, pattern_context pc) +compiler_pattern_constant(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Constant_kind); CHECK(pattern_load(c, p, pc)); @@ -5614,7 +5639,7 @@ compiler_pattern_constant(struct compiler *c, expr_ty p, pattern_context pc) static int -compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context pc) +compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) { basicblock *block, *end; CHECK(block = compiler_new_block(c)); @@ -5671,7 +5696,7 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context pc) static int -compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context pc) +compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == List_kind || p->kind == Tuple_kind); asdl_seq *values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; @@ -5741,7 +5766,7 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context pc) static int -compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context pc) +compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); @@ -5757,7 +5782,7 @@ compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context pc) static int -compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context pc) +compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == NamedExpr_kind); basicblock *block, *end; @@ -5778,7 +5803,7 @@ compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context pc) static int -compiler_pattern(struct compiler *c, expr_ty p, pattern_context pc) +compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc) { SET_LOC(c, p); switch (p->kind) { @@ -5837,10 +5862,9 @@ compiler_match(struct compiler *c, stmt_ty s) if (!last) { ADDOP(c, DUP_TOP); } - // TODO: Set pc.stores lazily. - CHECK(pc.stores = PySet_New(NULL)); - result = compiler_pattern(c, m->pattern, pc); - Py_DECREF(pc.stores); + pc.stores = NULL; + result = compiler_pattern(c, m->pattern, &pc); + Py_CLEAR(pc.stores); CHECK(result); ADDOP_JABS(c, POP_JUMP_IF_FALSE, next); if (m->guard) { From 1260139a373bdb889add2a384682b26062e2dd86 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 13 Jul 2020 10:12:46 -0700 Subject: [PATCH 133/189] Regenerate keyword module --- Lib/keyword.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/keyword.py b/Lib/keyword.py index ccc951500f6d8c..e6b5f3d9626512 100644 --- a/Lib/keyword.py +++ b/Lib/keyword.py @@ -54,7 +54,8 @@ ] softkwlist = [ - + 'case', + 'match' ] iskeyword = frozenset(kwlist).__contains__ From 34f8111aa140a66f584944a3e77fc546159a80ea Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 14 Jul 2020 09:09:19 -0700 Subject: [PATCH 134/189] Add a ton of tests --- Lib/test/test_patma.py | 407 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 401 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 2c14d485009339..8f7ffac487bc8a 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1,9 +1,11 @@ import collections import contextlib +import dataclasses +import enum import unittest -class TestMatch(unittest.TestCase): +class TestPatma(unittest.TestCase): def test_patma_000(self): match 0: @@ -1633,12 +1635,397 @@ def test_patma_173(self): self.assertEqual(x, 0) self.assertEqual(y, 0) + def test_patma_174(self): + def http_error(status): + match status: + case 400: + return "Bad request" + case 401: + return "Unauthorized" + case 403: + return "Forbidden" + case 404: + return "Not found" + case 418: + return "I'm a teapot" + case _: + return "Something else" + self.assertEqual(http_error(400), "Bad request") + self.assertEqual(http_error(401), "Unauthorized") + self.assertEqual(http_error(403), "Forbidden") + self.assertEqual(http_error(404), "Not found") + self.assertEqual(http_error(418), "I'm a teapot") + self.assertEqual(http_error(123), "Something else") + self.assertEqual(http_error("400"), "Something else") + self.assertEqual(http_error(401 | 403 | 404), "Something else") # 407 + + def test_patma_175(self): + def http_error(status): + match status: + case 400: + return "Bad request" + case 401 | 403 | 404: + return "Not allowed" + case 418: + return "I'm a teapot" + self.assertEqual(http_error(400), "Bad request") + self.assertEqual(http_error(401), "Not allowed") + self.assertEqual(http_error(403), "Not allowed") + self.assertEqual(http_error(404), "Not allowed") + self.assertEqual(http_error(418), "I'm a teapot") + self.assertIs(http_error(123), None) + self.assertIs(http_error("400"), None) + self.assertIs(http_error(401 | 403 | 404), None) # 407 + + def test_patma_176(self): + def whereis(point): + match point: + case (0, 0): + return "Origin" + case (0, y): + return f"Y={y}" + case (x, 0): + return f"X={x}" + case (x, y): + return f"X={x}, Y={y}" + case _: + raise ValueError("Not a point") + self.assertEqual(whereis((0, 0)), "Origin") + self.assertEqual(whereis((0, -1.0)), "Y=-1.0") + self.assertEqual(whereis(("X", 0)), "X=X") + self.assertEqual(whereis((None, 1j)), "X=None, Y=1j") + with self.assertRaises(ValueError): + whereis(42) + + def test_patma_177(self): + @dataclasses.dataclass + class Point: + x: int + y: int + def whereis(point): + match point: + case Point(0, 0): + return "Origin" + case Point(0, y): + return f"Y={y}" + case Point(x, 0): + return f"X={x}" + case Point(): + return "Somewhere else" + case _: + return "Not a point" + self.assertEqual(whereis(Point(1, 0)), "X=1") + self.assertEqual(whereis(Point(0, 0)), "Origin") + self.assertEqual(whereis(10), "Not a point") + self.assertEqual(whereis(Point(False, False)), "Origin") + self.assertEqual(whereis(Point(0, -1.0)), "Y=-1.0") + self.assertEqual(whereis(Point("X", 0)), "X=X") + self.assertEqual(whereis(Point(None, 1j)), "Somewhere else") + self.assertEqual(whereis(Point), "Not a point") + self.assertEqual(whereis(42), "Not a point") + + def test_patma_178(self): + @dataclasses.dataclass + class Point: + x: int + y: int + def whereis(point): + match point: + case Point(1, var): + return var + self.assertEqual(whereis(Point(1, 0)), 0) + self.assertIs(whereis(Point(0, 0)), None) + + def test_patma_179(self): + @dataclasses.dataclass + class Point: + x: int + y: int + def whereis(point): + match point: + case Point(1, y=var): + return var + self.assertEqual(whereis(Point(1, 0)), 0) + self.assertIs(whereis(Point(0, 0)), None) + + def test_patma_180(self): + @dataclasses.dataclass + class Point: + x: int + y: int + def whereis(point): + match point: + case Point(x=1, y=var): + return var + self.assertEqual(whereis(Point(1, 0)), 0) + self.assertIs(whereis(Point(0, 0)), None) + + def test_patma_181(self): + @dataclasses.dataclass + class Point: + x: int + y: int + def whereis(point): + match point: + case Point(y=var, x=1): + return var + self.assertEqual(whereis(Point(1, 0)), 0) + self.assertIs(whereis(Point(0, 0)), None) + + def test_patma_182(self): + @dataclasses.dataclass + class Point: + x: int + y: int + def whereis(points): + match points: + case []: + return "No points" + case [Point(0, 0)]: + return "The origin" + case [Point(x, y)]: + return f"Single point {x}, {y}" + case [Point(0, y1), Point(0, y2)]: + return f"Two on the Y axis at {y1}, {y2}" + case _: + return "Something else" + self.assertEqual(whereis([]), "No points") + self.assertEqual(whereis([Point(0, 0)]), "The origin") + self.assertEqual(whereis([Point(0, 1)]), "Single point 0, 1") + self.assertEqual(whereis([Point(0, 0), Point(0, 0)]), "Two on the Y axis at 0, 0") + self.assertEqual(whereis([Point(0, 1), Point(0, 1)]), "Two on the Y axis at 1, 1") + self.assertEqual(whereis([Point(0, 0), Point(1, 0)]), "Something else") + self.assertEqual(whereis([Point(0, 0), Point(0, 0), Point(0, 0)]), "Something else") + self.assertEqual(whereis([Point(0, 1), Point(0, 1), Point(0, 1)]), "Something else") + + def test_patma_183(self): + @dataclasses.dataclass + class Point: + x: int + y: int + def whereis(point): + match point: + case Point(x, y) if x == y: + return f"Y=X at {x}" + case Point(x, y): + return "Not on the diagonal" + self.assertEqual(whereis(Point(0, 0)), "Y=X at 0") + self.assertEqual(whereis(Point(0, False)), "Y=X at 0") + self.assertEqual(whereis(Point(False, 0)), "Y=X at False") + self.assertEqual(whereis(Point(-1 - 1j, -1 - 1j)), "Y=X at (-1-1j)") + self.assertEqual(whereis(Point("X", "X")), "Y=X at X") + self.assertEqual(whereis(Point("X", "x")), "Not on the diagonal") + + def test_patma_184(self): + class Seq(collections.abc.Sequence): + __getitem__ = None + def __len__(self): + return 0 + match Seq(): + case []: + y = 0 + self.assertEqual(y, 0) -class PerfMatch(TestMatch): + def test_patma_185(self): + class Seq(collections.abc.Sequence): + __getitem__ = None + def __len__(self): + return 42 + match Seq(): + case [*_]: + y = 0 + self.assertEqual(y, 0) - @staticmethod - def setUpClass(): - raise unittest.SkipTest("performance testing") + def test_patma_186(self): + class Seq(collections.abc.Sequence): + def __getitem__(self, i): + return i + def __len__(self): + return 42 + match Seq(): + case [x, *y, z]: + w = 0 + self.assertEqual(w, 0) + self.assertEqual(x, 0) + self.assertEqual(y, list(range(1, 41))) + self.assertEqual(z, 41) + + def test_patma_187(self): + w = range(10) + match w: + case [x, y, *rest]: + z = 0 + self.assertEqual(w, range(10)) + self.assertEqual(x, 0) + self.assertEqual(y, 1) + self.assertEqual(z, 0) + self.assertEqual(rest, list(range(2, 10))) + + def test_patma_188(self): + w = range(100) + match w: + case (x, y, *rest): + z = 0 + self.assertEqual(w, range(100)) + self.assertEqual(x, 0) + self.assertEqual(y, 1) + self.assertEqual(z, 0) + self.assertEqual(rest, list(range(2, 100))) + + def test_patma_189(self): + w = range(1000) + match w: + case x, y, *rest: + z = 0 + self.assertEqual(w, range(1000)) + self.assertEqual(x, 0) + self.assertEqual(y, 1) + self.assertEqual(z, 0) + self.assertEqual(rest, list(range(2, 1000))) + + def test_patma_190(self): + w = range(1 << 10) + match w: + case [x, y, *_]: + z = 0 + self.assertEqual(w, range(1 << 10)) + self.assertEqual(x, 0) + self.assertEqual(y, 1) + self.assertEqual(z, 0) + + def test_patma_191(self): + w = range(1 << 20) + match w: + case (x, y, *_): + z = 0 + self.assertEqual(w, range(1 << 20)) + self.assertEqual(x, 0) + self.assertEqual(y, 1) + self.assertEqual(z, 0) + + def test_patma_192(self): + w = range(1 << 30) + match w: + case x, y, *_: + z = 0 + self.assertEqual(w, range(1 << 30)) + self.assertEqual(x, 0) + self.assertEqual(y, 1) + self.assertEqual(z, 0) + + def test_patma_193(self): + x = {"bandwidth": 0, "latency": 1} + match x: + case {"bandwidth": b, "latency": l}: + y = 0 + self.assertEqual(x, {"bandwidth": 0, "latency": 1}) + self.assertIs(b, x["bandwidth"]) + self.assertIs(l, x["latency"]) + self.assertEqual(y, 0) + + def test_patma_194(self): + x = {"bandwidth": 0, "latency": 1, "key": "value"} + match x: + case {"latency": l, "bandwidth": b}: + y = 0 + self.assertEqual(x, {"bandwidth": 0, "latency": 1, "key": "value"}) + self.assertIs(l, x["latency"]) + self.assertIs(b, x["bandwidth"]) + self.assertEqual(y, 0) + + def test_patma_195(self): + x = {"bandwidth": 0, "latency": 1, "key": "value"} + match x: + case {"bandwidth": b, "latency": l, **rest}: + y = 0 + self.assertEqual(x, {"bandwidth": 0, "latency": 1, "key": "value"}) + self.assertIs(b, x["bandwidth"]) + self.assertIs(l, x["latency"]) + self.assertEqual(rest, {"key": "value"}) + self.assertEqual(y, 0) + + def test_patma_196(self): + x = {"bandwidth": 0, "latency": 1} + match x: + case {"latency": l, "bandwidth": b, **rest}: + y = 0 + self.assertEqual(x, {"bandwidth": 0, "latency": 1}) + self.assertIs(l, x["latency"]) + self.assertIs(b, x["bandwidth"]) + self.assertEqual(rest, {}) + self.assertEqual(y, 0) + + def test_patma_197(self): + @dataclasses.dataclass + class Point: + x: int + y: int + w = [Point(-1, 0), Point(1, 2)] + match w: + case (Point(x1, y1), p2 := Point(x2, y2)): + z = 0 + self.assertEqual(w, [Point(-1, 0), Point(1, 2)]) + self.assertIs(x1, w[0].x) + self.assertIs(y1, w[0].y) + self.assertIs(p2, w[1]) + self.assertIs(x2, w[1].x) + self.assertIs(y2, w[1].y) + self.assertIs(z, 0) + + def test_patma_198(self): + class Color(enum.Enum): + RED = 0 + GREEN = 1 + BLUE = 2 + def f(color): + match color: + case Color.RED: + return "I see red!" + case Color.GREEN: + return "Grass is green" + case Color.BLUE: + return "I'm feeling the blues :(" + self.assertEqual(f(Color.RED), "I see red!") + self.assertEqual(f(Color.GREEN), "Grass is green") + self.assertEqual(f(Color.BLUE), "I'm feeling the blues :(") + self.assertEqual(f(Color), None) + self.assertEqual(f(0), None) + self.assertEqual(f(1), None) + self.assertEqual(f(2), None) + self.assertEqual(f(3), None) + self.assertEqual(f(False), None) + self.assertEqual(f(True), None) + self.assertEqual(f(2+0j), None) + self.assertEqual(f(3.0), None) + + def test_patma_199(self): + class Color(int, enum.Enum): + RED = 0 + GREEN = 1 + BLUE = 2 + def f(color): + match color: + case Color.RED: + return "I see red!" + case Color.GREEN: + return "Grass is green" + case Color.BLUE: + return "I'm feeling the blues :(" + self.assertEqual(f(Color.RED), "I see red!") + self.assertEqual(f(Color.GREEN), "Grass is green") + self.assertEqual(f(Color.BLUE), "I'm feeling the blues :(") + self.assertEqual(f(Color), None) + self.assertEqual(f(0), "I see red!") + self.assertEqual(f(1), "Grass is green") + self.assertEqual(f(2), "I'm feeling the blues :(") + self.assertEqual(f(3), None) + self.assertEqual(f(False), "I see red!") + self.assertEqual(f(True), "Grass is green") + self.assertEqual(f(2+0j), "I'm feeling the blues :(") + self.assertEqual(f(3.0), None) + + +class PerfPatma(TestPatma): def assertEqual(*_, **__): pass @@ -1646,6 +2033,10 @@ def assertEqual(*_, **__): def assertIs(*_, **__): pass + @contextlib.contextmanager + def assertRaises(*_, **__): + yield + def run_perf(self): attrs = vars(type(self)).items() tests = [attr for name, attr in attrs if name.startswith("test_")] @@ -1653,9 +2044,13 @@ def run_perf(self): for test in tests: test(self) + @staticmethod + def setUpClass(): + raise unittest.SkipTest("performance testing") + """ sudo ./python -m pyperf system tune && \ - ./python -m pyperf timeit -s "from test.test_patma import PerfMatch; p = PerfMatch()" "p.run_perf()"; \ + ./python -m pyperf timeit -s "from test.test_patma import PerfPatma; p = PerfPatma()" "p.run_perf()"; \ sudo ./python -m pyperf system reset """ From 3eadc5357c216d7da311d264f2f720792c694495 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 14 Jul 2020 13:22:50 -0700 Subject: [PATCH 135/189] Add more tests --- Lib/test/test_patma.py | 225 +++++++++++++++++++++++++++++++++++------ 1 file changed, 193 insertions(+), 32 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 8f7ffac487bc8a..6458c9ccb0d46e 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -1,3 +1,4 @@ +import array import collections import contextlib import dataclasses @@ -5,6 +6,12 @@ import unittest +@dataclasses.dataclass +class Point: + x: int + y: int + + class TestPatma(unittest.TestCase): def test_patma_000(self): @@ -1698,10 +1705,6 @@ def whereis(point): whereis(42) def test_patma_177(self): - @dataclasses.dataclass - class Point: - x: int - y: int def whereis(point): match point: case Point(0, 0): @@ -1725,10 +1728,6 @@ def whereis(point): self.assertEqual(whereis(42), "Not a point") def test_patma_178(self): - @dataclasses.dataclass - class Point: - x: int - y: int def whereis(point): match point: case Point(1, var): @@ -1737,10 +1736,6 @@ def whereis(point): self.assertIs(whereis(Point(0, 0)), None) def test_patma_179(self): - @dataclasses.dataclass - class Point: - x: int - y: int def whereis(point): match point: case Point(1, y=var): @@ -1749,10 +1744,6 @@ def whereis(point): self.assertIs(whereis(Point(0, 0)), None) def test_patma_180(self): - @dataclasses.dataclass - class Point: - x: int - y: int def whereis(point): match point: case Point(x=1, y=var): @@ -1761,10 +1752,6 @@ def whereis(point): self.assertIs(whereis(Point(0, 0)), None) def test_patma_181(self): - @dataclasses.dataclass - class Point: - x: int - y: int def whereis(point): match point: case Point(y=var, x=1): @@ -1773,10 +1760,6 @@ def whereis(point): self.assertIs(whereis(Point(0, 0)), None) def test_patma_182(self): - @dataclasses.dataclass - class Point: - x: int - y: int def whereis(points): match points: case []: @@ -1799,10 +1782,6 @@ def whereis(points): self.assertEqual(whereis([Point(0, 1), Point(0, 1), Point(0, 1)]), "Something else") def test_patma_183(self): - @dataclasses.dataclass - class Point: - x: int - y: int def whereis(point): match point: case Point(x, y) if x == y: @@ -1956,10 +1935,6 @@ def test_patma_196(self): self.assertEqual(y, 0) def test_patma_197(self): - @dataclasses.dataclass - class Point: - x: int - y: int w = [Point(-1, 0), Point(1, 2)] match w: case (Point(x1, y1), p2 := Point(x2, y2)): @@ -2024,6 +1999,192 @@ def f(color): self.assertEqual(f(2+0j), "I'm feeling the blues :(") self.assertEqual(f(3.0), None) + def test_patma_200(self): + class Class: + __match_args__ = ["a", "b"] + c = Class() + c.a = 0 + c.b = 1 + match c: + case Class(x, y): + z = 0 + self.assertIs(x, c.a) + self.assertIs(y, c.b) + self.assertEqual(z, 0) + + def test_patma_201(self): + class Class: + __match_args__ = ("a", "b") + c = Class() + c.a = 0 + c.b = 1 + match c: + case Class(x, b=y): + z = 0 + self.assertIs(x, c.a) + self.assertIs(y, c.b) + self.assertEqual(z, 0) + + def test_patma_202(self): + class Parent: + __match_args__ = "a", "b" + class Child(Parent): + __match_args__ = ["c", "d"] + c = Child() + c.a = 0 + c.b = 1 + match c: + case Parent(x, y): + z = 0 + self.assertIs(x, c.a) + self.assertIs(y, c.b) + self.assertEqual(z, 0) + + def test_patma_203(self): + class Parent: + __match_args__ = ("a", "b") + class Child(Parent): + __match_args__ = "c", "d" + c = Child() + c.a = 0 + c.b = 1 + match c: + case Parent(x, b=y): + z = 0 + self.assertIs(x, c.a) + self.assertIs(y, c.b) + self.assertEqual(z, 0) + + def test_patma_204(self): + def f(w): + match w: + case 42: + out = locals().copy() + del out["w"] + return out + self.assertEqual(f(42), {}) + self.assertIs(f(0), None) + self.assertEqual(f(42.0), {}) + self.assertIs(f("42"), None) + + def test_patma_205(self): + def f(w): + match w: + case 42.0: + out = locals().copy() + del out["w"] + return out + self.assertEqual(f(42.0), {}) + self.assertEqual(f(42), {}) + self.assertIs(f(0.0), None) + self.assertIs(f(0), None) + + def test_patma_206(self): + def f(w): + match w: + case 1 | 2 | 3: + out = locals().copy() + del out["w"] + return out + self.assertEqual(f(1), {}) + self.assertEqual(f(2), {}) + self.assertEqual(f(3), {}) + self.assertEqual(f(3.0), {}) + self.assertIs(f(0), None) + self.assertIs(f(4), None) + self.assertIs(f("1"), None) + + def test_patma_207(self): + def f(w): + match w: + case [1, 2] | [3, 4]: + out = locals().copy() + del out["w"] + return out + self.assertEqual(f([1, 2]), {}) + self.assertEqual(f([3, 4]), {}) + self.assertIs(f(42), None) + self.assertIs(f([2, 3]), None) + self.assertIs(f([1, 2, 3]), None) + self.assertEqual(f([1, 2.0]), {}) + + def test_patma_208(self): + def f(w): + match w: + case x: + out = locals().copy() + del out["w"] + return out + self.assertEqual(f(42), {"x": 42}) + self.assertEqual(f((1, 2)), {"x": (1, 2)}) + self.assertEqual(f(None), {"x": None}) + + def test_patma_209(self): + def f(w): + match w: + case _: + out = locals().copy() + del out["w"] + return out + self.assertEqual(f(42), {}) + self.assertEqual(f(None), {}) + self.assertEqual(f((1, 2)), {}) + + def test_patma_210(self): + def f(w): + match w: + case (x, y, z): + out = locals().copy() + del out["w"] + return out + self.assertEqual(f((1, 2, 3)), {"x": 1, "y": 2, "z": 3}) + self.assertIs(f((1, 2)), None) + self.assertIs(f((1, 2, 3, 4)), None) + self.assertIs(f(123), None) + self.assertIs(f("abc"), None) + self.assertIs(f(b"abc"), None) + self.assertIs(f(array.array("b", b"abc")), None) + self.assertEqual(f(memoryview(b"abc")), {"x": 97, "y": 98, "z": 99}) + self.assertIs(f(bytearray(b"abc")), None) + + def test_patma_211(self): + def f(w): + match w: + case {"x": x, "y": "y", "z": z}: + out = locals().copy() + del out["w"] + return out + self.assertEqual(f({"x": "x", "y": "y", "z": "z"}), {"x": "x", "z": "z"}) + self.assertEqual(f({"x": "x", "y": "y", "z": "z", "a": "a"}), {"x": "x", "z": "z"}) + self.assertIs(f(({"x": "x", "y": "yy", "z": "z", "a": "a"})), None) + self.assertIs(f(({"x": "x", "y": "y"})), None) + + def test_patma_212(self): + @dataclasses.dataclass + class MyClass: + x: int + y: str + __match_args__ = ["x", "y"] + def f(w): + match w: + case MyClass(int(xx), y="hello"): + out = locals().copy() + del out["w"], out["MyClass"] + return out + self.assertEqual(f(MyClass(42, "hello")), {"xx": 42}) + + def test_patma_213(self): + def f(w): + match w: + case x := (p, q): + out = locals().copy() + del out["w"] + return out + self.assertEqual(f((1, 2)), {"p": 1, "q": 2, "x": (1, 2)}) + self.assertEqual(f([1, 2]), {"p": 1, "q": 2, "x": [1, 2]}) + self.assertIs(f(12), None) + self.assertIs(f((1, 2, 3)), None) + class PerfPatma(TestPatma): From 7d232590385edf99b68aa90a353a46e2c5534422 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 14 Jul 2020 13:58:10 -0700 Subject: [PATCH 136/189] Update test --- Lib/test/test_patma.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 6458c9ccb0d46e..f8f8714789edaf 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2143,7 +2143,7 @@ def f(w): self.assertIs(f(123), None) self.assertIs(f("abc"), None) self.assertIs(f(b"abc"), None) - self.assertIs(f(array.array("b", b"abc")), None) + self.assertEqual(f(array.array("b", b"abc")), {'x': 97, 'y': 98, 'z': 99}) self.assertEqual(f(memoryview(b"abc")), {"x": 97, "y": 98, "z": 99}) self.assertIs(f(bytearray(b"abc")), None) @@ -2185,6 +2185,12 @@ def f(w): self.assertIs(f(12), None) self.assertIs(f((1, 2, 3)), None) + # TODO: PEP tests + # TODO: Don't check side-effecty assignments + # TODO: Full coverage of errors and warnings + # TODO: Check numbers, dupes + # TODO: Better use of assertIs + class PerfPatma(TestPatma): From bed2e68225a68d487085b368a2c9df32e8ff9c36 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 14 Jul 2020 15:31:08 -0700 Subject: [PATCH 137/189] target -> subject --- Grammar/python.gram | 4 ++-- Include/Python-ast.h | 7 ++++--- Lib/ast.py | 2 +- Parser/Python.asdl | 2 +- Parser/parser.c | 6 +++--- Python/Python-ast.c | 32 ++++++++++++++++++-------------- Python/ast.c | 2 +- Python/ast_opt.c | 2 +- Python/ceval.c | 38 +++++++++++++++++++------------------- Python/compile.c | 9 +++++---- Python/symtable.c | 2 +- 11 files changed, 56 insertions(+), 50 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 1b9e9fbbbfa3d7..f8e488771fef9a 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -202,8 +202,8 @@ match_expr[expr_ty]: | named_expression match_stmt[stmt_ty]: - | "match" target=match_expr ':' NEWLINE INDENT cases=case_block+ DEDENT { - _Py_Match(target, cases, EXTRA) } + | "match" subject=match_expr ':' NEWLINE INDENT cases=case_block+ DEDENT { + _Py_Match(subject, cases, EXTRA) } case_block[match_case_ty]: | "case" pattern=patterns guard=guard? ':' body=block { _Py_match_case(pattern, guard, body, p->arena) } diff --git a/Include/Python-ast.h b/Include/Python-ast.h index f2ebf9244aa512..38cb5f840da4ed 100644 --- a/Include/Python-ast.h +++ b/Include/Python-ast.h @@ -180,7 +180,7 @@ struct _stmt { } AsyncWith; struct { - expr_ty target; + expr_ty subject; asdl_seq *cases; } Match; @@ -537,8 +537,9 @@ stmt_ty _Py_AsyncWith(asdl_seq * items, asdl_seq * body, string type_comment, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); #define Match(a0, a1, a2, a3, a4, a5, a6) _Py_Match(a0, a1, a2, a3, a4, a5, a6) -stmt_ty _Py_Match(expr_ty target, asdl_seq * cases, int lineno, int col_offset, - int end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _Py_Match(expr_ty subject, asdl_seq * cases, int lineno, int + col_offset, int end_lineno, int end_col_offset, PyArena + *arena); #define Raise(a0, a1, a2, a3, a4, a5, a6) _Py_Raise(a0, a1, a2, a3, a4, a5, a6) stmt_ty _Py_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); diff --git a/Lib/ast.py b/Lib/ast.py index 1085326b4a26b7..89c59f30152ae5 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -1417,7 +1417,7 @@ def visit_Slice(self, node): def visit_Match(self, node): self.fill("match ") - self.traverse(node.target) + self.traverse(node.subject) with self.block(): for case in node.cases: self.traverse(case) diff --git a/Parser/Python.asdl b/Parser/Python.asdl index 517aa256d8d00f..2ea375366873ee 100644 --- a/Parser/Python.asdl +++ b/Parser/Python.asdl @@ -36,7 +36,7 @@ module Python | With(withitem* items, stmt* body, string? type_comment) | AsyncWith(withitem* items, stmt* body, string? type_comment) - | Match(expr target, match_case* cases) + | Match(expr subject, match_case* cases) | Raise(expr? exc, expr? cause) | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody) diff --git a/Parser/parser.c b/Parser/parser.c index a2e39d8840d493..426a997a3356f6 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -4899,11 +4899,11 @@ match_stmt_rule(Parser *p) Token * dedent_var; Token * indent_var; Token * newline_var; - expr_ty target; + expr_ty subject; if ( (_keyword = _PyPegen_expect_soft_keyword(p, "match")) // soft_keyword='"match"' && - (target = match_expr_rule(p)) // match_expr + (subject = match_expr_rule(p)) // match_expr && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -4926,7 +4926,7 @@ match_stmt_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Match ( target , cases , EXTRA ); + _res = _Py_Match ( subject , cases , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); diff --git a/Python/Python-ast.c b/Python/Python-ast.c index 132a8276ce5360..afddbc623aa4b0 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -213,6 +213,7 @@ typedef struct { PyObject *slice; PyObject *step; PyObject *stmt_type; + PyObject *subject; PyObject *tag; PyObject *target; PyObject *targets; @@ -469,6 +470,7 @@ static int astmodule_clear(PyObject *module) Py_CLEAR(state->slice); Py_CLEAR(state->step); Py_CLEAR(state->stmt_type); + Py_CLEAR(state->subject); Py_CLEAR(state->tag); Py_CLEAR(state->target); Py_CLEAR(state->targets); @@ -695,6 +697,7 @@ static int astmodule_traverse(PyObject *module, visitproc visit, void* arg) Py_VISIT(state->slice); Py_VISIT(state->step); Py_VISIT(state->stmt_type); + Py_VISIT(state->subject); Py_VISIT(state->tag); Py_VISIT(state->target); Py_VISIT(state->targets); @@ -786,6 +789,7 @@ static int init_identifiers(astmodulestate *state) if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return 0; if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return 0; if ((state->step = PyUnicode_InternFromString("step")) == NULL) return 0; + if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return 0; if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return 0; if ((state->target = PyUnicode_InternFromString("target")) == NULL) return 0; if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return 0; @@ -902,7 +906,7 @@ static const char * const AsyncWith_fields[]={ "type_comment", }; static const char * const Match_fields[]={ - "target", + "subject", "cases", }; static const char * const Raise_fields[]={ @@ -1508,7 +1512,7 @@ static int init_types(astmodulestate *state) " | If(expr test, stmt* body, stmt* orelse)\n" " | With(withitem* items, stmt* body, string? type_comment)\n" " | AsyncWith(withitem* items, stmt* body, string? type_comment)\n" - " | Match(expr target, match_case* cases)\n" + " | Match(expr subject, match_case* cases)\n" " | Raise(expr? exc, expr? cause)\n" " | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n" " | Assert(expr test, expr? msg)\n" @@ -1613,7 +1617,7 @@ static int init_types(astmodulestate *state) return 0; state->Match_type = make_type(state, "Match", state->stmt_type, Match_fields, 2, - "Match(expr target, match_case* cases)"); + "Match(expr subject, match_case* cases)"); if (!state->Match_type) return 0; state->Raise_type = make_type(state, "Raise", state->stmt_type, Raise_fields, 2, @@ -2616,20 +2620,20 @@ AsyncWith(asdl_seq * items, asdl_seq * body, string type_comment, int lineno, } stmt_ty -Match(expr_ty target, asdl_seq * cases, int lineno, int col_offset, int +Match(expr_ty subject, asdl_seq * cases, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena) { stmt_ty p; - if (!target) { + if (!subject) { PyErr_SetString(PyExc_ValueError, - "field 'target' is required for Match"); + "field 'subject' is required for Match"); return NULL; } p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) return NULL; p->kind = Match_kind; - p->v.Match.target = target; + p->v.Match.subject = subject; p->v.Match.cases = cases; p->lineno = lineno; p->col_offset = col_offset; @@ -4100,9 +4104,9 @@ ast2obj_stmt(astmodulestate *state, void* _o) tp = (PyTypeObject *)state->Match_type; result = PyType_GenericNew(tp, NULL, NULL); if (!result) goto failed; - value = ast2obj_expr(state, o->v.Match.target); + value = ast2obj_expr(state, o->v.Match.subject); if (!value) goto failed; - if (PyObject_SetAttr(result, state->target, value) == -1) + if (PyObject_SetAttr(result, state->subject, value) == -1) goto failed; Py_DECREF(value); value = ast2obj_list(state, o->v.Match.cases, ast2obj_match_case); @@ -6873,19 +6877,19 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena) return 1; } if (isinstance) { - expr_ty target; + expr_ty subject; asdl_seq* cases; - if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) { + if (_PyObject_LookupAttr(obj, state->subject, &tmp) < 0) { return 1; } if (tmp == NULL) { - PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from Match"); + PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match"); return 1; } else { int res; - res = obj2ast_expr(state, tmp, &target, arena); + res = obj2ast_expr(state, tmp, &subject, arena); if (res != 0) goto failed; Py_CLEAR(tmp); } @@ -6922,7 +6926,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena) } Py_CLEAR(tmp); } - *out = Match(target, cases, lineno, col_offset, end_lineno, + *out = Match(subject, cases, lineno, col_offset, end_lineno, end_col_offset, arena); if (*out == NULL) goto failed; return 0; diff --git a/Python/ast.c b/Python/ast.c index 90e6e9b4313605..a80e45969e526b 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -538,7 +538,7 @@ validate_stmt(stmt_ty stmt) } return validate_body(stmt->v.AsyncWith.body, "AsyncWith"); case Match_kind: - if (!validate_expr(stmt->v.Match.target, Load) + if (!validate_expr(stmt->v.Match.subject, Load) || !validate_nonempty_seq(stmt->v.Match.cases, "cases", "Match")) { return 0; } diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 265d80aca0f529..a12c55471e4a6f 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -713,7 +713,7 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) CALL(astfold_expr, expr_ty, node_->v.Expr.value); break; case Match_kind: - CALL(astfold_expr, expr_ty, node_->v.Match.target); + CALL(astfold_expr, expr_ty, node_->v.Match.subject); CALL_SEQ(astfold_match_case, match_case_ty, node_->v.Match.cases); break; default: diff --git a/Python/ceval.c b/Python/ceval.c index 91d9c00fea0f48..fd59d5d756cd49 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -973,7 +973,7 @@ get_match_args(PyThreadState *tstate, PyObject *type) } static PyObject * -do_match(PyThreadState *tstate, Py_ssize_t nargs, PyObject *kwargs, PyObject *type, PyObject *target) +do_match(PyThreadState *tstate, Py_ssize_t nargs, PyObject *kwargs, PyObject *type, PyObject *subject) { // TODO: Break this up! if (!PyType_Check(type)) { @@ -982,7 +982,7 @@ do_match(PyThreadState *tstate, Py_ssize_t nargs, PyObject *kwargs, PyObject *ty return NULL; } assert(PyTuple_CheckExact(kwargs)); - if (PyObject_IsInstance(target, type) <= 0) { + if (PyObject_IsInstance(subject, type) <= 0) { return NULL; } PyObject *args = NULL; @@ -1040,8 +1040,8 @@ do_match(PyThreadState *tstate, Py_ssize_t nargs, PyObject *kwargs, PyObject *ty if (i < nargs) { if (!args) { assert(!i); - Py_INCREF(target); - PyTuple_SET_ITEM(attrs, 0, target); + Py_INCREF(subject); + PyTuple_SET_ITEM(attrs, 0, subject); continue; } name = PyTuple_GET_ITEM(args, i); @@ -1063,7 +1063,7 @@ do_match(PyThreadState *tstate, Py_ssize_t nargs, PyObject *kwargs, PyObject *ty } goto error; } - attr = PyObject_GetAttr(target, name); + attr = PyObject_GetAttr(subject, name); if (!attr) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { _PyErr_Clear(tstate); @@ -3536,11 +3536,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(MATCH_CLASS): { PyObject *names = POP(); PyObject *type = TOP(); - PyObject *target = SECOND(); - PyObject *attrs = do_match(tstate, oparg, names, type, target); + PyObject *subject = SECOND(); + PyObject *attrs = do_match(tstate, oparg, names, type, subject); Py_DECREF(names); if (attrs) { - Py_DECREF(target); + Py_DECREF(subject); SET_SECOND(attrs); } else if (_PyErr_Occurred(tstate)) { @@ -3573,11 +3573,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_SEQUENCE): { - PyObject *target = TOP(); - if (PyType_FastSubclass(Py_TYPE(target), + PyObject *subject = TOP(); + if (PyType_FastSubclass(Py_TYPE(subject), Py_TPFLAGS_BYTES_SUBCLASS | Py_TPFLAGS_UNICODE_SUBCLASS) - || PyIter_Check(target) - || PyByteArray_Check(target)) + || PyIter_Check(subject) + || PyByteArray_Check(subject)) { Py_INCREF(Py_False); PUSH(Py_False); @@ -3595,7 +3595,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) goto error; } } - int match = PyObject_IsInstance(target, interp->seq_abc); + int match = PyObject_IsInstance(subject, interp->seq_abc); if (match < 0) { goto error; } @@ -3605,8 +3605,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(MATCH_KEYS): { PyObject *keys = TOP(); - PyObject *target = SECOND(); - PyObject *values = match_map_items(tstate, target, keys); + PyObject *subject = SECOND(); + PyObject *values = match_map_items(tstate, subject, keys); if (!values) { if (_PyErr_Occurred(tstate)) { goto error; @@ -3619,12 +3619,12 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } if (oparg) { - PyObject *rest = match_map_copy(tstate, target, keys); + PyObject *rest = match_map_copy(tstate, subject, keys); if (!rest) { goto error; } SET_SECOND(rest); - Py_DECREF(target); + Py_DECREF(subject); } SET_TOP(values); Py_DECREF(keys); @@ -3668,10 +3668,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (!items) { goto error; } - PyObject *target = TOP(); + PyObject *subject = TOP(); PyObject *item; for (Py_ssize_t i = start; i < stop; i++) { - item = PySequence_GetItem(target, i); + item = PySequence_GetItem(subject, i); if (!item) { Py_DECREF(items); goto error; diff --git a/Python/compile.c b/Python/compile.c index 1c3355a534ccb9..032da7beb4454e 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5544,9 +5544,10 @@ compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context *pc) compiler_warn(c, "name capture pattern makes remaining alternate " "patterns unreachable"); } - if (!(pc->stores && compiler_addop(c, DUP_TOP) && - compiler_pattern(c, alt, pc) && - compiler_addop_j(c, JUMP_IF_TRUE_OR_POP, end, 1))) + if (!pc->stores || + !compiler_addop(c, DUP_TOP) || + !compiler_pattern(c, alt, pc) || + !compiler_addop_j(c, JUMP_IF_TRUE_OR_POP, end, 1)) { goto fail; } @@ -5841,7 +5842,7 @@ compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc) static int compiler_match(struct compiler *c, stmt_ty s) { - VISIT(c, expr, s->v.Match.target); + VISIT(c, expr, s->v.Match.subject); basicblock *next, *end; CHECK(end = compiler_new_block(c)); Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); diff --git a/Python/symtable.c b/Python/symtable.c index 5cf1f90ed5f942..83f744301257ee 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1293,7 +1293,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_SEQ(st, stmt, s->v.If.orelse); break; case Match_kind: - VISIT(st, expr, s->v.Match.target); + VISIT(st, expr, s->v.Match.subject); VISIT_SEQ(st, match_case, s->v.Match.cases); break; case Raise_kind: From 1a70d2c690f9cb82a859299767141b80b1a50525 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 15 Jul 2020 07:41:00 -0700 Subject: [PATCH 138/189] Add tests --- Lib/test/test_patma.py | 181 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 162 insertions(+), 19 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index f8f8714789edaf..cb67d8af3b9eba 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -3,7 +3,16 @@ import contextlib import dataclasses import enum +import inspect import unittest +import warnings + + +@dataclasses.dataclass +class MyClass: + x: int + y: str + __match_args__ = ["x", "y"] @dataclasses.dataclass @@ -2059,7 +2068,7 @@ def test_patma_204(self): def f(w): match w: case 42: - out = locals().copy() + out = locals() del out["w"] return out self.assertEqual(f(42), {}) @@ -2071,7 +2080,7 @@ def test_patma_205(self): def f(w): match w: case 42.0: - out = locals().copy() + out = locals() del out["w"] return out self.assertEqual(f(42.0), {}) @@ -2083,7 +2092,7 @@ def test_patma_206(self): def f(w): match w: case 1 | 2 | 3: - out = locals().copy() + out = locals() del out["w"] return out self.assertEqual(f(1), {}) @@ -2098,7 +2107,7 @@ def test_patma_207(self): def f(w): match w: case [1, 2] | [3, 4]: - out = locals().copy() + out = locals() del out["w"] return out self.assertEqual(f([1, 2]), {}) @@ -2112,7 +2121,7 @@ def test_patma_208(self): def f(w): match w: case x: - out = locals().copy() + out = locals() del out["w"] return out self.assertEqual(f(42), {"x": 42}) @@ -2123,7 +2132,7 @@ def test_patma_209(self): def f(w): match w: case _: - out = locals().copy() + out = locals() del out["w"] return out self.assertEqual(f(42), {}) @@ -2134,7 +2143,7 @@ def test_patma_210(self): def f(w): match w: case (x, y, z): - out = locals().copy() + out = locals() del out["w"] return out self.assertEqual(f((1, 2, 3)), {"x": 1, "y": 2, "z": 3}) @@ -2151,7 +2160,7 @@ def test_patma_211(self): def f(w): match w: case {"x": x, "y": "y", "z": z}: - out = locals().copy() + out = locals() del out["w"] return out self.assertEqual(f({"x": "x", "y": "y", "z": "z"}), {"x": "x", "z": "z"}) @@ -2160,16 +2169,11 @@ def f(w): self.assertIs(f(({"x": "x", "y": "y"})), None) def test_patma_212(self): - @dataclasses.dataclass - class MyClass: - x: int - y: str - __match_args__ = ["x", "y"] def f(w): match w: case MyClass(int(xx), y="hello"): - out = locals().copy() - del out["w"], out["MyClass"] + out = locals() + del out["w"] return out self.assertEqual(f(MyClass(42, "hello")), {"xx": 42}) @@ -2177,7 +2181,7 @@ def test_patma_213(self): def f(w): match w: case x := (p, q): - out = locals().copy() + out = locals() del out["w"] return out self.assertEqual(f((1, 2)), {"p": 1, "q": 2, "x": (1, 2)}) @@ -2185,6 +2189,136 @@ def f(w): self.assertIs(f(12), None) self.assertIs(f((1, 2, 3)), None) + def test_patma_214(self): + def f(): + match 42: + case 42: + return locals() + self.assertEqual(set(f()), set()) + + def test_patma_215(self): + def f(): + match 1: + case 1 | 2 | 3: + return locals() + self.assertEqual(set(f()), set()) + + def test_patma_216(self): + def f(): + match ...: + case _: + return locals() + self.assertEqual(set(f()), set()) + + def test_patma_217(self): + def f(): + match ...: + case abc: + return locals() + self.assertEqual(set(f()), {"abc"}) + + def test_patma_218(self): + namespace = {} + code = """ + match ...: + case a | a: + pass + """ + with self.assertWarns(SyntaxWarning): + exec(inspect.cleandoc(code), None, namespace) + self.assertEqual(set(namespace), {"a"}) + + def test_patma_219(self): + code = """ + match ...: + case a | "a": + pass + """ + with self.assertWarns(SyntaxWarning), self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_220(self): + def f(): + match ..., ...: + case a, b: + return locals() + self.assertEqual(set(f()), {"a", "b"}) + + def test_patma_221(self): + code = """ + match ...: + case a, a: + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_222(self): + def f(): + match {"k": ..., "l": ...}: + case {"k": a, "l": b}: + return locals() + self.assertEqual(set(f()), {"a", "b"}) + + def test_patma_223(self): + code = """ + match ...: + case {"k": a, "l": a}: + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_224(self): + def f(): + match MyClass(..., ...): + case MyClass(x, y=y): + return locals() + self.assertEqual(set(f()), {"x", "y"}) + + def test_patma_225(self): + code = """ + match ...: + case MyClass(x, x): + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_226(self): + code = """ + match ...: + case MyClass(x=x, y=x): + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_227(self): + code = """ + match ...: + case MyClass(x, y=x): + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_228(self): + def f(): + match ...: + case a := b: + return locals() + self.assertEqual(set(f()), {"a", "b"}) + + def test_patma_229(self): + code = """ + match ...: + case a := a: + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + # TODO: PEP tests # TODO: Don't check side-effecty assignments # TODO: Full coverage of errors and warnings @@ -2202,12 +2336,21 @@ def assertIs(*_, **__): @contextlib.contextmanager def assertRaises(*_, **__): - yield + try: + yield + except: + pass + + @contextlib.contextmanager + def assertWarns(*_, **__): + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + yield def run_perf(self): - attrs = vars(type(self)).items() + attrs = vars(TestPatma).items() tests = [attr for name, attr in attrs if name.startswith("test_")] - for _ in range(1 << 10): + for _ in range(1 << 8): for test in tests: test(self) From f83302ff389bc214b81b8c71c0fc36f180ad1cc6 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 15 Jul 2020 09:07:18 -0700 Subject: [PATCH 139/189] Refactor loads --- Python/ast_opt.c | 25 +++++++++------- Python/compile.c | 74 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 70 insertions(+), 29 deletions(-) diff --git a/Python/ast_opt.c b/Python/ast_opt.c index a12c55471e4a6f..f26bec062fb0e9 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -751,11 +751,16 @@ astfold_pattern_negative(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *stat assert(node_->v.UnaryOp.op == USub); assert(node_->v.UnaryOp.operand->kind == Constant_kind); PyObject *value = node_->v.UnaryOp.operand->v.Constant.value; - assert(PyComplex_CheckExact(value) || PyFloat_CheckExact(value) || PyLong_CheckExact(value)); + assert(PyComplex_CheckExact(value) || + PyFloat_CheckExact(value) || + PyLong_CheckExact(value)); PyObject *negated = PyNumber_Negative(value); if (!negated) { return 0; } + assert(PyComplex_CheckExact(negated) || + PyFloat_CheckExact(negated) || + PyLong_CheckExact(negated)); return make_const(node_, negated, ctx_); } @@ -763,31 +768,31 @@ static int astfold_pattern_complex(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) { expr_ty left = node_->v.BinOp.left; + expr_ty right = node_->v.BinOp.right; if (left->kind == UnaryOp_kind) { CALL(astfold_pattern_negative, expr_ty, left); } - expr_ty right = node_->v.BinOp.right; - assert(node_->v.BinOp.op == Add || node_->v.BinOp.op == Sub); - assert(node_->v.BinOp.left->kind = Constant_kind); - assert(node_->v.BinOp.right->kind = Constant_kind); - if (!PyFloat_CheckExact(left->v.Constant.value) && !PyLong_CheckExact(left->v.Constant.value)) { + assert(left->kind = Constant_kind); + assert(right->kind = Constant_kind); + if (!(PyFloat_CheckExact(left->v.Constant.value) || + PyLong_CheckExact(left->v.Constant.value)) || + !PyComplex_CheckExact(right->v.Constant.value)) + { // Not actually valid, but it's the complier's job to complain: return 1; } - if (!PyComplex_CheckExact(right->v.Constant.value)) { - // Ditto: - return 1; - } PyObject *new; if (node_->v.BinOp.op == Add) { new = PyNumber_Add(left->v.Constant.value, right->v.Constant.value); } else { + assert(node_->v.BinOp.op == Sub); new = PyNumber_Subtract(left->v.Constant.value, right->v.Constant.value); } if (!new) { return 0; } + assert(PyComplex_CheckExact(new)); return make_const(node_, new, ctx_); } diff --git a/Python/compile.c b/Python/compile.c index 032da7beb4454e..b92faa8bb33499 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5454,27 +5454,51 @@ compiler_slice(struct compiler *c, expr_ty s) static int -pattern_load(struct compiler *c, expr_ty p, pattern_context *pc) +pattern_load_name(struct compiler *c, expr_ty p, pattern_context *pc) { - if (p->kind == Attribute_kind) { - assert(p->v.Attribute.ctx == Load); - CHECK(pattern_load(c, p->v.Attribute.value, pc)); - ADDOP_NAME(c, LOAD_ATTR, p->v.Attribute.attr, names); - } - else if (p->kind == Name_kind) { - assert(p->v.Name.ctx == Load); - CHECK(compiler_nameop(c, p->v.Name.id, Load)); + assert(p->kind == Name_kind); + assert(p->v.Name.ctx == Load); + CHECK(compiler_nameop(c, p->v.Name.id, Load)); + return 1; +} + + +static int +pattern_load_attribute(struct compiler *c, expr_ty p, pattern_context *pc) +{ + assert(p->kind == Attribute_kind); + assert(p->v.Attribute.ctx == Load); + if (p->v.Attribute.value->kind == Attribute_kind) { + CHECK(pattern_load_attribute(c, p->v.Attribute.value, pc)); } else { - assert(p->kind == Constant_kind); - ADDOP_LOAD_CONST(c, p->v.Constant.value); + assert(p->v.Attribute.value->kind == Name_kind); + CHECK(pattern_load_name(c, p->v.Attribute.value, pc)); } + ADDOP_NAME(c, LOAD_ATTR, p->v.Attribute.attr, names); return 1; } static int -pattern_store(struct compiler *c, expr_ty p, pattern_context *pc) +pattern_load_constant(struct compiler *c, expr_ty p, pattern_context *pc) +{ + assert(p->kind == Constant_kind); + assert(PyBytes_CheckExact(p->v.Constant.value) || + PyComplex_CheckExact(p->v.Constant.value) || + PyFloat_CheckExact(p->v.Constant.value) || + PyLong_CheckExact(p->v.Constant.value) || + PyUnicode_CheckExact(p->v.Constant.value) || + p->v.Constant.value == Py_False || + p->v.Constant.value == Py_None || + p->v.Constant.value == Py_True); + ADDOP_LOAD_CONST(c, p->v.Constant.value); + return 1; +} + + +static int +pattern_store_name(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); @@ -5516,7 +5540,7 @@ compiler_pattern_attribute(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Attribute_kind); assert(p->v.Attribute.ctx == Load); - CHECK(pattern_load(c, p, pc)); + CHECK(pattern_load_attribute(c, p, pc)); ADDOP_COMPARE(c, Eq); return 1; } @@ -5596,7 +5620,13 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { CHECK(!validate_keywords(c, kwargs)); CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); - CHECK(pattern_load(c, p->v.Call.func, pc)); + if (p->v.Call.func->kind == Attribute_kind) { + CHECK(pattern_load_attribute(c, p->v.Call.func, pc)); + } + else { + assert(p->v.Call.func->kind == Name_kind); + CHECK(pattern_load_name(c, p->v.Call.func, pc)); + } PyObject *kwnames, *name; CHECK(kwnames = PyTuple_New(nkwargs)); Py_ssize_t i; @@ -5635,7 +5665,7 @@ static int compiler_pattern_constant(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Constant_kind); - CHECK(pattern_load(c, p, pc)); + CHECK(pattern_load_constant(c, p, pc)); ADDOP_COMPARE(c, Eq); return 1; } @@ -5666,7 +5696,13 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) if (!key) { return compiler_error(c, "can't use starred pattern here; consider moving to end?"); } - CHECK(pattern_load(c, key, pc)); + if (key->kind == Attribute_kind) { + CHECK(pattern_load_attribute(c, key, pc)); + } + else { + assert(key->kind == Constant_kind); + CHECK(pattern_load_constant(c, key, pc)); + } } ADDOP_I(c, BUILD_TUPLE, size - star); ADDOP_I(c, MATCH_KEYS, star); @@ -5682,7 +5718,7 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) } ADDOP(c, POP_TOP); if (star) { - CHECK(pattern_store(c, asdl_seq_GET(values, size - 1), pc)); + CHECK(pattern_store_name(c, asdl_seq_GET(values, size - 1), pc)); } else { ADDOP(c, POP_TOP); @@ -5777,7 +5813,7 @@ compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP(c, POP_TOP); } else { - CHECK(pattern_store(c, p, pc)); + CHECK(pattern_store_name(c, p, pc)); } ADDOP_LOAD_CONST(c, Py_True); return 1; @@ -5794,7 +5830,7 @@ compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP(c, DUP_TOP); CHECK(compiler_pattern(c, p->v.NamedExpr.value, pc)); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); - CHECK(pattern_store(c, p->v.NamedExpr.target, pc)); + CHECK(pattern_store_name(c, p->v.NamedExpr.target, pc)); ADDOP_LOAD_CONST(c, Py_True); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, block); From 1ba56a003b4e46c1833821c8133201e33b1ecddc Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 16 Jul 2020 17:23:24 -0700 Subject: [PATCH 140/189] Cleanup and better performance for default cases --- Lib/test/test_patma.py | 82 +++++++++++++++++--- Python/ceval.c | 45 ++++++++--- Python/compile.c | 169 ++++++++++++++++++----------------------- 3 files changed, 180 insertions(+), 116 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index cb67d8af3b9eba..06af444667d415 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -84,13 +84,11 @@ def test_patma_008(self): x = 0 class A: y = 1 - z = None match x: case z := A.y: pass self.assertEqual(x, 0) self.assertEqual(A.y, 1) - self.assertEqual(z, None) def test_patma_009(self): class A: @@ -245,13 +243,11 @@ def test_patma_027(self): def test_patma_028(self): x = {0: 3} y = None - z = None match x: case {0: (z := 0 | 1 | 2)}: y = 0 self.assertEqual(x, {0: 3}) self.assertEqual(y, None) - self.assertEqual(z, None) def test_patma_029(self): x = {} @@ -402,13 +398,11 @@ def test_patma_042(self): def test_patma_043(self): x = 3 y = None - z = None match x: case (z := 0) | (z := 1) | (z := 2) if z == x % 2: y = 0 self.assertEqual(x, 3) self.assertEqual(y, None) - self.assertEqual(z, None) def test_patma_044(self): x = () @@ -790,7 +784,6 @@ def test_patma_081(self): def test_patma_082(self): x = 0 - z = None match x: case (z := 1) if not (x := 1): y = 0 @@ -798,7 +791,6 @@ def test_patma_082(self): y = 1 self.assertEqual(x, 0) self.assertEqual(y, 1) - self.assertEqual(z, None) def test_patma_083(self): x = 0 @@ -812,13 +804,11 @@ def test_patma_083(self): def test_patma_084(self): x = 0 y = None - z = None match x: case (z := 1): y = 0 self.assertEqual(x, 0) self.assertEqual(y, None) - self.assertEqual(z, None) def test_patma_085(self): x = 0 @@ -2319,6 +2309,78 @@ def test_patma_229(self): with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) + def test_patma_230(self): + def f(x): + match x: + case _: + return 0 + self.assertEqual(f(0), 0) + self.assertEqual(f(1), 0) + self.assertEqual(f(2), 0) + self.assertEqual(f(3), 0) + + def test_patma_231(self): + def f(x): + match x: + case 0: + return 0 + self.assertEqual(f(0), 0) + self.assertIs(f(1), None) + self.assertIs(f(2), None) + self.assertIs(f(3), None) + + def test_patma_232(self): + def f(x): + match x: + case 0: + return 0 + case _: + return 1 + self.assertEqual(f(0), 0) + self.assertEqual(f(1), 1) + self.assertEqual(f(2), 1) + self.assertEqual(f(3), 1) + + def test_patma_233(self): + def f(x): + match x: + case 0: + return 0 + case 1: + return 1 + self.assertEqual(f(0), 0) + self.assertEqual(f(1), 1) + self.assertIs(f(2), None) + self.assertIs(f(3), None) + + def test_patma_234(self): + def f(x): + match x: + case 0: + return 0 + case 1: + return 1 + case _: + return 2 + self.assertEqual(f(0), 0) + self.assertEqual(f(1), 1) + self.assertEqual(f(2), 2) + self.assertEqual(f(3), 2) + + def test_patma_235(self): + def f(x): + match x: + case 0: + return 0 + case 1: + return 1 + case 2: + return 2 + self.assertEqual(f(0), 0) + self.assertEqual(f(1), 1) + self.assertEqual(f(2), 2) + self.assertIs(f(3), None) + # TODO: PEP tests # TODO: Don't check side-effecty assignments # TODO: Full coverage of errors and warnings diff --git a/Python/ceval.c b/Python/ceval.c index fd59d5d756cd49..448c354a9fe3c4 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -855,7 +855,10 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) if (!nkeys) { return PyTuple_New(0); } - PyObject *get = NULL, *dummy = NULL, *seen = NULL, *values = NULL; + PyObject *get = NULL; + PyObject *dummy = NULL; + PyObject *seen = NULL; + PyObject *values = NULL; if (!PyDict_CheckExact(map)) { _Py_IDENTIFIER(get); get = _PyObject_GetAttrId(map, &PyId_get); @@ -3634,6 +3637,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(GET_INDEX): { + // PUSH(TOS[oparg]) PyObject *item = PySequence_GetItem(TOP(), oparg); if (!item) { goto error; @@ -3643,6 +3647,12 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(GET_INDEX_END): { + // PUSH(TOS[TOS1 - 1 - oparg]) + // NOTE: We can't rely on support for negative indexing! + // Although PySequence_GetItem tries to correct negative indexes, we + // just use the length we already have at TOS1. In addition to + // avoiding tons of redundant __len__ calls, this also handles + // length changes during extraction more intuitively. Py_ssize_t len = PyLong_AsSsize_t(SECOND()); if (len < 0) { goto error; @@ -3657,6 +3667,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(GET_INDEX_SLICE): { + // PUSH(list(TOS[oparg & 0xFF: TOS1 - (oparg >> 8)])) + // NOTE: We can't rely on support for slicing or negative indexing! + // Ditto GET_INDEX_END's length handling. Py_ssize_t len = PyLong_AsSsize_t(SECOND()); if (len < 0) { goto error; @@ -3664,19 +3677,29 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) Py_ssize_t start = oparg & 0xFF; Py_ssize_t stop = len - (oparg >> 8); assert(start <= stop); - PyObject *items = PyList_New(stop - start); - if (!items) { - goto error; - } PyObject *subject = TOP(); - PyObject *item; - for (Py_ssize_t i = start; i < stop; i++) { - item = PySequence_GetItem(subject, i); - if (!item) { - Py_DECREF(items); + PyObject *items; + if (PyList_CheckExact(subject)) { + items = PyList_GetSlice(subject, start, stop); + if (!items) { + goto error; + } + assert(PyList_CheckExact(items)); + } + else { + items = PyList_New(stop - start); + if (!items) { goto error; } - PyList_SET_ITEM(items, i - start, item); + PyObject *item; + for (Py_ssize_t i = start; i < stop; i++) { + item = PySequence_GetItem(subject, i); + if (!item) { + Py_DECREF(items); + goto error; + } + PyList_SET_ITEM(items, i - start, item); + } } PUSH(items); DISPATCH(); diff --git a/Python/compile.c b/Python/compile.c index b92faa8bb33499..bd8a283328c943 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -186,7 +186,7 @@ static int compiler_next_instr(basicblock *); static int compiler_addop(struct compiler *, int); static int compiler_addop_i(struct compiler *, int, Py_ssize_t); static int compiler_addop_j(struct compiler *, int, basicblock *, int); -static int compiler_error(struct compiler *, const char *); +static int compiler_error(struct compiler *, const char *, ...); static int compiler_warn(struct compiler *, const char *, ...); static int compiler_nameop(struct compiler *, identifier, expr_context_ty); @@ -4129,13 +4129,8 @@ validate_keywords(struct compiler *c, asdl_seq *keywords) for (Py_ssize_t j = i + 1; j < nkeywords; j++) { keyword_ty other = ((keyword_ty)asdl_seq_GET(keywords, j)); if (other->arg && !PyUnicode_Compare(key->arg, other->arg)) { - PyObject *msg = PyUnicode_FromFormat("keyword argument repeated: %U", key->arg); - if (msg == NULL) { - return -1; - } c->u->u_col_offset = other->col_offset; - compiler_error(c, PyUnicode_AsUTF8(msg)); - Py_DECREF(msg); + compiler_error(c, "keyword argument repeated: %U", key->arg); return -1; } } @@ -5311,28 +5306,34 @@ compiler_annassign(struct compiler *c, stmt_ty s) */ static int -compiler_error(struct compiler *c, const char *errstr) +compiler_error(struct compiler *c, const char *format, ...) { - PyObject *loc; - PyObject *u = NULL, *v = NULL; - - loc = PyErr_ProgramTextObject(c->c_filename, c->u->u_lineno); + va_list vargs; +#ifdef HAVE_STDARG_PROTOTYPES + va_start(vargs, format); +#else + va_start(vargs); +#endif + PyObject *msg = PyUnicode_FromFormatV(format, vargs); + va_end(vargs); + if (!msg) { + return 0; + } + PyObject *loc = PyErr_ProgramTextObject(c->c_filename, c->u->u_lineno); if (!loc) { Py_INCREF(Py_None); loc = Py_None; } - u = Py_BuildValue("(OiiO)", c->c_filename, c->u->u_lineno, - c->u->u_col_offset + 1, loc); - if (!u) - goto exit; - v = Py_BuildValue("(zO)", errstr, u); - if (!v) + PyObject *args = Py_BuildValue("O(OiiO)", msg, c->c_filename, + c->u->u_lineno, c->u->u_col_offset + 1, loc); + Py_DECREF(msg); + if (!args) { goto exit; - PyErr_SetObject(PyExc_SyntaxError, v); + } + PyErr_SetObject(PyExc_SyntaxError, args); exit: Py_DECREF(loc); - Py_XDECREF(u); - Py_XDECREF(v); + Py_XDECREF(args); return 0; } @@ -5444,7 +5445,7 @@ compiler_slice(struct compiler *c, expr_ty s) // For now, we eschew a full decision tree in favor of a simpler pass that just // tracks the most-recently-checked subclass and length info for the current // subject in the pattern_context struct. Experimentation suggests that the -// current approach keeps most of the runtime benefits while dramatically +// current approach can keep most of the runtime benefits while dramatically // reducing compiler complexity. @@ -5453,16 +5454,6 @@ compiler_slice(struct compiler *c, expr_ty s) _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) -static int -pattern_load_name(struct compiler *c, expr_ty p, pattern_context *pc) -{ - assert(p->kind == Name_kind); - assert(p->v.Name.ctx == Load); - CHECK(compiler_nameop(c, p->v.Name.id, Load)); - return 1; -} - - static int pattern_load_attribute(struct compiler *c, expr_ty p, pattern_context *pc) { @@ -5473,7 +5464,8 @@ pattern_load_attribute(struct compiler *c, expr_ty p, pattern_context *pc) } else { assert(p->v.Attribute.value->kind == Name_kind); - CHECK(pattern_load_name(c, p->v.Attribute.value, pc)); + assert(p->v.Attribute.value->v.Name.ctx == Load); + CHECK(compiler_nameop(c, p->v.Attribute.value->v.Name.id, Load)); } ADDOP_NAME(c, LOAD_ATTR, p->v.Attribute.attr, names); return 1; @@ -5515,18 +5507,8 @@ pattern_store_name(struct compiler *c, expr_ty p, pattern_context *pc) return 0; } if (dupe) { - PyObject *str = PyUnicode_FromFormat( + return compiler_error(c, "multiple assignments to name %R in pattern", p->v.Name.id); - if (!str) { - return 0; - } - const char *s = PyUnicode_AsUTF8(str); - if (!s) { - return 0; - } - compiler_error(c, s); - Py_DECREF(str); - return 0; } } CHECK(!PySet_Add(pc->stores, p->v.Name.id)); @@ -5564,9 +5546,10 @@ compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context *pc) alt = asdl_seq_GET(p->v.BoolOp.values, i); pc->stores = PySet_New(stores_init); SET_LOC(c, alt); - if (alt->kind == Name_kind && alt->v.Name.ctx == Store && i != size - 1) { - compiler_warn(c, "name capture pattern makes remaining alternate " - "patterns unreachable"); + if (alt->kind == Name_kind && alt->v.Name.ctx == Store && i != size - 1) + { + compiler_warn(c, "name capture pattern %R makes remaining alternate " + "patterns unreachable", alt->v.Name.id); } if (!pc->stores || !compiler_addop(c, DUP_TOP) || @@ -5586,7 +5569,7 @@ compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context *pc) } if (PySet_GET_SIZE(diff)) { Py_DECREF(diff); - compiler_error(c, "pattern binds different names based on target"); + compiler_error(c, "alternate patterns bind different names"); goto fail; } Py_DECREF(diff); @@ -5625,7 +5608,8 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { } else { assert(p->v.Call.func->kind == Name_kind); - CHECK(pattern_load_name(c, p->v.Call.func, pc)); + assert(p->v.Call.func->v.Name.ctx == Load); + CHECK(compiler_nameop(c, p->v.Call.func->v.Name.id, Load)); } PyObject *kwnames, *name; CHECK(kwnames = PyTuple_New(nkwargs)); @@ -5690,33 +5674,36 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP_COMPARE(c, GtE); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); } - Py_ssize_t i; - for (i = 0; i < size - star; i++) { - expr_ty key = asdl_seq_GET(keys, i); - if (!key) { - return compiler_error(c, "can't use starred pattern here; consider moving to end?"); - } - if (key->kind == Attribute_kind) { - CHECK(pattern_load_attribute(c, key, pc)); - } - else { - assert(key->kind == Constant_kind); - CHECK(pattern_load_constant(c, key, pc)); - } - } - ADDOP_I(c, BUILD_TUPLE, size - star); - ADDOP_I(c, MATCH_KEYS, star); - ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); - for (i = 0; i < size - star; i++) { - expr_ty value = asdl_seq_GET(values, i); - if (WILDCARD_CHECK(value)) { - continue; + if (size) { + Py_ssize_t i; + for (i = 0; i < size - star; i++) { + expr_ty key = asdl_seq_GET(keys, i); + if (!key) { + return compiler_error(c, + "can't use starred pattern here; consider moving to end?"); + } + if (key->kind == Attribute_kind) { + CHECK(pattern_load_attribute(c, key, pc)); + } + else { + assert(key->kind == Constant_kind); + CHECK(pattern_load_constant(c, key, pc)); + } } - ADDOP_I(c, GET_INDEX, i); - CHECK(compiler_pattern(c, value, pc)); + ADDOP_I(c, BUILD_TUPLE, size - star); + ADDOP_I(c, MATCH_KEYS, star); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + for (i = 0; i < size - star; i++) { + expr_ty value = asdl_seq_GET(values, i); + if (WILDCARD_CHECK(value)) { + continue; + } + ADDOP_I(c, GET_INDEX, i); + CHECK(compiler_pattern(c, value, pc)); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); + } + ADDOP(c, POP_TOP); } - ADDOP(c, POP_TOP); if (star) { CHECK(pattern_store_name(c, asdl_seq_GET(values, size - 1), pc)); } @@ -5824,19 +5811,9 @@ static int compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == NamedExpr_kind); - basicblock *block, *end; - CHECK(block = compiler_new_block(c)); - CHECK(end = compiler_new_block(c)); ADDOP(c, DUP_TOP); - CHECK(compiler_pattern(c, p->v.NamedExpr.value, pc)); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); CHECK(pattern_store_name(c, p->v.NamedExpr.target, pc)); - ADDOP_LOAD_CONST(c, Py_True); - ADDOP_JREL(c, JUMP_FORWARD, end); - compiler_use_next_block(c, block); - ADDOP(c, ROT_TWO); - ADDOP(c, POP_TOP); - compiler_use_next_block(c, end); + CHECK(compiler_pattern(c, p->v.NamedExpr.value, pc)); return 1; } @@ -5884,21 +5861,22 @@ compiler_match(struct compiler *c, stmt_ty s) Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); assert(cases); pattern_context pc; - int last, result; + int keep_subject, result; match_case_ty m = asdl_seq_GET(s->v.Match.cases, cases - 1); - int has_default = WILDCARD_CHECK(m->pattern); + int has_default = WILDCARD_CHECK(m->pattern) && 1 < cases; for (Py_ssize_t i = 0; i < cases - has_default; i++) { - last = i == cases - 1 - has_default; + keep_subject = i < cases - has_default - 1; m = asdl_seq_GET(s->v.Match.cases, i); SET_LOC(c, m->pattern); if (!m->guard && m->pattern->kind == Name_kind && m->pattern->v.Name.ctx == Store && i != cases - 1) { - CHECK(compiler_warn(c, "unguarded name capture pattern makes " - "remaining cases unreachable")); + CHECK(compiler_warn(c, "unguarded name capture pattern %R makes " + "remaining cases unreachable", + m->pattern->v.Name.id)); } CHECK(next = compiler_new_block(c)); - if (!last) { + if (keep_subject) { ADDOP(c, DUP_TOP); } pc.stores = NULL; @@ -5909,17 +5887,18 @@ compiler_match(struct compiler *c, stmt_ty s) if (m->guard) { CHECK(compiler_jump_if(c, m->guard, next, 0)); } - if (!last) { + if (keep_subject) { ADDOP(c, POP_TOP); } VISIT_SEQ(c, stmt, m->body); - ADDOP_JREL(c, JUMP_FORWARD, end); + if (i != cases - 1) { + ADDOP_JREL(c, JUMP_FORWARD, end); + } compiler_use_next_block(c, next); } if (has_default) { - if (cases == 1) { - ADDOP(c, POP_TOP); - } + // A trailing "case _" is common, and lets us save a bit of redundant + // pushing and popping in the loop above: m = asdl_seq_GET(s->v.Match.cases, cases - 1); if (m->guard) { CHECK(compiler_jump_if(c, m->guard, end, 0)); From 3fd91d9d721f9da8b82e43552fe4e4534cbc0b98 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 20 Jul 2020 08:46:18 -0700 Subject: [PATCH 141/189] More cleanup --- Lib/test/test_patma.py | 92 +++++++++++++++++++++--------------------- Python/compile.c | 40 +++++++++--------- 2 files changed, 68 insertions(+), 64 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 06af444667d415..33264ed86cbdac 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -27,7 +27,7 @@ def test_patma_000(self): match 0: case 0: x = True - self.assertEqual(x, True) + self.assertIs(x, True) def test_patma_001(self): match 0: @@ -35,7 +35,7 @@ def test_patma_001(self): x = False case 0 if True: x = True - self.assertEqual(x, True) + self.assertIs(x, True) def test_patma_002(self): match 0: @@ -43,42 +43,42 @@ def test_patma_002(self): x = True case 0: x = False - self.assertEqual(x, True) + self.assertIs(x, True) def test_patma_003(self): x = False match 0: case 0 | 1 | 2 | 3: x = True - self.assertEqual(x, True) + self.assertIs(x, True) def test_patma_004(self): x = False match 1: case 0 | 1 | 2 | 3: x = True - self.assertEqual(x, True) + self.assertIs(x, True) def test_patma_005(self): x = False match 2: case 0 | 1 | 2 | 3: x = True - self.assertEqual(x, True) + self.assertIs(x, True) def test_patma_006(self): x = False match 3: case 0 | 1 | 2 | 3: x = True - self.assertEqual(x, True) + self.assertIs(x, True) def test_patma_007(self): x = False match 4: case 0 | 1 | 2 | 3: x = True - self.assertEqual(x, False) + self.assertIs(x, False) def test_patma_008(self): x = 0 @@ -211,7 +211,7 @@ def test_patma_024(self): case {0: 0}: y = 0 self.assertEqual(x, {}) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_025(self): x = {0: 0} @@ -247,7 +247,7 @@ def test_patma_028(self): case {0: (z := 0 | 1 | 2)}: y = 0 self.assertEqual(x, {0: 3}) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_029(self): x = {} @@ -260,7 +260,7 @@ def test_patma_029(self): case []: y = 2 self.assertEqual(x, {}) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_030(self): x = {False: (True, 2.0, {})} @@ -365,7 +365,7 @@ def test_patma_039(self): case 0 | 1 | 2: y = 0 self.assertEqual(x, 3) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_040(self): x = 0 @@ -392,7 +392,7 @@ def test_patma_042(self): case (z := 0) | (z := 1) | (z := 2) if z == x % 2: y = 0 self.assertEqual(x, 2) - self.assertEqual(y, None) + self.assertIs(y, None) self.assertEqual(z, 2) def test_patma_043(self): @@ -402,7 +402,7 @@ def test_patma_043(self): case (z := 0) | (z := 1) | (z := 2) if z == x % 2: y = 0 self.assertEqual(x, 3) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_044(self): x = () @@ -459,7 +459,7 @@ def test_patma_050(self): case [0, 1] | [1, 0]: y = 0 self.assertEqual(x, [0, 0]) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_051(self): w = None @@ -469,7 +469,7 @@ def test_patma_051(self): y = 0 case [z] | [1, (z := 0 | 1)] | [z]: y = 1 - self.assertEqual(w, None) + self.assertIs(w, None) self.assertEqual(x, [1, 0]) self.assertEqual(y, 1) self.assertEqual(z, 0) @@ -493,7 +493,7 @@ def test_patma_053(self): case [0]: y = 0 self.assertEqual(x, {0}) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_054(self): x = set() @@ -502,7 +502,7 @@ def test_patma_054(self): case []: y = 0 self.assertEqual(x, set()) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_055(self): x = iter([1, 2, 3]) @@ -511,7 +511,7 @@ def test_patma_055(self): case []: y = 0 self.assertEqual([*x], [1, 2, 3]) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_056(self): x = {} @@ -520,7 +520,7 @@ def test_patma_056(self): case []: y = 0 self.assertEqual(x, {}) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_057(self): x = {0: False, 1: True} @@ -529,7 +529,7 @@ def test_patma_057(self): case [0, 1]: y = 0 self.assertEqual(x, {0: False, 1: True}) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_058(self): x = 0 @@ -554,7 +554,7 @@ def test_patma_060(self): case 1: y = 0 self.assertEqual(x, 0) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_061(self): x = 0 @@ -563,7 +563,7 @@ def test_patma_061(self): case None: y = 0 self.assertEqual(x, 0) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_062(self): x = 0 @@ -584,7 +584,7 @@ def test_patma_063(self): case 1: y = 1 self.assertEqual(x, 0) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_064(self): x = "x" @@ -645,7 +645,7 @@ def test_patma_069(self): case 0 if 0: y = 1 self.assertEqual(x, 0) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_070(self): x = 0 @@ -698,7 +698,7 @@ def test_patma_074(self): case 1: y = 1 self.assertEqual(x, 1) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_075(self): x = "x" @@ -733,7 +733,7 @@ def test_patma_077(self): case 120: y = 1 self.assertEqual(x, b"x") - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_078(self): x = "" @@ -808,7 +808,7 @@ def test_patma_084(self): case (z := 1): y = 0 self.assertEqual(x, 0) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_085(self): x = 0 @@ -818,7 +818,7 @@ def test_patma_085(self): y = 0 self.assertEqual(w, 0) self.assertEqual(x, 0) - self.assertEqual(y, None) + self.assertIs(y, None) self.assertEqual(z, 0) def test_patma_086(self): @@ -862,7 +862,7 @@ def test_patma_090(self): case (0 | 1) | 2: y = 0 self.assertEqual(x, 3) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_091(self): x = 0 @@ -895,7 +895,7 @@ def test_patma_094(self): case 0 | (1 | 2): y = 0 self.assertEqual(x, 3) - self.assertEqual(y, None) + self.assertIs(y, None) def test_patma_095(self): x = 0 @@ -1962,15 +1962,15 @@ def f(color): self.assertEqual(f(Color.RED), "I see red!") self.assertEqual(f(Color.GREEN), "Grass is green") self.assertEqual(f(Color.BLUE), "I'm feeling the blues :(") - self.assertEqual(f(Color), None) - self.assertEqual(f(0), None) - self.assertEqual(f(1), None) - self.assertEqual(f(2), None) - self.assertEqual(f(3), None) - self.assertEqual(f(False), None) - self.assertEqual(f(True), None) - self.assertEqual(f(2+0j), None) - self.assertEqual(f(3.0), None) + self.assertIs(f(Color), None) + self.assertIs(f(0), None) + self.assertIs(f(1), None) + self.assertIs(f(2), None) + self.assertIs(f(3), None) + self.assertIs(f(False), None) + self.assertIs(f(True), None) + self.assertIs(f(2+0j), None) + self.assertIs(f(3.0), None) def test_patma_199(self): class Color(int, enum.Enum): @@ -1988,15 +1988,15 @@ def f(color): self.assertEqual(f(Color.RED), "I see red!") self.assertEqual(f(Color.GREEN), "Grass is green") self.assertEqual(f(Color.BLUE), "I'm feeling the blues :(") - self.assertEqual(f(Color), None) + self.assertIs(f(Color), None) self.assertEqual(f(0), "I see red!") self.assertEqual(f(1), "Grass is green") self.assertEqual(f(2), "I'm feeling the blues :(") - self.assertEqual(f(3), None) + self.assertIs(f(3), None) self.assertEqual(f(False), "I see red!") self.assertEqual(f(True), "Grass is green") self.assertEqual(f(2+0j), "I'm feeling the blues :(") - self.assertEqual(f(3.0), None) + self.assertIs(f(3.0), None) def test_patma_200(self): class Class: @@ -2381,11 +2381,11 @@ def f(x): self.assertEqual(f(2), 2) self.assertIs(f(3), None) - # TODO: PEP tests - # TODO: Don't check side-effecty assignments - # TODO: Full coverage of errors and warnings # TODO: Check numbers, dupes + # TODO: Full coverage of errors and warnings # TODO: Better use of assertIs + # TODO: PEP tests + # TODO: Don't check side-effecty assignments class PerfPatma(TestPatma): diff --git a/Python/compile.c b/Python/compile.c index bd8a283328c943..ce8672f65723ad 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5476,14 +5476,13 @@ static int pattern_load_constant(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Constant_kind); - assert(PyBytes_CheckExact(p->v.Constant.value) || + assert(PyBool_Check(p->v.Constant.value) || + PyBytes_CheckExact(p->v.Constant.value) || PyComplex_CheckExact(p->v.Constant.value) || PyFloat_CheckExact(p->v.Constant.value) || PyLong_CheckExact(p->v.Constant.value) || PyUnicode_CheckExact(p->v.Constant.value) || - p->v.Constant.value == Py_False || - p->v.Constant.value == Py_None || - p->v.Constant.value == Py_True); + p->v.Constant.value == Py_None); ADDOP_LOAD_CONST(c, p->v.Constant.value); return 1; } @@ -5495,20 +5494,21 @@ pattern_store_name(struct compiler *c, expr_ty p, pattern_context *pc) assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); if (WILDCARD_CHECK(p)) { - return compiler_error(c, - "can't assign to '_' here; consider removing or renaming?"); + const char *e = "can't assign to '_' here; consider removing or " + "renaming?"; + return compiler_error(c, e); } if (!pc->stores) { CHECK(pc->stores = PySet_New(NULL)); } else { - int dupe = PySet_Contains(pc->stores, p->v.Name.id); - if (dupe < 0) { + int duplicate = PySet_Contains(pc->stores, p->v.Name.id); + if (duplicate < 0) { return 0; } - if (dupe) { - return compiler_error(c, - "multiple assignments to name %R in pattern", p->v.Name.id); + if (duplicate) { + const char *e = "multiple assignments to name %R in pattern"; + return compiler_error(c, e, p->v.Name.id); } } CHECK(!PySet_Add(pc->stores, p->v.Name.id)); @@ -5548,8 +5548,11 @@ compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context *pc) SET_LOC(c, alt); if (alt->kind == Name_kind && alt->v.Name.ctx == Store && i != size - 1) { - compiler_warn(c, "name capture pattern %R makes remaining alternate " - "patterns unreachable", alt->v.Name.id); + const char *w = "name capture pattern %R makes remaining alternate " + "patterns unreachable" + if (compiler_warn(c, w, alt->v.Name.id)) { + goto fail; + } } if (!pc->stores || !compiler_addop(c, DUP_TOP) || @@ -5679,8 +5682,9 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) for (i = 0; i < size - star; i++) { expr_ty key = asdl_seq_GET(keys, i); if (!key) { - return compiler_error(c, - "can't use starred pattern here; consider moving to end?"); + const char *e = "can't use starred pattern here; consider " + "moving to end?"; + return compiler_error(c, e); } if (key->kind == Attribute_kind) { CHECK(pattern_load_attribute(c, key, pc)); @@ -5871,9 +5875,9 @@ compiler_match(struct compiler *c, stmt_ty s) if (!m->guard && m->pattern->kind == Name_kind && m->pattern->v.Name.ctx == Store && i != cases - 1) { - CHECK(compiler_warn(c, "unguarded name capture pattern %R makes " - "remaining cases unreachable", - m->pattern->v.Name.id)); + const char *w = "unguarded name capture pattern %R makes remaining " + "cases unreachable"; + CHECK(compiler_warn(c, w, m->pattern->v.Name.id)); } CHECK(next = compiler_new_block(c)); if (keep_subject) { From 1de2a1c923a7a3056b70301ff067c6425de90924 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sun, 16 Aug 2020 15:36:07 -0700 Subject: [PATCH 142/189] Ditch unhelpful warning and add OPTIM note --- Lib/test/test_patma.py | 10 ++++------ Python/compile.c | 10 ++-------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 33264ed86cbdac..99d1562360e8d3 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2208,15 +2208,13 @@ def f(): self.assertEqual(set(f()), {"abc"}) def test_patma_218(self): - namespace = {} code = """ match ...: - case a | a: + case "a" | a: pass """ - with self.assertWarns(SyntaxWarning): - exec(inspect.cleandoc(code), None, namespace) - self.assertEqual(set(namespace), {"a"}) + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) def test_patma_219(self): code = """ @@ -2224,7 +2222,7 @@ def test_patma_219(self): case a | "a": pass """ - with self.assertWarns(SyntaxWarning), self.assertRaises(SyntaxError): + with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) def test_patma_220(self): diff --git a/Python/compile.c b/Python/compile.c index ce8672f65723ad..0535e84709c8ae 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5546,14 +5546,6 @@ compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context *pc) alt = asdl_seq_GET(p->v.BoolOp.values, i); pc->stores = PySet_New(stores_init); SET_LOC(c, alt); - if (alt->kind == Name_kind && alt->v.Name.ctx == Store && i != size - 1) - { - const char *w = "name capture pattern %R makes remaining alternate " - "patterns unreachable" - if (compiler_warn(c, w, alt->v.Name.id)) { - goto fail; - } - } if (!pc->stores || !compiler_addop(c, DUP_TOP) || !compiler_pattern(c, alt, pc) || @@ -5816,6 +5808,8 @@ compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == NamedExpr_kind); ADDOP(c, DUP_TOP); + // OPTIM: We store the target *before* matching the inner pattern, to avoid + // complicated cleanup if the inner pattern fails to match. CHECK(pattern_store_name(c, p->v.NamedExpr.target, pc)); CHECK(compiler_pattern(c, p->v.NamedExpr.value, pc)); return 1; From 7864718292e21da438f9d461ff50fddfec26558a Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 17 Aug 2020 08:42:14 -0700 Subject: [PATCH 143/189] Preserve TOS when compiling patterns --- Lib/test/test_patma.py | 2 +- Python/compile.c | 102 ++++++++++++++++++++++------------------- 2 files changed, 57 insertions(+), 47 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 99d1562360e8d3..616f6d39db7811 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2421,6 +2421,6 @@ def setUpClass(): """ sudo ./python -m pyperf system tune && \ - ./python -m pyperf timeit -s "from test.test_patma import PerfPatma; p = PerfPatma()" "p.run_perf()"; \ + ./python -m pyperf timeit --rigorous --setup "from test.test_patma import PerfPatma; p = PerfPatma()" "p.run_perf()"; \ sudo ./python -m pyperf system reset """ diff --git a/Python/compile.c b/Python/compile.c index 0535e84709c8ae..27a965863580aa 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5432,10 +5432,11 @@ compiler_slice(struct compiler *c, expr_ty s) // PEP 622: Structural Pattern Matching // To keep things simple, all compiler_pattern_* routines follow the convention -// of replacing TOS (the subject for the given pattern) with either True (match) -// or False (no match). We do this even for irrefutable patterns; the idea is -// that it's much easier to smooth out any redundant pushing, popping, and -// jumping in the peephole optimizer than to detect or predict it here. +// of preserving TOS (the subject for the given pattern) and pushing either True +// (match) or False (no match) on top of it. We do this even for irrefutable +// patterns; the idea is that it's much easier to smooth out any redundant +// pushing, popping, and jumping in the peephole optimizer than to detect or +// predict it here. // Other than that, go nuts. The PEP intentionally gives us broad freedom to // take (reasonable) shortcuts - the AST optimization pass in particular is full @@ -5522,6 +5523,7 @@ compiler_pattern_attribute(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Attribute_kind); assert(p->v.Attribute.ctx == Load); + ADDOP(c, DUP_TOP); CHECK(pattern_load_attribute(c, p, pc)); ADDOP_COMPARE(c, Eq); return 1; @@ -5547,7 +5549,6 @@ compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context *pc) pc->stores = PySet_New(stores_init); SET_LOC(c, alt); if (!pc->stores || - !compiler_addop(c, DUP_TOP) || !compiler_pattern(c, alt, pc) || !compiler_addop_j(c, JUMP_IF_TRUE_OR_POP, end, 1)) { @@ -5575,8 +5576,6 @@ compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context *pc) pc->stores = control; ADDOP_LOAD_CONST(c, Py_False); compiler_use_next_block(c, end); - ADDOP(c, ROT_TWO); - ADDOP(c, POP_TOP); return 1; fail: Py_XDECREF(stores_init); @@ -5598,6 +5597,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { CHECK(!validate_keywords(c, kwargs)); CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); + ADDOP(c, DUP_TOP); // TODO: Refactor MATCH_CLASS if (p->v.Call.func->kind == Attribute_kind) { CHECK(pattern_load_attribute(c, p->v.Call.func, pc)); } @@ -5630,6 +5630,8 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { } ADDOP_I(c, GET_INDEX, i); CHECK(compiler_pattern(c, arg, pc)); + ADDOP(c, ROT_TWO); + ADDOP(c, POP_TOP); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } ADDOP_LOAD_CONST(c, Py_True); @@ -5644,6 +5646,7 @@ static int compiler_pattern_constant(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Constant_kind); + ADDOP(c, DUP_TOP); CHECK(pattern_load_constant(c, p, pc)); ADDOP_COMPARE(c, Eq); return 1; @@ -5660,16 +5663,17 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) asdl_seq *values = p->v.Dict.values; Py_ssize_t size = asdl_seq_LEN(values); int star = size ? !asdl_seq_GET(keys, size - 1) : 0; - // TODO :(i >= (1 << 8)) || (n-i-1 >= (INT_MAX >> 8)) + // TODO: (i >= (1 << 8)) || (n-i-1 >= (INT_MAX >> 8)) ADDOP(c, MATCH_MAPPING); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); if (size - star) { ADDOP(c, GET_LEN); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - star)); ADDOP_COMPARE(c, GtE); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); } if (size) { + ADDOP(c, DUP_TOP); Py_ssize_t i; for (i = 0; i < size - star; i++) { expr_ty key = asdl_seq_GET(keys, i); @@ -5696,15 +5700,17 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) } ADDOP_I(c, GET_INDEX, i); CHECK(compiler_pattern(c, value, pc)); + ADDOP(c, ROT_TWO); + ADDOP(c, POP_TOP); ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); } ADDOP(c, POP_TOP); - } - if (star) { - CHECK(pattern_store_name(c, asdl_seq_GET(values, size - 1), pc)); - } - else { - ADDOP(c, POP_TOP); + if (star) { + CHECK(pattern_store_name(c, asdl_seq_GET(values, size - 1), pc)); + } + else { + ADDOP(c, POP_TOP); + } } ADDOP_LOAD_CONST(c, Py_True); ADDOP_JREL(c, JUMP_FORWARD, end); @@ -5734,27 +5740,32 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) } star = i; } - basicblock *block, *end; - CHECK(block = compiler_new_block(c)); + basicblock *block, *end, *subblock; CHECK(end = compiler_new_block(c)); ADDOP(c, MATCH_SEQUENCE); ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); ADDOP(c, GET_LEN); + if (!size) { + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)); + ADDOP_COMPARE(c, Eq); + compiler_use_next_block(c, end); + return 1; + } + CHECK(subblock = compiler_new_block(c)); + CHECK(block = compiler_new_block(c)); + ADDOP(c, DUP_TOP); if (star < 0) { - ADDOP(c, DUP_TOP); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)); ADDOP_COMPARE(c, Eq); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); } - else if (size) { - ADDOP(c, DUP_TOP); + else { ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - 1)); ADDOP_COMPARE(c, GtE); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); } + ADDOP_JABS(c, POP_JUMP_IF_FALSE, block); ADDOP(c, ROT_TWO); for (Py_ssize_t i = 0; i < size; i++) { - // TODO :(i >= (1 << 8)) || (n-i-1 >= (INT_MAX >> 8)) + // TODO: (i >= (1 << 8)) || (n-i-1 >= (INT_MAX >> 8)) expr_ty value = asdl_seq_GET(values, i); if (WILDCARD_CHECK(value)) { continue; @@ -5774,15 +5785,20 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP_I(c, GET_INDEX_END, size - 1 - i); } CHECK(compiler_pattern(c, value, pc)); - ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, block); + ADDOP_JABS(c, POP_JUMP_IF_FALSE, subblock); + ADDOP(c, POP_TOP); } - ADDOP_LOAD_CONST(c, Py_True); - compiler_use_next_block(c, block); ADDOP(c, ROT_TWO); ADDOP(c, POP_TOP); - compiler_use_next_block(c, end); + ADDOP_LOAD_CONST(c, Py_True); + ADDOP_JREL(c, JUMP_FORWARD, end); + compiler_use_next_block(c, subblock); + ADDOP(c, POP_TOP); ADDOP(c, ROT_TWO); + compiler_use_next_block(c, block); ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_False); + compiler_use_next_block(c, end); return 1; } @@ -5792,10 +5808,8 @@ compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); - if (WILDCARD_CHECK(p)) { - ADDOP(c, POP_TOP); - } - else { + if (!WILDCARD_CHECK(p)) { + ADDOP(c, DUP_TOP); CHECK(pattern_store_name(c, p, pc)); } ADDOP_LOAD_CONST(c, Py_True); @@ -5807,11 +5821,14 @@ static int compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == NamedExpr_kind); + basicblock *end; + CHECK(end = compiler_new_block(c)); + CHECK(compiler_pattern(c, p->v.NamedExpr.value, pc)); + ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, end); ADDOP(c, DUP_TOP); - // OPTIM: We store the target *before* matching the inner pattern, to avoid - // complicated cleanup if the inner pattern fails to match. CHECK(pattern_store_name(c, p->v.NamedExpr.target, pc)); - CHECK(compiler_pattern(c, p->v.NamedExpr.value, pc)); + ADDOP_LOAD_CONST(c, Py_True); + compiler_use_next_block(c, end); return 1; } @@ -5859,11 +5876,10 @@ compiler_match(struct compiler *c, stmt_ty s) Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); assert(cases); pattern_context pc; - int keep_subject, result; + int result; match_case_ty m = asdl_seq_GET(s->v.Match.cases, cases - 1); int has_default = WILDCARD_CHECK(m->pattern) && 1 < cases; for (Py_ssize_t i = 0; i < cases - has_default; i++) { - keep_subject = i < cases - has_default - 1; m = asdl_seq_GET(s->v.Match.cases, i); SET_LOC(c, m->pattern); if (!m->guard && m->pattern->kind == Name_kind && @@ -5874,9 +5890,6 @@ compiler_match(struct compiler *c, stmt_ty s) CHECK(compiler_warn(c, w, m->pattern->v.Name.id)); } CHECK(next = compiler_new_block(c)); - if (keep_subject) { - ADDOP(c, DUP_TOP); - } pc.stores = NULL; result = compiler_pattern(c, m->pattern, &pc); Py_CLEAR(pc.stores); @@ -5885,15 +5898,12 @@ compiler_match(struct compiler *c, stmt_ty s) if (m->guard) { CHECK(compiler_jump_if(c, m->guard, next, 0)); } - if (keep_subject) { - ADDOP(c, POP_TOP); - } + ADDOP(c, POP_TOP); VISIT_SEQ(c, stmt, m->body); - if (i != cases - 1) { - ADDOP_JREL(c, JUMP_FORWARD, end); - } + ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, next); } + ADDOP(c, POP_TOP); if (has_default) { // A trailing "case _" is common, and lets us save a bit of redundant // pushing and popping in the loop above: From 6fdc00c65f7107b6eb13ef6438a2b665c86647fa Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 17 Aug 2020 22:42:31 -0700 Subject: [PATCH 144/189] Clean up some duplicate tests --- Lib/test/test_patma.py | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 616f6d39db7811..c97c1a65e07eb9 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -415,7 +415,7 @@ def test_patma_044(self): def test_patma_045(self): x = () match x: - case []: + case (): y = 0 self.assertEqual(x, ()) self.assertEqual(y, 0) @@ -609,12 +609,12 @@ def test_patma_065(self): def test_patma_066(self): x = "x" match x: - case "x": + case "": y = 0 - case "y": + case "x": y = 1 self.assertEqual(x, "x") - self.assertEqual(y, 0) + self.assertEqual(y, 1) def test_patma_067(self): x = b"x" @@ -1052,13 +1052,17 @@ def test_patma_113(self): class A: class B: C = 0 - x = 0 + D = 1 + x = 1 match x: case A.B.C: y = 0 + case A.B.D: + y = 1 self.assertEqual(A.B.C, 0) - self.assertEqual(x, 0) - self.assertEqual(y, 0) + self.assertEqual(A.B.D, 1) + self.assertEqual(x, 1) + self.assertEqual(y, 1) def test_patma_114(self): class A: @@ -1078,13 +1082,17 @@ class A: class B: class C: D = 0 - x = 0 + E = 1 + x = 1 match x: case A.B.C.D: y = 0 + case A.B.C.E: + y = 1 self.assertEqual(A.B.C.D, 0) - self.assertEqual(x, 0) - self.assertEqual(y, 0) + self.assertEqual(A.B.C.E, 1) + self.assertEqual(x, 1) + self.assertEqual(y, 1) def test_patma_116(self): match = case = 0 @@ -1447,7 +1455,7 @@ def test_patma_155(self): x = 0 y = None match x: - case 1: + case 1e1000: y = 0 self.assertEqual(x, 0) self.assertIs(y, None) @@ -1473,12 +1481,12 @@ def test_patma_157(self): def test_patma_158(self): x = 0 match x: - case 0: + case -1e1000: y = 0 case 0: y = 1 self.assertEqual(x, 0) - self.assertEqual(y, 0) + self.assertEqual(y, 1) def test_patma_159(self): x = 0 @@ -2379,10 +2387,8 @@ def f(x): self.assertEqual(f(2), 2) self.assertIs(f(3), None) - # TODO: Check numbers, dupes # TODO: Full coverage of errors and warnings # TODO: Better use of assertIs - # TODO: PEP tests # TODO: Don't check side-effecty assignments From ee2beb22a65751275b84bb711155732b1c2ff61c Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 18 Aug 2020 20:32:08 -0700 Subject: [PATCH 145/189] Improve test coverage for errors and warnings --- Lib/test/test_patma.py | 176 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 175 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index c97c1a65e07eb9..990e0400169806 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2387,7 +2387,181 @@ def f(x): self.assertEqual(f(2), 2) self.assertIs(f(3), None) - # TODO: Full coverage of errors and warnings + def test_patma_236(self): + code = """ + match ...: + case {**rest, "key": value}: + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_237(self): + code = """ + match ...: + case {"first": first, **rest, "last": last}: + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_238(self): + code = """ + match ...: + case *a, b, *c, d, *e: + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_239(self): + code = """ + match ...: + case a, *b, c, *d, e: + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_240(self): + code = """ + match ...: + case 0+0: + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_241(self): + code = """ + match ...: + case f"": + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_242(self): + code = """ + match ...: + case f"{x}": + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_243(self): + namespace = {} + code = """ + match 42: + case x: + pass + case y: + pass + """ + with self.assertWarns(SyntaxWarning): + exec(inspect.cleandoc(code), None, namespace) + self.assertEqual(namespace, {"x": 42}) + + def test_patma_244(self): + code = """ + match ...: + case {**_}: + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_245(self): + code = """ + match ...: + case _ := 42: + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_246(self): + class Class: + __match_args__ = None + x = Class() + y = z = None + with self.assertRaises(TypeError): + match x: + case Class(y): + z = 0 + self.assertIs(y, None) + self.assertIs(z, None) + + def test_patma_247(self): + class Class: + __match_args__ = "XYZ" + x = Class() + y = z = None + with self.assertRaises(TypeError): + match x: + case Class(y): + z = 0 + self.assertIs(y, None) + self.assertIs(z, None) + + def test_patma_248(self): + class Class: + __match_args__ = [None] + x = Class() + y = z = None + with self.assertRaises(TypeError): + match x: + case Class(y): + z = 0 + self.assertIs(y, None) + self.assertIs(z, None) + + def test_patma_249(self): + class Class: + __match_args__ = [] + x = Class() + y = z = None + with self.assertRaises(TypeError): + match x: + case Class(y): + z = 0 + self.assertIs(y, None) + self.assertIs(z, None) + + def test_patma_250(self): + code = """ + match ...: + case Class(a=_, a=_): + pass + """ + with self.assertRaises(SyntaxError): + exec(inspect.cleandoc(code)) + + def test_patma_251(self): + x = {"a": 0, "b": 1} + w = y = z = None + with self.assertRaises(ValueError): + match x: + case {"a": y, "a": z}: + w = 0 + self.assertIs(w, None) + self.assertIs(y, None) + self.assertIs(z, None) + + def test_patma_252(self): + class Keys: + KEY = "a" + x = {"a": 0, "b": 1} + w = y = z = None + with self.assertRaises(ValueError): + match x: + case {Keys.KEY: y, "a": z}: + w = 0 + self.assertIs(w, None) + self.assertIs(y, None) + self.assertIs(z, None) + # TODO: Better use of assertIs # TODO: Don't check side-effecty assignments From b4b841677c4cb4f90ed528d2a7364da384e98e44 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 18 Aug 2020 20:36:12 -0700 Subject: [PATCH 146/189] Add more tests for runtime errors --- Lib/test/test_patma.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 990e0400169806..d3b2da34b80eb0 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2562,6 +2562,34 @@ class Keys: self.assertIs(y, None) self.assertIs(z, None) + def test_patma_253(self): + class Class: + __match_args__ = ["a", "a"] + a = None + x = Class() + w = y = z = None + with self.assertRaises(TypeError): + match x: + case Class(y, z): + w = 0 + self.assertIs(w, None) + self.assertIs(y, None) + self.assertIs(z, None) + + def test_patma_254(self): + class Class: + __match_args__ = ["a"] + a = None + x = Class() + w = y = z = None + with self.assertRaises(TypeError): + match x: + case Class(y, a=z): + w = 0 + self.assertIs(w, None) + self.assertIs(y, None) + self.assertIs(z, None) + # TODO: Better use of assertIs # TODO: Don't check side-effecty assignments From f819084b89469e24fd9bcdc7b07f855db4f1f273 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 18 Aug 2020 20:36:38 -0700 Subject: [PATCH 147/189] Clean up comments --- Python/compile.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 27a965863580aa..e5ccfc34882c91 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5443,12 +5443,6 @@ compiler_slice(struct compiler *c, expr_ty s) // of low-hanging fruit. Please *always* document these with a comment of the // form "OPTIM: ...", so we can track exactly when and where they're happening. -// For now, we eschew a full decision tree in favor of a simpler pass that just -// tracks the most-recently-checked subclass and length info for the current -// subject in the pattern_context struct. Experimentation suggests that the -// current approach can keep most of the runtime benefits while dramatically -// reducing compiler complexity. - #define WILDCARD_CHECK(N) \ ((N)->kind == Name_kind && \ @@ -5597,7 +5591,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { CHECK(!validate_keywords(c, kwargs)); CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); - ADDOP(c, DUP_TOP); // TODO: Refactor MATCH_CLASS + ADDOP(c, DUP_TOP); // TODO: Refactor MATCH_CLASS? if (p->v.Call.func->kind == Attribute_kind) { CHECK(pattern_load_attribute(c, p->v.Call.func, pc)); } From 6228a57fdc6172f02af8f80e3e671c2d67da965f Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 18 Aug 2020 21:07:06 -0700 Subject: [PATCH 148/189] Fix bugs in peephole optimizer changes --- Python/peephole.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Python/peephole.c b/Python/peephole.c index 2e5c0436d5385d..e87a2951e4f787 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -306,9 +306,10 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, switch (opcode) { // Simplify LOAD_CONST followed by conditional jumping/popping: case LOAD_CONST: - cumlc = lastlc + 1; // TODO? if (!(JUMPS_ON_FALSE(nextop) || JUMPS_ON_TRUE(nextop)) || - !ISBASICBLOCK(blocks, op_start, i + 1)) { + !ISBASICBLOCK(blocks, op_start, nexti)) + { + cumlc = lastlc + 1; break; } PyObject* cnt = PyList_GET_ITEM(consts, get_arg(codestr, i)); @@ -326,7 +327,8 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, // Remove DUP_TOP + POP_TOP: case DUP_TOP: - if (nextop == POP_TOP) { + if (nextop == POP_TOP && ISBASICBLOCK(blocks, op_start, nexti)) + { fill_nops(codestr, op_start, nexti + 1); } break; From 92f6c53e706beedb73a3cec8a187763f6c6236c8 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 19 Aug 2020 19:19:58 -0700 Subject: [PATCH 149/189] Disable unfinished validation --- Python/ast.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Python/ast.c b/Python/ast.c index 7a71fd6317591d..9c3ec54f01cf6c 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -390,12 +390,12 @@ validate_pattern(expr_ty p) if (i != size - 1) { // TODO } - if (key->kind != Name_kind) { - // TODO - } - if (key->v.Name.ctx != Store) { - // TODO - } + // if (key->kind != Name_kind) { + // // TODO + // } + // if (key->v.Name.ctx != Store) { + // // TODO + // } } if (!validate_pattern(asdl_seq_GET(values, i))) { return 0; From 466becdf1400f36bd0621cb74551a396e9932e11 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 19 Aug 2020 22:20:48 -0700 Subject: [PATCH 150/189] Skip performance benchmarking for some tests --- Lib/test/test_patma.py | 49 +++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index d3b2da34b80eb0..fcd98d1e6b13ee 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -8,6 +8,11 @@ import warnings +def no_perf(f): + f.no_perf = None + return f + + @dataclasses.dataclass class MyClass: x: int @@ -1691,6 +1696,7 @@ def http_error(status): self.assertIs(http_error("400"), None) self.assertIs(http_error(401 | 403 | 404), None) # 407 + @no_perf def test_patma_176(self): def whereis(point): match point: @@ -2215,6 +2221,7 @@ def f(): return locals() self.assertEqual(set(f()), {"abc"}) + @no_perf def test_patma_218(self): code = """ match ...: @@ -2224,6 +2231,7 @@ def test_patma_218(self): with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) + @no_perf def test_patma_219(self): code = """ match ...: @@ -2240,6 +2248,7 @@ def f(): return locals() self.assertEqual(set(f()), {"a", "b"}) + @no_perf def test_patma_221(self): code = """ match ...: @@ -2256,6 +2265,7 @@ def f(): return locals() self.assertEqual(set(f()), {"a", "b"}) + @no_perf def test_patma_223(self): code = """ match ...: @@ -2272,6 +2282,7 @@ def f(): return locals() self.assertEqual(set(f()), {"x", "y"}) + @no_perf def test_patma_225(self): code = """ match ...: @@ -2281,6 +2292,7 @@ def test_patma_225(self): with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) + @no_perf def test_patma_226(self): code = """ match ...: @@ -2290,6 +2302,7 @@ def test_patma_226(self): with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) + @no_perf def test_patma_227(self): code = """ match ...: @@ -2306,6 +2319,7 @@ def f(): return locals() self.assertEqual(set(f()), {"a", "b"}) + @no_perf def test_patma_229(self): code = """ match ...: @@ -2387,6 +2401,7 @@ def f(x): self.assertEqual(f(2), 2) self.assertIs(f(3), None) + @no_perf def test_patma_236(self): code = """ match ...: @@ -2396,6 +2411,7 @@ def test_patma_236(self): with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) + @no_perf def test_patma_237(self): code = """ match ...: @@ -2405,6 +2421,7 @@ def test_patma_237(self): with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) + @no_perf def test_patma_238(self): code = """ match ...: @@ -2414,6 +2431,7 @@ def test_patma_238(self): with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) + @no_perf def test_patma_239(self): code = """ match ...: @@ -2423,6 +2441,7 @@ def test_patma_239(self): with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) + @no_perf def test_patma_240(self): code = """ match ...: @@ -2432,6 +2451,7 @@ def test_patma_240(self): with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) + @no_perf def test_patma_241(self): code = """ match ...: @@ -2441,6 +2461,7 @@ def test_patma_241(self): with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) + @no_perf def test_patma_242(self): code = """ match ...: @@ -2450,6 +2471,7 @@ def test_patma_242(self): with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) + @no_perf def test_patma_243(self): namespace = {} code = """ @@ -2463,6 +2485,7 @@ def test_patma_243(self): exec(inspect.cleandoc(code), None, namespace) self.assertEqual(namespace, {"x": 42}) + @no_perf def test_patma_244(self): code = """ match ...: @@ -2472,6 +2495,7 @@ def test_patma_244(self): with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) + @no_perf def test_patma_245(self): code = """ match ...: @@ -2481,6 +2505,7 @@ def test_patma_245(self): with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) + @no_perf def test_patma_246(self): class Class: __match_args__ = None @@ -2493,6 +2518,7 @@ class Class: self.assertIs(y, None) self.assertIs(z, None) + @no_perf def test_patma_247(self): class Class: __match_args__ = "XYZ" @@ -2505,6 +2531,7 @@ class Class: self.assertIs(y, None) self.assertIs(z, None) + @no_perf def test_patma_248(self): class Class: __match_args__ = [None] @@ -2517,6 +2544,7 @@ class Class: self.assertIs(y, None) self.assertIs(z, None) + @no_perf def test_patma_249(self): class Class: __match_args__ = [] @@ -2529,6 +2557,7 @@ class Class: self.assertIs(y, None) self.assertIs(z, None) + @no_perf def test_patma_250(self): code = """ match ...: @@ -2538,6 +2567,7 @@ def test_patma_250(self): with self.assertRaises(SyntaxError): exec(inspect.cleandoc(code)) + @no_perf def test_patma_251(self): x = {"a": 0, "b": 1} w = y = z = None @@ -2549,6 +2579,7 @@ def test_patma_251(self): self.assertIs(y, None) self.assertIs(z, None) + @no_perf def test_patma_252(self): class Keys: KEY = "a" @@ -2562,6 +2593,7 @@ class Keys: self.assertIs(y, None) self.assertIs(z, None) + @no_perf def test_patma_253(self): class Class: __match_args__ = ["a", "a"] @@ -2576,6 +2608,7 @@ class Class: self.assertIs(y, None) self.assertIs(z, None) + @no_perf def test_patma_254(self): class Class: __match_args__ = ["a"] @@ -2602,22 +2635,18 @@ def assertEqual(*_, **__): def assertIs(*_, **__): pass - @contextlib.contextmanager def assertRaises(*_, **__): - try: - yield - except: - pass + assert False, "this test should be decorated with @no_perf!" - @contextlib.contextmanager def assertWarns(*_, **__): - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - yield + assert False, "this test should be decorated with @no_perf!" def run_perf(self): attrs = vars(TestPatma).items() - tests = [attr for name, attr in attrs if name.startswith("test_")] + tests = [ + attr for name, attr in attrs + if name.startswith("test_") and not hasattr(attr, "no_perf") + ] for _ in range(1 << 8): for test in tests: test(self) From a8d0a86ed24a8354cbddc64d243a8a834472bb7c Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 19 Aug 2020 22:21:43 -0700 Subject: [PATCH 151/189] Fix typo --- Python/ast_opt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/ast_opt.c b/Python/ast_opt.c index f26bec062fb0e9..b3125781ee8d0d 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -778,7 +778,7 @@ astfold_pattern_complex(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state PyLong_CheckExact(left->v.Constant.value)) || !PyComplex_CheckExact(right->v.Constant.value)) { - // Not actually valid, but it's the complier's job to complain: + // Not actually valid, but it's the compiler's job to complain: return 1; } PyObject *new; @@ -810,7 +810,7 @@ astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) case Call_kind: case Constant_kind: case Dict_kind: - // Not actually valid, but it's the complier's job to complain: + // Not actually valid, but it's the compiler's job to complain: case JoinedStr_kind: case List_kind: case Name_kind: From 66d614b6dcf3c690ef34b3f069637c2835cb0d3c Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sat, 22 Aug 2020 17:46:59 -0700 Subject: [PATCH 152/189] Unify shared SyntaxError test logic --- Lib/test/test_patma.py | 112 +++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 72 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index fcd98d1e6b13ee..485fa6d8d3ef3a 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -28,6 +28,10 @@ class Point: class TestPatma(unittest.TestCase): + def assert_syntax_error(self, code: str): + with self.assertRaises(SyntaxError): + compile(inspect.cleandoc(code), "", "exec") + def test_patma_000(self): match 0: case 0: @@ -2223,23 +2227,19 @@ def f(): @no_perf def test_patma_218(self): - code = """ + self.assert_syntax_error(""" match ...: case "a" | a: pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) @no_perf def test_patma_219(self): - code = """ + self.assert_syntax_error(""" match ...: case a | "a": pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) def test_patma_220(self): def f(): @@ -2250,13 +2250,11 @@ def f(): @no_perf def test_patma_221(self): - code = """ + self.assert_syntax_error(""" match ...: case a, a: pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) def test_patma_222(self): def f(): @@ -2267,13 +2265,11 @@ def f(): @no_perf def test_patma_223(self): - code = """ + self.assert_syntax_error(""" match ...: case {"k": a, "l": a}: pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) def test_patma_224(self): def f(): @@ -2284,33 +2280,27 @@ def f(): @no_perf def test_patma_225(self): - code = """ + self.assert_syntax_error(""" match ...: case MyClass(x, x): pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) @no_perf def test_patma_226(self): - code = """ + self.assert_syntax_error(""" match ...: case MyClass(x=x, y=x): pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) @no_perf def test_patma_227(self): - code = """ + self.assert_syntax_error(""" match ...: case MyClass(x, y=x): pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) def test_patma_228(self): def f(): @@ -2321,13 +2311,11 @@ def f(): @no_perf def test_patma_229(self): - code = """ + self.assert_syntax_error(""" match ...: case a := a: pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) def test_patma_230(self): def f(x): @@ -2403,73 +2391,59 @@ def f(x): @no_perf def test_patma_236(self): - code = """ + self.assert_syntax_error(""" match ...: case {**rest, "key": value}: pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) @no_perf def test_patma_237(self): - code = """ + self.assert_syntax_error(""" match ...: case {"first": first, **rest, "last": last}: pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) @no_perf def test_patma_238(self): - code = """ + self.assert_syntax_error(""" match ...: case *a, b, *c, d, *e: pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) @no_perf def test_patma_239(self): - code = """ + self.assert_syntax_error(""" match ...: case a, *b, c, *d, e: pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) @no_perf def test_patma_240(self): - code = """ + self.assert_syntax_error(""" match ...: case 0+0: pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) @no_perf def test_patma_241(self): - code = """ + self.assert_syntax_error(""" match ...: case f"": pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) @no_perf def test_patma_242(self): - code = """ + self.assert_syntax_error(""" match ...: case f"{x}": pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) @no_perf def test_patma_243(self): @@ -2487,23 +2461,19 @@ def test_patma_243(self): @no_perf def test_patma_244(self): - code = """ + self.assert_syntax_error(""" match ...: case {**_}: pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) @no_perf def test_patma_245(self): - code = """ + self.assert_syntax_error(""" match ...: case _ := 42: pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) @no_perf def test_patma_246(self): @@ -2559,13 +2529,11 @@ class Class: @no_perf def test_patma_250(self): - code = """ + self.assert_syntax_error(""" match ...: case Class(a=_, a=_): pass - """ - with self.assertRaises(SyntaxError): - exec(inspect.cleandoc(code)) + """) @no_perf def test_patma_251(self): From 3f7640379a334c0b72ed0a3b7bed85981c0ed128 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sat, 22 Aug 2020 17:47:22 -0700 Subject: [PATCH 153/189] Add two more tests for soft keywords --- Lib/test/test_patma.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 485fa6d8d3ef3a..8a5202a492b065 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2591,6 +2591,20 @@ class Class: self.assertIs(y, None) self.assertIs(z, None) + def test_patma_255(self): + match(): + case(): + x = 0 + self.assertEqual(x, 0) + + def test_patma_256(self): + x = 0 + match(x): + case(x): + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + # TODO: Better use of assertIs # TODO: Don't check side-effecty assignments From a527f666be25656b07cb0b4a0522c4d7aa8b47d9 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Sat, 22 Aug 2020 17:47:41 -0700 Subject: [PATCH 154/189] Refactor MATCH_CLASS --- Python/ceval.c | 11 +++++------ Python/compile.c | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 57a44f772fd2a2..29af149f4d9d0d 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3543,20 +3543,19 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_CLASS): { - PyObject *names = POP(); - PyObject *type = TOP(); - PyObject *subject = SECOND(); + PyObject *names = TOP(); + PyObject *type = SECOND(); + PyObject *subject = THIRD(); PyObject *attrs = do_match(tstate, oparg, names, type, subject); - Py_DECREF(names); if (attrs) { - Py_DECREF(subject); + Py_DECREF(type); SET_SECOND(attrs); } else if (_PyErr_Occurred(tstate)) { goto error; } + Py_DECREF(names); SET_TOP(PyBool_FromLong(!!attrs)); - Py_DECREF(type); DISPATCH(); } diff --git a/Python/compile.c b/Python/compile.c index 257ae920b1d744..2a524bdc787fce 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1135,7 +1135,7 @@ stack_effect(int opcode, int oparg, int jump) case GET_LEN: return 1; case MATCH_CLASS: - return -1; + return 0; case GET_INDEX: case GET_INDEX_END: case GET_INDEX_SLICE: @@ -5613,7 +5613,6 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { CHECK(!validate_keywords(c, kwargs)); CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); - ADDOP(c, DUP_TOP); // TODO: Refactor MATCH_CLASS? if (p->v.Call.func->kind == Attribute_kind) { CHECK(pattern_load_attribute(c, p->v.Call.func, pc)); } @@ -5633,6 +5632,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { ADDOP_LOAD_CONST_NEW(c, kwnames); ADDOP_I(c, MATCH_CLASS, nargs); ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); + NEXT_BLOCK(c); expr_ty arg; for (i = 0; i < nargs + nkwargs; i++) { if (i < nargs) { From 19af7d547e094006bfdc40a358385ad49503c597 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 15 Sep 2020 20:46:54 -0700 Subject: [PATCH 155/189] Literal False/True/None compares by identity --- Lib/test/test_patma.py | 35 ++++++++++++++++++++++++++++++++++- Python/compile.c | 8 +++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 8a5202a492b065..90a855aff4ec1f 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -550,11 +550,12 @@ def test_patma_058(self): def test_patma_059(self): x = 0 + y = None match x: case False: y = 0 self.assertEqual(x, 0) - self.assertEqual(y, 0) + self.assertEqual(y, None) def test_patma_060(self): x = 0 @@ -2605,6 +2606,38 @@ def test_patma_256(self): self.assertEqual(x, 0) self.assertEqual(y, 0) + def test_patma_257(self): + x = 0 + match x: + case False: + y = 1 + case 0: + y = 2 + self.assertEqual(x, 0) + self.assertEqual(y, 2) + + def test_patma_258(self): + x = 1 + match x: + case True: + y = 1 + case 1: + y = 2 + self.assertEqual(x, 1) + self.assertEqual(y, 2) + + def test_patma_259(self): + class Eq: + def __eq__(self, other): + return True + x = eq = Eq() + y = None + match x: + case None: + y = 1 + self.assertIs(x, eq) + self.assertEqual(y, None) + # TODO: Better use of assertIs # TODO: Don't check side-effecty assignments diff --git a/Python/compile.c b/Python/compile.c index 2a524bdc787fce..487796568d6614 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5665,7 +5665,13 @@ compiler_pattern_constant(struct compiler *c, expr_ty p, pattern_context *pc) assert(p->kind == Constant_kind); ADDOP(c, DUP_TOP); CHECK(pattern_load_constant(c, p, pc)); - ADDOP_COMPARE(c, Eq); + PyObject *v = p->v.Constant.value; + if (v == Py_None || PyBool_Check(v)) { + ADDOP_COMPARE(c, Is); + } + else { + ADDOP_COMPARE(c, Eq); + } return 1; } From 601645b76a3443b60c6af97164158c62fa114610 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 15 Sep 2020 20:51:47 -0700 Subject: [PATCH 156/189] Remove sealed --- Lib/test/test_typing.py | 12 ------------ Lib/typing.py | 37 ------------------------------------- 2 files changed, 49 deletions(-) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 2c91734e4952bb..b3be99141afca9 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -23,7 +23,6 @@ from typing import IO, TextIO, BinaryIO from typing import Pattern, Match from typing import Annotated, ForwardRef -from typing import sealed import abc import typing import weakref @@ -2301,17 +2300,6 @@ def test_final_unmodified(self): def func(x): ... self.assertIs(func, final(func)) - def test_sealed_unmodified(self): - class C: ... - self.assertIs(C, sealed(C)) - - def test_sealed_type(self): - def f(): ... - with self.assertRaises(TypeError): - sealed(f) - with self.assertRaises(TypeError): - sealed(42) - class CastTests(BaseTestCase): diff --git a/Lib/typing.py b/Lib/typing.py index 407c0c478b74ff..2899a0213d4340 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -109,7 +109,6 @@ 'NoReturn', 'overload', 'runtime_checkable', - 'sealed', 'Text', 'TYPE_CHECKING', ] @@ -1561,42 +1560,6 @@ class Other(Leaf): # Error reported by type checker return f -def sealed(cls): - """A decorator to indicate sealed classes. - - Use this decorator to indicate to type checkers that all subclasses of this - class must be defined in the current module. The type checker can then treat - the sealed base class as a union of all its known subclasses, allowing for - static exhaustiveness checks. For example: - - @sealed - class Parent: - ... - - class Child(Parent): - ... - - class X(Child): - ... - - class Y(Child): - ... - - class Z(Parent): - ... - - With this definition: - - - Child can be treated as Union[X, Y] - - Parent can be treated as Union[X, Y, Z] - - There is no runtime-checking of this property. - """ - if not isinstance(cls, type): - raise TypeError("only classes can be @sealed") - return cls - - # Some unconstrained type variables. These are used by the container types. # (These are not for export.) T = TypeVar('T') # Any type. From eed68066c22cdf5fbc7f593754ed03f435559f19 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 15 Sep 2020 20:51:59 -0700 Subject: [PATCH 157/189] Revert whitespace change --- Python/compile.c | 1 - 1 file changed, 1 deletion(-) diff --git a/Python/compile.c b/Python/compile.c index 487796568d6614..a6b51cd1f10f44 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2768,7 +2768,6 @@ compiler_if(struct compiler *c, stmt_ty s) return 1; } - static int compiler_for(struct compiler *c, stmt_ty s) { From 3c4796c7bcecde12c5d38d3851c37aef1e8f4555 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 15 Sep 2020 21:14:53 -0700 Subject: [PATCH 158/189] Assorted cleanup --- Lib/ast.py | 2 +- Lib/test/test_collections.py | 2 +- Lib/test/test_dataclasses.py | 19 ++++++++----------- Python/symtable.c | 1 - 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Lib/ast.py b/Lib/ast.py index 76751f2b7bec59..e3383f8c99b751 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -1520,7 +1520,7 @@ def visit_match_case(self, node): if node.guard: self.write(" if ") self.traverse(node.guard) - with self.block(): + with self.block(): self.traverse(node.body) def unparse(ast_obj): diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index a1fc42ae1e8f53..807fbb9f3c0efd 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -667,7 +667,7 @@ class NewPoint(tuple): def test_match_args(self): Point = namedtuple('Point', 'x y') - self.assertEqual(Point.__match_args__, ('x', 'y')) # matches a real tuple + self.assertEqual(Point.__match_args__, ('x', 'y')) ################################################################################ diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index 81c3ec1e37814b..b36dfe88004630 100644 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -3335,20 +3335,17 @@ class C: class TestMatchArgs(unittest.TestCase): def test_match_args(self): @dataclass - class B: - x: int - - o = B(4) - self.assertEqual(o.__match_args__, ('x',)) + class C: + a: int + self.assertEqual(C(42).__match_args__, ('a',)) def test_explicit_match_args(self): + ma = [] @dataclass - class B: - x: int - __match_args__ = [] - - o = B(4) - self.assertEqual(o.__match_args__, []) + class C: + a: int + __match_args__ = ma + self.assertIs(C(42).__match_args__, ma) if __name__ == '__main__': unittest.main() diff --git a/Python/symtable.c b/Python/symtable.c index 83f744301257ee..223554ea22c17f 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1787,7 +1787,6 @@ symtable_visit_withitem(struct symtable *st, withitem_ty item) return 1; } - static int symtable_visit_match_case(struct symtable *st, match_case_ty m) { From 45b14293d1ee826690947bfaeee8a0fe85115ce0 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 15 Sep 2020 22:49:43 -0700 Subject: [PATCH 159/189] Add three more identity tests --- Lib/test/test_patma.py | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 90a855aff4ec1f..6530439784d727 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2610,21 +2610,21 @@ def test_patma_257(self): x = 0 match x: case False: - y = 1 + y = 0 case 0: - y = 2 + y = 1 self.assertEqual(x, 0) - self.assertEqual(y, 2) + self.assertEqual(y, 1) def test_patma_258(self): x = 1 match x: case True: - y = 1 + y = 0 case 1: - y = 2 + y = 1 self.assertEqual(x, 1) - self.assertEqual(y, 2) + self.assertEqual(y, 1) def test_patma_259(self): class Eq: @@ -2634,10 +2634,34 @@ def __eq__(self, other): y = None match x: case None: - y = 1 + y = 0 self.assertIs(x, eq) self.assertEqual(y, None) + def test_patma_260(self): + x = False + match x: + case False: + y = 0 + self.assertIs(x, False) + self.assertEqual(y, 0) + + def test_patma_261(self): + x = True + match x: + case True: + y = 0 + self.assertIs(x, True) + self.assertEqual(y, 0) + + def test_patma_262(self): + x = None + match x: + case None: + y = 0 + self.assertIs(x, None) + self.assertEqual(y, 0) + # TODO: Better use of assertIs # TODO: Don't check side-effecty assignments From 5505fc337bd4f5a5ee867f5fb4d0b574bf13ab7f Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 24 Sep 2020 23:37:16 -0700 Subject: [PATCH 160/189] Fixes for grammar changes --- Grammar/python.gram | 10 +++++----- Parser/parser.c | 24 ++++++++++++------------ Python/ast.c | 2 +- Python/ast_opt.c | 4 ++-- Python/compile.c | 10 +++++----- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index e90431bf825f3d..60c50d3e746caf 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -202,7 +202,7 @@ match_expr[expr_ty]: | named_expression match_stmt[stmt_ty]: - | "match" subject=match_expr ':' NEWLINE INDENT cases=case_block+ DEDENT { + | "match" subject=match_expr ':' NEWLINE INDENT cases[asdl_match_case_seq*]=case_block+ DEDENT { _Py_Match(subject, cases, EXTRA) } case_block[match_case_ty]: | "case" pattern=patterns guard=guard? ':' body=block { @@ -221,7 +221,7 @@ pattern[expr_ty]: | or_pattern or_pattern[expr_ty]: - | values='|'.closed_pattern+ { + | values[asdl_expr_seq*]='|'.closed_pattern+ { asdl_seq_LEN(values) == 1 ? asdl_seq_GET(values, 0) : _Py_BoolOp(Or, values, EXTRA) } closed_pattern[expr_ty]: @@ -255,11 +255,11 @@ mapping_pattern[expr_ty]: _Py_Dict(CHECK(_PyPegen_get_keys(p, items)), CHECK(_PyPegen_get_values(p, items)), EXTRA) } class_pattern[expr_ty]: | func=name_or_attr '(' ')' { _Py_Call(func, NULL, NULL, EXTRA) } - | func=name_or_attr '(' args=','.pattern+ ','? ')' { + | func=name_or_attr '(' args[asdl_expr_seq*]=','.pattern+ ','? ')' { _Py_Call(func, args, NULL, EXTRA) } - | func=name_or_attr '(' keywords=','.keyword_pattern+ ','? ')' { + | func=name_or_attr '(' keywords[asdl_keyword_seq*]=','.keyword_pattern+ ','? ')' { _Py_Call(func, NULL, keywords, EXTRA) } - | func=name_or_attr '(' args=','.pattern+ ',' keywords=','.keyword_pattern+ ','? ')' { + | func=name_or_attr '(' args[asdl_expr_seq*]=','.pattern+ ',' keywords[asdl_keyword_seq*]=','.keyword_pattern+ ','? ')' { _Py_Call(func, args, keywords, EXTRA) } | func=name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' error=pattern [',' ','.error_argument_pattern+] ','? ')' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "positional pattern follows keyword pattern") } diff --git a/Parser/parser.c b/Parser/parser.c index 911175678c9e05..57f95658a7d1cb 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -4909,7 +4909,7 @@ match_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"match\" match_expr ':' NEWLINE INDENT case_block+ DEDENT")); expr_ty _keyword; Token * _literal; - asdl_seq * cases; + asdl_match_case_seq* cases; Token * dedent_var; Token * indent_var; Token * newline_var; @@ -4925,7 +4925,7 @@ match_stmt_rule(Parser *p) && (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' && - (cases = _loop1_50_rule(p)) // case_block+ + (cases = (asdl_match_case_seq*)_loop1_50_rule(p)) // case_block+ && (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' ) @@ -5249,9 +5249,9 @@ or_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> or_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|'.closed_pattern+")); - asdl_seq * values; + asdl_expr_seq* values; if ( - (values = _gather_51_rule(p)) // '|'.closed_pattern+ + (values = (asdl_expr_seq*)_gather_51_rule(p)) // '|'.closed_pattern+ ) { D(fprintf(stderr, "%*c+ or_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'|'.closed_pattern+")); @@ -6063,14 +6063,14 @@ class_pattern_rule(Parser *p) Token * _literal_1; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings - asdl_seq * args; + asdl_expr_seq* args; expr_ty func; if ( (func = name_or_attr_rule(p)) // name_or_attr && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (args = _gather_56_rule(p)) // ','.pattern+ + (args = (asdl_expr_seq*)_gather_56_rule(p)) // ','.pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -6110,13 +6110,13 @@ class_pattern_rule(Parser *p) void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings expr_ty func; - asdl_seq * keywords; + asdl_keyword_seq* keywords; if ( (func = name_or_attr_rule(p)) // name_or_attr && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (keywords = _gather_58_rule(p)) // ','.keyword_pattern+ + (keywords = (asdl_keyword_seq*)_gather_58_rule(p)) // ','.keyword_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -6156,19 +6156,19 @@ class_pattern_rule(Parser *p) Token * _literal_2; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings - asdl_seq * args; + asdl_expr_seq* args; expr_ty func; - asdl_seq * keywords; + asdl_keyword_seq* keywords; if ( (func = name_or_attr_rule(p)) // name_or_attr && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (args = _gather_60_rule(p)) // ','.pattern+ + (args = (asdl_expr_seq*)_gather_60_rule(p)) // ','.pattern+ && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (keywords = _gather_62_rule(p)) // ','.keyword_pattern+ + (keywords = (asdl_keyword_seq*)_gather_62_rule(p)) // ','.keyword_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? && diff --git a/Python/ast.c b/Python/ast.c index 6a40d4f836e210..3d1d5b7dc7f00c 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -326,7 +326,7 @@ validate_expr(expr_ty exp, expr_context_ty ctx) static int validate_pattern(expr_ty p) { - asdl_seq *keys, *values; + asdl_expr_seq *keys, *values; expr_ty key, value; Py_ssize_t i, size; switch (p->kind) { diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 9bd7893c0ecdf8..d79ef4c80ffb43 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -714,7 +714,7 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) break; case Match_kind: CALL(astfold_expr, expr_ty, node_->v.Match.subject); - CALL_SEQ(astfold_match_case, match_case_ty, node_->v.Match.cases); + CALL_SEQ(astfold_match_case, match_case, node_->v.Match.cases); break; default: break; @@ -831,7 +831,7 @@ astfold_match_case(match_case_ty node_, PyArena *ctx_, _PyASTOptimizeState *stat { CALL(astfold_pattern, expr_ty, node_->pattern); CALL_OPT(astfold_expr, expr_ty, node_->guard); - CALL_SEQ(astfold_stmt, stmt_ty, node_->body); + CALL_SEQ(astfold_stmt, stmt, node_->body); return 1; } diff --git a/Python/compile.c b/Python/compile.c index b6206e6377c7ed..c6333494f7c10c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5598,8 +5598,8 @@ compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context *pc) static int compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { - asdl_seq *args = p->v.Call.args; - asdl_seq *kwargs = p->v.Call.keywords; + asdl_expr_seq *args = p->v.Call.args; + asdl_keyword_seq *kwargs = p->v.Call.keywords; Py_ssize_t nargs = asdl_seq_LEN(args); Py_ssize_t nkwargs = asdl_seq_LEN(kwargs); if (nargs + nkwargs > INT_MAX) { @@ -5678,8 +5678,8 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) basicblock *block, *end; CHECK(block = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); - asdl_seq *keys = p->v.Dict.keys; - asdl_seq *values = p->v.Dict.values; + asdl_expr_seq *keys = p->v.Dict.keys; + asdl_expr_seq *values = p->v.Dict.values; Py_ssize_t size = asdl_seq_LEN(values); int star = size ? !asdl_seq_GET(keys, size - 1) : 0; // TODO: (i >= (1 << 8)) || (n-i-1 >= (INT_MAX >> 8)) @@ -5750,7 +5750,7 @@ static int compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == List_kind || p->kind == Tuple_kind); - asdl_seq *values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; + asdl_expr_seq *values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; Py_ssize_t size = asdl_seq_LEN(values); Py_ssize_t star = -1; for (Py_ssize_t i = 0; i < size; i++) { From 587ba871896b44af3ee8471d7a6bf9bf668579ac Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 19 Oct 2020 10:11:36 -0700 Subject: [PATCH 161/189] Use sets to track map keys and attribute names. --- Python/ceval.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 0df1ec3d6e27cd..686de3db92c0b2 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -860,7 +860,7 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) goto fail; } } - seen = PyList_New(0); + seen = PySet_New(NULL); if (!seen) { goto fail; } @@ -871,7 +871,7 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) PyObject *key, *value; for (Py_ssize_t i = 0; i < nkeys; i++) { key = PyTuple_GET_ITEM(keys, i); - if (PySequence_Contains(seen, key) || PyList_Append(seen, key)) { + if (PySet_Contains(seen, key) || PySet_Add(seen, key)) { if (!_PyErr_Occurred(tstate)) { _PyErr_Format(tstate, PyExc_ValueError, "mapping pattern checks duplicate key (%R)", key); @@ -1024,7 +1024,7 @@ do_match(PyThreadState *tstate, Py_ssize_t nargs, PyObject *kwargs, PyObject *ty if (!attrs) { goto error; } - seen = PyList_New(0); + seen = PySet_New(NULL); if (!seen) { goto error; } @@ -1048,7 +1048,7 @@ do_match(PyThreadState *tstate, Py_ssize_t nargs, PyObject *kwargs, PyObject *ty else { name = PyTuple_GET_ITEM(kwargs, i - nargs); } - if (PySequence_Contains(seen, name) || PyList_Append(seen, name)) { + if (PySet_Contains(seen, name) || PySet_Add(seen, name)) { if (!_PyErr_Occurred(tstate)) { _PyErr_Format(tstate, PyExc_TypeError, "%s() got multiple sub-patterns for attribute %R", From a1e88fe3c2eb2e99ab08f2293b2f53b2075e8283 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 19 Oct 2020 10:13:24 -0700 Subject: [PATCH 162/189] Add a few notes. --- Python/ast.c | 8 ++++---- Python/ceval.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Python/ast.c b/Python/ast.c index 3d1d5b7dc7f00c..dc76e5f4726008 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -331,7 +331,7 @@ validate_pattern(expr_ty p) Py_ssize_t i, size; switch (p->kind) { case Attribute_kind: - return validate_expr(p, Load); + return validate_expr(p, Load); // TODO case BinOp_kind: // TODO return 1; @@ -358,7 +358,7 @@ validate_pattern(expr_ty p) // TODO return 1; case Constant_kind: - return validate_expr(p, Load); + return validate_expr(p, Load); // TODO case Dict_kind: keys = p->v.Dict.keys; values = p->v.Dict.values; @@ -431,10 +431,10 @@ validate_pattern(expr_ty p) "Name ctx in pattern must be Load or Store"); return 0; } - return validate_expr(p, p->v.Name.ctx); + return validate_expr(p, p->v.Name.ctx); // TODO case NamedExpr_kind: return (validate_pattern(p->v.NamedExpr.value) - && validate_expr(p->v.NamedExpr.target, Store)); + && validate_expr(p->v.NamedExpr.target, Store)); // TODO case UnaryOp_kind: // TODO return 1; diff --git a/Python/ceval.c b/Python/ceval.c index 686de3db92c0b2..a0e29e5a4cae00 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -984,7 +984,7 @@ do_match(PyThreadState *tstate, Py_ssize_t nargs, PyObject *kwargs, PyObject *ty Py_ssize_t nkwargs = PyTuple_GET_SIZE(kwargs); Py_ssize_t count = nargs + nkwargs; Py_ssize_t nmatch_args; - // TODO: Just build attrs in two passes (nargs and nkwargs) + // TODO: Just build attrs in two passes (nargs and nkwargs)? if (!nargs) { nmatch_args = 0; args = PyTuple_New(0); From 91661eb08ae100bdadf9f6c5ae74d4804c93f824 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 19 Oct 2020 11:54:03 -0700 Subject: [PATCH 163/189] "n := p" -> "p as n" --- Grammar/python.gram | 2 +- Lib/ast.py | 15 ++++++++--- Lib/test/test_patma.py | 58 +++++++++++++++++++++++++----------------- Parser/parser.c | 18 ++++++------- 4 files changed, 55 insertions(+), 38 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 00925d4fa8676d..1e9cc7ed80ba12 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -216,7 +216,7 @@ patterns[expr_ty]: | pattern pattern[expr_ty]: - | target=NAME ':=' value=or_pattern { + | value=or_pattern 'as' target=NAME { _Py_NamedExpr(CHECK(_PyPegen_set_expr_context(p, target, Store)), value, EXTRA) } | or_pattern diff --git a/Lib/ast.py b/Lib/ast.py index 350bdd49212419..af27f40997cce7 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -743,6 +743,7 @@ def pattern(self): assert self._pattern self._pattern = False + @property def in_pattern(self): return self._pattern @@ -839,9 +840,15 @@ def visit_Expr(self, node): def visit_NamedExpr(self, node): with self.require_parens(_Precedence.TUPLE, node): self.set_precedence(_Precedence.ATOM, node.target, node.value) - self.traverse(node.target) - self.write(" := ") - self.traverse(node.value) + # XXX + if self.in_pattern: + self.traverse(node.value) + self.write(" as ") + self.traverse(node.target) + else: + self.traverse(node.target) + self.write(" := ") + self.traverse(node.value) def visit_Import(self, node): self.fill("import ") @@ -1346,7 +1353,7 @@ def visit_Compare(self, node): boolop_precedence = {"and": _Precedence.AND, "or": _Precedence.OR} def visit_BoolOp(self, node): - if self.in_pattern(): + if self.in_pattern: operator = "|" operator_precedence = _Precedence.OR else: diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 6530439784d727..40cf89ec82e273 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -94,7 +94,7 @@ def test_patma_008(self): class A: y = 1 match x: - case z := A.y: + case A.y as z: pass self.assertEqual(x, 0) self.assertEqual(A.y, 1) @@ -105,7 +105,7 @@ class A: match 0: case x if x: z = 0 - case y := _ if y == x and y: + case _ as y if y == x and y: z = 1 case A.B: z = 2 @@ -225,7 +225,7 @@ def test_patma_024(self): def test_patma_025(self): x = {0: 0} match x: - case {0: (z := 0 | 1 | 2)}: + case {0: (0 | 1 | 2 as z)}: y = 0 self.assertEqual(x, {0: 0}) self.assertEqual(y, 0) @@ -234,7 +234,7 @@ def test_patma_025(self): def test_patma_026(self): x = {0: 1} match x: - case {0: (z := 0 | 1 | 2)}: + case {0: (0 | 1 | 2 as z)}: y = 0 self.assertEqual(x, {0: 1}) self.assertEqual(y, 0) @@ -243,7 +243,7 @@ def test_patma_026(self): def test_patma_027(self): x = {0: 2} match x: - case {0: (z := 0 | 1 | 2)}: + case {0: (0 | 1 | 2 as z)}: y = 0 self.assertEqual(x, {0: 2}) self.assertEqual(y, 0) @@ -253,7 +253,7 @@ def test_patma_028(self): x = {0: 3} y = None match x: - case {0: (z := 0 | 1 | 2)}: + case {0: (0 | 1 | 2 as z)}: y = 0 self.assertEqual(x, {0: 3}) self.assertIs(y, None) @@ -379,7 +379,7 @@ def test_patma_039(self): def test_patma_040(self): x = 0 match x: - case (z := 0) | (z := 1) | (z := 2) if z == x % 2: + case (0 as z) | (1 as z) | (2 as z) if z == x % 2: y = 0 self.assertEqual(x, 0) self.assertEqual(y, 0) @@ -388,7 +388,7 @@ def test_patma_040(self): def test_patma_041(self): x = 1 match x: - case (z := 0) | (z := 1) | (z := 2) if z == x % 2: + case (0 as z) | (1 as z) | (2 as z) if z == x % 2: y = 0 self.assertEqual(x, 1) self.assertEqual(y, 0) @@ -398,7 +398,7 @@ def test_patma_042(self): x = 2 y = None match x: - case (z := 0) | (z := 1) | (z := 2) if z == x % 2: + case (0 as z) | (1 as z) | (2 as z) if z == x % 2: y = 0 self.assertEqual(x, 2) self.assertIs(y, None) @@ -408,7 +408,7 @@ def test_patma_043(self): x = 3 y = None match x: - case (z := 0) | (z := 1) | (z := 2) if z == x % 2: + case (0 as z) | (1 as z) | (2 as z) if z == x % 2: y = 0 self.assertEqual(x, 3) self.assertIs(y, None) @@ -474,9 +474,9 @@ def test_patma_051(self): w = None x = [1, 0] match x: - case [(w := 0)]: + case [(0 as w)]: y = 0 - case [z] | [1, (z := 0 | 1)] | [z]: + case [z] | [1, (0 | 1 as z)] | [z]: y = 1 self.assertIs(w, None) self.assertEqual(x, [1, 0]) @@ -786,7 +786,7 @@ def test_patma_081(self): match x: case 0 if not (x := 1): y = 0 - case (z := 0): + case (0 as z): y = 1 self.assertEqual(x, 1) self.assertEqual(y, 1) @@ -795,7 +795,7 @@ def test_patma_081(self): def test_patma_082(self): x = 0 match x: - case (z := 1) if not (x := 1): + case (1 as z) if not (x := 1): y = 0 case 0: y = 1 @@ -805,7 +805,7 @@ def test_patma_082(self): def test_patma_083(self): x = 0 match x: - case (z := 0): + case (0 as z): y = 0 self.assertEqual(x, 0) self.assertEqual(y, 0) @@ -815,7 +815,7 @@ def test_patma_084(self): x = 0 y = None match x: - case (z := 1): + case (1 as z): y = 0 self.assertEqual(x, 0) self.assertIs(y, None) @@ -824,7 +824,7 @@ def test_patma_085(self): x = 0 y = None match x: - case (z := 0) if (w := 0): + case (0 as z) if (w := 0): y = 0 self.assertEqual(w, 0) self.assertEqual(x, 0) @@ -834,7 +834,7 @@ def test_patma_085(self): def test_patma_086(self): x = 0 match x: - case (z := (w := 0)): + case ((0 as w) as z): y = 0 self.assertEqual(w, 0) self.assertEqual(x, 0) @@ -1444,7 +1444,7 @@ def test_patma_152(self): def test_patma_153(self): x = 0 match w := x,: - case v := y,: + case y as v,: z = 0 self.assertEqual(x, 0) self.assertIs(y, x) @@ -1955,7 +1955,7 @@ def test_patma_196(self): def test_patma_197(self): w = [Point(-1, 0), Point(1, 2)] match w: - case (Point(x1, y1), p2 := Point(x2, y2)): + case (Point(x1, y1), Point(x2, y2) as p2): z = 0 self.assertEqual(w, [Point(-1, 0), Point(1, 2)]) self.assertIs(x1, w[0].x) @@ -2189,7 +2189,7 @@ def f(w): def test_patma_213(self): def f(w): match w: - case x := (p, q): + case (p, q) as x: out = locals() del out["w"] return out @@ -2306,7 +2306,7 @@ def test_patma_227(self): def test_patma_228(self): def f(): match ...: - case a := b: + case b as a: return locals() self.assertEqual(set(f()), {"a", "b"}) @@ -2314,7 +2314,7 @@ def f(): def test_patma_229(self): self.assert_syntax_error(""" match ...: - case a := a: + case a as a: pass """) @@ -2472,7 +2472,7 @@ def test_patma_244(self): def test_patma_245(self): self.assert_syntax_error(""" match ...: - case _ := 42: + case 42 as _: pass """) @@ -2662,6 +2662,16 @@ def test_patma_262(self): self.assertIs(x, None) self.assertEqual(y, 0) + def test_patma_263(self): + x = 0 + match x: + case (0 as w) as z: + y = 0 + self.assertEqual(w, 0) + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertEqual(z, 0) + # TODO: Better use of assertIs # TODO: Don't check side-effecty assignments diff --git a/Parser/parser.c b/Parser/parser.c index eec96bccbb8d20..8e3ea334d8ccfa 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -5142,7 +5142,7 @@ patterns_rule(Parser *p) return _res; } -// pattern: NAME ':=' or_pattern | or_pattern +// pattern: or_pattern 'as' NAME | or_pattern static expr_ty pattern_rule(Parser *p) { @@ -5162,24 +5162,24 @@ pattern_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME ':=' or_pattern + { // or_pattern 'as' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':=' or_pattern")); - Token * _literal; + D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' NAME")); + Token * _keyword; expr_ty target; expr_ty value; if ( - (target = _PyPegen_name_token(p)) // NAME + (value = or_pattern_rule(p)) // or_pattern && - (_literal = _PyPegen_expect_token(p, 53)) // token=':=' + (_keyword = _PyPegen_expect_token(p, 520)) // token='as' && - (value = or_pattern_rule(p)) // or_pattern + (target = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ':=' or_pattern")); + D(fprintf(stderr, "%*c+ pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' NAME")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5199,7 +5199,7 @@ pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':=' or_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "or_pattern 'as' NAME")); } { // or_pattern if (p->error_indicator) { From 28ba072423109de35472c15aed8ebe539c703e1a Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 19 Oct 2020 14:24:21 -0700 Subject: [PATCH 164/189] Use new MatchAs node for named patterns --- Grammar/python.gram | 7 ++- Include/Python-ast.h | 12 ++++- Lib/ast.py | 17 ++++--- Lib/test/test_patma.py | 29 ++++++++++++ Lib/test/test_unparse.py | 2 +- Parser/Python.asdl | 3 ++ Parser/parser.c | 28 +++++------ Python/Python-ast.c | 100 ++++++++++++++++++++++++++++++++++++++- Python/ast.c | 10 ++-- Python/ast_opt.c | 2 +- Python/compile.c | 33 ++++++------- Python/symtable.c | 4 ++ 12 files changed, 196 insertions(+), 51 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 1e9cc7ed80ba12..43c8749845194e 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -216,8 +216,7 @@ patterns[expr_ty]: | pattern pattern[expr_ty]: - | value=or_pattern 'as' target=NAME { - _Py_NamedExpr(CHECK(_PyPegen_set_expr_context(p, target, Store)), value, EXTRA) } + | value=or_pattern 'as' target=NAME { _Py_MatchAs(value, target->v.Name.id, EXTRA) } | or_pattern or_pattern[expr_ty]: @@ -281,7 +280,7 @@ values_pattern[asdl_seq*]: items_pattern[asdl_seq*]: | items=','.key_value_pattern+ ','? { items } keyword_pattern[keyword_ty]: - | arg=NAME '=' value=or_pattern { _Py_keyword(arg->v.Name.id, value, EXTRA) } + | arg=NAME '=' value=pattern { _Py_keyword(arg->v.Name.id, value, EXTRA) } error_argument_pattern: | pattern | keyword_pattern @@ -292,7 +291,7 @@ value_pattern[expr_ty]: | '*' value=name_pattern { _Py_Starred(value, Store, EXTRA) } | pattern key_value_pattern[KeyValuePair*]: - | key=(literal_pattern | constant_pattern) ':' value=or_pattern { + | key=(literal_pattern | constant_pattern) ':' value=pattern { _PyPegen_key_value_pair(p, key, value) } | '**' value=name_pattern { _PyPegen_key_value_pair(p, NULL, value) } diff --git a/Include/Python-ast.h b/Include/Python-ast.h index 8c6c17022a7ceb..25f2deed378fff 100644 --- a/Include/Python-ast.h +++ b/Include/Python-ast.h @@ -326,7 +326,8 @@ enum _expr_kind {BoolOp_kind=1, NamedExpr_kind=2, BinOp_kind=3, UnaryOp_kind=4, YieldFrom_kind=15, Compare_kind=16, Call_kind=17, FormattedValue_kind=18, JoinedStr_kind=19, Constant_kind=20, Attribute_kind=21, Subscript_kind=22, Starred_kind=23, - Name_kind=24, List_kind=25, Tuple_kind=26, Slice_kind=27}; + Name_kind=24, List_kind=25, Tuple_kind=26, Slice_kind=27, + MatchAs_kind=28}; struct _expr { enum _expr_kind kind; union { @@ -469,6 +470,11 @@ struct _expr { expr_ty step; } Slice; + struct { + expr_ty pattern; + identifier name; + } MatchAs; + } v; int lineno; int col_offset; @@ -768,6 +774,10 @@ expr_ty _Py_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int expr_ty _Py_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); +#define MatchAs(a0, a1, a2, a3, a4, a5, a6) _Py_MatchAs(a0, a1, a2, a3, a4, a5, a6) +expr_ty _Py_MatchAs(expr_ty pattern, identifier name, int lineno, int + col_offset, int end_lineno, int end_col_offset, PyArena + *arena); #define comprehension(a0, a1, a2, a3, a4) _Py_comprehension(a0, a1, a2, a3, a4) comprehension_ty _Py_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int is_async, PyArena *arena); diff --git a/Lib/ast.py b/Lib/ast.py index af27f40997cce7..cc9c57752776c6 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -840,15 +840,9 @@ def visit_Expr(self, node): def visit_NamedExpr(self, node): with self.require_parens(_Precedence.TUPLE, node): self.set_precedence(_Precedence.ATOM, node.target, node.value) - # XXX - if self.in_pattern: - self.traverse(node.value) - self.write(" as ") - self.traverse(node.target) - else: - self.traverse(node.target) - self.write(" := ") - self.traverse(node.value) + self.traverse(node.target) + self.write(" := ") + self.traverse(node.value) def visit_Import(self, node): self.fill("import ") @@ -1537,6 +1531,11 @@ def visit_match_case(self, node): with self.block(): self.traverse(node.body) + def visit_MatchAs(self, node): + with self.require_parens(_Precedence.TUPLE, node): + self.traverse(node.pattern) + self.write(f" as {node.name}") + def unparse(ast_obj): unparser = _Unparser() return unparser.visit(ast_obj) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 40cf89ec82e273..7a9e36911214cd 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2672,6 +2672,35 @@ def test_patma_263(self): self.assertEqual(y, 0) self.assertEqual(z, 0) + def test_patma_264(self): + x = 0 + match x: + case (0 as w) as z: + y = 0 + self.assertEqual(w, 0) + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertEqual(z, 0) + + def test_patma_265(self): + x = ((0, 1), (2, 3)) + match x: + case ((a as b, c as d) as e) as w, ((f as g, h) as i) as z: + y = 0 + self.assertEqual(a, 0) + self.assertEqual(b, 0) + self.assertEqual(c, 1) + self.assertEqual(d, 1) + self.assertEqual(e, (0, 1)) + self.assertEqual(f, 2) + self.assertEqual(g, 2) + self.assertEqual(h, 3) + self.assertEqual(i, (2, 3)) + self.assertEqual(w, (0, 1)) + self.assertEqual(x, ((0, 1), (2, 3))) + self.assertEqual(y, 0) + self.assertEqual(z, (2, 3)) + # TODO: Better use of assertIs # TODO: Don't check side-effecty assignments diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py index 532aa3a6390414..4701f81562f498 100644 --- a/Lib/test/test_unparse.py +++ b/Lib/test/test_unparse.py @@ -485,7 +485,7 @@ class DirectoryTestCase(ASTTestCase): test_directories = (lib_dir, lib_dir / "test") skip_files = {"test_fstring.py"} run_always_files = {"test_grammar.py", "test_syntax.py", "test_compile.py", - "test_ast.py", "test_asdl_parser.py"} + "test_ast.py", "test_asdl_parser.py", "test_patma.py"} # XXX _files_to_test = None diff --git a/Parser/Python.asdl b/Parser/Python.asdl index 2ea375366873ee..8b0c1ef7ba60eb 100644 --- a/Parser/Python.asdl +++ b/Parser/Python.asdl @@ -89,6 +89,9 @@ module Python -- can appear only in Subscript | Slice(expr? lower, expr? upper, expr? step) + -- only used for named patterns + | MatchAs(expr pattern, identifier name) + -- col_offset is the byte offset in the utf8 string the parser uses attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset) diff --git a/Parser/parser.c b/Parser/parser.c index 8e3ea334d8ccfa..592420876f2151 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -5189,7 +5189,7 @@ pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , target , Store ) ) , value , EXTRA ); + _res = _Py_MatchAs ( value , target -> v . Name . id , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6624,7 +6624,7 @@ items_pattern_rule(Parser *p) return _res; } -// keyword_pattern: NAME '=' or_pattern +// keyword_pattern: NAME '=' pattern static keyword_ty keyword_pattern_rule(Parser *p) { @@ -6644,12 +6644,12 @@ keyword_pattern_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME '=' or_pattern + { // NAME '=' pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> keyword_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' or_pattern")); + D(fprintf(stderr, "%*c> keyword_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' pattern")); Token * _literal; expr_ty arg; expr_ty value; @@ -6658,10 +6658,10 @@ keyword_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 22)) // token='=' && - (value = or_pattern_rule(p)) // or_pattern + (value = pattern_rule(p)) // pattern ) { - D(fprintf(stderr, "%*c+ keyword_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' or_pattern")); + D(fprintf(stderr, "%*c+ keyword_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' pattern")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -6681,7 +6681,7 @@ keyword_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s keyword_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' or_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' pattern")); } _res = NULL; done: @@ -6869,9 +6869,7 @@ value_pattern_rule(Parser *p) return _res; } -// key_value_pattern: -// | (literal_pattern | constant_pattern) ':' or_pattern -// | '**' name_pattern +// key_value_pattern: (literal_pattern | constant_pattern) ':' pattern | '**' name_pattern static KeyValuePair* key_value_pattern_rule(Parser *p) { @@ -6882,12 +6880,12 @@ key_value_pattern_rule(Parser *p) } KeyValuePair* _res = NULL; int _mark = p->mark; - { // (literal_pattern | constant_pattern) ':' or_pattern + { // (literal_pattern | constant_pattern) ':' pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(literal_pattern | constant_pattern) ':' or_pattern")); + D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(literal_pattern | constant_pattern) ':' pattern")); Token * _literal; void *key; expr_ty value; @@ -6896,10 +6894,10 @@ key_value_pattern_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && - (value = or_pattern_rule(p)) // or_pattern + (value = pattern_rule(p)) // pattern ) { - D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(literal_pattern | constant_pattern) ':' or_pattern")); + D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(literal_pattern | constant_pattern) ':' pattern")); _res = _PyPegen_key_value_pair ( p , key , value ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -6910,7 +6908,7 @@ key_value_pattern_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s key_value_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(literal_pattern | constant_pattern) ':' or_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(literal_pattern | constant_pattern) ':' pattern")); } { // '**' name_pattern if (p->error_indicator) { diff --git a/Python/Python-ast.c b/Python/Python-ast.c index c599a86adea581..e81247dc8a6519 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -87,6 +87,7 @@ typedef struct { PyObject *Lt_type; PyObject *MatMult_singleton; PyObject *MatMult_type; + PyObject *MatchAs_type; PyObject *Match_type; PyObject *Mod_singleton; PyObject *Mod_type; @@ -339,6 +340,7 @@ void _PyAST_Fini(PyThreadState *tstate) Py_CLEAR(state->Lt_type); Py_CLEAR(state->MatMult_singleton); Py_CLEAR(state->MatMult_type); + Py_CLEAR(state->MatchAs_type); Py_CLEAR(state->Match_type); Py_CLEAR(state->Mod_singleton); Py_CLEAR(state->Mod_type); @@ -836,6 +838,10 @@ static const char * const Slice_fields[]={ "upper", "step", }; +static const char * const MatchAs_fields[]={ + "pattern", + "name", +}; static PyObject* ast2obj_expr_context(astmodulestate *state, expr_context_ty); static PyObject* ast2obj_boolop(astmodulestate *state, boolop_ty); static PyObject* ast2obj_operator(astmodulestate *state, operator_ty); @@ -1474,7 +1480,8 @@ static int init_types(astmodulestate *state) " | Name(identifier id, expr_context ctx)\n" " | List(expr* elts, expr_context ctx)\n" " | Tuple(expr* elts, expr_context ctx)\n" - " | Slice(expr? lower, expr? upper, expr? step)"); + " | Slice(expr? lower, expr? upper, expr? step)\n" + " | MatchAs(expr pattern, identifier name)"); if (!state->expr_type) return 0; if (!add_attributes(state, state->expr_type, expr_attributes, 4)) return 0; if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1) @@ -1607,6 +1614,10 @@ static int init_types(astmodulestate *state) return 0; if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1) return 0; + state->MatchAs_type = make_type(state, "MatchAs", state->expr_type, + MatchAs_fields, 2, + "MatchAs(expr pattern, identifier name)"); + if (!state->MatchAs_type) return 0; state->expr_context_type = make_type(state, "expr_context", state->AST_type, NULL, 0, "expr_context = Load | Store | Del"); @@ -3297,6 +3308,34 @@ Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int col_offset, return p; } +expr_ty +MatchAs(expr_ty pattern, identifier name, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena) +{ + expr_ty p; + if (!pattern) { + PyErr_SetString(PyExc_ValueError, + "field 'pattern' is required for MatchAs"); + return NULL; + } + if (!name) { + PyErr_SetString(PyExc_ValueError, + "field 'name' is required for MatchAs"); + return NULL; + } + p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); + if (!p) + return NULL; + p->kind = MatchAs_kind; + p->v.MatchAs.pattern = pattern; + p->v.MatchAs.name = name; + p->lineno = lineno; + p->col_offset = col_offset; + p->end_lineno = end_lineno; + p->end_col_offset = end_col_offset; + return p; +} + comprehension_ty comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int is_async, PyArena *arena) @@ -4528,6 +4567,21 @@ ast2obj_expr(astmodulestate *state, void* _o) goto failed; Py_DECREF(value); break; + case MatchAs_kind: + tp = (PyTypeObject *)state->MatchAs_type; + result = PyType_GenericNew(tp, NULL, NULL); + if (!result) goto failed; + value = ast2obj_expr(state, o->v.MatchAs.pattern); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->pattern, value) == -1) + goto failed; + Py_DECREF(value); + value = ast2obj_identifier(state, o->v.MatchAs.name); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->name, value) == -1) + goto failed; + Py_DECREF(value); + break; } value = ast2obj_int(state, o->lineno); if (!value) goto failed; @@ -8751,6 +8805,46 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena) if (*out == NULL) goto failed; return 0; } + tp = state->MatchAs_type; + isinstance = PyObject_IsInstance(obj, tp); + if (isinstance == -1) { + return 1; + } + if (isinstance) { + expr_ty pattern; + identifier name; + + if (_PyObject_LookupAttr(obj, state->pattern, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from MatchAs"); + return 1; + } + else { + int res; + res = obj2ast_expr(state, tmp, &pattern, arena); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from MatchAs"); + return 1; + } + else { + int res; + res = obj2ast_identifier(state, tmp, &name, arena); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + *out = MatchAs(pattern, name, lineno, col_offset, end_lineno, + end_col_offset, arena); + if (*out == NULL) goto failed; + return 0; + } PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj); failed: @@ -10209,6 +10303,10 @@ astmodule_exec(PyObject *m) return -1; } Py_INCREF(state->Slice_type); + if (PyModule_AddObject(m, "MatchAs", state->MatchAs_type) < 0) { + return -1; + } + Py_INCREF(state->MatchAs_type); if (PyModule_AddObject(m, "expr_context", state->expr_context_type) < 0) { return -1; } diff --git a/Python/ast.c b/Python/ast.c index 6a0e21c3a8efa6..419eaf5a29ca34 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -309,6 +309,10 @@ validate_expr(expr_ty exp, expr_context_ty ctx) return validate_exprs(exp->v.Tuple.elts, ctx, 0); case NamedExpr_kind: return validate_expr(exp->v.NamedExpr.value, Load); + case MatchAs_kind: + PyErr_SetString( + PyExc_ValueError, "MatchAs can only be used in match_case patterns"); + return 0; /* This last case doesn't have any checking. */ case Name_kind: return 1; @@ -426,9 +430,9 @@ validate_pattern(expr_ty p) return 0; } return validate_expr(p, p->v.Name.ctx); // TODO - case NamedExpr_kind: - return (validate_pattern(p->v.NamedExpr.value) - && validate_expr(p->v.NamedExpr.target, Store)); // TODO + case MatchAs_kind: + return validate_pattern(p->v.MatchAs.pattern) + && validate_name(p->v.MatchAs.name); case UnaryOp_kind: // TODO return 1; diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 025e168a01283b..9e451b57491017 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -789,8 +789,8 @@ astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) // Not actually valid, but it's the compiler's job to complain: case JoinedStr_kind: case List_kind: + case MatchAs_kind: case Name_kind: - case NamedExpr_kind: case Tuple_kind: return 1; case UnaryOp_kind: diff --git a/Python/compile.c b/Python/compile.c index de59011f8a08fb..2884aa5138d15e 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5130,6 +5130,9 @@ compiler_visit_expr1(struct compiler *c, expr_ty e) return compiler_list(c, e); case Tuple_kind: return compiler_tuple(c, e); + case MatchAs_kind: + // Can only occur in patterns, which are handled elsewhere. + Py_UNREACHABLE(); } return 1; } @@ -5494,11 +5497,9 @@ pattern_load_constant(struct compiler *c, expr_ty p, pattern_context *pc) static int -pattern_store_name(struct compiler *c, expr_ty p, pattern_context *pc) +pattern_store_name(struct compiler *c, identifier n, pattern_context *pc) { - assert(p->kind == Name_kind); - assert(p->v.Name.ctx == Store); - if (WILDCARD_CHECK(p)) { + if (_PyUnicode_EqualToASCIIString(n, "_")) { const char *e = "can't assign to '_' here; consider removing or " "renaming?"; return compiler_error(c, e); @@ -5507,17 +5508,17 @@ pattern_store_name(struct compiler *c, expr_ty p, pattern_context *pc) CHECK(pc->stores = PySet_New(NULL)); } else { - int duplicate = PySet_Contains(pc->stores, p->v.Name.id); + int duplicate = PySet_Contains(pc->stores, n); if (duplicate < 0) { return 0; } if (duplicate) { const char *e = "multiple assignments to name %R in pattern"; - return compiler_error(c, e, p->v.Name.id); + return compiler_error(c, e, n); } } - CHECK(!PySet_Add(pc->stores, p->v.Name.id)); - CHECK(compiler_nameop(c, p->v.Name.id, Store)); + CHECK(!PySet_Add(pc->stores, n)); + CHECK(compiler_nameop(c, n, Store)); return 1; } @@ -5722,7 +5723,7 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) } ADDOP(c, POP_TOP); if (star) { - CHECK(pattern_store_name(c, asdl_seq_GET(values, size - 1), pc)); + CHECK(pattern_store_name(c, asdl_seq_GET(values, size - 1)->v.Name.id, pc)); } else { ADDOP(c, POP_TOP); @@ -5829,7 +5830,7 @@ compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) assert(p->v.Name.ctx == Store); if (!WILDCARD_CHECK(p)) { ADDOP(c, DUP_TOP); - CHECK(pattern_store_name(c, p, pc)); + CHECK(pattern_store_name(c, p->v.Name.id, pc)); } ADDOP_LOAD_CONST(c, Py_True); return 1; @@ -5837,16 +5838,16 @@ compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) static int -compiler_pattern_namedexpr(struct compiler *c, expr_ty p, pattern_context *pc) +compiler_pattern_as(struct compiler *c, expr_ty p, pattern_context *pc) { - assert(p->kind == NamedExpr_kind); + assert(p->kind == MatchAs_kind); basicblock *end; CHECK(end = compiler_new_block(c)); - CHECK(compiler_pattern(c, p->v.NamedExpr.value, pc)); + CHECK(compiler_pattern(c, p->v.MatchAs.pattern, pc)); ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); NEXT_BLOCK(c); ADDOP(c, DUP_TOP); - CHECK(pattern_store_name(c, p->v.NamedExpr.target, pc)); + CHECK(pattern_store_name(c, p->v.MatchAs.name, pc)); ADDOP_LOAD_CONST(c, Py_True); compiler_use_next_block(c, end); return 1; @@ -5877,10 +5878,10 @@ compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc) case List_kind: case Tuple_kind: return compiler_pattern_list_tuple(c, p, pc); + case MatchAs_kind: + return compiler_pattern_as(c, p, pc); case Name_kind: return compiler_pattern_name(c, p, pc); - case NamedExpr_kind: - return compiler_pattern_namedexpr(c, p, pc); default: Py_UNREACHABLE(); } diff --git a/Python/symtable.c b/Python/symtable.c index 9f4e2c06cd985d..6f208d3ca7169e 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1669,6 +1669,10 @@ symtable_visit_expr(struct symtable *st, expr_ty e) case Tuple_kind: VISIT_SEQ(st, expr, e->v.Tuple.elts); break; + case MatchAs_kind: + VISIT(st, expr, e->v.MatchAs.pattern); + symtable_add_def(st, e->v.MatchAs.name, DEF_LOCAL); + break; } VISIT_QUIT(st, 1); } From 462796eec213f33ea3adf74464e272728f51f4e2 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 19 Oct 2020 15:27:06 -0700 Subject: [PATCH 165/189] Add version check --- Grammar/python.gram | 2 +- Parser/parser.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 43c8749845194e..a470fb4a1b540b 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -203,7 +203,7 @@ match_expr[expr_ty]: match_stmt[stmt_ty]: | "match" subject=match_expr ':' NEWLINE INDENT cases[asdl_match_case_seq*]=case_block+ DEDENT { - _Py_Match(subject, cases, EXTRA) } + CHECK_VERSION(10, "Pattern matching is", _Py_Match(subject, cases, EXTRA)) } case_block[match_case_ty]: | "case" pattern=patterns guard=guard? ':' body=block { _Py_match_case(pattern, guard, body, p->arena) } diff --git a/Parser/parser.c b/Parser/parser.c index 592420876f2151..2b7ca3dcd99389 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -4943,7 +4943,7 @@ match_stmt_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Match ( subject , cases , EXTRA ); + _res = CHECK_VERSION ( 10 , "Pattern matching is" , _Py_Match ( subject , cases , EXTRA ) ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); From ebd95c62ac1929084210009ce485f6b0e4e526fe Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 19 Oct 2020 17:03:22 -0700 Subject: [PATCH 166/189] Raise for unreachable patterns --- Lib/test/test_patma.py | 88 +++++++++++++++++++++++++++++++++++++++--- Python/compile.c | 47 +++++++++++++++------- 2 files changed, 114 insertions(+), 21 deletions(-) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 7a9e36911214cd..bae1df45e7313e 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2448,17 +2448,13 @@ def test_patma_242(self): @no_perf def test_patma_243(self): - namespace = {} - code = """ + self.assert_syntax_error(""" match 42: case x: pass case y: pass - """ - with self.assertWarns(SyntaxWarning): - exec(inspect.cleandoc(code), None, namespace) - self.assertEqual(namespace, {"x": 42}) + """) @no_perf def test_patma_244(self): @@ -2701,6 +2697,86 @@ def test_patma_265(self): self.assertEqual(y, 0) self.assertEqual(z, (2, 3)) + @no_perf + def test_patma_266(self): + self.assert_syntax_error(""" + match ...: + case _ | _: + pass + """) + + @no_perf + def test_patma_267(self): + self.assert_syntax_error(""" + match ...: + case (_ as x) | [x]: + pass + """) + + + @no_perf + def test_patma_268(self): + self.assert_syntax_error(""" + match ...: + case _ | _ if condition(): + pass + """) + + + @no_perf + def test_patma_269(self): + self.assert_syntax_error(""" + match ...: + case x | [_ as x] if x: + pass + """) + + @no_perf + def test_patma_270(self): + self.assert_syntax_error(""" + match ...: + case _: + pass + case None: + pass + """) + + @no_perf + def test_patma_271(self): + self.assert_syntax_error(""" + match ...: + case x: + pass + case [x] if x: + pass + """) + + @no_perf + def test_patma_272(self): + self.assert_syntax_error(""" + match ...: + case x: + pass + case _: + pass + """) + + @no_perf + def test_patma_273(self): + self.assert_syntax_error(""" + match ...: + case (None | _) | _: + pass + """) + + @no_perf + def test_patma_274(self): + self.assert_syntax_error(""" + match ...: + case _ | (True | False): + pass + """) + # TODO: Better use of assertIs # TODO: Don't check side-effecty assignments diff --git a/Python/compile.c b/Python/compile.c index 2884aa5138d15e..ebde815491a6a8 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -203,6 +203,7 @@ struct compiler { typedef struct { PyObject *stores; + int irrefutable; } pattern_context; static int compiler_enter_scope(struct compiler *, identifier, int, void *, int); @@ -250,6 +251,7 @@ static int compiler_async_comprehension_generator( int depth, expr_ty elt, expr_ty val, int type); +static int compiler_subpattern(struct compiler *, expr_ty, pattern_context *); static int compiler_pattern(struct compiler *, expr_ty, pattern_context *); static int compiler_match(struct compiler *, stmt_ty); @@ -5451,11 +5453,6 @@ compiler_slice(struct compiler *c, expr_ty s) // pushing, popping, and jumping in the peephole optimizer than to detect or // predict it here. -// Other than that, go nuts. The PEP intentionally gives us broad freedom to -// take (reasonable) shortcuts - the AST optimization pass in particular is full -// of low-hanging fruit. Please *always* document these with a comment of the -// form "OPTIM: ...", so we can track exactly when and where they're happening. - #define WILDCARD_CHECK(N) \ ((N)->kind == Name_kind && \ @@ -5547,12 +5544,17 @@ compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context *pc) Py_ssize_t size = asdl_seq_LEN(p->v.BoolOp.values); assert(size > 1); PyObject *stores_init = pc->stores; + assert(!pc->irrefutable); expr_ty alt; for (Py_ssize_t i = 0; i < size; i++) { // Can't use our helpful returning macros here (they'll leak sets): alt = asdl_seq_GET(p->v.BoolOp.values, i); pc->stores = PySet_New(stores_init); SET_LOC(c, alt); + if (pc->irrefutable) { + compiler_error(c, "pattern follows an irrefutable alternative"); + goto fail; + } if (!pc->stores || !compiler_pattern(c, alt, pc) || !compiler_addop_j(c, JUMP_IF_TRUE_OR_POP, end) || @@ -5635,7 +5637,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { continue; } ADDOP_I(c, GET_INDEX, i); - CHECK(compiler_pattern(c, arg, pc)); + CHECK(compiler_subpattern(c, arg, pc)); ADDOP(c, ROT_TWO); ADDOP(c, POP_TOP); ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); @@ -5715,7 +5717,7 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) continue; } ADDOP_I(c, GET_INDEX, i); - CHECK(compiler_pattern(c, value, pc)); + CHECK(compiler_subpattern(c, value, pc)); ADDOP(c, ROT_TWO); ADDOP(c, POP_TOP); ADDOP_JUMP(c, POP_JUMP_IF_FALSE, block); @@ -5803,7 +5805,7 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) else { ADDOP_I(c, GET_INDEX_END, size - 1 - i); } - CHECK(compiler_pattern(c, value, pc)); + CHECK(compiler_subpattern(c, value, pc)); ADDOP_JUMP(c, POP_JUMP_IF_FALSE, subblock); NEXT_BLOCK(c); ADDOP(c, POP_TOP); @@ -5828,6 +5830,7 @@ compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); + pc->irrefutable = 1; if (!WILDCARD_CHECK(p)) { ADDOP(c, DUP_TOP); CHECK(pattern_store_name(c, p->v.Name.id, pc)); @@ -5854,6 +5857,16 @@ compiler_pattern_as(struct compiler *c, expr_ty p, pattern_context *pc) } +static int +compiler_subpattern(struct compiler *c, expr_ty p, pattern_context *pc) +{ + assert(!pc->irrefutable); + CHECK(compiler_pattern(c, p, pc)); + pc->irrefutable = 0; + return 1; +} + + static int compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc) { @@ -5897,27 +5910,26 @@ compiler_match(struct compiler *c, stmt_ty s) Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); assert(cases); pattern_context pc; + pc.irrefutable = 0; + pc.stores = NULL; int result; match_case_ty m = asdl_seq_GET(s->v.Match.cases, cases - 1); int has_default = WILDCARD_CHECK(m->pattern) && 1 < cases; for (Py_ssize_t i = 0; i < cases - has_default; i++) { m = asdl_seq_GET(s->v.Match.cases, i); SET_LOC(c, m->pattern); - if (!m->guard && m->pattern->kind == Name_kind && - m->pattern->v.Name.ctx == Store && i != cases - 1) - { - const char *w = "unguarded name capture pattern %R makes remaining " - "cases unreachable"; - CHECK(compiler_warn(c, w, m->pattern->v.Name.id)); + if (pc.irrefutable) { + const char *w = "case follows irrefutable match arm"; + CHECK(compiler_error(c, w, m->pattern->v.Name.id)); } CHECK(next = compiler_new_block(c)); - pc.stores = NULL; result = compiler_pattern(c, m->pattern, &pc); Py_CLEAR(pc.stores); CHECK(result); ADDOP_JUMP(c, POP_JUMP_IF_FALSE, next); NEXT_BLOCK(c); if (m->guard) { + pc.irrefutable = 0; CHECK(compiler_jump_if(c, m->guard, next, 0)); } ADDOP(c, POP_TOP); @@ -5930,6 +5942,11 @@ compiler_match(struct compiler *c, stmt_ty s) // A trailing "case _" is common, and lets us save a bit of redundant // pushing and popping in the loop above: m = asdl_seq_GET(s->v.Match.cases, cases - 1); + SET_LOC(c, m->pattern); + if (pc.irrefutable) { + const char *w = "case follows irrefutable match arm"; + CHECK(compiler_error(c, w, m->pattern->v.Name.id)); + } if (m->guard) { CHECK(compiler_jump_if(c, m->guard, end, 0)); } From de1b0208a31df1e30b9c27f443014c8a4dc95534 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Mon, 19 Oct 2020 17:31:49 -0700 Subject: [PATCH 167/189] Clean up error messages --- Python/compile.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index ebde815491a6a8..789405c11918a8 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5552,7 +5552,9 @@ compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context *pc) pc->stores = PySet_New(stores_init); SET_LOC(c, alt); if (pc->irrefutable) { - compiler_error(c, "pattern follows an irrefutable alternative"); + const char *e = "the previous pattern always matches, making this " + "one unreachable"; + compiler_error(c, e); goto fail; } if (!pc->stores || @@ -5919,8 +5921,9 @@ compiler_match(struct compiler *c, stmt_ty s) m = asdl_seq_GET(s->v.Match.cases, i); SET_LOC(c, m->pattern); if (pc.irrefutable) { - const char *w = "case follows irrefutable match arm"; - CHECK(compiler_error(c, w, m->pattern->v.Name.id)); + const char *e = "the previous case always matches, making this one " + "unreachable"; + CHECK(compiler_error(c, e)); } CHECK(next = compiler_new_block(c)); result = compiler_pattern(c, m->pattern, &pc); @@ -5944,8 +5947,9 @@ compiler_match(struct compiler *c, stmt_ty s) m = asdl_seq_GET(s->v.Match.cases, cases - 1); SET_LOC(c, m->pattern); if (pc.irrefutable) { - const char *w = "case follows irrefutable match arm"; - CHECK(compiler_error(c, w, m->pattern->v.Name.id)); + const char *e = "the previous case always matches, making this one " + "unreachable"; + CHECK(compiler_error(c, e)); } if (m->guard) { CHECK(compiler_jump_if(c, m->guard, end, 0)); From f5c248200e27330bdad5804c4a708f52c94622e0 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 20 Oct 2020 09:59:21 -0700 Subject: [PATCH 168/189] Minor cleanup --- Doc/library/dis.rst | 17 +++++++++++++++++ Lib/test/test_unparse.py | 2 +- Python/compile.c | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 91c0d5ebe124c5..8dfa1fe38b88de 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1241,6 +1241,14 @@ All of the following opcodes use their arguments. TODO + TOS is a tuple of keyword attribute names. + TOS1 is the "class" being called. + TOS2 is the subject. + *oparg* is the number of positional sub-patterns. + + On match, replaces TOS1 with a tuple extracted attributes, and TOS with True. + On no match, replaces TOS with False. + .. versionadded:: 3.10 @@ -1248,6 +1256,15 @@ All of the following opcodes use their arguments. TODO + TOS is a tuple of keys. + TOS1 is the match subject. + + On failure, replaces TOS with None and pushes False. + + On success, replaces TOS with a tuple of keys and pushes TRUE. If *oparg* is + non-zero, gather remaining items into a dict and put it on the stack where + the subject used to be. + .. versionadded:: 3.10 diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py index 4701f81562f498..532aa3a6390414 100644 --- a/Lib/test/test_unparse.py +++ b/Lib/test/test_unparse.py @@ -485,7 +485,7 @@ class DirectoryTestCase(ASTTestCase): test_directories = (lib_dir, lib_dir / "test") skip_files = {"test_fstring.py"} run_always_files = {"test_grammar.py", "test_syntax.py", "test_compile.py", - "test_ast.py", "test_asdl_parser.py", "test_patma.py"} # XXX + "test_ast.py", "test_asdl_parser.py"} _files_to_test = None diff --git a/Python/compile.c b/Python/compile.c index 789405c11918a8..f14b413130ec68 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5444,7 +5444,7 @@ compiler_slice(struct compiler *c, expr_ty s) } -// PEP 622: Structural Pattern Matching +// PEP 634: Structural Pattern Matching // To keep things simple, all compiler_pattern_* routines follow the convention // of preserving TOS (the subject for the given pattern) and pushing either True From 4de619a49dac871b5d60d4956927f2a1464b29e5 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 20 Oct 2020 22:50:48 -0700 Subject: [PATCH 169/189] Reorganize some sequence/mapping logic --- Include/internal/pycore_interp.h | 1 + Lib/importlib/_bootstrap_external.py | 4 +- Python/ceval.c | 101 ++++++++++++++++----------- Python/compile.c | 31 +++----- Python/importlib_external.h | 2 +- 5 files changed, 74 insertions(+), 65 deletions(-) diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h index 55745f110d3b4e..38713c4be8a2f4 100644 --- a/Include/internal/pycore_interp.h +++ b/Include/internal/pycore_interp.h @@ -193,6 +193,7 @@ struct _is { // Kept handy for pattern matching: PyObject *map_abc; // _collections_abc.Mapping PyObject *seq_abc; // _collections_abc.Sequence + Py_ssize_t get_len; // Cached length of subject /* Used in Modules/_threadmodule.c. */ long num_threads; diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 862149c7ad9f1b..588141213a1899 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -278,7 +278,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) # Python 3.10a1 3430 (Make 'annotations' future by default) -# Python 3.10a1 3467 (add structural pattern matching) +# Python 3.10a1 3470 (add structural pattern matching) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -288,7 +288,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3467).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3470).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Python/ceval.c b/Python/ceval.c index b9b6a196b456fd..0a34505bd78814 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -834,6 +834,34 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) // Need these for pattern matching: +static PyObject* +get_seq_abc() +{ + PyInterpreterState *interp = PyInterpreterState_Get(); + if (!interp->seq_abc) { + PyObject *abc = PyImport_ImportModule("_collections_abc"); + if (!abc) { + return NULL; + } + interp->seq_abc = PyObject_GetAttrString(abc, "Sequence"); + } + return interp->seq_abc; +} + +static PyObject* +get_map_abc() +{ + PyInterpreterState *interp = PyInterpreterState_Get(); + if (!interp->map_abc) { + PyObject *abc = PyImport_ImportModule("_collections_abc"); + if (!abc) { + return NULL; + } + interp->map_abc = PyObject_GetAttrString(abc, "Sequence"); + } + return interp->map_abc; +} + static PyObject* match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) { @@ -3537,6 +3565,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (l < 0) { goto error; } + PyInterpreterState *interp = PyInterpreterState_Get(); + interp->get_len = l; PyObject *len = PyLong_FromSsize_t(l); if (!len) { goto error; @@ -3563,19 +3593,17 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_MAPPING): { - PyInterpreterState *interp = PyInterpreterState_Get(); - if (!interp->map_abc) { - PyObject *abc = PyImport_ImportModule("_collections_abc"); - if (!abc) { - goto error; - } - interp->map_abc = PyObject_GetAttrString(abc, "Mapping"); - Py_DECREF(abc); - if (!interp->map_abc) { - goto error; - } + PyObject *subject = TOP(); + if (PyDict_Check(subject)) { + Py_INCREF(Py_True); + PUSH(Py_True); + DISPATCH(); } - int match = PyObject_IsInstance(TOP(), interp->map_abc); + PyObject *map_abc = get_map_abc(); + if (!map_abc) { + goto error; + } + int match = PyObject_IsInstance(subject, map_abc); if (match < 0) { goto error; } @@ -3586,7 +3614,16 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(MATCH_SEQUENCE): { PyObject *subject = TOP(); if (PyType_FastSubclass(Py_TYPE(subject), - Py_TPFLAGS_BYTES_SUBCLASS | Py_TPFLAGS_UNICODE_SUBCLASS) + Py_TPFLAGS_LIST_SUBCLASS | + Py_TPFLAGS_TUPLE_SUBCLASS)) + { + Py_INCREF(Py_True); + PUSH(Py_True); + DISPATCH(); + } + if (PyType_FastSubclass(Py_TYPE(subject), + Py_TPFLAGS_BYTES_SUBCLASS | + Py_TPFLAGS_UNICODE_SUBCLASS) || PyIter_Check(subject) || PyByteArray_Check(subject)) { @@ -3594,19 +3631,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) PUSH(Py_False); DISPATCH(); } - PyInterpreterState *interp = PyInterpreterState_Get(); - if (!interp->seq_abc) { - PyObject *abc = PyImport_ImportModule("_collections_abc"); - if (!abc) { - goto error; - } - interp->seq_abc = PyObject_GetAttrString(abc, "Sequence"); - Py_DECREF(abc); - if (!interp->seq_abc) { - goto error; - } + PyObject *seq_abc = get_seq_abc(); + if (!seq_abc) { + goto error; } - int match = PyObject_IsInstance(subject, interp->seq_abc); + int match = PyObject_IsInstance(subject, seq_abc); if (match < 0) { goto error; } @@ -3655,18 +3684,15 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(GET_INDEX_END): { - // PUSH(TOS[TOS1 - 1 - oparg]) + // PUSH(TOS[len(TOS) - 1 - oparg]) // NOTE: We can't rely on support for negative indexing! // Although PySequence_GetItem tries to correct negative indexes, we - // just use the length we already have at TOS1. In addition to + // just use the length we already cached from GET_LEN. In addition to // avoiding tons of redundant __len__ calls, this also handles // length changes during extraction more intuitively. - Py_ssize_t len = PyLong_AsSsize_t(SECOND()); - if (len < 0) { - goto error; - } - assert(len - 1 - oparg >= 0); - PyObject *item = PySequence_GetItem(TOP(), len - 1 - oparg); + PyInterpreterState *interp = PyInterpreterState_Get(); + assert(interp->get_len - 1 - oparg >= 0); + PyObject *item = PySequence_GetItem(TOP(), interp->get_len - 1 - oparg); if (!item) { goto error; } @@ -3675,15 +3701,12 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(GET_INDEX_SLICE): { - // PUSH(list(TOS[oparg & 0xFF: TOS1 - (oparg >> 8)])) + // PUSH(list(TOS[oparg & 0xFF: len(TOS) - (oparg >> 8)])) // NOTE: We can't rely on support for slicing or negative indexing! // Ditto GET_INDEX_END's length handling. - Py_ssize_t len = PyLong_AsSsize_t(SECOND()); - if (len < 0) { - goto error; - } + PyInterpreterState *interp = PyInterpreterState_Get(); Py_ssize_t start = oparg & 0xFF; - Py_ssize_t stop = len - (oparg >> 8); + Py_ssize_t stop = interp->get_len - (oparg >> 8); assert(start <= stop); PyObject *subject = TOP(); PyObject *items; diff --git a/Python/compile.c b/Python/compile.c index f14b413130ec68..292ea1cb643d0f 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5660,12 +5660,9 @@ compiler_pattern_constant(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP(c, DUP_TOP); CHECK(pattern_load_constant(c, p, pc)); PyObject *v = p->v.Constant.value; - if (v == Py_None || PyBool_Check(v)) { - ADDOP_COMPARE(c, Is); - } - else { - ADDOP_COMPARE(c, Eq); - } + // Literal True, False, and None are compared by identity. + // All others use equality. + ADDOP_COMPARE(c, v == Py_None || PyBool_Check(v) ? Is : Eq); return 1; } @@ -5761,7 +5758,7 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) } star = i; } - basicblock *block, *end, *subblock; + basicblock *end; CHECK(end = compiler_new_block(c)); ADDOP(c, MATCH_SEQUENCE); ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); @@ -5773,9 +5770,6 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) compiler_use_next_block(c, end); return 1; } - CHECK(subblock = compiler_new_block(c)); - CHECK(block = compiler_new_block(c)); - ADDOP(c, DUP_TOP); if (star < 0) { ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)); ADDOP_COMPARE(c, Eq); @@ -5784,9 +5778,8 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - 1)); ADDOP_COMPARE(c, GtE); } - ADDOP_JUMP(c, POP_JUMP_IF_FALSE, block); + ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); NEXT_BLOCK(c); - ADDOP(c, ROT_TWO); for (Py_ssize_t i = 0; i < size; i++) { // TODO: (i >= (1 << 8)) || (n-i-1 >= (INT_MAX >> 8)) expr_ty value = asdl_seq_GET(values, i); @@ -5808,20 +5801,12 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP_I(c, GET_INDEX_END, size - 1 - i); } CHECK(compiler_subpattern(c, value, pc)); - ADDOP_JUMP(c, POP_JUMP_IF_FALSE, subblock); - NEXT_BLOCK(c); + ADDOP(c, ROT_TWO); ADDOP(c, POP_TOP); + ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); + NEXT_BLOCK(c); } - ADDOP(c, ROT_TWO); - ADDOP(c, POP_TOP); ADDOP_LOAD_CONST(c, Py_True); - ADDOP_JUMP(c, JUMP_FORWARD, end); - compiler_use_next_block(c, subblock); - ADDOP(c, POP_TOP); - ADDOP(c, ROT_TWO); - compiler_use_next_block(c, block); - ADDOP(c, POP_TOP); - ADDOP_LOAD_CONST(c, Py_False); compiler_use_next_block(c, end); return 1; } diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 9259090d00450b..36e58673c584bd 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -285,7 +285,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,218,13,95,119,114,105,116,101,95,97,116,111,109,105,99, 120,0,0,0,115,28,0,0,0,0,5,16,1,6,1,22, 255,4,2,2,3,14,1,40,1,16,1,12,1,2,1,14, - 1,12,1,6,1,114,69,0,0,0,105,139,13,0,0,114, + 1,12,1,6,1,114,69,0,0,0,105,142,13,0,0,114, 28,0,0,0,114,17,0,0,0,115,2,0,0,0,13,10, 90,11,95,95,112,121,99,97,99,104,101,95,95,122,4,111, 112,116,45,122,3,46,112,121,122,4,46,112,121,99,78,41, From 9f1c91d1f05694e4e82657cd458841444f2da09b Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 20 Oct 2020 23:40:15 -0700 Subject: [PATCH 170/189] More ceval cleanup --- Python/ceval.c | 114 ++++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 58 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 0a34505bd78814..2bd7f30976b894 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -834,34 +834,6 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) // Need these for pattern matching: -static PyObject* -get_seq_abc() -{ - PyInterpreterState *interp = PyInterpreterState_Get(); - if (!interp->seq_abc) { - PyObject *abc = PyImport_ImportModule("_collections_abc"); - if (!abc) { - return NULL; - } - interp->seq_abc = PyObject_GetAttrString(abc, "Sequence"); - } - return interp->seq_abc; -} - -static PyObject* -get_map_abc() -{ - PyInterpreterState *interp = PyInterpreterState_Get(); - if (!interp->map_abc) { - PyObject *abc = PyImport_ImportModule("_collections_abc"); - if (!abc) { - return NULL; - } - interp->map_abc = PyObject_GetAttrString(abc, "Sequence"); - } - return interp->map_abc; -} - static PyObject* match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) { @@ -3565,6 +3537,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (l < 0) { goto error; } + // We might have one or more GET_INDEX_* instructions soon. Cache + // the length on the PyInterpreterState struct so they can reuse it: PyInterpreterState *interp = PyInterpreterState_Get(); interp->get_len = l; PyObject *len = PyLong_FromSsize_t(l); @@ -3594,16 +3568,26 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(MATCH_MAPPING): { PyObject *subject = TOP(); + // Fast path for dicts: if (PyDict_Check(subject)) { Py_INCREF(Py_True); PUSH(Py_True); DISPATCH(); } - PyObject *map_abc = get_map_abc(); - if (!map_abc) { - goto error; + // Lazily import _collections_abc.Mapping, and keep it handy on the + // PyInterpreterState struct (it gets cleaned up at exit): + PyInterpreterState *interp = PyInterpreterState_Get(); + if (!interp->map_abc) { + PyObject *abc = PyImport_ImportModule("_collections_abc"); + if (!abc) { + goto error; + } + interp->map_abc = PyObject_GetAttrString(abc, "Mapping"); + if (!interp->map_abc) { + goto error; + } } - int match = PyObject_IsInstance(subject, map_abc); + int match = PyObject_IsInstance(subject, interp->map_abc); if (match < 0) { goto error; } @@ -3613,6 +3597,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) case TARGET(MATCH_SEQUENCE): { PyObject *subject = TOP(); + // Fast path for lists and tuples: if (PyType_FastSubclass(Py_TYPE(subject), Py_TPFLAGS_LIST_SUBCLASS | Py_TPFLAGS_TUPLE_SUBCLASS)) @@ -3621,21 +3606,31 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) PUSH(Py_True); DISPATCH(); } + // Bail on some possible Sequences that we intentionally exclude: if (PyType_FastSubclass(Py_TYPE(subject), Py_TPFLAGS_BYTES_SUBCLASS | - Py_TPFLAGS_UNICODE_SUBCLASS) - || PyIter_Check(subject) - || PyByteArray_Check(subject)) + Py_TPFLAGS_UNICODE_SUBCLASS) || + PyIter_Check(subject) || + PyByteArray_Check(subject)) { Py_INCREF(Py_False); PUSH(Py_False); DISPATCH(); } - PyObject *seq_abc = get_seq_abc(); - if (!seq_abc) { - goto error; + // Lazily import _collections_abc.Sequence, and keep it handy on the + // PyInterpreterState struct (it gets cleaned up at exit): + PyInterpreterState *interp = PyInterpreterState_Get(); + if (!interp->seq_abc) { + PyObject *abc = PyImport_ImportModule("_collections_abc"); + if (!abc) { + goto error; + } + interp->seq_abc = PyObject_GetAttrString(abc, "Sequence"); + if (!interp->seq_abc) { + goto error; + } } - int match = PyObject_IsInstance(subject, seq_abc); + int match = PyObject_IsInstance(subject, interp->seq_abc); if (match < 0) { goto error; } @@ -3687,9 +3682,12 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) // PUSH(TOS[len(TOS) - 1 - oparg]) // NOTE: We can't rely on support for negative indexing! // Although PySequence_GetItem tries to correct negative indexes, we - // just use the length we already cached from GET_LEN. In addition to - // avoiding tons of redundant __len__ calls, this also handles - // length changes during extraction more intuitively. + // just use the length we already have cached from GET_LEN on the + // PyInterpreterState struct. In addition to avoiding tons of + // redundant __len__ calls, this also handles length changes during + // extraction more intuitively. It's also much faster and simpler + // than trying to rotate it around on the stack and pop it off when + // we're done. PyInterpreterState *interp = PyInterpreterState_Get(); assert(interp->get_len - 1 - oparg >= 0); PyObject *item = PySequence_GetItem(TOP(), interp->get_len - 1 - oparg); @@ -3708,31 +3706,31 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) Py_ssize_t start = oparg & 0xFF; Py_ssize_t stop = interp->get_len - (oparg >> 8); assert(start <= stop); + PyObject *slice = PyList_New(stop - start); + if (!slice) { + goto error; + } + PyObject **slice_items = PySequence_Fast_ITEMS(slice); PyObject *subject = TOP(); - PyObject *items; - if (PyList_CheckExact(subject)) { - items = PyList_GetSlice(subject, start, stop); - if (!items) { - goto error; + if (PyList_CheckExact(subject) || PyTuple_CheckExact(subject)) { + // Fast path for lists and tuples: no errors! + assert(stop <= PySequence_Fast_GET_SIZE(subject)); + PyObject **subject_items = PySequence_Fast_ITEMS(subject); + for (Py_ssize_t i = start; i < stop; i++) { + slice_items[i - start] = subject_items[i]; + Py_INCREF(subject_items[i]); } - assert(PyList_CheckExact(items)); } else { - items = PyList_New(stop - start); - if (!items) { - goto error; - } - PyObject *item; for (Py_ssize_t i = start; i < stop; i++) { - item = PySequence_GetItem(subject, i); - if (!item) { - Py_DECREF(items); + slice_items[i - start] = PySequence_GetItem(subject, i); + if (!slice_items[i - start]) { + Py_DECREF(slice); goto error; } - PyList_SET_ITEM(items, i - start, item); } } - PUSH(items); + PUSH(slice); DISPATCH(); } From 88bd791dd5eb8f79da1c38a556924dd51d3a7c06 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 21 Oct 2020 09:04:05 -0700 Subject: [PATCH 171/189] Don't mark _ as local in patterns --- Include/symtable.h | 1 + Python/symtable.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Include/symtable.h b/Include/symtable.h index abd19a7923e1ba..6f0b7cb8b1c6ac 100644 --- a/Include/symtable.h +++ b/Include/symtable.h @@ -33,6 +33,7 @@ struct symtable { the symbol table */ int recursion_depth; /* current recursion depth */ int recursion_limit; /* recursion limit */ + int in_pattern; /* whether we are currently in a pattern */ }; typedef struct _symtable_entry { diff --git a/Python/symtable.c b/Python/symtable.c index 6f208d3ca7169e..bccdb756581dab 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -240,6 +240,7 @@ symtable_new(void) goto fail; st->st_cur = NULL; st->st_private = NULL; + st->in_pattern = 0; return st; fail: PySymtable_Free(st); @@ -1650,6 +1651,13 @@ symtable_visit_expr(struct symtable *st, expr_ty e) VISIT(st, expr, e->v.Slice.step) break; case Name_kind: + // Don't make "_" a local when used in a pattern: + if (st->in_pattern && + e->v.Name.ctx == Store && + _PyUnicode_EqualToASCIIString(e->v.Name.id, "_")) + { + break; + } if (!symtable_add_def(st, e->v.Name.id, e->v.Name.ctx == Load ? USE : DEF_LOCAL)) VISIT_QUIT(st, 0); @@ -1671,6 +1679,7 @@ symtable_visit_expr(struct symtable *st, expr_ty e) break; case MatchAs_kind: VISIT(st, expr, e->v.MatchAs.pattern); + // "_" is not actually valid, but it's the compiler's job to complain: symtable_add_def(st, e->v.MatchAs.name, DEF_LOCAL); break; } @@ -1794,7 +1803,11 @@ symtable_visit_withitem(struct symtable *st, withitem_ty item) static int symtable_visit_match_case(struct symtable *st, match_case_ty m) { + assert(!st->in_pattern); + st->in_pattern = 1; VISIT(st, expr, m->pattern); + assert(st->in_pattern); + st->in_pattern = 0; if (m->guard) { VISIT(st, expr, m->guard); } From 12b65753145e38d9e4aa93ff8f5f11480b4153fe Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 21 Oct 2020 09:04:43 -0700 Subject: [PATCH 172/189] More cleanup --- Python/ceval.c | 47 ++++++++++++++++++++++++++--------------------- Python/compile.c | 5 ++++- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 2bd7f30976b894..10682d99ceef64 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3533,19 +3533,20 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(GET_LEN): { - Py_ssize_t l = PyObject_Length(TOP()); - if (l < 0) { + // PUSH(len(TOS)) + Py_ssize_t len_i = PyObject_Length(TOP()); + if (len_i < 0) { goto error; } // We might have one or more GET_INDEX_* instructions soon. Cache // the length on the PyInterpreterState struct so they can reuse it: PyInterpreterState *interp = PyInterpreterState_Get(); - interp->get_len = l; - PyObject *len = PyLong_FromSsize_t(l); - if (!len) { + interp->get_len = len_i; + PyObject *len_o = PyLong_FromSsize_t(len_i); + if (!len_o) { goto error; } - PUSH(len); + PUSH(len_o); DISPATCH(); } @@ -3567,6 +3568,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_MAPPING): { + // PUSH(isinstance(TOS, _collections_abc.Mapping)) PyObject *subject = TOP(); // Fast path for dicts: if (PyDict_Check(subject)) { @@ -3596,6 +3598,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_SEQUENCE): { + // PUSH(isinstance(TOS, _collections_abc.Sequence) + // and not isinstance(TOS, (bytearray, bytes, str)) + // and not hasattr(TOS, "__next__")) PyObject *subject = TOP(); // Fast path for lists and tuples: if (PyType_FastSubclass(Py_TYPE(subject), @@ -3618,7 +3623,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) DISPATCH(); } // Lazily import _collections_abc.Sequence, and keep it handy on the - // PyInterpreterState struct (it gets cleaned up at exit): + // PyInterpreterState struct (it gets cleaned up at exit): PyInterpreterState *interp = PyInterpreterState_Get(); if (!interp->seq_abc) { PyObject *abc = PyImport_ImportModule("_collections_abc"); @@ -3686,8 +3691,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) // PyInterpreterState struct. In addition to avoiding tons of // redundant __len__ calls, this also handles length changes during // extraction more intuitively. It's also much faster and simpler - // than trying to rotate it around on the stack and pop it off when - // we're done. + // than trying to rotate the length around on the stack and pop it + // off when we're done. PyInterpreterState *interp = PyInterpreterState_Get(); assert(interp->get_len - 1 - oparg >= 0); PyObject *item = PySequence_GetItem(TOP(), interp->get_len - 1 - oparg); @@ -3704,27 +3709,27 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) // Ditto GET_INDEX_END's length handling. PyInterpreterState *interp = PyInterpreterState_Get(); Py_ssize_t start = oparg & 0xFF; - Py_ssize_t stop = interp->get_len - (oparg >> 8); - assert(start <= stop); - PyObject *slice = PyList_New(stop - start); + Py_ssize_t size = interp->get_len - (oparg >> 8) - start; + assert(0 <= size); + PyObject *slice = PyList_New(size); if (!slice) { goto error; } PyObject **slice_items = PySequence_Fast_ITEMS(slice); PyObject *subject = TOP(); if (PyList_CheckExact(subject) || PyTuple_CheckExact(subject)) { - // Fast path for lists and tuples: no errors! - assert(stop <= PySequence_Fast_GET_SIZE(subject)); - PyObject **subject_items = PySequence_Fast_ITEMS(subject); - for (Py_ssize_t i = start; i < stop; i++) { - slice_items[i - start] = subject_items[i]; - Py_INCREF(subject_items[i]); + // Fast path for lists and tuples (no errors)! + assert(start + size <= PySequence_Fast_GET_SIZE(subject)); + memcpy(slice_items, &PySequence_Fast_ITEMS(subject)[start], + size * sizeof(PyObject*)); + for (Py_ssize_t i = 0; i < size; i++) { + Py_INCREF(slice_items[i]); } } else { - for (Py_ssize_t i = start; i < stop; i++) { - slice_items[i - start] = PySequence_GetItem(subject, i); - if (!slice_items[i - start]) { + for (Py_ssize_t i = 0; i < size; i++) { + slice_items[i] = PySequence_GetItem(subject, start + i); + if (!slice_items[i]) { Py_DECREF(slice); goto error; } diff --git a/Python/compile.c b/Python/compile.c index 292ea1cb643d0f..dc25b08c54d69b 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5662,7 +5662,7 @@ compiler_pattern_constant(struct compiler *c, expr_ty p, pattern_context *pc) PyObject *v = p->v.Constant.value; // Literal True, False, and None are compared by identity. // All others use equality. - ADDOP_COMPARE(c, v == Py_None || PyBool_Check(v) ? Is : Eq); + ADDOP_COMPARE(c, (v == Py_None || PyBool_Check(v)) ? Is : Eq); return 1; } @@ -5946,6 +5946,9 @@ compiler_match(struct compiler *c, stmt_ty s) } +#undef WILDCARD_CHECK + + /* End of the compiler section, beginning of the assembler section */ /* do depth-first search of basic block graph, starting with block. From d394aa489f26d3f063f4b10f3e8c258a2ee6231e Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 21 Oct 2020 09:37:18 -0700 Subject: [PATCH 173/189] Add some tests for non-dict Mappings --- Lib/test/test_patma.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index bae1df45e7313e..6727a2f7113226 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2777,6 +2777,23 @@ def test_patma_274(self): pass """) + def test_patma_275(self): + x = collections.UserDict({0: 1, 2: 3}) + match x: + case {2: 3}: + y = 0 + self.assertEqual(x, {0: 1, 2: 3}) + self.assertEqual(y, 0) + + def test_patma_276(self): + x = collections.UserDict({0: 1, 2: 3}) + match x: + case {2: 3, **z}: + y = 0 + self.assertEqual(x, {0: 1, 2: 3}) + self.assertEqual(y, 0) + self.assertEqual(z, {0: 1}) + # TODO: Better use of assertIs # TODO: Don't check side-effecty assignments From 2028445b02eb227629f7dabf9fa4717537ab45aa Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 21 Oct 2020 11:38:59 -0700 Subject: [PATCH 174/189] Remove half-finished PyAST_Validate implementation --- Python/ast.c | 122 ++------------------------------------------------- 1 file changed, 4 insertions(+), 118 deletions(-) diff --git a/Python/ast.c b/Python/ast.c index 419eaf5a29ca34..f52f1dfc424dbd 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -310,8 +310,8 @@ validate_expr(expr_ty exp, expr_context_ty ctx) case NamedExpr_kind: return validate_expr(exp->v.NamedExpr.value, Load); case MatchAs_kind: - PyErr_SetString( - PyExc_ValueError, "MatchAs can only be used in match_case patterns"); + PyErr_SetString(PyExc_ValueError, + "MatchAs is only valid in match_case patterns"); return 0; /* This last case doesn't have any checking. */ case Name_kind: @@ -324,122 +324,8 @@ validate_expr(expr_ty exp, expr_context_ty ctx) static int validate_pattern(expr_ty p) { - asdl_expr_seq *keys, *values; - expr_ty key, value; - Py_ssize_t i, size; - switch (p->kind) { - case Attribute_kind: - return validate_expr(p, Load); // TODO - case BinOp_kind: - // TODO - return 1; - case BoolOp_kind: - if (p->v.BoolOp.op != Or) { - PyErr_SetString(PyExc_ValueError, - "BoolOp op in pattern must be Or"); - return 0; - } - values = p->v.BoolOp.values; - size = asdl_seq_LEN(values); - if (size < 2) { - PyErr_SetString(PyExc_ValueError, - "BoolOp must have at least two values"); - return 0; - } - for (i = 0; i < size; i++) { - if (!validate_pattern(asdl_seq_GET(values, i))) { - return 0; - } - } - return 1; - case Call_kind: - // TODO - return 1; - case Constant_kind: - return validate_expr(p, Load); // TODO - case Dict_kind: - keys = p->v.Dict.keys; - values = p->v.Dict.values; - size = asdl_seq_LEN(values); - if (asdl_seq_LEN(keys) != size) { - PyErr_SetString(PyExc_ValueError, - "Dict keys and values must be equal-length"); - return 0; - } - for (i = 0; i < size; i++) { - key = asdl_seq_GET(keys, i); - if (key) { - // TODO: Attribute is valid here, not Name! - // if (key->kind == Name_kind) { - // if (key->v.Name.ctx != Load) { - // PyErr_SetString(PyExc_ValueError, - // "Name ctx in Dict keys pattern must be Load"); - // return 0; - // } - // } - // else if (key->kind != Constant_kind) { - // PyErr_SetString(PyExc_ValueError, - // "Dict keys pattern must be Constant or Name"); - // return 0; - // } - return validate_expr(key, Load); - } - else { - if (i != size - 1) { - // TODO - } - // if (key->kind != Name_kind) { - // // TODO - // } - // if (key->v.Name.ctx != Store) { - // // TODO - // } - } - if (!validate_pattern(asdl_seq_GET(values, i))) { - return 0; - } - } - return 1; - case JoinedStr_kind: - // Not actually valid, but it's the compiler's job to complain: - return 1; - case List_kind: - case Tuple_kind: - values = p->kind == List_kind ? p->v.List.elts : p->v.Tuple.elts; - size = asdl_seq_LEN(values); - for (i = 0; i < size; i++) { - value = asdl_seq_GET(values, i); - if (value->kind == Starred_kind) { - value = value->v.Starred.value; - if (value->kind != Name_kind) { - // TODO - } - if (value->v.Name.ctx != Store) { - // TODO - } - } - if (!validate_pattern(value)) { - return 0; - } - } - return 1; - case Name_kind: - if (p->v.Name.ctx != Load && p->v.Name.ctx != Store) { - PyErr_SetString(PyExc_ValueError, - "Name ctx in pattern must be Load or Store"); - return 0; - } - return validate_expr(p, p->v.Name.ctx); // TODO - case MatchAs_kind: - return validate_pattern(p->v.MatchAs.pattern) - && validate_name(p->v.MatchAs.name); - case UnaryOp_kind: - // TODO - return 1; - default: - PyErr_SetString(PyExc_ValueError, "invalid Match pattern"); - return 0; - } + // Coming soon (thanks Batuhan)! + return 1; } static int From 20b59b214f1790603ad72bd09dc1f3510684e0d1 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 21 Oct 2020 12:55:23 -0700 Subject: [PATCH 175/189] Remove some questionable fast paths --- Python/ceval.c | 80 +++++++++++++++++++------------------------------- 1 file changed, 31 insertions(+), 49 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 10682d99ceef64..5710c56b538d54 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -842,20 +842,16 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) if (!nkeys) { return PyTuple_New(0); } - PyObject *get = NULL; - PyObject *dummy = NULL; PyObject *seen = NULL; PyObject *values = NULL; - if (!PyDict_CheckExact(map)) { - _Py_IDENTIFIER(get); - get = _PyObject_GetAttrId(map, &PyId_get); - if (!get) { - return NULL; - } - dummy = _PyObject_CallNoArg((PyObject *)&PyBaseObject_Type); - if (!dummy) { - goto fail; - } + _Py_IDENTIFIER(get); + PyObject *get = _PyObject_GetAttrId(map, &PyId_get); + if (!get) { + return NULL; + } + PyObject *dummy = _PyObject_CallNoArg((PyObject *)&PyBaseObject_Type); + if (!dummy) { + goto fail; } seen = PySet_New(NULL); if (!seen) { @@ -875,30 +871,19 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) } goto fail; } - if (!get) { - assert(PyDict_CheckExact(map)); - value = PyDict_GetItemWithError(map, key); - if (!value) { - goto fail; - } - Py_INCREF(value); - } - else { - assert(dummy); - value = PyObject_CallFunctionObjArgs(get, key, dummy, NULL); - if (!value || value == dummy) { - Py_XDECREF(value); - goto fail; - } + value = PyObject_CallFunctionObjArgs(get, key, dummy, NULL); + if (!value || value == dummy) { + Py_XDECREF(value); + goto fail; } PyTuple_SET_ITEM(values, i, value); } - Py_XDECREF(get); - Py_XDECREF(dummy); + Py_DECREF(get); + Py_DECREF(dummy); Py_DECREF(seen); return values; fail: - Py_XDECREF(get); + Py_DECREF(get); Py_XDECREF(dummy); Py_XDECREF(seen); Py_XDECREF(values); @@ -3538,8 +3523,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (len_i < 0) { goto error; } - // We might have one or more GET_INDEX_* instructions soon. Cache - // the length on the PyInterpreterState struct so they can reuse it: + // We might have one or more GET_INDEX_* instructions coming up. + // Cache the length on the PyInterpreterState struct so they can + // reuse it: PyInterpreterState *interp = PyInterpreterState_Get(); interp->get_len = len_i; PyObject *len_o = PyLong_FromSsize_t(len_i); @@ -3551,6 +3537,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_CLASS): { + // TODO PyObject *names = TOP(); PyObject *type = SECOND(); PyObject *subject = THIRD(); @@ -3644,6 +3631,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(MATCH_KEYS): { + // TODO PyObject *keys = TOP(); PyObject *subject = SECOND(); PyObject *values = match_map_items(tstate, subject, keys); @@ -3715,25 +3703,19 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (!slice) { goto error; } - PyObject **slice_items = PySequence_Fast_ITEMS(slice); PyObject *subject = TOP(); - if (PyList_CheckExact(subject) || PyTuple_CheckExact(subject)) { - // Fast path for lists and tuples (no errors)! - assert(start + size <= PySequence_Fast_GET_SIZE(subject)); - memcpy(slice_items, &PySequence_Fast_ITEMS(subject)[start], - size * sizeof(PyObject*)); - for (Py_ssize_t i = 0; i < size; i++) { - Py_INCREF(slice_items[i]); - } - } - else { - for (Py_ssize_t i = 0; i < size; i++) { - slice_items[i] = PySequence_GetItem(subject, start + i); - if (!slice_items[i]) { - Py_DECREF(slice); - goto error; - } + // NOTE: Fast path for lists and tuples showed no perf improvement, + // likely because test_patma's star-unpacking examples are too small + // to make a difference. It will be interesting to see if real-world + // code commonly uses star-unpacking in patterns with big list/tuple + // subjects. A fast path could pay off, if so. + for (Py_ssize_t i = 0; i < size; i++) { + PyObject *item = PySequence_GetItem(subject, start + i); + if (!item) { + Py_DECREF(slice); + goto error; } + PyList_SET_ITEM(slice, i, item); } PUSH(slice); DISPATCH(); From b42a3ac222efe36b9d2f721949d9c462b95d5c3e Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 21 Oct 2020 12:55:33 -0700 Subject: [PATCH 176/189] Add test_patma to PGO --- Lib/test/libregrtest/pgo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/libregrtest/pgo.py b/Lib/test/libregrtest/pgo.py index 379ff05fb955a5..582e812e284cc9 100644 --- a/Lib/test/libregrtest/pgo.py +++ b/Lib/test/libregrtest/pgo.py @@ -35,6 +35,7 @@ 'test_memoryview', 'test_operator', 'test_ordered_dict', + 'test_patma', 'test_pickle', 'test_pprint', 'test_re', From ccb5d907c25f5fa425f276d443a032c5b82b59bc Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 21 Oct 2020 17:27:18 -0700 Subject: [PATCH 177/189] Clean up SyntaxErroring --- Python/compile.c | 59 +++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index dc25b08c54d69b..9d638fe2a82c8e 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -203,7 +203,7 @@ struct compiler { typedef struct { PyObject *stores; - int irrefutable; + int allow_irrefutable; } pattern_context; static int compiler_enter_scope(struct compiler *, identifier, int, void *, int); @@ -5481,13 +5481,13 @@ static int pattern_load_constant(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Constant_kind); - assert(PyBool_Check(p->v.Constant.value) || + assert(p->v.Constant.value == Py_None || + PyBool_Check(p->v.Constant.value) || PyBytes_CheckExact(p->v.Constant.value) || PyComplex_CheckExact(p->v.Constant.value) || PyFloat_CheckExact(p->v.Constant.value) || PyLong_CheckExact(p->v.Constant.value) || - PyUnicode_CheckExact(p->v.Constant.value) || - p->v.Constant.value == Py_None); + PyUnicode_CheckExact(p->v.Constant.value)); ADDOP_LOAD_CONST(c, p->v.Constant.value); return 1; } @@ -5497,8 +5497,8 @@ static int pattern_store_name(struct compiler *c, identifier n, pattern_context *pc) { if (_PyUnicode_EqualToASCIIString(n, "_")) { - const char *e = "can't assign to '_' here; consider removing or " - "renaming?"; + const char *e = "can't assign to '_' here " + "(consider removing or renaming)"; return compiler_error(c, e); } if (!pc->stores) { @@ -5544,19 +5544,15 @@ compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context *pc) Py_ssize_t size = asdl_seq_LEN(p->v.BoolOp.values); assert(size > 1); PyObject *stores_init = pc->stores; - assert(!pc->irrefutable); + int allow_irrefutable = pc->allow_irrefutable; expr_ty alt; for (Py_ssize_t i = 0; i < size; i++) { - // Can't use our helpful returning macros here (they'll leak sets): + // Can't use our helpful returning macros here: they'll leak sets! alt = asdl_seq_GET(p->v.BoolOp.values, i); pc->stores = PySet_New(stores_init); + // An irrefutable sub-pattern must be last, if it is allowed at all: + pc->allow_irrefutable = allow_irrefutable && (i == size - 1); SET_LOC(c, alt); - if (pc->irrefutable) { - const char *e = "the previous pattern always matches, making this " - "one unreachable"; - compiler_error(c, e); - goto fail; - } if (!pc->stores || !compiler_pattern(c, alt, pc) || !compiler_addop_j(c, JUMP_IF_TRUE_OR_POP, end) || @@ -5584,6 +5580,7 @@ compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context *pc) } Py_XDECREF(stores_init); pc->stores = control; + pc->allow_irrefutable = allow_irrefutable; ADDOP_LOAD_CONST(c, Py_False); compiler_use_next_block(c, end); return 1; @@ -5601,7 +5598,8 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { Py_ssize_t nargs = asdl_seq_LEN(args); Py_ssize_t nkwargs = asdl_seq_LEN(kwargs); if (nargs + nkwargs > INT_MAX) { - return compiler_error(c, "too many sub-patterns in class pattern"); + const char *e = "too many sub-patterns in class pattern %R"; + return compiler_error(c, e, p->v.Call.func); } basicblock *block, *end; CHECK(!validate_keywords(c, kwargs)); @@ -5694,8 +5692,8 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) for (i = 0; i < size - star; i++) { expr_ty key = asdl_seq_GET(keys, i); if (!key) { - const char *e = "can't use starred pattern here; consider " - "moving to end?"; + const char *e = "can't use starred name here " + "(consider moving to end)"; return compiler_error(c, e); } if (key->kind == Attribute_kind) { @@ -5754,7 +5752,8 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) continue; } if (star >= 0) { - return compiler_error(c, "multiple starred names in pattern"); + const char *e = "multiple starred names in sequence pattern"; + return compiler_error(c, e); } star = i; } @@ -5817,7 +5816,10 @@ compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); - pc->irrefutable = 1; + if (!pc->allow_irrefutable) { + const char *e = "name capture %R makes remaining patterns unreachable"; + return compiler_error(c, e, p->v.Name.id); + } if (!WILDCARD_CHECK(p)) { ADDOP(c, DUP_TOP); CHECK(pattern_store_name(c, p->v.Name.id, pc)); @@ -5847,9 +5849,10 @@ compiler_pattern_as(struct compiler *c, expr_ty p, pattern_context *pc) static int compiler_subpattern(struct compiler *c, expr_ty p, pattern_context *pc) { - assert(!pc->irrefutable); + int allow_irrefutable = pc->allow_irrefutable; + pc->allow_irrefutable = 1; CHECK(compiler_pattern(c, p, pc)); - pc->irrefutable = 0; + pc->allow_irrefutable = allow_irrefutable; return 1; } @@ -5897,7 +5900,6 @@ compiler_match(struct compiler *c, stmt_ty s) Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); assert(cases); pattern_context pc; - pc.irrefutable = 0; pc.stores = NULL; int result; match_case_ty m = asdl_seq_GET(s->v.Match.cases, cases - 1); @@ -5905,19 +5907,15 @@ compiler_match(struct compiler *c, stmt_ty s) for (Py_ssize_t i = 0; i < cases - has_default; i++) { m = asdl_seq_GET(s->v.Match.cases, i); SET_LOC(c, m->pattern); - if (pc.irrefutable) { - const char *e = "the previous case always matches, making this one " - "unreachable"; - CHECK(compiler_error(c, e)); - } CHECK(next = compiler_new_block(c)); + // An irrefutable case must be either guarded, last, or both: + pc.allow_irrefutable = !!m->guard || (i == cases - 1); result = compiler_pattern(c, m->pattern, &pc); Py_CLEAR(pc.stores); CHECK(result); ADDOP_JUMP(c, POP_JUMP_IF_FALSE, next); NEXT_BLOCK(c); if (m->guard) { - pc.irrefutable = 0; CHECK(compiler_jump_if(c, m->guard, next, 0)); } ADDOP(c, POP_TOP); @@ -5931,11 +5929,6 @@ compiler_match(struct compiler *c, stmt_ty s) // pushing and popping in the loop above: m = asdl_seq_GET(s->v.Match.cases, cases - 1); SET_LOC(c, m->pattern); - if (pc.irrefutable) { - const char *e = "the previous case always matches, making this one " - "unreachable"; - CHECK(compiler_error(c, e)); - } if (m->guard) { CHECK(compiler_jump_if(c, m->guard, end, 0)); } From 7a97a1f19217394b46ecc9d7a64011abaf5415bc Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 21 Oct 2020 18:03:11 -0700 Subject: [PATCH 178/189] Unsafe caching strikes again --- Lib/importlib/_bootstrap_external.py | 4 ++-- Python/ceval.c | 29 ++++++++++++++-------------- Python/compile.c | 25 ++++++++++++++++++------ Python/importlib_external.h | 2 +- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 588141213a1899..2afa5b258eb973 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -278,7 +278,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) # Python 3.10a1 3430 (Make 'annotations' future by default) -# Python 3.10a1 3470 (add structural pattern matching) +# Python 3.10a1 3471 (add structural pattern matching) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -288,7 +288,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3470).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3471).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Python/ceval.c b/Python/ceval.c index 5710c56b538d54..3f3d28fb47238f 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3523,11 +3523,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (len_i < 0) { goto error; } - // We might have one or more GET_INDEX_* instructions coming up. - // Cache the length on the PyInterpreterState struct so they can - // reuse it: - PyInterpreterState *interp = PyInterpreterState_Get(); - interp->get_len = len_i; PyObject *len_o = PyLong_FromSsize_t(len_i); if (!len_o) { goto error; @@ -3672,18 +3667,19 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(GET_INDEX_END): { - // PUSH(TOS[len(TOS) - 1 - oparg]) + // PUSH(TOS[TOS1 - 1 - oparg]) // NOTE: We can't rely on support for negative indexing! // Although PySequence_GetItem tries to correct negative indexes, we // just use the length we already have cached from GET_LEN on the // PyInterpreterState struct. In addition to avoiding tons of // redundant __len__ calls, this also handles length changes during - // extraction more intuitively. It's also much faster and simpler - // than trying to rotate the length around on the stack and pop it - // off when we're done. - PyInterpreterState *interp = PyInterpreterState_Get(); - assert(interp->get_len - 1 - oparg >= 0); - PyObject *item = PySequence_GetItem(TOP(), interp->get_len - 1 - oparg); + // extraction more intuitively. + Py_ssize_t len = PyLong_AsSsize_t(SECOND()); + if (len < 0) { + goto error; + } + assert(0 <= len - 1 - oparg); + PyObject *item = PySequence_GetItem(TOP(), len - 1 - oparg); if (!item) { goto error; } @@ -3692,12 +3688,15 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(GET_INDEX_SLICE): { - // PUSH(list(TOS[oparg & 0xFF: len(TOS) - (oparg >> 8)])) + // PUSH(list(TOS[oparg & 0xFF: TOS1 - (oparg >> 8)])) // NOTE: We can't rely on support for slicing or negative indexing! // Ditto GET_INDEX_END's length handling. - PyInterpreterState *interp = PyInterpreterState_Get(); + Py_ssize_t len = PyLong_AsSsize_t(SECOND()); + if (len < 0) { + goto error; + } Py_ssize_t start = oparg & 0xFF; - Py_ssize_t size = interp->get_len - (oparg >> 8) - start; + Py_ssize_t size = len - (oparg >> 8) - start; assert(0 <= size); PyObject *slice = PyList_New(size); if (!slice) { diff --git a/Python/compile.c b/Python/compile.c index 9d638fe2a82c8e..9130f9a00457b0 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5743,7 +5743,8 @@ static int compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == List_kind || p->kind == Tuple_kind); - asdl_expr_seq *values = p->kind == Tuple_kind ? p->v.Tuple.elts : p->v.List.elts; + asdl_expr_seq *values = (p->kind == Tuple_kind) ? p->v.Tuple.elts + : p->v.List.elts; Py_ssize_t size = asdl_seq_LEN(values); Py_ssize_t star = -1; for (Py_ssize_t i = 0; i < size; i++) { @@ -5757,7 +5758,7 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) } star = i; } - basicblock *end; + basicblock *wrong_size, *end, *fail; CHECK(end = compiler_new_block(c)); ADDOP(c, MATCH_SEQUENCE); ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); @@ -5769,6 +5770,9 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) compiler_use_next_block(c, end); return 1; } + CHECK(fail = compiler_new_block(c)); + CHECK(wrong_size = compiler_new_block(c)); + ADDOP(c, DUP_TOP) if (star < 0) { ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)); ADDOP_COMPARE(c, Eq); @@ -5777,8 +5781,9 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - 1)); ADDOP_COMPARE(c, GtE); } - ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, wrong_size); NEXT_BLOCK(c); + ADDOP(c, ROT_TWO); for (Py_ssize_t i = 0; i < size; i++) { // TODO: (i >= (1 << 8)) || (n-i-1 >= (INT_MAX >> 8)) expr_ty value = asdl_seq_GET(values, i); @@ -5800,12 +5805,20 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP_I(c, GET_INDEX_END, size - 1 - i); } CHECK(compiler_subpattern(c, value, pc)); - ADDOP(c, ROT_TWO); - ADDOP(c, POP_TOP); - ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail) NEXT_BLOCK(c); + ADDOP(c, POP_TOP); } + ADDOP(c, ROT_TWO); + ADDOP(c, POP_TOP); ADDOP_LOAD_CONST(c, Py_True); + ADDOP_JUMP(c, JUMP_FORWARD, end); + compiler_use_next_block(c, fail); + ADDOP(c, POP_TOP); + ADDOP(c, ROT_TWO); + compiler_use_next_block(c, wrong_size); + ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_False); compiler_use_next_block(c, end); return 1; } diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 36e58673c584bd..bfe027cd6a128b 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -285,7 +285,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,218,13,95,119,114,105,116,101,95,97,116,111,109,105,99, 120,0,0,0,115,28,0,0,0,0,5,16,1,6,1,22, 255,4,2,2,3,14,1,40,1,16,1,12,1,2,1,14, - 1,12,1,6,1,114,69,0,0,0,105,142,13,0,0,114, + 1,12,1,6,1,114,69,0,0,0,105,143,13,0,0,114, 28,0,0,0,114,17,0,0,0,115,2,0,0,0,13,10, 90,11,95,95,112,121,99,97,99,104,101,95,95,122,4,111, 112,116,45,122,3,46,112,121,122,4,46,112,121,99,78,41, From ff011e007fd14f9ebb6b7d91f1d346452b4ac7ef Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 21 Oct 2020 18:06:21 -0700 Subject: [PATCH 179/189] Fix comment --- Python/ceval.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 3f3d28fb47238f..36eaa3643acf2c 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3670,10 +3670,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) // PUSH(TOS[TOS1 - 1 - oparg]) // NOTE: We can't rely on support for negative indexing! // Although PySequence_GetItem tries to correct negative indexes, we - // just use the length we already have cached from GET_LEN on the - // PyInterpreterState struct. In addition to avoiding tons of - // redundant __len__ calls, this also handles length changes during - // extraction more intuitively. + // just use the length we already have at TOS1. In addition to + // avoiding tons of redundant __len__ calls, this also handles + // length changes during extraction more intuitively. + assert(PyLong_CheckExact(SECOND())); Py_ssize_t len = PyLong_AsSsize_t(SECOND()); if (len < 0) { goto error; @@ -3691,6 +3691,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) // PUSH(list(TOS[oparg & 0xFF: TOS1 - (oparg >> 8)])) // NOTE: We can't rely on support for slicing or negative indexing! // Ditto GET_INDEX_END's length handling. + assert(PyLong_CheckExact(SECOND())); Py_ssize_t len = PyLong_AsSsize_t(SECOND()); if (len < 0) { goto error; From 99ae758db9de436d35e56dc33e9baed9b6229638 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 21 Oct 2020 18:11:37 -0700 Subject: [PATCH 180/189] Remove unused get_len member --- Include/internal/pycore_interp.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h index 38713c4be8a2f4..55745f110d3b4e 100644 --- a/Include/internal/pycore_interp.h +++ b/Include/internal/pycore_interp.h @@ -193,7 +193,6 @@ struct _is { // Kept handy for pattern matching: PyObject *map_abc; // _collections_abc.Mapping PyObject *seq_abc; // _collections_abc.Sequence - Py_ssize_t get_len; // Cached length of subject /* Used in Modules/_threadmodule.c. */ long num_threads; From ad844037c0a6f3aca9b99f12e9038195b1aa208c Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 21 Oct 2020 22:48:33 -0700 Subject: [PATCH 181/189] Rename simple match flag --- Include/object.h | 2 +- Objects/bytearrayobject.c | 2 +- Objects/bytesobject.c | 2 +- Objects/dictobject.c | 2 +- Objects/floatobject.c | 2 +- Objects/listobject.c | 2 +- Objects/longobject.c | 2 +- Objects/setobject.c | 7 +++---- Objects/tupleobject.c | 2 +- Objects/typeobject.c | 4 ++-- Objects/unicodeobject.c | 2 +- Python/ceval.c | 2 +- 12 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Include/object.h b/Include/object.h index b53949692105d4..615eaeb77bfa6d 100644 --- a/Include/object.h +++ b/Include/object.h @@ -359,7 +359,7 @@ given type object has a specified feature. // This undocumented flag gives certain built-ins their unique pattern-matching // behavior, which allows a single positional subpattern to match against the // match proxy itself (rather than a mapped attribute on it): -#define _Py_TPFLAGS_SIMPLE_MATCH (1UL << 21) +#define _Py_TPFLAGS_MATCH_SELF (1UL << 21) /* These flags are used to determine if a type is a subclass. */ #define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24) diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 61c6513c9dc0e2..2b9a79060490e5 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -2341,7 +2341,7 @@ PyTypeObject PyByteArray_Type = { 0, /* tp_setattro */ &bytearray_as_buffer, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ + _Py_TPFLAGS_MATCH_SELF, /* tp_flags */ bytearray_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 9fd25dbc828392..a9c18d5c852b79 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2942,7 +2942,7 @@ PyTypeObject PyBytes_Type = { &bytes_as_buffer, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_BYTES_SUBCLASS | - _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ + _Py_TPFLAGS_MATCH_SELF, /* tp_flags */ bytes_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 94d398aaa09c01..790869478d6e77 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -3503,7 +3503,7 @@ PyTypeObject PyDict_Type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_DICT_SUBCLASS | - _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ + _Py_TPFLAGS_MATCH_SELF, /* tp_flags */ dictionary_doc, /* tp_doc */ dict_traverse, /* tp_traverse */ dict_tp_clear, /* tp_clear */ diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 6ab08399d8775f..fcc1b68d5883a3 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -1937,7 +1937,7 @@ PyTypeObject PyFloat_Type = { 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ + _Py_TPFLAGS_MATCH_SELF, /* tp_flags */ float_new__doc__, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Objects/listobject.c b/Objects/listobject.c index c3c6f2574b800a..c3aa41aac8cbba 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3053,7 +3053,7 @@ PyTypeObject PyList_Type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_LIST_SUBCLASS | - _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ + _Py_TPFLAGS_MATCH_SELF, /* tp_flags */ list___init____doc__, /* tp_doc */ (traverseproc)list_traverse, /* tp_traverse */ (inquiry)_list_clear, /* tp_clear */ diff --git a/Objects/longobject.c b/Objects/longobject.c index aa4cb85dd6867e..741ea60aec0b2b 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -5648,7 +5648,7 @@ PyTypeObject PyLong_Type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_LONG_SUBCLASS | - _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ + _Py_TPFLAGS_MATCH_SELF, /* tp_flags */ long_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Objects/setobject.c b/Objects/setobject.c index 9513871cfe7ef8..c235aaf6618f13 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -2092,10 +2092,9 @@ PyTypeObject PySet_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE | - _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ + _Py_TPFLAGS_MATCH_SELF, /* tp_flags */ set_doc, /* tp_doc */ (traverseproc)set_traverse, /* tp_traverse */ (inquiry)set_clear_internal, /* tp_clear */ @@ -2196,7 +2195,7 @@ PyTypeObject PyFrozenSet_Type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE | - _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ + _Py_TPFLAGS_MATCH_SELF, /* tp_flags */ frozenset_doc, /* tp_doc */ (traverseproc)set_traverse, /* tp_traverse */ (inquiry)set_clear_internal, /* tp_clear */ diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 605551af6dd753..8d04ebfbd8c150 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -918,7 +918,7 @@ PyTypeObject PyTuple_Type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TUPLE_SUBCLASS | - _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ + _Py_TPFLAGS_MATCH_SELF, /* tp_flags */ tuple_new__doc__, /* tp_doc */ (traverseproc)tupletraverse, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 7c34f653ba192d..f3a2380f488c65 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -5173,8 +5173,8 @@ inherit_special(PyTypeObject *type, PyTypeObject *base) else if (PyType_IsSubtype(base, &PyDict_Type)) type->tp_flags |= Py_TPFLAGS_DICT_SUBCLASS; - if (PyType_HasFeature(base, _Py_TPFLAGS_SIMPLE_MATCH)) { - type->tp_flags |= _Py_TPFLAGS_SIMPLE_MATCH; + if (PyType_HasFeature(base, _Py_TPFLAGS_MATCH_SELF)) { + type->tp_flags |= _Py_TPFLAGS_MATCH_SELF; } } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index f29cc799787404..ecff587d57f26d 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -15629,7 +15629,7 @@ PyTypeObject PyUnicode_Type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_UNICODE_SUBCLASS | - _Py_TPFLAGS_SIMPLE_MATCH, /* tp_flags */ + _Py_TPFLAGS_MATCH_SELF, /* tp_flags */ unicode_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Python/ceval.c b/Python/ceval.c index 36eaa3643acf2c..e2b0b2771d3e91 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -984,7 +984,7 @@ do_match(PyThreadState *tstate, Py_ssize_t nargs, PyObject *kwargs, PyObject *ty if (!nmatch_args) { Py_DECREF(match_args); nmatch_args = PyType_HasFeature((PyTypeObject *)type, - _Py_TPFLAGS_SIMPLE_MATCH); + _Py_TPFLAGS_MATCH_SELF); args = NULL; } else { From 1b0602fa5e8e4e91cc1176e749e3f01d2092055e Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 22 Oct 2020 11:05:20 -0700 Subject: [PATCH 182/189] BoolOp -> MatchOr and fix constant folding --- Grammar/python.gram | 2 +- Include/Python-ast.h | 9 +++- Lib/ast.py | 32 +++++---------- Lib/test/test_patma.py | 9 ++++ Parser/Python.asdl | 3 +- Parser/parser.c | 2 +- Python/Python-ast.c | 93 +++++++++++++++++++++++++++++++++++++++++- Python/ast.c | 4 ++ Python/ast_opt.c | 37 ++++++++++++++--- Python/compile.c | 18 ++++---- Python/symtable.c | 3 ++ 11 files changed, 171 insertions(+), 41 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index a470fb4a1b540b..2f4b5de2ef1a9e 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -221,7 +221,7 @@ pattern[expr_ty]: or_pattern[expr_ty]: | values[asdl_expr_seq*]='|'.closed_pattern+ { - asdl_seq_LEN(values) == 1 ? asdl_seq_GET(values, 0) : _Py_BoolOp(Or, values, EXTRA) } + asdl_seq_LEN(values) == 1 ? asdl_seq_GET(values, 0) : _Py_MatchOr(values, EXTRA) } closed_pattern[expr_ty]: | name_pattern diff --git a/Include/Python-ast.h b/Include/Python-ast.h index 25f2deed378fff..f9f15ab5125a20 100644 --- a/Include/Python-ast.h +++ b/Include/Python-ast.h @@ -327,7 +327,7 @@ enum _expr_kind {BoolOp_kind=1, NamedExpr_kind=2, BinOp_kind=3, UnaryOp_kind=4, FormattedValue_kind=18, JoinedStr_kind=19, Constant_kind=20, Attribute_kind=21, Subscript_kind=22, Starred_kind=23, Name_kind=24, List_kind=25, Tuple_kind=26, Slice_kind=27, - MatchAs_kind=28}; + MatchAs_kind=28, MatchOr_kind=29}; struct _expr { enum _expr_kind kind; union { @@ -475,6 +475,10 @@ struct _expr { identifier name; } MatchAs; + struct { + asdl_expr_seq *patterns; + } MatchOr; + } v; int lineno; int col_offset; @@ -778,6 +782,9 @@ expr_ty _Py_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int expr_ty _Py_MatchAs(expr_ty pattern, identifier name, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); +#define MatchOr(a0, a1, a2, a3, a4, a5) _Py_MatchOr(a0, a1, a2, a3, a4, a5) +expr_ty _Py_MatchOr(asdl_expr_seq * patterns, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); #define comprehension(a0, a1, a2, a3, a4) _Py_comprehension(a0, a1, a2, a3, a4) comprehension_ty _Py_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int is_async, PyArena *arena); diff --git a/Lib/ast.py b/Lib/ast.py index cc9c57752776c6..1f71b452db99c5 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -673,7 +673,6 @@ def __init__(self): self._precedences = {} self._type_ignores = {} self._indent = 0 - self._pattern = False def interleave(self, inter, f, seq): """Call f on each item in seq, calling inter() in between.""" @@ -735,18 +734,6 @@ def block(self, *, extra = None): yield self._indent -= 1 - @contextmanager - def pattern(self): - assert not self._pattern - self._pattern = True - yield - assert self._pattern - self._pattern = False - - @property - def in_pattern(self): - return self._pattern - @contextmanager def delimit(self, start, end): """A context manager for preparing the source for expressions. It adds @@ -1347,12 +1334,8 @@ def visit_Compare(self, node): boolop_precedence = {"and": _Precedence.AND, "or": _Precedence.OR} def visit_BoolOp(self, node): - if self.in_pattern: - operator = "|" - operator_precedence = _Precedence.OR - else: - operator = self.boolops[node.op.__class__.__name__] - operator_precedence = self.boolop_precedence[operator] + operator = self.boolops[node.op.__class__.__name__] + operator_precedence = self.boolop_precedence[operator] def increasing_level_traverse(node): nonlocal operator_precedence @@ -1523,8 +1506,7 @@ def visit_withitem(self, node): def visit_match_case(self, node): self.fill("case ") - with self.pattern(): - self.traverse(node.pattern) + self.traverse(node.pattern) if node.guard: self.write(" if ") self.traverse(node.guard) @@ -1532,10 +1514,16 @@ def visit_match_case(self, node): self.traverse(node.body) def visit_MatchAs(self, node): - with self.require_parens(_Precedence.TUPLE, node): + with self.require_parens(_Precedence.TEST, node): + self.set_precedence(_Precedence.EXPR, node.pattern) self.traverse(node.pattern) self.write(f" as {node.name}") + def visit_MatchOr(self, node): + with self.require_parens(_Precedence.EXPR, node): + self.set_precedence(_Precedence.ATOM, *node.patterns) + self.interleave(lambda: self.write(" | "), self.traverse, node.patterns) + def unparse(ast_obj): unparser = _Unparser() return unparser.visit(ast_obj) diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 6727a2f7113226..cb735efc8fcf65 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2794,6 +2794,15 @@ def test_patma_276(self): self.assertEqual(y, 0) self.assertEqual(z, {0: 1}) + def test_patma_277(self): + x = [[{0: 0}]] + match x: + case list([({-0-0j: int(real=0+0j, imag=0-0j) | (1) as z},)]): + y = 0 + self.assertEqual(x, [[{0: 0}]]) + self.assertEqual(y, 0) + self.assertEqual(z, 0) + # TODO: Better use of assertIs # TODO: Don't check side-effecty assignments diff --git a/Parser/Python.asdl b/Parser/Python.asdl index 8b0c1ef7ba60eb..ddc019da48e8ae 100644 --- a/Parser/Python.asdl +++ b/Parser/Python.asdl @@ -89,8 +89,9 @@ module Python -- can appear only in Subscript | Slice(expr? lower, expr? upper, expr? step) - -- only used for named patterns + -- only used in patterns | MatchAs(expr pattern, identifier name) + | MatchOr(expr* patterns) -- col_offset is the byte offset in the utf8 string the parser uses attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset) diff --git a/Parser/parser.c b/Parser/parser.c index 2b7ca3dcd99389..9c46f3bd11133a 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -5267,7 +5267,7 @@ or_pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = asdl_seq_LEN ( values ) == 1 ? asdl_seq_GET ( values , 0 ) : _Py_BoolOp ( Or , values , EXTRA ); + _res = asdl_seq_LEN ( values ) == 1 ? asdl_seq_GET ( values , 0 ) : _Py_MatchOr ( values , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); diff --git a/Python/Python-ast.c b/Python/Python-ast.c index e81247dc8a6519..55ca099b02a638 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -88,6 +88,7 @@ typedef struct { PyObject *MatMult_singleton; PyObject *MatMult_type; PyObject *MatchAs_type; + PyObject *MatchOr_type; PyObject *Match_type; PyObject *Mod_singleton; PyObject *Mod_type; @@ -207,6 +208,7 @@ typedef struct { PyObject *optional_vars; PyObject *orelse; PyObject *pattern; + PyObject *patterns; PyObject *posonlyargs; PyObject *returns; PyObject *right; @@ -341,6 +343,7 @@ void _PyAST_Fini(PyThreadState *tstate) Py_CLEAR(state->MatMult_singleton); Py_CLEAR(state->MatMult_type); Py_CLEAR(state->MatchAs_type); + Py_CLEAR(state->MatchOr_type); Py_CLEAR(state->Match_type); Py_CLEAR(state->Mod_singleton); Py_CLEAR(state->Mod_type); @@ -460,6 +463,7 @@ void _PyAST_Fini(PyThreadState *tstate) Py_CLEAR(state->optional_vars); Py_CLEAR(state->orelse); Py_CLEAR(state->pattern); + Py_CLEAR(state->patterns); Py_CLEAR(state->posonlyargs); Py_CLEAR(state->returns); Py_CLEAR(state->right); @@ -549,6 +553,7 @@ static int init_identifiers(astmodulestate *state) if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return 0; if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return 0; if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return 0; + if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return 0; if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return 0; if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return 0; if ((state->right = PyUnicode_InternFromString("right")) == NULL) return 0; @@ -842,6 +847,9 @@ static const char * const MatchAs_fields[]={ "pattern", "name", }; +static const char * const MatchOr_fields[]={ + "patterns", +}; static PyObject* ast2obj_expr_context(astmodulestate *state, expr_context_ty); static PyObject* ast2obj_boolop(astmodulestate *state, boolop_ty); static PyObject* ast2obj_operator(astmodulestate *state, operator_ty); @@ -1481,7 +1489,8 @@ static int init_types(astmodulestate *state) " | List(expr* elts, expr_context ctx)\n" " | Tuple(expr* elts, expr_context ctx)\n" " | Slice(expr? lower, expr? upper, expr? step)\n" - " | MatchAs(expr pattern, identifier name)"); + " | MatchAs(expr pattern, identifier name)\n" + " | MatchOr(expr* patterns)"); if (!state->expr_type) return 0; if (!add_attributes(state, state->expr_type, expr_attributes, 4)) return 0; if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1) @@ -1618,6 +1627,10 @@ static int init_types(astmodulestate *state) MatchAs_fields, 2, "MatchAs(expr pattern, identifier name)"); if (!state->MatchAs_type) return 0; + state->MatchOr_type = make_type(state, "MatchOr", state->expr_type, + MatchOr_fields, 1, + "MatchOr(expr* patterns)"); + if (!state->MatchOr_type) return 0; state->expr_context_type = make_type(state, "expr_context", state->AST_type, NULL, 0, "expr_context = Load | Store | Del"); @@ -3336,6 +3349,23 @@ MatchAs(expr_ty pattern, identifier name, int lineno, int col_offset, int return p; } +expr_ty +MatchOr(asdl_expr_seq * patterns, int lineno, int col_offset, int end_lineno, + int end_col_offset, PyArena *arena) +{ + expr_ty p; + p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); + if (!p) + return NULL; + p->kind = MatchOr_kind; + p->v.MatchOr.patterns = patterns; + p->lineno = lineno; + p->col_offset = col_offset; + p->end_lineno = end_lineno; + p->end_col_offset = end_col_offset; + return p; +} + comprehension_ty comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int is_async, PyArena *arena) @@ -4582,6 +4612,17 @@ ast2obj_expr(astmodulestate *state, void* _o) goto failed; Py_DECREF(value); break; + case MatchOr_kind: + tp = (PyTypeObject *)state->MatchOr_type; + result = PyType_GenericNew(tp, NULL, NULL); + if (!result) goto failed; + value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns, + ast2obj_expr); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->patterns, value) == -1) + goto failed; + Py_DECREF(value); + break; } value = ast2obj_int(state, o->lineno); if (!value) goto failed; @@ -8845,6 +8886,52 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena) if (*out == NULL) goto failed; return 0; } + tp = state->MatchOr_type; + isinstance = PyObject_IsInstance(obj, tp); + if (isinstance == -1) { + return 1; + } + if (isinstance) { + asdl_expr_seq* patterns; + + if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchOr"); + return 1; + } + else { + int res; + Py_ssize_t len; + Py_ssize_t i; + if (!PyList_Check(tmp)) { + PyErr_Format(PyExc_TypeError, "MatchOr field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp))); + goto failed; + } + len = PyList_GET_SIZE(tmp); + patterns = _Py_asdl_expr_seq_new(len, arena); + if (patterns == NULL) goto failed; + for (i = 0; i < len; i++) { + expr_ty val; + PyObject *tmp2 = PyList_GET_ITEM(tmp, i); + Py_INCREF(tmp2); + res = obj2ast_expr(state, tmp2, &val, arena); + Py_DECREF(tmp2); + if (res != 0) goto failed; + if (len != PyList_GET_SIZE(tmp)) { + PyErr_SetString(PyExc_RuntimeError, "MatchOr field \"patterns\" changed size during iteration"); + goto failed; + } + asdl_seq_SET(patterns, i, val); + } + Py_CLEAR(tmp); + } + *out = MatchOr(patterns, lineno, col_offset, end_lineno, + end_col_offset, arena); + if (*out == NULL) goto failed; + return 0; + } PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj); failed: @@ -10307,6 +10394,10 @@ astmodule_exec(PyObject *m) return -1; } Py_INCREF(state->MatchAs_type); + if (PyModule_AddObject(m, "MatchOr", state->MatchOr_type) < 0) { + return -1; + } + Py_INCREF(state->MatchOr_type); if (PyModule_AddObject(m, "expr_context", state->expr_context_type) < 0) { return -1; } diff --git a/Python/ast.c b/Python/ast.c index f52f1dfc424dbd..9133aaea88634c 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -313,6 +313,10 @@ validate_expr(expr_ty exp, expr_context_ty ctx) PyErr_SetString(PyExc_ValueError, "MatchAs is only valid in match_case patterns"); return 0; + case MatchOr_kind: + PyErr_SetString(PyExc_ValueError, + "MatchOr is only valid in match_case patterns"); + return 0; /* This last case doesn't have any checking. */ case Name_kind: return 1; diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 9e451b57491017..0d7351f602e0af 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -395,6 +395,7 @@ static int astfold_keyword(keyword_ty node_, PyArena *ctx_, _PyASTOptimizeState static int astfold_withitem(withitem_ty node_, PyArena *ctx_, _PyASTOptimizeState *state); static int astfold_excepthandler(excepthandler_ty node_, PyArena *ctx_, _PyASTOptimizeState *state); static int astfold_match_case(match_case_ty node_, PyArena *ctx_, _PyASTOptimizeState *state); +static int astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state); #define CALL(FUNC, TYPE, ARG) \ if (!FUNC((ARG), ctx_, state)) \ @@ -772,30 +773,56 @@ astfold_pattern_complex(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state return make_const(node_, new, ctx_); } +static int +astfold_pattern_keyword(keyword_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) +{ + CALL(astfold_pattern, expr_ty, node_->value); + return 1; +} + static int astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) { // Don't blindly optimize the pattern as an expr; it plays by its own rules! switch (node_->kind) { case Attribute_kind: - return 1; + break; case BinOp_kind: CALL(astfold_pattern_complex, expr_ty, node_); - return 1; - case BoolOp_kind: + break; case Call_kind: + CALL_SEQ(astfold_pattern, expr, node_->v.Call.args); + CALL_SEQ(astfold_pattern_keyword, keyword, node_->v.Call.keywords); + break; case Constant_kind: + break; case Dict_kind: + CALL_SEQ(astfold_pattern, expr, node_->v.Dict.keys); + CALL_SEQ(astfold_pattern, expr, node_->v.Dict.values); + break; // Not actually valid, but it's the compiler's job to complain: case JoinedStr_kind: + break; case List_kind: + CALL_SEQ(astfold_pattern, expr, node_->v.List.elts); + break; case MatchAs_kind: + CALL(astfold_pattern, expr_ty, node_->v.MatchAs.pattern); + break; + case MatchOr_kind: + CALL_SEQ(astfold_pattern, expr, node_->v.MatchOr.patterns); + break; case Name_kind: + break; + case Starred_kind: + CALL(astfold_pattern, expr_ty, node_->v.Starred.value); + break; case Tuple_kind: - return 1; + CALL_SEQ(astfold_pattern, expr, node_->v.Tuple.elts); + break; case UnaryOp_kind: CALL(astfold_pattern_negative, expr_ty, node_); - return 1; + break; default: Py_UNREACHABLE(); } diff --git a/Python/compile.c b/Python/compile.c index 9130f9a00457b0..df19167343b3d8 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5133,6 +5133,7 @@ compiler_visit_expr1(struct compiler *c, expr_ty e) case Tuple_kind: return compiler_tuple(c, e); case MatchAs_kind: + case MatchOr_kind: // Can only occur in patterns, which are handled elsewhere. Py_UNREACHABLE(); } @@ -5533,22 +5534,21 @@ compiler_pattern_attribute(struct compiler *c, expr_ty p, pattern_context *pc) static int -compiler_pattern_boolop(struct compiler *c, expr_ty p, pattern_context *pc) +compiler_pattern_match_or(struct compiler *c, expr_ty p, pattern_context *pc) { - assert(p->kind == BoolOp_kind); - assert(p->v.BoolOp.op == Or); + assert(p->kind == MatchOr_kind); basicblock *end; PyObject *control = NULL; PyObject *diff; CHECK(end = compiler_new_block(c)); - Py_ssize_t size = asdl_seq_LEN(p->v.BoolOp.values); + Py_ssize_t size = asdl_seq_LEN(p->v.MatchOr.patterns); assert(size > 1); PyObject *stores_init = pc->stores; int allow_irrefutable = pc->allow_irrefutable; expr_ty alt; for (Py_ssize_t i = 0; i < size; i++) { // Can't use our helpful returning macros here: they'll leak sets! - alt = asdl_seq_GET(p->v.BoolOp.values, i); + alt = asdl_seq_GET(p->v.MatchOr.patterns, i); pc->stores = PySet_New(stores_init); // An irrefutable sub-pattern must be last, if it is allowed at all: pc->allow_irrefutable = allow_irrefutable && (i == size - 1); @@ -5843,7 +5843,7 @@ compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) static int -compiler_pattern_as(struct compiler *c, expr_ty p, pattern_context *pc) +compiler_pattern_match_as(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == MatchAs_kind); basicblock *end; @@ -5880,8 +5880,6 @@ compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc) case BinOp_kind: // Because we allow "2+2j", things like "2+2" make it this far: return compiler_error(c, "patterns cannot include operators"); - case BoolOp_kind: - return compiler_pattern_boolop(c, p, pc); case Call_kind: return compiler_pattern_call(c, p, pc); case Constant_kind: @@ -5895,7 +5893,9 @@ compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc) case Tuple_kind: return compiler_pattern_list_tuple(c, p, pc); case MatchAs_kind: - return compiler_pattern_as(c, p, pc); + return compiler_pattern_match_as(c, p, pc); + case MatchOr_kind: + return compiler_pattern_match_or(c, p, pc); case Name_kind: return compiler_pattern_name(c, p, pc); default: diff --git a/Python/symtable.c b/Python/symtable.c index bccdb756581dab..3521f3aa524aa6 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1682,6 +1682,9 @@ symtable_visit_expr(struct symtable *st, expr_ty e) // "_" is not actually valid, but it's the compiler's job to complain: symtable_add_def(st, e->v.MatchAs.name, DEF_LOCAL); break; + case MatchOr_kind: + VISIT_SEQ(st, expr, e->v.MatchOr.patterns); + break; } VISIT_QUIT(st, 1); } From e212cebcf05afd925bba2dabb3c038cc62bb2c9e Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 22 Oct 2020 12:49:07 -0700 Subject: [PATCH 183/189] Minor cleanup --- Include/object.h | 2 +- Lib/dataclasses.py | 13 +++++-------- Python/ast.c | 6 ++---- Python/ast_opt.c | 2 ++ 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Include/object.h b/Include/object.h index 615eaeb77bfa6d..94b17dfbac66f3 100644 --- a/Include/object.h +++ b/Include/object.h @@ -358,7 +358,7 @@ given type object has a specified feature. // This undocumented flag gives certain built-ins their unique pattern-matching // behavior, which allows a single positional subpattern to match against the -// match proxy itself (rather than a mapped attribute on it): +// subject itself (rather than a mapped attribute on it): #define _Py_TPFLAGS_MATCH_SELF (1UL << 21) /* These flags are used to determine if a type is a subclass. */ diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py index f2a2256924e2d2..c33f99e6821cf9 100644 --- a/Lib/dataclasses.py +++ b/Lib/dataclasses.py @@ -158,9 +158,8 @@ # +=======+=======+ # | add | | <- the default # +=======+=======+ -# __match_args__ is always added unless the class already defines it. -# __match_args__ contains the set of names of __init__ parameters. -# Non-init fields must be matched by name. +# __match_args__ is always added unless the class already defines it. It is a +# tuple of __init__ parameter names; non-init fields must be matched by keyword. # Raised when an attempt is made to modify a frozen class. @@ -1010,12 +1009,10 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen): cls.__doc__ = (cls.__name__ + str(inspect.signature(cls)).replace(' -> NoneType', '')) - abc.update_abstractmethods(cls) + if '__match_args__' not in cls.__dict__: + cls.__match_args__ = tuple(f.name for f in flds if f.init) - match_args = cls.__dict__.get('__match_args__', MISSING) - if match_args is MISSING: - # Create a __match_args__ attribute. - _set_new_attribute(cls, '__match_args__', tuple(f.name for f in flds if f.init)) + abc.update_abstractmethods(cls) return cls diff --git a/Python/ast.c b/Python/ast.c index 9133aaea88634c..c58b4a69b1e321 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -435,10 +435,8 @@ validate_stmt(stmt_ty stmt) || !validate_nonempty_seq(stmt->v.Match.cases, "cases", "Match")) { return 0; } - match_case_ty m; - Py_ssize_t cases = asdl_seq_LEN(stmt->v.Match.cases); - for (i = 0; i < cases; i++) { - m = asdl_seq_GET(stmt->v.Match.cases, i); + for (i = 0; i < asdl_seq_LEN(stmt->v.Match.cases); i++) { + match_case_ty m = asdl_seq_GET(stmt->v.Match.cases, i); if (!validate_pattern(m->pattern) || (m->guard && !validate_expr(m->guard, Load)) || !validate_body(m->body, "match_case")) { diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 0d7351f602e0af..9728fc5cecb7f0 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -751,6 +751,7 @@ astfold_pattern_complex(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state } assert(left->kind = Constant_kind); assert(right->kind = Constant_kind); + // LHS must be real, RHS must be imaginary: if (!(PyFloat_CheckExact(left->v.Constant.value) || PyLong_CheckExact(left->v.Constant.value)) || !PyComplex_CheckExact(right->v.Constant.value)) @@ -784,6 +785,7 @@ static int astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) { // Don't blindly optimize the pattern as an expr; it plays by its own rules! + // Currently, this is only used to form complex/negative numeric constants. switch (node_->kind) { case Attribute_kind: break; From 94b19ee4b020ab2173b952468b0681e01ff759be Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 22 Oct 2020 15:12:02 -0700 Subject: [PATCH 184/189] Unify grammar with PEP 634 (mostly) --- Grammar/python.gram | 123 +- Parser/parser.c | 7730 +++++++++++++++++++------------------------ Python/compile.c | 10 +- Python/symtable.c | 1 - 4 files changed, 3474 insertions(+), 4390 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 2f4b5de2ef1a9e..8db40e0c5e19cf 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -196,44 +196,40 @@ except_block[excepthandler_ty]: | 'except' ':' b=block { _Py_ExceptHandler(NULL, NULL, b, EXTRA) } finally_block[asdl_stmt_seq*]: 'finally' ':' a=block { a } -match_expr[expr_ty]: +match_stmt[stmt_ty]: + | "match" subject=subject_expr ':' NEWLINE INDENT cases[asdl_match_case_seq*]=case_block+ DEDENT { + CHECK_VERSION(10, "Pattern matching is", _Py_Match(subject, cases, EXTRA)) } +subject_expr[expr_ty]: | value=star_named_expression ',' values=star_named_expressions? { _Py_Tuple(CHECK(_PyPegen_seq_insert_in_front(p, value, values)), Load, EXTRA) } | named_expression - -match_stmt[stmt_ty]: - | "match" subject=match_expr ':' NEWLINE INDENT cases[asdl_match_case_seq*]=case_block+ DEDENT { - CHECK_VERSION(10, "Pattern matching is", _Py_Match(subject, cases, EXTRA)) } case_block[match_case_ty]: | "case" pattern=patterns guard=guard? ':' body=block { _Py_match_case(pattern, guard, body, p->arena) } -guard[expr_ty]: - | 'if' guard=named_expression { guard } +guard[expr_ty]: 'if' guard=named_expression { guard } patterns[expr_ty]: - | value=value_pattern ',' values=values_pattern? { - _Py_Tuple(CHECK(_PyPegen_seq_insert_in_front(p, value, values)), Load, EXTRA) } + | open_sequence_pattern | pattern - pattern[expr_ty]: - | value=or_pattern 'as' target=NAME { _Py_MatchAs(value, target->v.Name.id, EXTRA) } + | as_pattern | or_pattern - +as_pattern[expr_ty]: + | pattern=or_pattern 'as' target=capture_pattern { + _Py_MatchAs(pattern, target->v.Name.id, EXTRA) } or_pattern[expr_ty]: - | values[asdl_expr_seq*]='|'.closed_pattern+ { - asdl_seq_LEN(values) == 1 ? asdl_seq_GET(values, 0) : _Py_MatchOr(values, EXTRA) } - + | patterns[asdl_expr_seq*]='|'.closed_pattern+ { + asdl_seq_LEN(patterns) == 1 ? asdl_seq_GET(patterns, 0) : _Py_MatchOr(patterns, EXTRA) } closed_pattern[expr_ty]: - | name_pattern | literal_pattern - | constant_pattern + | capture_pattern + | wildcard_pattern + | value_pattern | group_pattern | sequence_pattern | mapping_pattern | class_pattern -name_pattern[expr_ty]: - | name=NAME !('.' | '(' | '=') { _PyPegen_set_expr_context(p, name, Store) } literal_pattern[expr_ty]: | signed_number !('+' | '-') | real=signed_number '+' imag=NUMBER { _Py_BinOp(real, Add, imag, EXTRA) } @@ -242,32 +238,19 @@ literal_pattern[expr_ty]: | 'None' { _Py_Constant(Py_None, NULL, EXTRA) } | 'True' { _Py_Constant(Py_True, NULL, EXTRA) } | 'False' { _Py_Constant(Py_False, NULL, EXTRA) } -constant_pattern[expr_ty]: - | attr=attr !('.' | '(' | '=') { attr } -group_pattern[expr_ty]: - | '(' pattern=patterns ')' { pattern } -sequence_pattern[expr_ty]: - | '[' values=values_pattern? ']' { _Py_List(values, Load, EXTRA) } - | '(' ')' { _Py_Tuple(NULL, Load, EXTRA) } -mapping_pattern[expr_ty]: - | '{' items=items_pattern? '}' { - _Py_Dict(CHECK(_PyPegen_get_keys(p, items)), CHECK(_PyPegen_get_values(p, items)), EXTRA) } -class_pattern[expr_ty]: - | func=name_or_attr '(' ')' { _Py_Call(func, NULL, NULL, EXTRA) } - | func=name_or_attr '(' args[asdl_expr_seq*]=','.pattern+ ','? ')' { - _Py_Call(func, args, NULL, EXTRA) } - | func=name_or_attr '(' keywords[asdl_keyword_seq*]=','.keyword_pattern+ ','? ')' { - _Py_Call(func, NULL, keywords, EXTRA) } - | func=name_or_attr '(' args[asdl_expr_seq*]=','.pattern+ ',' keywords[asdl_keyword_seq*]=','.keyword_pattern+ ','? ')' { - _Py_Call(func, args, keywords, EXTRA) } - | func=name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' error=pattern [',' ','.error_argument_pattern+] ','? ')' { - RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "positional pattern follows keyword pattern") } - | func=name_or_attr '(' [','.error_argument_pattern+ ','] error=error_star [',' ','.(error_argument_pattern | error_star)+] ','? ')' { - RAISE_SYNTAX_ERROR_KNOWN_LOCATION(error, "can't use starred pattern here") } - signed_number[expr_ty]: | NUMBER | '-' number=NUMBER { _Py_UnaryOp(USub, number, EXTRA) } + +capture_pattern[expr_ty]: + | !"_" name=NAME !('.' | '(' | '=') { + _PyPegen_set_expr_context(p, name, Store) } + +wildcard_pattern[expr_ty]: + | "_" { _Py_Name(CHECK(_PyPegen_new_identifier(p, "_")), Store, EXTRA) } + +value_pattern[expr_ty]: + | attr=attr !('.' | '(' | '=') { attr } attr[expr_ty]: | value=name_or_attr '.' attr=NAME { _Py_Attribute(value, attr->v.Name.id, Load, EXTRA) } @@ -275,25 +258,51 @@ name_or_attr[expr_ty]: | attr | NAME -values_pattern[asdl_seq*]: - | values=','.value_pattern+ ','? { values } -items_pattern[asdl_seq*]: - | items=','.key_value_pattern+ ','? { items } -keyword_pattern[keyword_ty]: - | arg=NAME '=' value=pattern { _Py_keyword(arg->v.Name.id, value, EXTRA) } -error_argument_pattern: - | pattern - | keyword_pattern -error_star[expr_ty]: - | ('*' | '**') error=NAME { error } +group_pattern[expr_ty]: + | '(' pattern=pattern ')' { pattern } -value_pattern[expr_ty]: - | '*' value=name_pattern { _Py_Starred(value, Store, EXTRA) } +sequence_pattern[expr_ty]: + | '[' values=maybe_sequence_pattern? ']' { _Py_List(values, Load, EXTRA) } + | '(' values=open_sequence_pattern? ')' { + values ? values : _Py_Tuple(values, Load, EXTRA) } +open_sequence_pattern[expr_ty]: + | value=maybe_star_pattern ',' values=maybe_sequence_pattern? { + _Py_Tuple(CHECK(_PyPegen_seq_insert_in_front(p, value, values)), Load, EXTRA) } +maybe_sequence_pattern[asdl_seq*]: + | values=','.maybe_star_pattern+ ','? { values } +maybe_star_pattern[expr_ty]: + | star_pattern | pattern +star_pattern[expr_ty]: + | '*' value=(capture_pattern | wildcard_pattern) { + _Py_Starred(value, Store, EXTRA) } + +mapping_pattern[expr_ty]: + | '{' items=items_pattern? '}' { + _Py_Dict(CHECK(_PyPegen_get_keys(p, items)), CHECK(_PyPegen_get_values(p, items)), EXTRA) } +items_pattern[asdl_seq*]: + | items=','.key_value_pattern+ ','? { items } key_value_pattern[KeyValuePair*]: - | key=(literal_pattern | constant_pattern) ':' value=pattern { + | key=(literal_pattern | value_pattern) ':' value=pattern { _PyPegen_key_value_pair(p, key, value) } - | '**' value=name_pattern { _PyPegen_key_value_pair(p, NULL, value) } + | double_star_pattern +double_star_pattern[KeyValuePair*]: + | '**' value=capture_pattern { _PyPegen_key_value_pair(p, NULL, value) } + +class_pattern[expr_ty]: + | func=name_or_attr '(' ')' { _Py_Call(func, NULL, NULL, EXTRA) } + | func=name_or_attr '(' args=positional_patterns ','? ')' { + _Py_Call(func, args, NULL, EXTRA) } + | func=name_or_attr '(' keywords=keyword_patterns ','? ')' { + _Py_Call(func, NULL, keywords, EXTRA) } + | func=name_or_attr '(' args=positional_patterns ',' keywords=keyword_patterns ','? ')' { + _Py_Call(func, args, keywords, EXTRA) } +positional_patterns[asdl_expr_seq*]: + | args[asdl_expr_seq*]=','.pattern+ { args } +keyword_patterns[asdl_keyword_seq*]: + | keywords[asdl_keyword_seq*]=','.keyword_pattern+ { keywords } +keyword_pattern[keyword_ty]: + | arg=NAME '=' value=pattern { _Py_keyword(arg->v.Name.id, value, EXTRA) } return_stmt[stmt_ty]: | 'return' a=[star_expressions] { _Py_Return(a, EXTRA) } diff --git a/Parser/parser.c b/Parser/parser.c index 9c46f3bd11133a..6683ca4ec1bf72 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -104,345 +104,331 @@ static KeywordToken *reserved_keywords[] = { #define try_stmt_type 1035 #define except_block_type 1036 #define finally_block_type 1037 -#define match_expr_type 1038 -#define match_stmt_type 1039 +#define match_stmt_type 1038 +#define subject_expr_type 1039 #define case_block_type 1040 #define guard_type 1041 #define patterns_type 1042 #define pattern_type 1043 -#define or_pattern_type 1044 -#define closed_pattern_type 1045 -#define name_pattern_type 1046 +#define as_pattern_type 1044 +#define or_pattern_type 1045 +#define closed_pattern_type 1046 #define literal_pattern_type 1047 -#define constant_pattern_type 1048 -#define group_pattern_type 1049 -#define sequence_pattern_type 1050 -#define mapping_pattern_type 1051 -#define class_pattern_type 1052 -#define signed_number_type 1053 -#define attr_type 1054 // Left-recursive -#define name_or_attr_type 1055 // Left-recursive -#define values_pattern_type 1056 -#define items_pattern_type 1057 -#define keyword_pattern_type 1058 -#define error_argument_pattern_type 1059 -#define error_star_type 1060 -#define value_pattern_type 1061 +#define signed_number_type 1048 +#define capture_pattern_type 1049 +#define wildcard_pattern_type 1050 +#define value_pattern_type 1051 +#define attr_type 1052 // Left-recursive +#define name_or_attr_type 1053 // Left-recursive +#define group_pattern_type 1054 +#define sequence_pattern_type 1055 +#define open_sequence_pattern_type 1056 +#define maybe_sequence_pattern_type 1057 +#define maybe_star_pattern_type 1058 +#define star_pattern_type 1059 +#define mapping_pattern_type 1060 +#define items_pattern_type 1061 #define key_value_pattern_type 1062 -#define return_stmt_type 1063 -#define raise_stmt_type 1064 -#define function_def_type 1065 -#define function_def_raw_type 1066 -#define func_type_comment_type 1067 -#define params_type 1068 -#define parameters_type 1069 -#define slash_no_default_type 1070 -#define slash_with_default_type 1071 -#define star_etc_type 1072 -#define kwds_type 1073 -#define param_no_default_type 1074 -#define param_with_default_type 1075 -#define param_maybe_default_type 1076 -#define param_type 1077 -#define annotation_type 1078 -#define default_type 1079 -#define decorators_type 1080 -#define class_def_type 1081 -#define class_def_raw_type 1082 -#define block_type 1083 -#define expressions_list_type 1084 -#define star_expressions_type 1085 -#define star_expression_type 1086 -#define star_named_expressions_type 1087 -#define star_named_expression_type 1088 -#define named_expression_type 1089 -#define annotated_rhs_type 1090 -#define expressions_type 1091 -#define expression_type 1092 -#define lambdef_type 1093 -#define lambda_params_type 1094 -#define lambda_parameters_type 1095 -#define lambda_slash_no_default_type 1096 -#define lambda_slash_with_default_type 1097 -#define lambda_star_etc_type 1098 -#define lambda_kwds_type 1099 -#define lambda_param_no_default_type 1100 -#define lambda_param_with_default_type 1101 -#define lambda_param_maybe_default_type 1102 -#define lambda_param_type 1103 -#define disjunction_type 1104 -#define conjunction_type 1105 -#define inversion_type 1106 -#define comparison_type 1107 -#define compare_op_bitwise_or_pair_type 1108 -#define eq_bitwise_or_type 1109 -#define noteq_bitwise_or_type 1110 -#define lte_bitwise_or_type 1111 -#define lt_bitwise_or_type 1112 -#define gte_bitwise_or_type 1113 -#define gt_bitwise_or_type 1114 -#define notin_bitwise_or_type 1115 -#define in_bitwise_or_type 1116 -#define isnot_bitwise_or_type 1117 -#define is_bitwise_or_type 1118 -#define bitwise_or_type 1119 // Left-recursive -#define bitwise_xor_type 1120 // Left-recursive -#define bitwise_and_type 1121 // Left-recursive -#define shift_expr_type 1122 // Left-recursive -#define sum_type 1123 // Left-recursive -#define term_type 1124 // Left-recursive -#define factor_type 1125 -#define power_type 1126 -#define await_primary_type 1127 -#define primary_type 1128 // Left-recursive -#define slices_type 1129 -#define slice_type 1130 -#define atom_type 1131 -#define strings_type 1132 -#define list_type 1133 -#define listcomp_type 1134 -#define tuple_type 1135 -#define group_type 1136 -#define genexp_type 1137 -#define set_type 1138 -#define setcomp_type 1139 -#define dict_type 1140 -#define dictcomp_type 1141 -#define double_starred_kvpairs_type 1142 -#define double_starred_kvpair_type 1143 -#define kvpair_type 1144 -#define for_if_clauses_type 1145 -#define for_if_clause_type 1146 -#define yield_expr_type 1147 -#define arguments_type 1148 -#define args_type 1149 -#define kwargs_type 1150 -#define starred_expression_type 1151 -#define kwarg_or_starred_type 1152 -#define kwarg_or_double_starred_type 1153 -#define star_targets_type 1154 -#define star_targets_seq_type 1155 -#define star_target_type 1156 -#define star_atom_type 1157 -#define single_target_type 1158 -#define single_subscript_attribute_target_type 1159 -#define del_targets_type 1160 -#define del_target_type 1161 -#define del_t_atom_type 1162 -#define targets_type 1163 -#define target_type 1164 -#define t_primary_type 1165 // Left-recursive -#define t_lookahead_type 1166 -#define t_atom_type 1167 -#define incorrect_arguments_type 1168 -#define invalid_kwarg_type 1169 -#define invalid_named_expression_type 1170 -#define invalid_assignment_type 1171 -#define invalid_ann_assign_target_type 1172 -#define invalid_del_stmt_type 1173 -#define invalid_block_type 1174 -#define invalid_comprehension_type 1175 -#define invalid_dict_comprehension_type 1176 -#define invalid_parameters_type 1177 -#define invalid_lambda_parameters_type 1178 -#define invalid_star_etc_type 1179 -#define invalid_lambda_star_etc_type 1180 -#define invalid_double_type_comments_type 1181 -#define invalid_with_item_type 1182 -#define invalid_for_target_type 1183 -#define invalid_group_type 1184 -#define invalid_import_from_targets_type 1185 -#define _loop0_1_type 1186 -#define _loop0_2_type 1187 -#define _loop0_4_type 1188 -#define _gather_3_type 1189 -#define _loop0_6_type 1190 -#define _gather_5_type 1191 -#define _loop0_8_type 1192 -#define _gather_7_type 1193 -#define _loop0_10_type 1194 -#define _gather_9_type 1195 -#define _loop1_11_type 1196 -#define _loop0_13_type 1197 -#define _gather_12_type 1198 -#define _tmp_14_type 1199 -#define _tmp_15_type 1200 -#define _tmp_16_type 1201 -#define _tmp_17_type 1202 -#define _tmp_18_type 1203 -#define _tmp_19_type 1204 -#define _tmp_20_type 1205 -#define _tmp_21_type 1206 -#define _loop1_22_type 1207 -#define _tmp_23_type 1208 -#define _tmp_24_type 1209 -#define _loop0_26_type 1210 -#define _gather_25_type 1211 -#define _loop0_28_type 1212 -#define _gather_27_type 1213 -#define _tmp_29_type 1214 -#define _tmp_30_type 1215 -#define _loop0_31_type 1216 -#define _loop1_32_type 1217 -#define _loop0_34_type 1218 -#define _gather_33_type 1219 -#define _tmp_35_type 1220 -#define _loop0_37_type 1221 -#define _gather_36_type 1222 -#define _tmp_38_type 1223 -#define _loop0_40_type 1224 -#define _gather_39_type 1225 -#define _loop0_42_type 1226 -#define _gather_41_type 1227 -#define _loop0_44_type 1228 -#define _gather_43_type 1229 -#define _loop0_46_type 1230 -#define _gather_45_type 1231 -#define _tmp_47_type 1232 -#define _loop1_48_type 1233 -#define _tmp_49_type 1234 -#define _loop1_50_type 1235 -#define _loop0_52_type 1236 -#define _gather_51_type 1237 -#define _tmp_53_type 1238 -#define _tmp_54_type 1239 -#define _tmp_55_type 1240 -#define _loop0_57_type 1241 -#define _gather_56_type 1242 -#define _loop0_59_type 1243 -#define _gather_58_type 1244 -#define _loop0_61_type 1245 -#define _gather_60_type 1246 -#define _loop0_63_type 1247 -#define _gather_62_type 1248 -#define _tmp_64_type 1249 -#define _loop0_66_type 1250 -#define _gather_65_type 1251 -#define _tmp_67_type 1252 -#define _tmp_68_type 1253 -#define _tmp_69_type 1254 -#define _loop0_71_type 1255 -#define _gather_70_type 1256 -#define _loop0_73_type 1257 -#define _gather_72_type 1258 -#define _tmp_74_type 1259 -#define _tmp_75_type 1260 -#define _tmp_76_type 1261 -#define _tmp_77_type 1262 -#define _tmp_78_type 1263 -#define _tmp_79_type 1264 -#define _loop0_80_type 1265 -#define _loop0_81_type 1266 -#define _loop0_82_type 1267 -#define _loop1_83_type 1268 -#define _loop0_84_type 1269 -#define _loop1_85_type 1270 -#define _loop1_86_type 1271 -#define _loop1_87_type 1272 -#define _loop0_88_type 1273 -#define _loop1_89_type 1274 -#define _loop0_90_type 1275 -#define _loop1_91_type 1276 -#define _loop0_92_type 1277 -#define _loop1_93_type 1278 -#define _loop1_94_type 1279 -#define _tmp_95_type 1280 -#define _loop0_97_type 1281 -#define _gather_96_type 1282 -#define _loop1_98_type 1283 -#define _loop0_100_type 1284 -#define _gather_99_type 1285 -#define _loop1_101_type 1286 -#define _loop0_102_type 1287 -#define _loop0_103_type 1288 -#define _loop0_104_type 1289 -#define _loop1_105_type 1290 -#define _loop0_106_type 1291 -#define _loop1_107_type 1292 -#define _loop1_108_type 1293 -#define _loop1_109_type 1294 -#define _loop0_110_type 1295 -#define _loop1_111_type 1296 -#define _loop0_112_type 1297 -#define _loop1_113_type 1298 -#define _loop0_114_type 1299 -#define _loop1_115_type 1300 -#define _loop1_116_type 1301 -#define _loop1_117_type 1302 -#define _loop1_118_type 1303 -#define _tmp_119_type 1304 -#define _loop0_121_type 1305 -#define _gather_120_type 1306 -#define _tmp_122_type 1307 -#define _tmp_123_type 1308 -#define _tmp_124_type 1309 -#define _tmp_125_type 1310 -#define _loop1_126_type 1311 -#define _tmp_127_type 1312 -#define _tmp_128_type 1313 -#define _loop0_130_type 1314 -#define _gather_129_type 1315 -#define _loop1_131_type 1316 -#define _loop0_132_type 1317 -#define _loop0_133_type 1318 -#define _loop0_135_type 1319 -#define _gather_134_type 1320 -#define _tmp_136_type 1321 -#define _loop0_138_type 1322 -#define _gather_137_type 1323 -#define _loop0_140_type 1324 -#define _gather_139_type 1325 -#define _loop0_142_type 1326 -#define _gather_141_type 1327 -#define _loop0_144_type 1328 -#define _gather_143_type 1329 -#define _loop0_145_type 1330 -#define _loop0_147_type 1331 -#define _gather_146_type 1332 -#define _tmp_148_type 1333 -#define _loop0_150_type 1334 -#define _gather_149_type 1335 -#define _loop0_152_type 1336 -#define _gather_151_type 1337 -#define _tmp_153_type 1338 -#define _loop0_154_type 1339 -#define _loop0_155_type 1340 -#define _loop0_156_type 1341 -#define _tmp_157_type 1342 -#define _tmp_158_type 1343 -#define _loop0_159_type 1344 -#define _tmp_160_type 1345 -#define _loop0_161_type 1346 -#define _tmp_162_type 1347 -#define _tmp_163_type 1348 -#define _tmp_164_type 1349 -#define _tmp_165_type 1350 -#define _tmp_166_type 1351 -#define _tmp_167_type 1352 -#define _loop0_169_type 1353 -#define _gather_168_type 1354 -#define _loop0_171_type 1355 -#define _gather_170_type 1356 -#define _loop0_173_type 1357 -#define _gather_172_type 1358 -#define _loop0_175_type 1359 -#define _gather_174_type 1360 -#define _tmp_176_type 1361 -#define _tmp_177_type 1362 -#define _tmp_178_type 1363 -#define _tmp_179_type 1364 -#define _tmp_180_type 1365 -#define _tmp_181_type 1366 -#define _tmp_182_type 1367 -#define _tmp_183_type 1368 -#define _tmp_184_type 1369 -#define _tmp_185_type 1370 -#define _tmp_186_type 1371 -#define _loop1_187_type 1372 -#define _loop1_188_type 1373 -#define _tmp_189_type 1374 -#define _tmp_190_type 1375 -#define _tmp_191_type 1376 +#define double_star_pattern_type 1063 +#define class_pattern_type 1064 +#define positional_patterns_type 1065 +#define keyword_patterns_type 1066 +#define keyword_pattern_type 1067 +#define return_stmt_type 1068 +#define raise_stmt_type 1069 +#define function_def_type 1070 +#define function_def_raw_type 1071 +#define func_type_comment_type 1072 +#define params_type 1073 +#define parameters_type 1074 +#define slash_no_default_type 1075 +#define slash_with_default_type 1076 +#define star_etc_type 1077 +#define kwds_type 1078 +#define param_no_default_type 1079 +#define param_with_default_type 1080 +#define param_maybe_default_type 1081 +#define param_type 1082 +#define annotation_type 1083 +#define default_type 1084 +#define decorators_type 1085 +#define class_def_type 1086 +#define class_def_raw_type 1087 +#define block_type 1088 +#define expressions_list_type 1089 +#define star_expressions_type 1090 +#define star_expression_type 1091 +#define star_named_expressions_type 1092 +#define star_named_expression_type 1093 +#define named_expression_type 1094 +#define annotated_rhs_type 1095 +#define expressions_type 1096 +#define expression_type 1097 +#define lambdef_type 1098 +#define lambda_params_type 1099 +#define lambda_parameters_type 1100 +#define lambda_slash_no_default_type 1101 +#define lambda_slash_with_default_type 1102 +#define lambda_star_etc_type 1103 +#define lambda_kwds_type 1104 +#define lambda_param_no_default_type 1105 +#define lambda_param_with_default_type 1106 +#define lambda_param_maybe_default_type 1107 +#define lambda_param_type 1108 +#define disjunction_type 1109 +#define conjunction_type 1110 +#define inversion_type 1111 +#define comparison_type 1112 +#define compare_op_bitwise_or_pair_type 1113 +#define eq_bitwise_or_type 1114 +#define noteq_bitwise_or_type 1115 +#define lte_bitwise_or_type 1116 +#define lt_bitwise_or_type 1117 +#define gte_bitwise_or_type 1118 +#define gt_bitwise_or_type 1119 +#define notin_bitwise_or_type 1120 +#define in_bitwise_or_type 1121 +#define isnot_bitwise_or_type 1122 +#define is_bitwise_or_type 1123 +#define bitwise_or_type 1124 // Left-recursive +#define bitwise_xor_type 1125 // Left-recursive +#define bitwise_and_type 1126 // Left-recursive +#define shift_expr_type 1127 // Left-recursive +#define sum_type 1128 // Left-recursive +#define term_type 1129 // Left-recursive +#define factor_type 1130 +#define power_type 1131 +#define await_primary_type 1132 +#define primary_type 1133 // Left-recursive +#define slices_type 1134 +#define slice_type 1135 +#define atom_type 1136 +#define strings_type 1137 +#define list_type 1138 +#define listcomp_type 1139 +#define tuple_type 1140 +#define group_type 1141 +#define genexp_type 1142 +#define set_type 1143 +#define setcomp_type 1144 +#define dict_type 1145 +#define dictcomp_type 1146 +#define double_starred_kvpairs_type 1147 +#define double_starred_kvpair_type 1148 +#define kvpair_type 1149 +#define for_if_clauses_type 1150 +#define for_if_clause_type 1151 +#define yield_expr_type 1152 +#define arguments_type 1153 +#define args_type 1154 +#define kwargs_type 1155 +#define starred_expression_type 1156 +#define kwarg_or_starred_type 1157 +#define kwarg_or_double_starred_type 1158 +#define star_targets_type 1159 +#define star_targets_seq_type 1160 +#define star_target_type 1161 +#define star_atom_type 1162 +#define single_target_type 1163 +#define single_subscript_attribute_target_type 1164 +#define del_targets_type 1165 +#define del_target_type 1166 +#define del_t_atom_type 1167 +#define targets_type 1168 +#define target_type 1169 +#define t_primary_type 1170 // Left-recursive +#define t_lookahead_type 1171 +#define t_atom_type 1172 +#define incorrect_arguments_type 1173 +#define invalid_kwarg_type 1174 +#define invalid_named_expression_type 1175 +#define invalid_assignment_type 1176 +#define invalid_ann_assign_target_type 1177 +#define invalid_del_stmt_type 1178 +#define invalid_block_type 1179 +#define invalid_comprehension_type 1180 +#define invalid_dict_comprehension_type 1181 +#define invalid_parameters_type 1182 +#define invalid_lambda_parameters_type 1183 +#define invalid_star_etc_type 1184 +#define invalid_lambda_star_etc_type 1185 +#define invalid_double_type_comments_type 1186 +#define invalid_with_item_type 1187 +#define invalid_for_target_type 1188 +#define invalid_group_type 1189 +#define invalid_import_from_targets_type 1190 +#define _loop0_1_type 1191 +#define _loop0_2_type 1192 +#define _loop0_4_type 1193 +#define _gather_3_type 1194 +#define _loop0_6_type 1195 +#define _gather_5_type 1196 +#define _loop0_8_type 1197 +#define _gather_7_type 1198 +#define _loop0_10_type 1199 +#define _gather_9_type 1200 +#define _loop1_11_type 1201 +#define _loop0_13_type 1202 +#define _gather_12_type 1203 +#define _tmp_14_type 1204 +#define _tmp_15_type 1205 +#define _tmp_16_type 1206 +#define _tmp_17_type 1207 +#define _tmp_18_type 1208 +#define _tmp_19_type 1209 +#define _tmp_20_type 1210 +#define _tmp_21_type 1211 +#define _loop1_22_type 1212 +#define _tmp_23_type 1213 +#define _tmp_24_type 1214 +#define _loop0_26_type 1215 +#define _gather_25_type 1216 +#define _loop0_28_type 1217 +#define _gather_27_type 1218 +#define _tmp_29_type 1219 +#define _tmp_30_type 1220 +#define _loop0_31_type 1221 +#define _loop1_32_type 1222 +#define _loop0_34_type 1223 +#define _gather_33_type 1224 +#define _tmp_35_type 1225 +#define _loop0_37_type 1226 +#define _gather_36_type 1227 +#define _tmp_38_type 1228 +#define _loop0_40_type 1229 +#define _gather_39_type 1230 +#define _loop0_42_type 1231 +#define _gather_41_type 1232 +#define _loop0_44_type 1233 +#define _gather_43_type 1234 +#define _loop0_46_type 1235 +#define _gather_45_type 1236 +#define _tmp_47_type 1237 +#define _loop1_48_type 1238 +#define _tmp_49_type 1239 +#define _loop1_50_type 1240 +#define _loop0_52_type 1241 +#define _gather_51_type 1242 +#define _tmp_53_type 1243 +#define _tmp_54_type 1244 +#define _tmp_55_type 1245 +#define _loop0_57_type 1246 +#define _gather_56_type 1247 +#define _tmp_58_type 1248 +#define _loop0_60_type 1249 +#define _gather_59_type 1250 +#define _tmp_61_type 1251 +#define _loop0_63_type 1252 +#define _gather_62_type 1253 +#define _loop0_65_type 1254 +#define _gather_64_type 1255 +#define _tmp_66_type 1256 +#define _tmp_67_type 1257 +#define _tmp_68_type 1258 +#define _tmp_69_type 1259 +#define _loop0_70_type 1260 +#define _loop0_71_type 1261 +#define _loop0_72_type 1262 +#define _loop1_73_type 1263 +#define _loop0_74_type 1264 +#define _loop1_75_type 1265 +#define _loop1_76_type 1266 +#define _loop1_77_type 1267 +#define _loop0_78_type 1268 +#define _loop1_79_type 1269 +#define _loop0_80_type 1270 +#define _loop1_81_type 1271 +#define _loop0_82_type 1272 +#define _loop1_83_type 1273 +#define _loop1_84_type 1274 +#define _tmp_85_type 1275 +#define _loop0_87_type 1276 +#define _gather_86_type 1277 +#define _loop1_88_type 1278 +#define _loop0_90_type 1279 +#define _gather_89_type 1280 +#define _loop1_91_type 1281 +#define _loop0_92_type 1282 +#define _loop0_93_type 1283 +#define _loop0_94_type 1284 +#define _loop1_95_type 1285 +#define _loop0_96_type 1286 +#define _loop1_97_type 1287 +#define _loop1_98_type 1288 +#define _loop1_99_type 1289 +#define _loop0_100_type 1290 +#define _loop1_101_type 1291 +#define _loop0_102_type 1292 +#define _loop1_103_type 1293 +#define _loop0_104_type 1294 +#define _loop1_105_type 1295 +#define _loop1_106_type 1296 +#define _loop1_107_type 1297 +#define _loop1_108_type 1298 +#define _tmp_109_type 1299 +#define _loop0_111_type 1300 +#define _gather_110_type 1301 +#define _tmp_112_type 1302 +#define _tmp_113_type 1303 +#define _tmp_114_type 1304 +#define _tmp_115_type 1305 +#define _loop1_116_type 1306 +#define _tmp_117_type 1307 +#define _tmp_118_type 1308 +#define _loop0_120_type 1309 +#define _gather_119_type 1310 +#define _loop1_121_type 1311 +#define _loop0_122_type 1312 +#define _loop0_123_type 1313 +#define _loop0_125_type 1314 +#define _gather_124_type 1315 +#define _tmp_126_type 1316 +#define _loop0_128_type 1317 +#define _gather_127_type 1318 +#define _loop0_130_type 1319 +#define _gather_129_type 1320 +#define _loop0_132_type 1321 +#define _gather_131_type 1322 +#define _loop0_134_type 1323 +#define _gather_133_type 1324 +#define _loop0_135_type 1325 +#define _loop0_137_type 1326 +#define _gather_136_type 1327 +#define _tmp_138_type 1328 +#define _loop0_140_type 1329 +#define _gather_139_type 1330 +#define _loop0_142_type 1331 +#define _gather_141_type 1332 +#define _tmp_143_type 1333 +#define _loop0_144_type 1334 +#define _loop0_145_type 1335 +#define _loop0_146_type 1336 +#define _tmp_147_type 1337 +#define _tmp_148_type 1338 +#define _loop0_149_type 1339 +#define _tmp_150_type 1340 +#define _loop0_151_type 1341 +#define _tmp_152_type 1342 +#define _tmp_153_type 1343 +#define _tmp_154_type 1344 +#define _tmp_155_type 1345 +#define _tmp_156_type 1346 +#define _tmp_157_type 1347 +#define _tmp_158_type 1348 +#define _tmp_159_type 1349 +#define _tmp_160_type 1350 +#define _tmp_161_type 1351 +#define _tmp_162_type 1352 +#define _tmp_163_type 1353 +#define _tmp_164_type 1354 +#define _tmp_165_type 1355 +#define _tmp_166_type 1356 +#define _tmp_167_type 1357 +#define _tmp_168_type 1358 +#define _loop1_169_type 1359 +#define _loop1_170_type 1360 +#define _tmp_171_type 1361 +#define _tmp_172_type 1362 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -482,31 +468,36 @@ static withitem_ty with_item_rule(Parser *p); static stmt_ty try_stmt_rule(Parser *p); static excepthandler_ty except_block_rule(Parser *p); static asdl_stmt_seq* finally_block_rule(Parser *p); -static expr_ty match_expr_rule(Parser *p); static stmt_ty match_stmt_rule(Parser *p); +static expr_ty subject_expr_rule(Parser *p); static match_case_ty case_block_rule(Parser *p); static expr_ty guard_rule(Parser *p); static expr_ty patterns_rule(Parser *p); static expr_ty pattern_rule(Parser *p); +static expr_ty as_pattern_rule(Parser *p); static expr_ty or_pattern_rule(Parser *p); static expr_ty closed_pattern_rule(Parser *p); -static expr_ty name_pattern_rule(Parser *p); static expr_ty literal_pattern_rule(Parser *p); -static expr_ty constant_pattern_rule(Parser *p); -static expr_ty group_pattern_rule(Parser *p); -static expr_ty sequence_pattern_rule(Parser *p); -static expr_ty mapping_pattern_rule(Parser *p); -static expr_ty class_pattern_rule(Parser *p); static expr_ty signed_number_rule(Parser *p); +static expr_ty capture_pattern_rule(Parser *p); +static expr_ty wildcard_pattern_rule(Parser *p); +static expr_ty value_pattern_rule(Parser *p); static expr_ty attr_rule(Parser *p); static expr_ty name_or_attr_rule(Parser *p); -static asdl_seq* values_pattern_rule(Parser *p); +static expr_ty group_pattern_rule(Parser *p); +static expr_ty sequence_pattern_rule(Parser *p); +static expr_ty open_sequence_pattern_rule(Parser *p); +static asdl_seq* maybe_sequence_pattern_rule(Parser *p); +static expr_ty maybe_star_pattern_rule(Parser *p); +static expr_ty star_pattern_rule(Parser *p); +static expr_ty mapping_pattern_rule(Parser *p); static asdl_seq* items_pattern_rule(Parser *p); -static keyword_ty keyword_pattern_rule(Parser *p); -static void *error_argument_pattern_rule(Parser *p); -static expr_ty error_star_rule(Parser *p); -static expr_ty value_pattern_rule(Parser *p); static KeyValuePair* key_value_pattern_rule(Parser *p); +static KeyValuePair* double_star_pattern_rule(Parser *p); +static expr_ty class_pattern_rule(Parser *p); +static asdl_expr_seq* positional_patterns_rule(Parser *p); +static asdl_keyword_seq* keyword_patterns_rule(Parser *p); +static keyword_ty keyword_pattern_rule(Parser *p); static stmt_ty return_stmt_rule(Parser *p); static stmt_ty raise_stmt_rule(Parser *p); static stmt_ty function_def_rule(Parser *p); @@ -687,140 +678,121 @@ static void *_tmp_54_rule(Parser *p); static void *_tmp_55_rule(Parser *p); static asdl_seq *_loop0_57_rule(Parser *p); static asdl_seq *_gather_56_rule(Parser *p); -static asdl_seq *_loop0_59_rule(Parser *p); -static asdl_seq *_gather_58_rule(Parser *p); -static asdl_seq *_loop0_61_rule(Parser *p); -static asdl_seq *_gather_60_rule(Parser *p); +static void *_tmp_58_rule(Parser *p); +static asdl_seq *_loop0_60_rule(Parser *p); +static asdl_seq *_gather_59_rule(Parser *p); +static void *_tmp_61_rule(Parser *p); static asdl_seq *_loop0_63_rule(Parser *p); static asdl_seq *_gather_62_rule(Parser *p); -static void *_tmp_64_rule(Parser *p); -static asdl_seq *_loop0_66_rule(Parser *p); -static asdl_seq *_gather_65_rule(Parser *p); +static asdl_seq *_loop0_65_rule(Parser *p); +static asdl_seq *_gather_64_rule(Parser *p); +static void *_tmp_66_rule(Parser *p); static void *_tmp_67_rule(Parser *p); static void *_tmp_68_rule(Parser *p); static void *_tmp_69_rule(Parser *p); +static asdl_seq *_loop0_70_rule(Parser *p); static asdl_seq *_loop0_71_rule(Parser *p); -static asdl_seq *_gather_70_rule(Parser *p); -static asdl_seq *_loop0_73_rule(Parser *p); -static asdl_seq *_gather_72_rule(Parser *p); -static void *_tmp_74_rule(Parser *p); -static void *_tmp_75_rule(Parser *p); -static void *_tmp_76_rule(Parser *p); -static void *_tmp_77_rule(Parser *p); -static void *_tmp_78_rule(Parser *p); -static void *_tmp_79_rule(Parser *p); +static asdl_seq *_loop0_72_rule(Parser *p); +static asdl_seq *_loop1_73_rule(Parser *p); +static asdl_seq *_loop0_74_rule(Parser *p); +static asdl_seq *_loop1_75_rule(Parser *p); +static asdl_seq *_loop1_76_rule(Parser *p); +static asdl_seq *_loop1_77_rule(Parser *p); +static asdl_seq *_loop0_78_rule(Parser *p); +static asdl_seq *_loop1_79_rule(Parser *p); static asdl_seq *_loop0_80_rule(Parser *p); -static asdl_seq *_loop0_81_rule(Parser *p); +static asdl_seq *_loop1_81_rule(Parser *p); static asdl_seq *_loop0_82_rule(Parser *p); static asdl_seq *_loop1_83_rule(Parser *p); -static asdl_seq *_loop0_84_rule(Parser *p); -static asdl_seq *_loop1_85_rule(Parser *p); -static asdl_seq *_loop1_86_rule(Parser *p); -static asdl_seq *_loop1_87_rule(Parser *p); -static asdl_seq *_loop0_88_rule(Parser *p); -static asdl_seq *_loop1_89_rule(Parser *p); +static asdl_seq *_loop1_84_rule(Parser *p); +static void *_tmp_85_rule(Parser *p); +static asdl_seq *_loop0_87_rule(Parser *p); +static asdl_seq *_gather_86_rule(Parser *p); +static asdl_seq *_loop1_88_rule(Parser *p); static asdl_seq *_loop0_90_rule(Parser *p); +static asdl_seq *_gather_89_rule(Parser *p); static asdl_seq *_loop1_91_rule(Parser *p); static asdl_seq *_loop0_92_rule(Parser *p); -static asdl_seq *_loop1_93_rule(Parser *p); -static asdl_seq *_loop1_94_rule(Parser *p); -static void *_tmp_95_rule(Parser *p); -static asdl_seq *_loop0_97_rule(Parser *p); -static asdl_seq *_gather_96_rule(Parser *p); +static asdl_seq *_loop0_93_rule(Parser *p); +static asdl_seq *_loop0_94_rule(Parser *p); +static asdl_seq *_loop1_95_rule(Parser *p); +static asdl_seq *_loop0_96_rule(Parser *p); +static asdl_seq *_loop1_97_rule(Parser *p); static asdl_seq *_loop1_98_rule(Parser *p); +static asdl_seq *_loop1_99_rule(Parser *p); static asdl_seq *_loop0_100_rule(Parser *p); -static asdl_seq *_gather_99_rule(Parser *p); static asdl_seq *_loop1_101_rule(Parser *p); static asdl_seq *_loop0_102_rule(Parser *p); -static asdl_seq *_loop0_103_rule(Parser *p); +static asdl_seq *_loop1_103_rule(Parser *p); static asdl_seq *_loop0_104_rule(Parser *p); static asdl_seq *_loop1_105_rule(Parser *p); -static asdl_seq *_loop0_106_rule(Parser *p); +static asdl_seq *_loop1_106_rule(Parser *p); static asdl_seq *_loop1_107_rule(Parser *p); static asdl_seq *_loop1_108_rule(Parser *p); -static asdl_seq *_loop1_109_rule(Parser *p); -static asdl_seq *_loop0_110_rule(Parser *p); -static asdl_seq *_loop1_111_rule(Parser *p); -static asdl_seq *_loop0_112_rule(Parser *p); -static asdl_seq *_loop1_113_rule(Parser *p); -static asdl_seq *_loop0_114_rule(Parser *p); -static asdl_seq *_loop1_115_rule(Parser *p); +static void *_tmp_109_rule(Parser *p); +static asdl_seq *_loop0_111_rule(Parser *p); +static asdl_seq *_gather_110_rule(Parser *p); +static void *_tmp_112_rule(Parser *p); +static void *_tmp_113_rule(Parser *p); +static void *_tmp_114_rule(Parser *p); +static void *_tmp_115_rule(Parser *p); static asdl_seq *_loop1_116_rule(Parser *p); -static asdl_seq *_loop1_117_rule(Parser *p); -static asdl_seq *_loop1_118_rule(Parser *p); -static void *_tmp_119_rule(Parser *p); -static asdl_seq *_loop0_121_rule(Parser *p); -static asdl_seq *_gather_120_rule(Parser *p); -static void *_tmp_122_rule(Parser *p); -static void *_tmp_123_rule(Parser *p); -static void *_tmp_124_rule(Parser *p); -static void *_tmp_125_rule(Parser *p); -static asdl_seq *_loop1_126_rule(Parser *p); -static void *_tmp_127_rule(Parser *p); -static void *_tmp_128_rule(Parser *p); +static void *_tmp_117_rule(Parser *p); +static void *_tmp_118_rule(Parser *p); +static asdl_seq *_loop0_120_rule(Parser *p); +static asdl_seq *_gather_119_rule(Parser *p); +static asdl_seq *_loop1_121_rule(Parser *p); +static asdl_seq *_loop0_122_rule(Parser *p); +static asdl_seq *_loop0_123_rule(Parser *p); +static asdl_seq *_loop0_125_rule(Parser *p); +static asdl_seq *_gather_124_rule(Parser *p); +static void *_tmp_126_rule(Parser *p); +static asdl_seq *_loop0_128_rule(Parser *p); +static asdl_seq *_gather_127_rule(Parser *p); static asdl_seq *_loop0_130_rule(Parser *p); static asdl_seq *_gather_129_rule(Parser *p); -static asdl_seq *_loop1_131_rule(Parser *p); static asdl_seq *_loop0_132_rule(Parser *p); -static asdl_seq *_loop0_133_rule(Parser *p); +static asdl_seq *_gather_131_rule(Parser *p); +static asdl_seq *_loop0_134_rule(Parser *p); +static asdl_seq *_gather_133_rule(Parser *p); static asdl_seq *_loop0_135_rule(Parser *p); -static asdl_seq *_gather_134_rule(Parser *p); -static void *_tmp_136_rule(Parser *p); -static asdl_seq *_loop0_138_rule(Parser *p); -static asdl_seq *_gather_137_rule(Parser *p); +static asdl_seq *_loop0_137_rule(Parser *p); +static asdl_seq *_gather_136_rule(Parser *p); +static void *_tmp_138_rule(Parser *p); static asdl_seq *_loop0_140_rule(Parser *p); static asdl_seq *_gather_139_rule(Parser *p); static asdl_seq *_loop0_142_rule(Parser *p); static asdl_seq *_gather_141_rule(Parser *p); +static void *_tmp_143_rule(Parser *p); static asdl_seq *_loop0_144_rule(Parser *p); -static asdl_seq *_gather_143_rule(Parser *p); static asdl_seq *_loop0_145_rule(Parser *p); -static asdl_seq *_loop0_147_rule(Parser *p); -static asdl_seq *_gather_146_rule(Parser *p); +static asdl_seq *_loop0_146_rule(Parser *p); +static void *_tmp_147_rule(Parser *p); static void *_tmp_148_rule(Parser *p); -static asdl_seq *_loop0_150_rule(Parser *p); -static asdl_seq *_gather_149_rule(Parser *p); -static asdl_seq *_loop0_152_rule(Parser *p); -static asdl_seq *_gather_151_rule(Parser *p); +static asdl_seq *_loop0_149_rule(Parser *p); +static void *_tmp_150_rule(Parser *p); +static asdl_seq *_loop0_151_rule(Parser *p); +static void *_tmp_152_rule(Parser *p); static void *_tmp_153_rule(Parser *p); -static asdl_seq *_loop0_154_rule(Parser *p); -static asdl_seq *_loop0_155_rule(Parser *p); -static asdl_seq *_loop0_156_rule(Parser *p); +static void *_tmp_154_rule(Parser *p); +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 void *_tmp_160_rule(Parser *p); -static asdl_seq *_loop0_161_rule(Parser *p); +static void *_tmp_161_rule(Parser *p); static void *_tmp_162_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 void *_tmp_167_rule(Parser *p); -static asdl_seq *_loop0_169_rule(Parser *p); -static asdl_seq *_gather_168_rule(Parser *p); -static asdl_seq *_loop0_171_rule(Parser *p); -static asdl_seq *_gather_170_rule(Parser *p); -static asdl_seq *_loop0_173_rule(Parser *p); -static asdl_seq *_gather_172_rule(Parser *p); -static asdl_seq *_loop0_175_rule(Parser *p); -static asdl_seq *_gather_174_rule(Parser *p); -static void *_tmp_176_rule(Parser *p); -static void *_tmp_177_rule(Parser *p); -static void *_tmp_178_rule(Parser *p); -static void *_tmp_179_rule(Parser *p); -static void *_tmp_180_rule(Parser *p); -static void *_tmp_181_rule(Parser *p); -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 asdl_seq *_loop1_187_rule(Parser *p); -static asdl_seq *_loop1_188_rule(Parser *p); -static void *_tmp_189_rule(Parser *p); -static void *_tmp_190_rule(Parser *p); -static void *_tmp_191_rule(Parser *p); +static void *_tmp_168_rule(Parser *p); +static asdl_seq *_loop1_169_rule(Parser *p); +static asdl_seq *_loop1_170_rule(Parser *p); +static void *_tmp_171_rule(Parser *p); +static void *_tmp_172_rule(Parser *p); // file: statements? $ @@ -4800,16 +4772,16 @@ finally_block_rule(Parser *p) return _res; } -// match_expr: star_named_expression ',' star_named_expressions? | named_expression -static expr_ty -match_expr_rule(Parser *p) +// match_stmt: "match" subject_expr ':' NEWLINE INDENT case_block+ DEDENT +static stmt_ty +match_stmt_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + stmt_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -4820,24 +4792,36 @@ match_expr_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // star_named_expression ',' star_named_expressions? + { // "match" subject_expr ':' NEWLINE INDENT case_block+ DEDENT if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> match_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c> match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"match\" subject_expr ':' NEWLINE INDENT case_block+ DEDENT")); + expr_ty _keyword; Token * _literal; - expr_ty value; - void *values; + asdl_match_case_seq* cases; + Token * dedent_var; + Token * indent_var; + Token * newline_var; + expr_ty subject; if ( - (value = star_named_expression_rule(p)) // star_named_expression + (_keyword = _PyPegen_expect_soft_keyword(p, "match")) // soft_keyword='"match"' && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (subject = subject_expr_rule(p)) // subject_expr && - (values = star_named_expressions_rule(p), 1) // star_named_expressions? + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' + && + (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' + && + (cases = (asdl_match_case_seq*)_loop1_50_rule(p)) // case_block+ + && + (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' ) { - D(fprintf(stderr, "%*c+ match_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c+ match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"match\" subject_expr ':' NEWLINE INDENT case_block+ DEDENT")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -4847,7 +4831,7 @@ match_expr_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , value , values ) ) , Load , EXTRA ); + _res = CHECK_VERSION ( 10 , "Pattern matching is" , _Py_Match ( subject , cases , EXTRA ) ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -4856,27 +4840,8 @@ match_expr_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s match_expr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); - } - { // named_expression - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> match_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); - expr_ty named_expression_var; - if ( - (named_expression_var = named_expression_rule(p)) // named_expression - ) - { - D(fprintf(stderr, "%*c+ match_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); - _res = named_expression_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s match_expr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c%s match_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"match\" subject_expr ':' NEWLINE INDENT case_block+ DEDENT")); } _res = NULL; done: @@ -4884,16 +4849,16 @@ match_expr_rule(Parser *p) return _res; } -// match_stmt: "match" match_expr ':' NEWLINE INDENT case_block+ DEDENT -static stmt_ty -match_stmt_rule(Parser *p) +// subject_expr: star_named_expression ',' star_named_expressions? | named_expression +static expr_ty +subject_expr_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - stmt_ty _res = NULL; + expr_ty _res = NULL; int _mark = p->mark; if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { p->error_indicator = 1; @@ -4904,36 +4869,24 @@ match_stmt_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // "match" match_expr ':' NEWLINE INDENT case_block+ DEDENT + { // star_named_expression ',' star_named_expressions? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"match\" match_expr ':' NEWLINE INDENT case_block+ DEDENT")); - expr_ty _keyword; + D(fprintf(stderr, "%*c> subject_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); Token * _literal; - asdl_match_case_seq* cases; - Token * dedent_var; - Token * indent_var; - Token * newline_var; - expr_ty subject; + expr_ty value; + void *values; if ( - (_keyword = _PyPegen_expect_soft_keyword(p, "match")) // soft_keyword='"match"' - && - (subject = match_expr_rule(p)) // match_expr - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' + (value = star_named_expression_rule(p)) // star_named_expression && - (cases = (asdl_match_case_seq*)_loop1_50_rule(p)) // case_block+ + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' + (values = star_named_expressions_rule(p), 1) // star_named_expressions? ) { - D(fprintf(stderr, "%*c+ match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"match\" match_expr ':' NEWLINE INDENT case_block+ DEDENT")); + D(fprintf(stderr, "%*c+ subject_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -4943,7 +4896,7 @@ match_stmt_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = CHECK_VERSION ( 10 , "Pattern matching is" , _Py_Match ( subject , cases , EXTRA ) ); + _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , value , values ) ) , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -4952,8 +4905,27 @@ match_stmt_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s match_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"match\" match_expr ':' NEWLINE INDENT case_block+ DEDENT")); + D(fprintf(stderr, "%*c%s subject_expr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + } + { // named_expression + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> subject_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); + expr_ty named_expression_var; + if ( + (named_expression_var = named_expression_rule(p)) // named_expression + ) + { + D(fprintf(stderr, "%*c+ subject_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + _res = named_expression_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s subject_expr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); } _res = NULL; done: @@ -5058,7 +5030,7 @@ guard_rule(Parser *p) return _res; } -// patterns: value_pattern ',' values_pattern? | pattern +// patterns: open_sequence_pattern | pattern static expr_ty patterns_rule(Parser *p) { @@ -5069,53 +5041,24 @@ patterns_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // value_pattern ',' values_pattern? + { // open_sequence_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> patterns[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern ',' values_pattern?")); - Token * _literal; - expr_ty value; - void *values; + D(fprintf(stderr, "%*c> patterns[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "open_sequence_pattern")); + expr_ty open_sequence_pattern_var; if ( - (value = value_pattern_rule(p)) // value_pattern - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (values = values_pattern_rule(p), 1) // values_pattern? + (open_sequence_pattern_var = open_sequence_pattern_rule(p)) // open_sequence_pattern ) { - D(fprintf(stderr, "%*c+ patterns[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern ',' values_pattern?")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , value , values ) ) , Load , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ patterns[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "open_sequence_pattern")); + _res = open_sequence_pattern_var; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s patterns[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern ',' values_pattern?")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "open_sequence_pattern")); } { // pattern if (p->error_indicator) { @@ -5142,9 +5085,64 @@ patterns_rule(Parser *p) return _res; } -// pattern: or_pattern 'as' NAME | or_pattern +// pattern: as_pattern | or_pattern static expr_ty pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + { // as_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "as_pattern")); + expr_ty as_pattern_var; + if ( + (as_pattern_var = as_pattern_rule(p)) // as_pattern + ) + { + D(fprintf(stderr, "%*c+ pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "as_pattern")); + _res = as_pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "as_pattern")); + } + { // or_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "or_pattern")); + expr_ty or_pattern_var; + if ( + (or_pattern_var = or_pattern_rule(p)) // or_pattern + ) + { + D(fprintf(stderr, "%*c+ pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "or_pattern")); + _res = or_pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "or_pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// as_pattern: or_pattern 'as' capture_pattern +static expr_ty +as_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -5162,24 +5160,24 @@ pattern_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // or_pattern 'as' NAME + { // or_pattern 'as' capture_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' NAME")); + D(fprintf(stderr, "%*c> as_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' capture_pattern")); Token * _keyword; + expr_ty pattern; expr_ty target; - expr_ty value; if ( - (value = or_pattern_rule(p)) // or_pattern + (pattern = or_pattern_rule(p)) // or_pattern && (_keyword = _PyPegen_expect_token(p, 520)) // token='as' && - (target = _PyPegen_name_token(p)) // NAME + (target = capture_pattern_rule(p)) // capture_pattern ) { - D(fprintf(stderr, "%*c+ pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' NAME")); + D(fprintf(stderr, "%*c+ as_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' capture_pattern")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5189,7 +5187,7 @@ pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_MatchAs ( value , target -> v . Name . id , EXTRA ); + _res = _Py_MatchAs ( pattern , target -> v . Name . id , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5198,27 +5196,8 @@ pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "or_pattern 'as' NAME")); - } - { // or_pattern - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "or_pattern")); - expr_ty or_pattern_var; - if ( - (or_pattern_var = or_pattern_rule(p)) // or_pattern - ) - { - D(fprintf(stderr, "%*c+ pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "or_pattern")); - _res = or_pattern_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "or_pattern")); + D(fprintf(stderr, "%*c%s as_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "or_pattern 'as' capture_pattern")); } _res = NULL; done: @@ -5252,9 +5231,9 @@ or_pattern_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> or_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|'.closed_pattern+")); - asdl_expr_seq* values; + asdl_expr_seq* patterns; if ( - (values = (asdl_expr_seq*)_gather_51_rule(p)) // '|'.closed_pattern+ + (patterns = (asdl_expr_seq*)_gather_51_rule(p)) // '|'.closed_pattern+ ) { D(fprintf(stderr, "%*c+ or_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'|'.closed_pattern+")); @@ -5267,7 +5246,7 @@ or_pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = asdl_seq_LEN ( values ) == 1 ? asdl_seq_GET ( values , 0 ) : _Py_MatchOr ( values , EXTRA ); + _res = asdl_seq_LEN ( patterns ) == 1 ? asdl_seq_GET ( patterns , 0 ) : _Py_MatchOr ( patterns , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5286,9 +5265,10 @@ or_pattern_rule(Parser *p) } // closed_pattern: -// | name_pattern // | literal_pattern -// | constant_pattern +// | capture_pattern +// | wildcard_pattern +// | value_pattern // | group_pattern // | sequence_pattern // | mapping_pattern @@ -5303,62 +5283,81 @@ closed_pattern_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; - { // name_pattern + { // literal_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_pattern")); - expr_ty name_pattern_var; + D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + expr_ty literal_pattern_var; if ( - (name_pattern_var = name_pattern_rule(p)) // name_pattern + (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern ) { - D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_pattern")); - _res = name_pattern_var; + D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + _res = literal_pattern_var; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern")); } - { // literal_pattern + { // capture_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); - expr_ty literal_pattern_var; + D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "capture_pattern")); + expr_ty capture_pattern_var; if ( - (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern + (capture_pattern_var = capture_pattern_rule(p)) // capture_pattern ) { - D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); - _res = literal_pattern_var; + D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "capture_pattern")); + _res = capture_pattern_var; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "capture_pattern")); + } + { // wildcard_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "wildcard_pattern")); + expr_ty wildcard_pattern_var; + if ( + (wildcard_pattern_var = wildcard_pattern_rule(p)) // wildcard_pattern + ) + { + D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "wildcard_pattern")); + _res = wildcard_pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "wildcard_pattern")); } - { // constant_pattern + { // value_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern")); - expr_ty constant_pattern_var; + D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern")); + expr_ty value_pattern_var; if ( - (constant_pattern_var = constant_pattern_rule(p)) // constant_pattern + (value_pattern_var = value_pattern_rule(p)) // value_pattern ) { - D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "constant_pattern")); - _res = constant_pattern_var; + D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern")); + _res = value_pattern_var; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "constant_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern")); } { // group_pattern if (p->error_indicator) { @@ -5442,9 +5441,16 @@ closed_pattern_rule(Parser *p) return _res; } -// name_pattern: NAME !('.' | '(' | '=') +// literal_pattern: +// | signed_number !('+' | '-') +// | signed_number '+' NUMBER +// | signed_number '-' NUMBER +// | strings +// | 'None' +// | 'True' +// | 'False' static expr_ty -name_pattern_rule(Parser *p) +literal_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -5453,77 +5459,27 @@ name_pattern_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; - { // NAME !('.' | '(' | '=') + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // signed_number !('+' | '-') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> name_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME !('.' | '(' | '=')")); - expr_ty name; + D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "signed_number !('+' | '-')")); + expr_ty signed_number_var; if ( - (name = _PyPegen_name_token(p)) // NAME + (signed_number_var = signed_number_rule(p)) // signed_number && _PyPegen_lookahead(0, _tmp_53_rule, p) ) - { - D(fprintf(stderr, "%*c+ name_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME !('.' | '(' | '=')")); - _res = _PyPegen_set_expr_context ( p , name , Store ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s name_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME !('.' | '(' | '=')")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// literal_pattern: -// | signed_number !('+' | '-') -// | signed_number '+' NUMBER -// | signed_number '-' NUMBER -// | strings -// | 'None' -// | 'True' -// | 'False' -static expr_ty -literal_pattern_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - expr_ty _res = NULL; - int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // signed_number !('+' | '-') - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "signed_number !('+' | '-')")); - expr_ty signed_number_var; - if ( - (signed_number_var = signed_number_rule(p)) // signed_number - && - _PyPegen_lookahead(0, _tmp_54_rule, p) - ) { D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "signed_number !('+' | '-')")); _res = signed_number_var; @@ -5735,9 +5691,9 @@ literal_pattern_rule(Parser *p) return _res; } -// constant_pattern: attr !('.' | '(' | '=') +// signed_number: NUMBER | '-' NUMBER static expr_ty -constant_pattern_rule(Parser *p) +signed_number_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -5746,21 +5702,59 @@ constant_pattern_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; - { // attr !('.' | '(' | '=') + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // NUMBER if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> constant_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "attr !('.' | '(' | '=')")); - expr_ty attr; + D(fprintf(stderr, "%*c> signed_number[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NUMBER")); + expr_ty number_var; if ( - (attr = attr_rule(p)) // attr + (number_var = _PyPegen_number_token(p)) // NUMBER + ) + { + D(fprintf(stderr, "%*c+ signed_number[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NUMBER")); + _res = number_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s signed_number[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER")); + } + { // '-' NUMBER + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> signed_number[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-' NUMBER")); + Token * _literal; + expr_ty number; + if ( + (_literal = _PyPegen_expect_token(p, 15)) // token='-' && - _PyPegen_lookahead(0, _tmp_55_rule, p) + (number = _PyPegen_number_token(p)) // NUMBER ) { - D(fprintf(stderr, "%*c+ constant_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "attr !('.' | '(' | '=')")); - _res = attr; + D(fprintf(stderr, "%*c+ signed_number[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-' NUMBER")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_UnaryOp ( USub , number , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5769,8 +5763,8 @@ constant_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s constant_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "attr !('.' | '(' | '=')")); + D(fprintf(stderr, "%*c%s signed_number[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-' NUMBER")); } _res = NULL; done: @@ -5778,9 +5772,9 @@ constant_pattern_rule(Parser *p) return _res; } -// group_pattern: '(' patterns ')' +// capture_pattern: !"_" NAME !('.' | '(' | '=') static expr_ty -group_pattern_rule(Parser *p) +capture_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -5789,25 +5783,23 @@ group_pattern_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; - { // '(' patterns ')' + { // !"_" NAME !('.' | '(' | '=') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> group_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' patterns ')'")); - Token * _literal; - Token * _literal_1; - expr_ty pattern; + D(fprintf(stderr, "%*c> capture_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!\"_\" NAME !('.' | '(' | '=')")); + expr_ty name; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' + _PyPegen_lookahead_with_string(0, _PyPegen_expect_soft_keyword, p, "_") && - (pattern = patterns_rule(p)) // patterns + (name = _PyPegen_name_token(p)) // NAME && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + _PyPegen_lookahead(0, _tmp_54_rule, p) ) { - D(fprintf(stderr, "%*c+ group_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' patterns ')'")); - _res = pattern; + D(fprintf(stderr, "%*c+ capture_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!\"_\" NAME !('.' | '(' | '=')")); + _res = _PyPegen_set_expr_context ( p , name , Store ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5816,8 +5808,8 @@ group_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s group_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' patterns ')'")); + D(fprintf(stderr, "%*c%s capture_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!\"_\" NAME !('.' | '(' | '=')")); } _res = NULL; done: @@ -5825,9 +5817,9 @@ group_pattern_rule(Parser *p) return _res; } -// sequence_pattern: '[' values_pattern? ']' | '(' ')' +// wildcard_pattern: "_" static expr_ty -sequence_pattern_rule(Parser *p) +wildcard_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -5845,24 +5837,18 @@ sequence_pattern_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '[' values_pattern? ']' + { // "_" if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' values_pattern? ']'")); - Token * _literal; - Token * _literal_1; - void *values; + D(fprintf(stderr, "%*c> wildcard_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"_\"")); + expr_ty _keyword; if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - && - (values = values_pattern_rule(p), 1) // values_pattern? - && - (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + (_keyword = _PyPegen_expect_soft_keyword(p, "_")) // soft_keyword='"_"' ) { - D(fprintf(stderr, "%*c+ sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' values_pattern? ']'")); + D(fprintf(stderr, "%*c+ wildcard_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"_\"")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5872,7 +5858,7 @@ sequence_pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_List ( values , Load , EXTRA ); + _res = _Py_Name ( CHECK ( _PyPegen_new_identifier ( p , "_" ) ) , Store , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5881,34 +5867,41 @@ sequence_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' values_pattern? ']'")); + D(fprintf(stderr, "%*c%s wildcard_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"_\"")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// value_pattern: attr !('.' | '(' | '=') +static expr_ty +value_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; } - { // '(' ')' + expr_ty _res = NULL; + int _mark = p->mark; + { // attr !('.' | '(' | '=') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' ')'")); - Token * _literal; - Token * _literal_1; + D(fprintf(stderr, "%*c> value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "attr !('.' | '(' | '=')")); + expr_ty attr; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' + (attr = attr_rule(p)) // attr && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + _PyPegen_lookahead(0, _tmp_55_rule, p) ) { - D(fprintf(stderr, "%*c+ sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' ')'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( NULL , Load , EXTRA ); + D(fprintf(stderr, "%*c+ value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "attr !('.' | '(' | '=')")); + _res = attr; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5917,8 +5910,8 @@ sequence_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' ')'")); + D(fprintf(stderr, "%*c%s value_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "attr !('.' | '(' | '=')")); } _res = NULL; done: @@ -5926,9 +5919,39 @@ sequence_pattern_rule(Parser *p) return _res; } -// mapping_pattern: '{' items_pattern? '}' +// Left-recursive +// attr: name_or_attr '.' NAME +static expr_ty attr_raw(Parser *); static expr_ty -mapping_pattern_rule(Parser *p) +attr_rule(Parser *p) +{ + D(p->level++); + expr_ty _res = NULL; + if (_PyPegen_is_memoized(p, attr_type, &_res)) { + D(p->level--); + return _res; + } + int _mark = p->mark; + int _resmark = p->mark; + while (1) { + int tmpvar_1 = _PyPegen_update_memo(p, _mark, attr_type, _res); + if (tmpvar_1) { + D(p->level--); + return _res; + } + p->mark = _mark; + void *_raw = attr_raw(p); + if (_raw == NULL || p->mark <= _resmark) + break; + _resmark = p->mark; + _res = _raw; + } + p->mark = _resmark; + D(p->level--); + return _res; +} +static expr_ty +attr_raw(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -5946,24 +5969,24 @@ mapping_pattern_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '{' items_pattern? '}' + { // name_or_attr '.' NAME if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> mapping_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' items_pattern? '}'")); + D(fprintf(stderr, "%*c> attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME")); Token * _literal; - Token * _literal_1; - void *items; + expr_ty attr; + expr_ty value; if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' + (value = name_or_attr_rule(p)) // name_or_attr && - (items = items_pattern_rule(p), 1) // items_pattern? + (_literal = _PyPegen_expect_token(p, 23)) // token='.' && - (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' + (attr = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ mapping_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' items_pattern? '}'")); + D(fprintf(stderr, "%*c+ attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -5973,7 +5996,7 @@ mapping_pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , items ) ) , CHECK ( _PyPegen_get_values ( p , items ) ) , EXTRA ); + _res = _Py_Attribute ( value , attr -> v . Name . id , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -5982,8 +6005,8 @@ mapping_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s mapping_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' items_pattern? '}'")); + D(fprintf(stderr, "%*c%s attr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '.' NAME")); } _res = NULL; done: @@ -5991,15 +6014,10 @@ mapping_pattern_rule(Parser *p) return _res; } -// class_pattern: -// | name_or_attr '(' ')' -// | name_or_attr '(' ','.pattern+ ','? ')' -// | name_or_attr '(' ','.keyword_pattern+ ','? ')' -// | name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')' -// | name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.error_argument_pattern+] ','? ')' -// | name_or_attr '(' [','.error_argument_pattern+ ','] error_star [',' ','.(error_argument_pattern | error_star)+] ','? ')' +// Left-recursive +// name_or_attr: attr | NAME static expr_ty -class_pattern_rule(Parser *p) +name_or_attr_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -6008,89 +6026,80 @@ class_pattern_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // name_or_attr '(' ')' + { // attr if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ')'")); - Token * _literal; - Token * _literal_1; - expr_ty func; + D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "attr")); + expr_ty attr_var; if ( - (func = name_or_attr_rule(p)) // name_or_attr - && - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (attr_var = attr_rule(p)) // attr ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ')'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Call ( func , NULL , NULL , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ name_or_attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "attr")); + _res = attr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ')'")); + D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "attr")); + } + { // NAME + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); + expr_ty name_var; + if ( + (name_var = _PyPegen_name_token(p)) // NAME + ) + { + D(fprintf(stderr, "%*c+ name_or_attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); + _res = name_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// group_pattern: '(' pattern ')' +static expr_ty +group_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; } - { // name_or_attr '(' ','.pattern+ ','? ')' + expr_ty _res = NULL; + int _mark = p->mark; + { // '(' pattern ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ','? ')'")); + D(fprintf(stderr, "%*c> group_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' pattern ')'")); Token * _literal; Token * _literal_1; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - asdl_expr_seq* args; - expr_ty func; + expr_ty pattern; if ( - (func = name_or_attr_rule(p)) // name_or_attr - && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (args = (asdl_expr_seq*)_gather_56_rule(p)) // ','.pattern+ - && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + (pattern = pattern_rule(p)) // pattern && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ','? ')'")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Call ( func , args , NULL , EXTRA ); + D(fprintf(stderr, "%*c+ group_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' pattern ')'")); + _res = pattern; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6099,34 +6108,53 @@ class_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.pattern+ ','? ')'")); + D(fprintf(stderr, "%*c%s group_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' pattern ')'")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// sequence_pattern: '[' maybe_sequence_pattern? ']' | '(' open_sequence_pattern? ')' +static expr_ty +sequence_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; } - { // name_or_attr '(' ','.keyword_pattern+ ','? ')' + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // '[' maybe_sequence_pattern? ']' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.keyword_pattern+ ','? ')'")); + D(fprintf(stderr, "%*c> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' maybe_sequence_pattern? ']'")); Token * _literal; Token * _literal_1; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty func; - asdl_keyword_seq* keywords; + void *values; if ( - (func = name_or_attr_rule(p)) // name_or_attr - && - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (keywords = (asdl_keyword_seq*)_gather_58_rule(p)) // ','.keyword_pattern+ + (_literal = _PyPegen_expect_token(p, 9)) // token='[' && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + (values = maybe_sequence_pattern_rule(p), 1) // maybe_sequence_pattern? && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.keyword_pattern+ ','? ')'")); + D(fprintf(stderr, "%*c+ sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' maybe_sequence_pattern? ']'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -6136,7 +6164,7 @@ class_pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Call ( func , NULL , keywords , EXTRA ); + _res = _Py_List ( values , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6145,40 +6173,27 @@ class_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.keyword_pattern+ ','? ')'")); + D(fprintf(stderr, "%*c%s sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' maybe_sequence_pattern? ']'")); } - { // name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')' + { // '(' open_sequence_pattern? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'")); + D(fprintf(stderr, "%*c> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' open_sequence_pattern? ')'")); Token * _literal; Token * _literal_1; - Token * _literal_2; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - asdl_expr_seq* args; - expr_ty func; - asdl_keyword_seq* keywords; + void *values; if ( - (func = name_or_attr_rule(p)) // name_or_attr - && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (args = (asdl_expr_seq*)_gather_60_rule(p)) // ','.pattern+ - && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' - && - (keywords = (asdl_keyword_seq*)_gather_62_rule(p)) // ','.keyword_pattern+ + (values = open_sequence_pattern_rule(p), 1) // open_sequence_pattern? && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? - && - (_literal_2 = _PyPegen_expect_token(p, 8)) // token=')' + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'")); + D(fprintf(stderr, "%*c+ sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' open_sequence_pattern? ')'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -6188,7 +6203,7 @@ class_pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Call ( func , args , keywords , EXTRA ); + _res = values ? values : _Py_Tuple ( values , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6197,49 +6212,63 @@ class_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ','.pattern+ ',' ','.keyword_pattern+ ','? ')'")); + D(fprintf(stderr, "%*c%s sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' open_sequence_pattern? ')'")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// open_sequence_pattern: maybe_star_pattern ',' maybe_sequence_pattern? +static expr_ty +open_sequence_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; } - { // name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.error_argument_pattern+] ','? ')' + expr_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // maybe_star_pattern ',' maybe_sequence_pattern? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.error_argument_pattern+] ','? ')'")); - asdl_seq * _gather_65_var; + D(fprintf(stderr, "%*c> open_sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern ',' maybe_sequence_pattern?")); Token * _literal; - Token * _literal_1; - Token * _literal_2; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - void *_opt_var_2; - UNUSED(_opt_var_2); // Silence compiler warnings - expr_ty error; - expr_ty func; + expr_ty value; + void *values; if ( - (func = name_or_attr_rule(p)) // name_or_attr - && - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (_opt_var = _tmp_64_rule(p), 1) // [','.pattern+ ','] - && - (_gather_65_var = _gather_65_rule(p)) // ','.keyword_pattern+ - && - (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' - && - (error = pattern_rule(p)) // pattern + (value = maybe_star_pattern_rule(p)) // maybe_star_pattern && - (_opt_var_1 = _tmp_67_rule(p), 1) // [',' ','.error_argument_pattern+] - && - (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_literal_2 = _PyPegen_expect_token(p, 8)) // token=')' + (values = maybe_sequence_pattern_rule(p), 1) // maybe_sequence_pattern? ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.error_argument_pattern+] ','? ')'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "positional pattern follows keyword pattern" ); + D(fprintf(stderr, "%*c+ open_sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern ',' maybe_sequence_pattern?")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , value , values ) ) , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6248,43 +6277,43 @@ class_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' [','.pattern+ ','] ','.keyword_pattern+ ',' pattern [',' ','.error_argument_pattern+] ','? ')'")); + D(fprintf(stderr, "%*c%s open_sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "maybe_star_pattern ',' maybe_sequence_pattern?")); } - { // name_or_attr '(' [','.error_argument_pattern+ ','] error_star [',' ','.(error_argument_pattern | error_star)+] ','? ')' + _res = NULL; + done: + D(p->level--); + return _res; +} + +// maybe_sequence_pattern: ','.maybe_star_pattern+ ','? +static asdl_seq* +maybe_sequence_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq* _res = NULL; + int _mark = p->mark; + { // ','.maybe_star_pattern+ ','? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.error_argument_pattern+ ','] error_star [',' ','.(error_argument_pattern | error_star)+] ','? ')'")); - Token * _literal; - Token * _literal_1; + D(fprintf(stderr, "%*c> maybe_sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.maybe_star_pattern+ ','?")); void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings - void *_opt_var_1; - UNUSED(_opt_var_1); // Silence compiler warnings - void *_opt_var_2; - UNUSED(_opt_var_2); // Silence compiler warnings - expr_ty error; - expr_ty func; + asdl_seq * values; if ( - (func = name_or_attr_rule(p)) // name_or_attr - && - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (_opt_var = _tmp_68_rule(p), 1) // [','.error_argument_pattern+ ','] - && - (error = error_star_rule(p)) // error_star + (values = _gather_56_rule(p)) // ','.maybe_star_pattern+ && - (_opt_var_1 = _tmp_69_rule(p), 1) // [',' ','.(error_argument_pattern | error_star)+] - && - (_opt_var_2 = _PyPegen_expect_token(p, 12), 1) // ','? - && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) { - D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' [','.error_argument_pattern+ ','] error_star [',' ','.(error_argument_pattern | error_star)+] ','? ')'")); - _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( error , "can't use starred pattern here" ); + D(fprintf(stderr, "%*c+ maybe_sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.maybe_star_pattern+ ','?")); + _res = values; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6293,8 +6322,8 @@ class_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' [','.error_argument_pattern+ ','] error_star [',' ','.(error_argument_pattern | error_star)+] ','? ')'")); + D(fprintf(stderr, "%*c%s maybe_sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.maybe_star_pattern+ ','?")); } _res = NULL; done: @@ -6302,9 +6331,9 @@ class_pattern_rule(Parser *p) return _res; } -// signed_number: NUMBER | '-' NUMBER +// maybe_star_pattern: star_pattern | pattern static expr_ty -signed_number_rule(Parser *p) +maybe_star_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -6313,69 +6342,43 @@ signed_number_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NUMBER + { // star_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> signed_number[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NUMBER")); - expr_ty number_var; + D(fprintf(stderr, "%*c> maybe_star_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_pattern")); + expr_ty star_pattern_var; if ( - (number_var = _PyPegen_number_token(p)) // NUMBER + (star_pattern_var = star_pattern_rule(p)) // star_pattern ) { - D(fprintf(stderr, "%*c+ signed_number[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NUMBER")); - _res = number_var; + D(fprintf(stderr, "%*c+ maybe_star_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_pattern")); + _res = star_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s signed_number[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER")); + D(fprintf(stderr, "%*c%s maybe_star_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_pattern")); } - { // '-' NUMBER + { // pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> signed_number[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-' NUMBER")); - Token * _literal; - expr_ty number; + D(fprintf(stderr, "%*c> maybe_star_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); + expr_ty pattern_var; if ( - (_literal = _PyPegen_expect_token(p, 15)) // token='-' - && - (number = _PyPegen_number_token(p)) // NUMBER + (pattern_var = pattern_rule(p)) // pattern ) { - D(fprintf(stderr, "%*c+ signed_number[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-' NUMBER")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_UnaryOp ( USub , number , EXTRA ); - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ maybe_star_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); + _res = pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s signed_number[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-' NUMBER")); + D(fprintf(stderr, "%*c%s maybe_star_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); } _res = NULL; done: @@ -6383,39 +6386,9 @@ signed_number_rule(Parser *p) return _res; } -// Left-recursive -// attr: name_or_attr '.' NAME -static expr_ty attr_raw(Parser *); -static expr_ty -attr_rule(Parser *p) -{ - D(p->level++); - expr_ty _res = NULL; - if (_PyPegen_is_memoized(p, attr_type, &_res)) { - D(p->level--); - return _res; - } - int _mark = p->mark; - int _resmark = p->mark; - while (1) { - int tmpvar_1 = _PyPegen_update_memo(p, _mark, attr_type, _res); - if (tmpvar_1) { - D(p->level--); - return _res; - } - p->mark = _mark; - void *_raw = attr_raw(p); - if (_raw == NULL || p->mark <= _resmark) - break; - _resmark = p->mark; - _res = _raw; - } - p->mark = _resmark; - D(p->level--); - return _res; -} +// star_pattern: '*' (capture_pattern | wildcard_pattern) static expr_ty -attr_raw(Parser *p) +star_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -6433,24 +6406,21 @@ attr_raw(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // name_or_attr '.' NAME + { // '*' (capture_pattern | wildcard_pattern) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME")); + D(fprintf(stderr, "%*c> star_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (capture_pattern | wildcard_pattern)")); Token * _literal; - expr_ty attr; - expr_ty value; + void *value; if ( - (value = name_or_attr_rule(p)) // name_or_attr - && - (_literal = _PyPegen_expect_token(p, 23)) // token='.' + (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (attr = _PyPegen_name_token(p)) // NAME + (value = _tmp_58_rule(p)) // capture_pattern | wildcard_pattern ) { - D(fprintf(stderr, "%*c+ attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME")); + D(fprintf(stderr, "%*c+ star_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (capture_pattern | wildcard_pattern)")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -6460,7 +6430,7 @@ attr_raw(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Attribute ( value , attr -> v . Name . id , Load , EXTRA ); + _res = _Py_Starred ( value , Store , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6469,8 +6439,8 @@ attr_raw(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s attr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '.' NAME")); + D(fprintf(stderr, "%*c%s star_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (capture_pattern | wildcard_pattern)")); } _res = NULL; done: @@ -6478,10 +6448,9 @@ attr_raw(Parser *p) return _res; } -// Left-recursive -// name_or_attr: attr | NAME +// mapping_pattern: '{' items_pattern? '}' static expr_ty -name_or_attr_rule(Parser *p) +mapping_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -6490,78 +6459,43 @@ name_or_attr_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; - { // attr - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "attr")); - expr_ty attr_var; - if ( - (attr_var = attr_rule(p)) // attr - ) - { - D(fprintf(stderr, "%*c+ name_or_attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "attr")); - _res = attr_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "attr")); - } - { // NAME - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); - expr_ty name_var; - if ( - (name_var = _PyPegen_name_token(p)) // NAME - ) - { - D(fprintf(stderr, "%*c+ name_or_attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); - _res = name_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// values_pattern: ','.value_pattern+ ','? -static asdl_seq* -values_pattern_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; D(p->level--); return NULL; } - asdl_seq* _res = NULL; - int _mark = p->mark; - { // ','.value_pattern+ ','? + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // '{' items_pattern? '}' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> values_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.value_pattern+ ','?")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - asdl_seq * values; + D(fprintf(stderr, "%*c> mapping_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' items_pattern? '}'")); + Token * _literal; + Token * _literal_1; + void *items; if ( - (values = _gather_70_rule(p)) // ','.value_pattern+ + (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + (items = items_pattern_rule(p), 1) // items_pattern? + && + (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' ) { - D(fprintf(stderr, "%*c+ values_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.value_pattern+ ','?")); - _res = values; + D(fprintf(stderr, "%*c+ mapping_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' items_pattern? '}'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , items ) ) , CHECK ( _PyPegen_get_values ( p , items ) ) , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6570,8 +6504,8 @@ values_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s values_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.value_pattern+ ','?")); + D(fprintf(stderr, "%*c%s mapping_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' items_pattern? '}'")); } _res = NULL; done: @@ -6600,7 +6534,7 @@ items_pattern_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * items; if ( - (items = _gather_72_rule(p)) // ','.key_value_pattern+ + (items = _gather_59_rule(p)) // ','.key_value_pattern+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -6624,54 +6558,36 @@ items_pattern_rule(Parser *p) return _res; } -// keyword_pattern: NAME '=' pattern -static keyword_ty -keyword_pattern_rule(Parser *p) +// key_value_pattern: (literal_pattern | value_pattern) ':' pattern | double_star_pattern +static KeyValuePair* +key_value_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - keyword_ty _res = NULL; + KeyValuePair* _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro - { // NAME '=' pattern + { // (literal_pattern | value_pattern) ':' pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> keyword_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' pattern")); + D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(literal_pattern | value_pattern) ':' pattern")); Token * _literal; - expr_ty arg; + void *key; expr_ty value; if ( - (arg = _PyPegen_name_token(p)) // NAME + (key = _tmp_61_rule(p)) // literal_pattern | value_pattern && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' + (_literal = _PyPegen_expect_token(p, 11)) // token=':' && (value = pattern_rule(p)) // pattern ) { - D(fprintf(stderr, "%*c+ keyword_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' pattern")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_keyword ( arg -> v . Name . id , value , EXTRA ); + D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(literal_pattern | value_pattern) ':' pattern")); + _res = _PyPegen_key_value_pair ( p , key , value ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6680,63 +6596,27 @@ keyword_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s keyword_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' pattern")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// error_argument_pattern: pattern | keyword_pattern -static void * -error_argument_pattern_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // pattern - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> error_argument_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); - expr_ty pattern_var; - if ( - (pattern_var = pattern_rule(p)) // pattern - ) - { - D(fprintf(stderr, "%*c+ error_argument_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); - _res = pattern_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s error_argument_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); + D(fprintf(stderr, "%*c%s key_value_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(literal_pattern | value_pattern) ':' pattern")); } - { // keyword_pattern + { // double_star_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> error_argument_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); - keyword_ty keyword_pattern_var; + D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_star_pattern")); + KeyValuePair* double_star_pattern_var; if ( - (keyword_pattern_var = keyword_pattern_rule(p)) // keyword_pattern + (double_star_pattern_var = double_star_pattern_rule(p)) // double_star_pattern ) { - D(fprintf(stderr, "%*c+ error_argument_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern")); - _res = keyword_pattern_var; + D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_star_pattern")); + _res = double_star_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s error_argument_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern")); + D(fprintf(stderr, "%*c%s key_value_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_star_pattern")); } _res = NULL; done: @@ -6744,33 +6624,33 @@ error_argument_pattern_rule(Parser *p) return _res; } -// error_star: ('*' | '**') NAME -static expr_ty -error_star_rule(Parser *p) +// double_star_pattern: '**' capture_pattern +static KeyValuePair* +double_star_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - expr_ty _res = NULL; + KeyValuePair* _res = NULL; int _mark = p->mark; - { // ('*' | '**') NAME + { // '**' capture_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> error_star[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('*' | '**') NAME")); - void *_tmp_74_var; - expr_ty error; + D(fprintf(stderr, "%*c> double_star_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' capture_pattern")); + Token * _literal; + expr_ty value; if ( - (_tmp_74_var = _tmp_74_rule(p)) // '*' | '**' + (_literal = _PyPegen_expect_token(p, 35)) // token='**' && - (error = _PyPegen_name_token(p)) // NAME + (value = capture_pattern_rule(p)) // capture_pattern ) { - D(fprintf(stderr, "%*c+ error_star[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('*' | '**') NAME")); - _res = error; + D(fprintf(stderr, "%*c+ double_star_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' capture_pattern")); + _res = _PyPegen_key_value_pair ( p , NULL , value ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6779,8 +6659,8 @@ error_star_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s error_star[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('*' | '**') NAME")); + D(fprintf(stderr, "%*c%s double_star_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' capture_pattern")); } _res = NULL; done: @@ -6788,9 +6668,13 @@ error_star_rule(Parser *p) return _res; } -// value_pattern: '*' name_pattern | pattern +// class_pattern: +// | name_or_attr '(' ')' +// | name_or_attr '(' positional_patterns ','? ')' +// | name_or_attr '(' keyword_patterns ','? ')' +// | name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')' static expr_ty -value_pattern_rule(Parser *p) +class_pattern_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -6808,21 +6692,24 @@ value_pattern_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro - { // '*' name_pattern + { // name_or_attr '(' ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' name_pattern")); + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ')'")); Token * _literal; - expr_ty value; + Token * _literal_1; + expr_ty func; if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' + (func = name_or_attr_rule(p)) // name_or_attr + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (value = name_pattern_rule(p)) // name_pattern + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' name_pattern")); + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ')'")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { D(p->level--); @@ -6832,7 +6719,7 @@ value_pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Starred ( value , Store , EXTRA ); + _res = _Py_Call ( func , NULL , NULL , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6841,27 +6728,152 @@ value_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s value_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' name_pattern")); + D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ')'")); } - { // pattern + { // name_or_attr '(' positional_patterns ','? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); - expr_ty pattern_var; + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' positional_patterns ','? ')'")); + Token * _literal; + Token * _literal_1; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_expr_seq* args; + expr_ty func; if ( - (pattern_var = pattern_rule(p)) // pattern + (func = name_or_attr_rule(p)) // name_or_attr + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (args = positional_patterns_rule(p)) // positional_patterns + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); - _res = pattern_var; + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' positional_patterns ','? ')'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Call ( func , args , NULL , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s value_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); + D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' positional_patterns ','? ')'")); + } + { // name_or_attr '(' keyword_patterns ','? ')' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' keyword_patterns ','? ')'")); + Token * _literal; + Token * _literal_1; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + expr_ty func; + asdl_keyword_seq* keywords; + if ( + (func = name_or_attr_rule(p)) // name_or_attr + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (keywords = keyword_patterns_rule(p)) // keyword_patterns + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' keyword_patterns ','? ')'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Call ( func , NULL , keywords , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' keyword_patterns ','? ')'")); + } + { // name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')'")); + Token * _literal; + Token * _literal_1; + Token * _literal_2; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_expr_seq* args; + expr_ty func; + asdl_keyword_seq* keywords; + if ( + (func = name_or_attr_rule(p)) // name_or_attr + && + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (args = positional_patterns_rule(p)) // positional_patterns + && + (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' + && + (keywords = keyword_patterns_rule(p)) // keyword_patterns + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + && + (_literal_2 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')'")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Call ( func , args , keywords , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')'")); } _res = NULL; done: @@ -6869,36 +6881,30 @@ value_pattern_rule(Parser *p) return _res; } -// key_value_pattern: (literal_pattern | constant_pattern) ':' pattern | '**' name_pattern -static KeyValuePair* -key_value_pattern_rule(Parser *p) +// positional_patterns: ','.pattern+ +static asdl_expr_seq* +positional_patterns_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - KeyValuePair* _res = NULL; + asdl_expr_seq* _res = NULL; int _mark = p->mark; - { // (literal_pattern | constant_pattern) ':' pattern + { // ','.pattern+ if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(literal_pattern | constant_pattern) ':' pattern")); - Token * _literal; - void *key; - expr_ty value; + D(fprintf(stderr, "%*c> positional_patterns[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+")); + asdl_expr_seq* args; if ( - (key = _tmp_75_rule(p)) // literal_pattern | constant_pattern - && - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (value = pattern_rule(p)) // pattern + (args = (asdl_expr_seq*)_gather_62_rule(p)) // ','.pattern+ ) { - D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(literal_pattern | constant_pattern) ':' pattern")); - _res = _PyPegen_key_value_pair ( p , key , value ); + D(fprintf(stderr, "%*c+ positional_patterns[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.pattern+")); + _res = args; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6907,25 +6913,104 @@ key_value_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s key_value_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(literal_pattern | constant_pattern) ':' pattern")); + D(fprintf(stderr, "%*c%s positional_patterns[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.pattern+")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// keyword_patterns: ','.keyword_pattern+ +static asdl_keyword_seq* +keyword_patterns_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_keyword_seq* _res = NULL; + int _mark = p->mark; + { // ','.keyword_pattern+ + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> keyword_patterns[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.keyword_pattern+")); + asdl_keyword_seq* keywords; + if ( + (keywords = (asdl_keyword_seq*)_gather_64_rule(p)) // ','.keyword_pattern+ + ) + { + D(fprintf(stderr, "%*c+ keyword_patterns[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.keyword_pattern+")); + _res = keywords; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s keyword_patterns[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.keyword_pattern+")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// keyword_pattern: NAME '=' pattern +static keyword_ty +keyword_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + keyword_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; } - { // '**' name_pattern + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro + { // NAME '=' pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' name_pattern")); + D(fprintf(stderr, "%*c> keyword_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' pattern")); Token * _literal; + expr_ty arg; expr_ty value; if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' + (arg = _PyPegen_name_token(p)) // NAME + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' && - (value = name_pattern_rule(p)) // name_pattern + (value = pattern_rule(p)) // pattern ) { - D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' name_pattern")); - _res = _PyPegen_key_value_pair ( p , NULL , value ); + D(fprintf(stderr, "%*c+ keyword_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' pattern")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_keyword ( arg -> v . Name . id , value , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6934,8 +7019,8 @@ key_value_pattern_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s key_value_pattern[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' name_pattern")); + D(fprintf(stderr, "%*c%s keyword_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' pattern")); } _res = NULL; done: @@ -7039,7 +7124,7 @@ raise_stmt_rule(Parser *p) && (a = expression_rule(p)) // expression && - (b = _tmp_76_rule(p), 1) // ['from' expression] + (b = _tmp_66_rule(p), 1) // ['from' expression] ) { D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); @@ -7214,7 +7299,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_77_rule(p), 1) // ['->' expression] + (a = _tmp_67_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -7274,7 +7359,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_78_rule(p), 1) // ['->' expression] + (a = _tmp_68_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -7338,7 +7423,7 @@ func_type_comment_rule(Parser *p) && (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' && - _PyPegen_lookahead(1, _tmp_79_rule, p) + _PyPegen_lookahead(1, _tmp_69_rule, p) ) { D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); @@ -7482,9 +7567,9 @@ parameters_rule(Parser *p) if ( (a = slash_no_default_rule(p)) // slash_no_default && - (b = (asdl_arg_seq*)_loop0_80_rule(p)) // param_no_default* + (b = (asdl_arg_seq*)_loop0_70_rule(p)) // param_no_default* && - (c = _loop0_81_rule(p)) // param_with_default* + (c = _loop0_71_rule(p)) // param_with_default* && (d = star_etc_rule(p), 1) // star_etc? ) @@ -7514,7 +7599,7 @@ parameters_rule(Parser *p) if ( (a = slash_with_default_rule(p)) // slash_with_default && - (b = _loop0_82_rule(p)) // param_with_default* + (b = _loop0_72_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -7542,9 +7627,9 @@ parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = (asdl_arg_seq*)_loop1_83_rule(p)) // param_no_default+ + (a = (asdl_arg_seq*)_loop1_73_rule(p)) // param_no_default+ && - (b = _loop0_84_rule(p)) // param_with_default* + (b = _loop0_74_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -7571,7 +7656,7 @@ parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_85_rule(p)) // param_with_default+ + (a = _loop1_75_rule(p)) // param_with_default+ && (b = star_etc_rule(p), 1) // star_etc? ) @@ -7640,7 +7725,7 @@ slash_no_default_rule(Parser *p) Token * _literal_1; asdl_arg_seq* a; if ( - (a = (asdl_arg_seq*)_loop1_86_rule(p)) // param_no_default+ + (a = (asdl_arg_seq*)_loop1_76_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7669,7 +7754,7 @@ slash_no_default_rule(Parser *p) Token * _literal; asdl_arg_seq* a; if ( - (a = (asdl_arg_seq*)_loop1_87_rule(p)) // param_no_default+ + (a = (asdl_arg_seq*)_loop1_77_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7719,9 +7804,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_88_rule(p)) // param_no_default* + (a = _loop0_78_rule(p)) // param_no_default* && - (b = _loop1_89_rule(p)) // param_with_default+ + (b = _loop1_79_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7751,9 +7836,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_90_rule(p)) // param_no_default* + (a = _loop0_80_rule(p)) // param_no_default* && - (b = _loop1_91_rule(p)) // param_with_default+ + (b = _loop1_81_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7809,7 +7894,7 @@ star_etc_rule(Parser *p) && (a = param_no_default_rule(p)) // param_no_default && - (b = _loop0_92_rule(p)) // param_maybe_default* + (b = _loop0_82_rule(p)) // param_maybe_default* && (c = kwds_rule(p), 1) // kwds? ) @@ -7842,7 +7927,7 @@ star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_93_rule(p)) // param_maybe_default+ + (b = _loop1_83_rule(p)) // param_maybe_default+ && (c = kwds_rule(p), 1) // kwds? ) @@ -8364,7 +8449,7 @@ decorators_rule(Parser *p) D(fprintf(stderr, "%*c> decorators[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_loop1_94_rule(p)) // (('@' named_expression NEWLINE))+ + (a = (asdl_expr_seq*)_loop1_84_rule(p)) // (('@' named_expression NEWLINE))+ ) { D(fprintf(stderr, "%*c+ decorators[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); @@ -8485,7 +8570,7 @@ class_def_raw_rule(Parser *p) && (a = _PyPegen_name_token(p)) // NAME && - (b = _tmp_95_rule(p), 1) // ['(' arguments? ')'] + (b = _tmp_85_rule(p), 1) // ['(' arguments? ')'] && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -8634,7 +8719,7 @@ expressions_list_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_96_rule(p)) // ','.star_expression+ + (a = (asdl_expr_seq*)_gather_86_rule(p)) // ','.star_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8694,7 +8779,7 @@ star_expressions_rule(Parser *p) if ( (a = star_expression_rule(p)) // star_expression && - (b = _loop1_98_rule(p)) // ((',' star_expression))+ + (b = _loop1_88_rule(p)) // ((',' star_expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -8889,7 +8974,7 @@ star_named_expressions_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_99_rule(p)) // ','.star_named_expression+ + (a = (asdl_expr_seq*)_gather_89_rule(p)) // ','.star_named_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -9194,7 +9279,7 @@ expressions_rule(Parser *p) if ( (a = expression_rule(p)) // expression && - (b = _loop1_101_rule(p)) // ((',' expression))+ + (b = _loop1_91_rule(p)) // ((',' expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -9548,9 +9633,9 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default && - (b = (asdl_arg_seq*)_loop0_102_rule(p)) // lambda_param_no_default* + (b = (asdl_arg_seq*)_loop0_92_rule(p)) // lambda_param_no_default* && - (c = _loop0_103_rule(p)) // lambda_param_with_default* + (c = _loop0_93_rule(p)) // lambda_param_with_default* && (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9580,7 +9665,7 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default && - (b = _loop0_104_rule(p)) // lambda_param_with_default* + (b = _loop0_94_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9608,9 +9693,9 @@ lambda_parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = (asdl_arg_seq*)_loop1_105_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_95_rule(p)) // lambda_param_no_default+ && - (b = _loop0_106_rule(p)) // lambda_param_with_default* + (b = _loop0_96_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9637,7 +9722,7 @@ lambda_parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_107_rule(p)) // lambda_param_with_default+ + (a = _loop1_97_rule(p)) // lambda_param_with_default+ && (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -9708,7 +9793,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal_1; asdl_arg_seq* a; if ( - (a = (asdl_arg_seq*)_loop1_108_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_98_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9737,7 +9822,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal; asdl_arg_seq* a; if ( - (a = (asdl_arg_seq*)_loop1_109_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_99_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9787,9 +9872,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_110_rule(p)) // lambda_param_no_default* + (a = _loop0_100_rule(p)) // lambda_param_no_default* && - (b = _loop1_111_rule(p)) // lambda_param_with_default+ + (b = _loop1_101_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9819,9 +9904,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_112_rule(p)) // lambda_param_no_default* + (a = _loop0_102_rule(p)) // lambda_param_no_default* && - (b = _loop1_113_rule(p)) // lambda_param_with_default+ + (b = _loop1_103_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -9877,7 +9962,7 @@ lambda_star_etc_rule(Parser *p) && (a = lambda_param_no_default_rule(p)) // lambda_param_no_default && - (b = _loop0_114_rule(p)) // lambda_param_maybe_default* + (b = _loop0_104_rule(p)) // lambda_param_maybe_default* && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -9910,7 +9995,7 @@ lambda_star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_115_rule(p)) // lambda_param_maybe_default+ + (b = _loop1_105_rule(p)) // lambda_param_maybe_default+ && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -10337,7 +10422,7 @@ disjunction_rule(Parser *p) if ( (a = conjunction_rule(p)) // conjunction && - (b = _loop1_116_rule(p)) // (('or' conjunction))+ + (b = _loop1_106_rule(p)) // (('or' conjunction))+ ) { D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); @@ -10423,7 +10508,7 @@ conjunction_rule(Parser *p) if ( (a = inversion_rule(p)) // inversion && - (b = _loop1_117_rule(p)) // (('and' inversion))+ + (b = _loop1_107_rule(p)) // (('and' inversion))+ ) { D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); @@ -10591,7 +10676,7 @@ comparison_rule(Parser *p) if ( (a = bitwise_or_rule(p)) // bitwise_or && - (b = _loop1_118_rule(p)) // compare_op_bitwise_or_pair+ + (b = _loop1_108_rule(p)) // compare_op_bitwise_or_pair+ ) { D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); @@ -10919,10 +11004,10 @@ noteq_bitwise_or_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); - void *_tmp_119_var; + void *_tmp_109_var; expr_ty a; if ( - (_tmp_119_var = _tmp_119_rule(p)) // '!=' + (_tmp_109_var = _tmp_109_rule(p)) // '!=' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -12851,7 +12936,7 @@ slices_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_120_rule(p)) // ','.slice+ + (a = (asdl_expr_seq*)_gather_110_rule(p)) // ','.slice+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -12921,7 +13006,7 @@ slice_rule(Parser *p) && (b = expression_rule(p), 1) // expression? && - (c = _tmp_122_rule(p), 1) // [':' expression?] + (c = _tmp_112_rule(p), 1) // [':' expression?] ) { D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); @@ -13170,15 +13255,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - void *_tmp_123_var; + void *_tmp_113_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' && - (_tmp_123_var = _tmp_123_rule(p)) // tuple | group | genexp + (_tmp_113_var = _tmp_113_rule(p)) // tuple | group | genexp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - _res = _tmp_123_var; + _res = _tmp_113_var; goto done; } p->mark = _mark; @@ -13191,15 +13276,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - void *_tmp_124_var; + void *_tmp_114_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' && - (_tmp_124_var = _tmp_124_rule(p)) // list | listcomp + (_tmp_114_var = _tmp_114_rule(p)) // list | listcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - _res = _tmp_124_var; + _res = _tmp_114_var; goto done; } p->mark = _mark; @@ -13212,15 +13297,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - void *_tmp_125_var; + void *_tmp_115_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' && - (_tmp_125_var = _tmp_125_rule(p)) // dict | set | dictcomp | setcomp + (_tmp_115_var = _tmp_115_rule(p)) // dict | set | dictcomp | setcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - _res = _tmp_125_var; + _res = _tmp_115_var; goto done; } p->mark = _mark; @@ -13289,7 +13374,7 @@ strings_rule(Parser *p) D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+")); asdl_seq * a; if ( - (a = _loop1_126_rule(p)) // STRING+ + (a = _loop1_116_rule(p)) // STRING+ ) { D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+")); @@ -13503,7 +13588,7 @@ tuple_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_127_rule(p), 1) // [star_named_expression ',' star_named_expressions?] + (a = _tmp_117_rule(p), 1) // [star_named_expression ',' star_named_expressions?] && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -13559,7 +13644,7 @@ group_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_128_rule(p)) // yield_expr | named_expression + (a = _tmp_118_rule(p)) // yield_expr | named_expression && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -14028,7 +14113,7 @@ double_starred_kvpairs_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_129_rule(p)) // ','.double_starred_kvpair+ + (a = _gather_119_rule(p)) // ','.double_starred_kvpair+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -14181,7 +14266,7 @@ for_if_clauses_rule(Parser *p) D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); asdl_comprehension_seq* a; if ( - (a = (asdl_comprehension_seq*)_loop1_131_rule(p)) // for_if_clause+ + (a = (asdl_comprehension_seq*)_loop1_121_rule(p)) // for_if_clause+ ) { D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); @@ -14243,7 +14328,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = (asdl_expr_seq*)_loop0_132_rule(p)) // (('if' disjunction))* + (c = (asdl_expr_seq*)_loop0_122_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' ~ disjunction (('if' disjunction))*")); @@ -14286,7 +14371,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = (asdl_expr_seq*)_loop0_133_rule(p)) // (('if' disjunction))* + (c = (asdl_expr_seq*)_loop0_123_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' ~ disjunction (('if' disjunction))*")); @@ -14532,9 +14617,9 @@ args_rule(Parser *p) asdl_expr_seq* a; void *b; if ( - (a = (asdl_expr_seq*)_gather_134_rule(p)) // ','.(starred_expression | named_expression !'=')+ + (a = (asdl_expr_seq*)_gather_124_rule(p)) // ','.(starred_expression | named_expression !'=')+ && - (b = _tmp_136_rule(p), 1) // [',' kwargs] + (b = _tmp_126_rule(p), 1) // [',' kwargs] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.(starred_expression | named_expression !'=')+ [',' kwargs]")); @@ -14622,11 +14707,11 @@ kwargs_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _gather_137_rule(p)) // ','.kwarg_or_starred+ + (a = _gather_127_rule(p)) // ','.kwarg_or_starred+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _gather_139_rule(p)) // ','.kwarg_or_double_starred+ + (b = _gather_129_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); @@ -14648,13 +14733,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - asdl_seq * _gather_141_var; + asdl_seq * _gather_131_var; if ( - (_gather_141_var = _gather_141_rule(p)) // ','.kwarg_or_starred+ + (_gather_131_var = _gather_131_rule(p)) // ','.kwarg_or_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - _res = _gather_141_var; + _res = _gather_131_var; goto done; } p->mark = _mark; @@ -14667,13 +14752,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - asdl_seq * _gather_143_var; + asdl_seq * _gather_133_var; if ( - (_gather_143_var = _gather_143_rule(p)) // ','.kwarg_or_double_starred+ + (_gather_133_var = _gather_133_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - _res = _gather_143_var; + _res = _gather_133_var; goto done; } p->mark = _mark; @@ -15035,7 +15120,7 @@ star_targets_rule(Parser *p) if ( (a = star_target_rule(p)) // star_target && - (b = _loop0_145_rule(p)) // ((',' star_target))* + (b = _loop0_135_rule(p)) // ((',' star_target))* && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -15089,7 +15174,7 @@ star_targets_seq_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_146_rule(p)) // ','.star_target+ + (a = (asdl_expr_seq*)_gather_136_rule(p)) // ','.star_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -15152,7 +15237,7 @@ star_target_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (a = _tmp_148_rule(p)) // !'*' star_target + (a = _tmp_138_rule(p)) // !'*' star_target ) { D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); @@ -15674,7 +15759,7 @@ del_targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_149_rule(p)) // ','.del_target+ + (a = (asdl_expr_seq*)_gather_139_rule(p)) // ','.del_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -16015,7 +16100,7 @@ targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_151_rule(p)) // ','.target+ + (a = (asdl_expr_seq*)_gather_141_rule(p)) // ','.target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -16727,7 +16812,7 @@ incorrect_arguments_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_opt_var = _tmp_153_rule(p), 1) // [args | expression for_if_clauses] + (_opt_var = _tmp_143_rule(p), 1) // [args | expression for_if_clauses] ) { D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); @@ -16985,7 +17070,7 @@ invalid_assignment_rule(Parser *p) D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':' expression")); Token * _literal; Token * _literal_1; - asdl_seq * _loop0_154_var; + asdl_seq * _loop0_144_var; expr_ty a; expr_ty expression_var; if ( @@ -16993,7 +17078,7 @@ invalid_assignment_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_loop0_154_var = _loop0_154_rule(p)) // star_named_expressions* + (_loop0_144_var = _loop0_144_rule(p)) // star_named_expressions* && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -17050,10 +17135,10 @@ invalid_assignment_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='")); Token * _literal; - asdl_seq * _loop0_155_var; + asdl_seq * _loop0_145_var; expr_ty a; if ( - (_loop0_155_var = _loop0_155_rule(p)) // ((star_targets '='))* + (_loop0_145_var = _loop0_145_rule(p)) // ((star_targets '='))* && (a = star_expressions_rule(p)) // star_expressions && @@ -17080,10 +17165,10 @@ invalid_assignment_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='")); Token * _literal; - asdl_seq * _loop0_156_var; + asdl_seq * _loop0_146_var; expr_ty a; if ( - (_loop0_156_var = _loop0_156_rule(p)) // ((star_targets '='))* + (_loop0_146_var = _loop0_146_rule(p)) // ((star_targets '='))* && (a = yield_expr_rule(p)) // yield_expr && @@ -17109,7 +17194,7 @@ invalid_assignment_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); - void *_tmp_157_var; + void *_tmp_147_var; expr_ty a; AugOperator* augassign_var; if ( @@ -17117,7 +17202,7 @@ invalid_assignment_rule(Parser *p) && (augassign_var = augassign_rule(p)) // augassign && - (_tmp_157_var = _tmp_157_rule(p)) // yield_expr | star_expressions + (_tmp_147_var = _tmp_147_rule(p)) // yield_expr | star_expressions ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); @@ -17328,11 +17413,11 @@ invalid_comprehension_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); - void *_tmp_158_var; + void *_tmp_148_var; expr_ty a; asdl_comprehension_seq* for_if_clauses_var; if ( - (_tmp_158_var = _tmp_158_rule(p)) // '[' | '(' | '{' + (_tmp_148_var = _tmp_148_rule(p)) // '[' | '(' | '{' && (a = starred_expression_rule(p)) // starred_expression && @@ -17429,13 +17514,13 @@ invalid_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); - asdl_seq * _loop0_159_var; - void *_tmp_160_var; + asdl_seq * _loop0_149_var; + void *_tmp_150_var; arg_ty param_no_default_var; if ( - (_loop0_159_var = _loop0_159_rule(p)) // param_no_default* + (_loop0_149_var = _loop0_149_rule(p)) // param_no_default* && - (_tmp_160_var = _tmp_160_rule(p)) // slash_with_default | param_with_default+ + (_tmp_150_var = _tmp_150_rule(p)) // slash_with_default | param_with_default+ && (param_no_default_var = param_no_default_rule(p)) // param_no_default ) @@ -17477,13 +17562,13 @@ invalid_lambda_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default")); - asdl_seq * _loop0_161_var; - void *_tmp_162_var; + asdl_seq * _loop0_151_var; + void *_tmp_152_var; arg_ty lambda_param_no_default_var; if ( - (_loop0_161_var = _loop0_161_rule(p)) // lambda_param_no_default* + (_loop0_151_var = _loop0_151_rule(p)) // lambda_param_no_default* && - (_tmp_162_var = _tmp_162_rule(p)) // lambda_slash_with_default | lambda_param_with_default+ + (_tmp_152_var = _tmp_152_rule(p)) // lambda_slash_with_default | lambda_param_with_default+ && (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default ) @@ -17525,11 +17610,11 @@ invalid_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); Token * _literal; - void *_tmp_163_var; + void *_tmp_153_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_163_var = _tmp_163_rule(p)) // ')' | ',' (')' | '**') + (_tmp_153_var = _tmp_153_rule(p)) // ')' | ',' (')' | '**') ) { D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); @@ -17599,11 +17684,11 @@ invalid_lambda_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); Token * _literal; - void *_tmp_164_var; + void *_tmp_154_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_164_var = _tmp_164_rule(p)) // ':' | ',' (':' | '**') + (_tmp_154_var = _tmp_154_rule(p)) // ':' | ',' (':' | '**') ) { D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); @@ -19112,12 +19197,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_155_var; while ( - (_tmp_165_var = _tmp_165_rule(p)) // star_targets '=' + (_tmp_155_var = _tmp_155_rule(p)) // star_targets '=' ) { - _res = _tmp_165_var; + _res = _tmp_155_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -19620,12 +19705,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_156_var; while ( - (_tmp_166_var = _tmp_166_rule(p)) // '.' | '...' + (_tmp_156_var = _tmp_156_rule(p)) // '.' | '...' ) { - _res = _tmp_166_var; + _res = _tmp_156_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -19686,12 +19771,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_157_var; while ( - (_tmp_167_var = _tmp_167_rule(p)) // '.' | '...' + (_tmp_157_var = _tmp_157_rule(p)) // '.' | '...' ) { - _res = _tmp_167_var; + _res = _tmp_157_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -20876,7 +20961,7 @@ _gather_51_rule(Parser *p) return _res; } -// _tmp_53: '.' | '(' | '=' +// _tmp_53: '+' | '-' static void * _tmp_53_rule(Parser *p) { @@ -20887,62 +20972,43 @@ _tmp_53_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '.' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 23)) // token='.' - ) - { - D(fprintf(stderr, "%*c+ _tmp_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_53[%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_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c> _tmp_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+'")); Token * _literal; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' + (_literal = _PyPegen_expect_token(p, 14)) // token='+' ) { - D(fprintf(stderr, "%*c+ _tmp_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c+ _tmp_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+'")); _res = _literal; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_53[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+'")); } - { // '=' + { // '-' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); + D(fprintf(stderr, "%*c> _tmp_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-'")); Token * _literal; if ( - (_literal = _PyPegen_expect_token(p, 22)) // token='=' + (_literal = _PyPegen_expect_token(p, 15)) // token='-' ) { - D(fprintf(stderr, "%*c+ _tmp_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); + D(fprintf(stderr, "%*c+ _tmp_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-'")); _res = _literal; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_53[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-'")); } _res = NULL; done: @@ -20950,7 +21016,7 @@ _tmp_53_rule(Parser *p) return _res; } -// _tmp_54: '+' | '-' +// _tmp_54: '.' | '(' | '=' static void * _tmp_54_rule(Parser *p) { @@ -20961,43 +21027,62 @@ _tmp_54_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '+' + { // '.' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+'")); + D(fprintf(stderr, "%*c> _tmp_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( - (_literal = _PyPegen_expect_token(p, 14)) // token='+' + (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+'")); + D(fprintf(stderr, "%*c+ _tmp_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_54[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } - { // '-' + { // '(' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-'")); + D(fprintf(stderr, "%*c> _tmp_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); Token * _literal; if ( - (_literal = _PyPegen_expect_token(p, 15)) // token='-' + (_literal = _PyPegen_expect_token(p, 7)) // token='(' ) { - D(fprintf(stderr, "%*c+ _tmp_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-'")); + D(fprintf(stderr, "%*c+ _tmp_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); _res = _literal; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_54[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); + } + { // '=' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + ) + { + D(fprintf(stderr, "%*c+ _tmp_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_54[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); } _res = NULL; done: @@ -21079,7 +21164,7 @@ _tmp_55_rule(Parser *p) return _res; } -// _loop0_57: ',' pattern +// _loop0_57: ',' maybe_star_pattern static asdl_seq * _loop0_57_rule(Parser *p) { @@ -21100,18 +21185,18 @@ _loop0_57_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' pattern + { // ',' maybe_star_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' maybe_star_pattern")); Token * _literal; expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = pattern_rule(p)) // pattern + (elem = maybe_star_pattern_rule(p)) // maybe_star_pattern ) { _res = elem; @@ -21137,7 +21222,7 @@ _loop0_57_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s _loop0_57[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' maybe_star_pattern")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -21154,7 +21239,7 @@ _loop0_57_rule(Parser *p) return _seq; } -// _gather_56: pattern _loop0_57 +// _gather_56: maybe_star_pattern _loop0_57 static asdl_seq * _gather_56_rule(Parser *p) { @@ -21165,27 +21250,27 @@ _gather_56_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // pattern _loop0_57 + { // maybe_star_pattern _loop0_57 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_57")); + D(fprintf(stderr, "%*c> _gather_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern _loop0_57")); expr_ty elem; asdl_seq * seq; if ( - (elem = pattern_rule(p)) // pattern + (elem = maybe_star_pattern_rule(p)) // maybe_star_pattern && (seq = _loop0_57_rule(p)) // _loop0_57 ) { - D(fprintf(stderr, "%*c+ _gather_56[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_57")); + D(fprintf(stderr, "%*c+ _gather_56[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern _loop0_57")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _gather_56[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_57")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "maybe_star_pattern _loop0_57")); } _res = NULL; done: @@ -21193,113 +21278,54 @@ _gather_56_rule(Parser *p) return _res; } -// _loop0_59: ',' keyword_pattern -static asdl_seq * -_loop0_59_rule(Parser *p) +// _tmp_58: capture_pattern | wildcard_pattern +static void * +_tmp_58_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void *_res = 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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ',' keyword_pattern + { // capture_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); - Token * _literal; - keyword_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = keyword_pattern_rule(p)) // keyword_pattern + D(fprintf(stderr, "%*c> _tmp_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "capture_pattern")); + expr_ty capture_pattern_var; + if ( + (capture_pattern_var = capture_pattern_rule(p)) // capture_pattern ) { - _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; + D(fprintf(stderr, "%*c+ _tmp_58[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "capture_pattern")); + _res = capture_pattern_var; + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_59[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); - } - 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_59_type, _seq); - D(p->level--); - return _seq; -} - -// _gather_58: keyword_pattern _loop0_59 -static asdl_seq * -_gather_58_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s _tmp_58[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "capture_pattern")); } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // keyword_pattern _loop0_59 + { // wildcard_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_59")); - keyword_ty elem; - asdl_seq * seq; + D(fprintf(stderr, "%*c> _tmp_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "wildcard_pattern")); + expr_ty wildcard_pattern_var; if ( - (elem = keyword_pattern_rule(p)) // keyword_pattern - && - (seq = _loop0_59_rule(p)) // _loop0_59 + (wildcard_pattern_var = wildcard_pattern_rule(p)) // wildcard_pattern ) { - D(fprintf(stderr, "%*c+ _gather_58[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_59")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); + D(fprintf(stderr, "%*c+ _tmp_58[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "wildcard_pattern")); + _res = wildcard_pattern_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_58[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_59")); + D(fprintf(stderr, "%*c%s _tmp_58[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "wildcard_pattern")); } _res = NULL; done: @@ -21307,9 +21333,9 @@ _gather_58_rule(Parser *p) return _res; } -// _loop0_61: ',' pattern +// _loop0_60: ',' key_value_pattern static asdl_seq * -_loop0_61_rule(Parser *p) +_loop0_60_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21328,18 +21354,18 @@ _loop0_61_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' pattern + { // ',' key_value_pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c> _loop0_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); Token * _literal; - expr_ty elem; + KeyValuePair* elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = pattern_rule(p)) // pattern + (elem = key_value_pattern_rule(p)) // key_value_pattern ) { _res = elem; @@ -21364,8 +21390,8 @@ _loop0_61_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_61[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c%s _loop0_60[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' key_value_pattern")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -21377,14 +21403,14 @@ _loop0_61_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_61_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_60_type, _seq); D(p->level--); return _seq; } -// _gather_60: pattern _loop0_61 +// _gather_59: key_value_pattern _loop0_60 static asdl_seq * -_gather_60_rule(Parser *p) +_gather_59_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21393,27 +21419,82 @@ _gather_60_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // pattern _loop0_61 + { // key_value_pattern _loop0_60 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_61")); - expr_ty elem; + D(fprintf(stderr, "%*c> _gather_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_60")); + KeyValuePair* elem; asdl_seq * seq; if ( - (elem = pattern_rule(p)) // pattern + (elem = key_value_pattern_rule(p)) // key_value_pattern && - (seq = _loop0_61_rule(p)) // _loop0_61 + (seq = _loop0_60_rule(p)) // _loop0_60 ) { - D(fprintf(stderr, "%*c+ _gather_60[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_61")); + D(fprintf(stderr, "%*c+ _gather_59[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_60")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_60[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_61")); + D(fprintf(stderr, "%*c%s _gather_59[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_60")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_61: literal_pattern | value_pattern +static void * +_tmp_61_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // literal_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + expr_ty literal_pattern_var; + if ( + (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern + ) + { + D(fprintf(stderr, "%*c+ _tmp_61[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); + _res = literal_pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_61[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern")); + } + { // value_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern")); + expr_ty value_pattern_var; + if ( + (value_pattern_var = value_pattern_rule(p)) // value_pattern + ) + { + D(fprintf(stderr, "%*c+ _tmp_61[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern")); + _res = value_pattern_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_61[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern")); } _res = NULL; done: @@ -21421,7 +21502,7 @@ _gather_60_rule(Parser *p) return _res; } -// _loop0_63: ',' keyword_pattern +// _loop0_63: ',' pattern static asdl_seq * _loop0_63_rule(Parser *p) { @@ -21442,18 +21523,18 @@ _loop0_63_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' keyword_pattern + { // ',' pattern if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); + D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); Token * _literal; - keyword_ty elem; + expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = keyword_pattern_rule(p)) // keyword_pattern + (elem = pattern_rule(p)) // pattern ) { _res = elem; @@ -21479,7 +21560,7 @@ _loop0_63_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s _loop0_63[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -21496,7 +21577,7 @@ _loop0_63_rule(Parser *p) return _seq; } -// _gather_62: keyword_pattern _loop0_63 +// _gather_62: pattern _loop0_63 static asdl_seq * _gather_62_rule(Parser *p) { @@ -21507,66 +21588,27 @@ _gather_62_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // keyword_pattern _loop0_63 + { // pattern _loop0_63 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_63")); - keyword_ty elem; + D(fprintf(stderr, "%*c> _gather_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_63")); + expr_ty elem; asdl_seq * seq; if ( - (elem = keyword_pattern_rule(p)) // keyword_pattern + (elem = pattern_rule(p)) // pattern && (seq = _loop0_63_rule(p)) // _loop0_63 ) { - D(fprintf(stderr, "%*c+ _gather_62[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_63")); + D(fprintf(stderr, "%*c+ _gather_62[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_63")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _gather_62[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_63")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_64: ','.pattern+ ',' -static void * -_tmp_64_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // ','.pattern+ ',' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); - asdl_seq * _gather_168_var; - Token * _literal; - if ( - (_gather_168_var = _gather_168_rule(p)) // ','.pattern+ - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ _tmp_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.pattern+ ','")); - _res = _PyPegen_dummy_name(p, _gather_168_var, _literal); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_64[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.pattern+ ','")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_63")); } _res = NULL; done: @@ -21574,9 +21616,9 @@ _tmp_64_rule(Parser *p) return _res; } -// _loop0_66: ',' keyword_pattern +// _loop0_65: ',' keyword_pattern static asdl_seq * -_loop0_66_rule(Parser *p) +_loop0_65_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21600,7 +21642,7 @@ _loop0_66_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); + D(fprintf(stderr, "%*c> _loop0_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); Token * _literal; keyword_ty elem; while ( @@ -21631,7 +21673,7 @@ _loop0_66_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_66[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_65[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -21644,14 +21686,14 @@ _loop0_66_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_66_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_65_type, _seq); D(p->level--); return _seq; } -// _gather_65: keyword_pattern _loop0_66 +// _gather_64: keyword_pattern _loop0_65 static asdl_seq * -_gather_65_rule(Parser *p) +_gather_64_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21660,27 +21702,27 @@ _gather_65_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // keyword_pattern _loop0_66 + { // keyword_pattern _loop0_65 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_66")); + D(fprintf(stderr, "%*c> _gather_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_65")); keyword_ty elem; asdl_seq * seq; if ( (elem = keyword_pattern_rule(p)) // keyword_pattern && - (seq = _loop0_66_rule(p)) // _loop0_66 + (seq = _loop0_65_rule(p)) // _loop0_65 ) { - D(fprintf(stderr, "%*c+ _gather_65[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_66")); + D(fprintf(stderr, "%*c+ _gather_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_65")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_65[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_66")); + D(fprintf(stderr, "%*c%s _gather_64[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_65")); } _res = NULL; done: @@ -21688,9 +21730,9 @@ _gather_65_rule(Parser *p) return _res; } -// _tmp_67: ',' ','.error_argument_pattern+ +// _tmp_66: 'from' expression static void * -_tmp_67_rule(Parser *p) +_tmp_66_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21699,27 +21741,32 @@ _tmp_67_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ',' ','.error_argument_pattern+ + { // 'from' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.error_argument_pattern+")); - asdl_seq * _gather_170_var; - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); + Token * _keyword; + expr_ty z; if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (_keyword = _PyPegen_expect_token(p, 514)) // token='from' && - (_gather_170_var = _gather_170_rule(p)) // ','.error_argument_pattern+ + (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.error_argument_pattern+")); - _res = _PyPegen_dummy_name(p, _literal, _gather_170_var); + D(fprintf(stderr, "%*c+ _tmp_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); + _res = z; + 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_67[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.error_argument_pattern+")); + D(fprintf(stderr, "%*c%s _tmp_66[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression")); } _res = NULL; done: @@ -21727,9 +21774,9 @@ _tmp_67_rule(Parser *p) return _res; } -// _tmp_68: ','.error_argument_pattern+ ',' +// _tmp_67: '->' expression static void * -_tmp_68_rule(Parser *p) +_tmp_67_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21738,27 +21785,32 @@ _tmp_68_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ','.error_argument_pattern+ ',' + { // '->' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.error_argument_pattern+ ','")); - asdl_seq * _gather_172_var; + D(fprintf(stderr, "%*c> _tmp_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; + expr_ty z; if ( - (_gather_172_var = _gather_172_rule(p)) // ','.error_argument_pattern+ + (_literal = _PyPegen_expect_token(p, 51)) // token='->' && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.error_argument_pattern+ ','")); - _res = _PyPegen_dummy_name(p, _gather_172_var, _literal); + D(fprintf(stderr, "%*c+ _tmp_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + _res = z; + 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_68[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.error_argument_pattern+ ','")); + D(fprintf(stderr, "%*c%s _tmp_67[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; done: @@ -21766,9 +21818,9 @@ _tmp_68_rule(Parser *p) return _res; } -// _tmp_69: ',' ','.(error_argument_pattern | error_star)+ +// _tmp_68: '->' expression static void * -_tmp_69_rule(Parser *p) +_tmp_68_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21777,27 +21829,32 @@ _tmp_69_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ',' ','.(error_argument_pattern | error_star)+ + { // '->' expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' ','.(error_argument_pattern | error_star)+")); - asdl_seq * _gather_174_var; + D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; + expr_ty z; if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (_literal = _PyPegen_expect_token(p, 51)) // token='->' && - (_gather_174_var = _gather_174_rule(p)) // ','.(error_argument_pattern | error_star)+ + (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' ','.(error_argument_pattern | error_star)+")); - _res = _PyPegen_dummy_name(p, _literal, _gather_174_var); + D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + _res = z; + 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_69[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' ','.(error_argument_pattern | error_star)+")); + D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; done: @@ -21805,48 +21862,78 @@ _tmp_69_rule(Parser *p) return _res; } -// _loop0_71: ',' value_pattern -static asdl_seq * -_loop0_71_rule(Parser *p) +// _tmp_69: NEWLINE INDENT +static void * +_tmp_69_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void *_res = 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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ',' value_pattern + { // NEWLINE INDENT if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' value_pattern")); - Token * _literal; - expr_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + Token * indent_var; + Token * newline_var; + if ( + (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' && - (elem = value_pattern_rule(p)) // value_pattern + (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' ) { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + _res = _PyPegen_dummy_name(p, newline_var, indent_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_69[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_70: param_no_default +static asdl_seq * +_loop0_70_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // param_no_default + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_70[%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 + ) + { + _res = param_no_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -21862,8 +21949,8 @@ _loop0_71_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_71[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' value_pattern")); + D(fprintf(stderr, "%*c%s _loop0_70[%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); if (!_seq) { @@ -21875,53 +21962,80 @@ _loop0_71_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_71_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_70_type, _seq); D(p->level--); return _seq; } -// _gather_70: value_pattern _loop0_71 +// _loop0_71: param_with_default static asdl_seq * -_gather_70_rule(Parser *p) +_loop0_71_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - asdl_seq * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // value_pattern _loop0_71 + int _start_mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // param_with_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_71")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = value_pattern_rule(p)) // value_pattern - && - (seq = _loop0_71_rule(p)) // _loop0_71 + D(fprintf(stderr, "%*c> _loop0_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + NameDefaultPair* param_with_default_var; + while ( + (param_with_default_var = param_with_default_rule(p)) // param_with_default ) { - D(fprintf(stderr, "%*c+ _gather_70[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern _loop0_71")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; + _res = param_with_default_var; + 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 _gather_70[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern _loop0_71")); + D(fprintf(stderr, "%*c%s _loop0_71[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } - _res = NULL; - done: + 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_71_type, _seq); D(p->level--); - return _res; + return _seq; } -// _loop0_73: ',' key_value_pattern +// _loop0_72: param_with_default static asdl_seq * -_loop0_73_rule(Parser *p) +_loop0_72_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21940,27 +22054,18 @@ _loop0_73_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' key_value_pattern + { // param_with_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); - Token * _literal; - KeyValuePair* elem; + D(fprintf(stderr, "%*c> _loop0_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + NameDefaultPair* param_with_default_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = key_value_pattern_rule(p)) // key_value_pattern + (param_with_default_var = param_with_default_rule(p)) // param_with_default ) { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - D(p->level--); - return NULL; - } + _res = param_with_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -21976,8 +22081,8 @@ _loop0_73_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_73[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' key_value_pattern")); + D(fprintf(stderr, "%*c%s _loop0_72[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -21989,364 +22094,115 @@ _loop0_73_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_73_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_72_type, _seq); D(p->level--); return _seq; } -// _gather_72: key_value_pattern _loop0_73 +// _loop1_73: param_no_default static asdl_seq * -_gather_72_rule(Parser *p) +_loop1_73_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - asdl_seq * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // key_value_pattern _loop0_73 - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _gather_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_73")); - KeyValuePair* elem; - asdl_seq * seq; - if ( - (elem = key_value_pattern_rule(p)) // key_value_pattern - && - (seq = _loop0_73_rule(p)) // _loop0_73 - ) - { - D(fprintf(stderr, "%*c+ _gather_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_73")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_72[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_73")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_74: '*' | '**' -static void * -_tmp_74_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { + int _start_mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); D(p->level--); return NULL; } - void * _res = NULL; - int _mark = p->mark; - { // '*' + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // param_no_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' + D(fprintf(stderr, "%*c> _loop1_73[%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 ) { - D(fprintf(stderr, "%*c+ _tmp_74[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); - _res = _literal; - goto done; + _res = param_no_default_var; + 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 _tmp_74[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); + D(fprintf(stderr, "%*c%s _loop1_73[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } - { // '**' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' - ) - { - D(fprintf(stderr, "%*c+ _tmp_74[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_74[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; } - _res = NULL; - done: + 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, _loop1_73_type, _seq); D(p->level--); - return _res; + return _seq; } -// _tmp_75: literal_pattern | constant_pattern -static void * -_tmp_75_rule(Parser *p) +// _loop0_74: param_with_default +static asdl_seq * +_loop0_74_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // literal_pattern + int _start_mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // param_with_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); - expr_ty literal_pattern_var; - if ( - (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern + D(fprintf(stderr, "%*c> _loop0_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + NameDefaultPair* param_with_default_var; + while ( + (param_with_default_var = param_with_default_rule(p)) // param_with_default ) { - D(fprintf(stderr, "%*c+ _tmp_75[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); - _res = literal_pattern_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_75[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern")); - } - { // constant_pattern - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "constant_pattern")); - expr_ty constant_pattern_var; - if ( - (constant_pattern_var = constant_pattern_rule(p)) // constant_pattern - ) - { - D(fprintf(stderr, "%*c+ _tmp_75[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "constant_pattern")); - _res = constant_pattern_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_75[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "constant_pattern")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_76: 'from' expression -static void * -_tmp_76_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'from' expression - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); - Token * _keyword; - expr_ty z; - if ( - (_keyword = _PyPegen_expect_token(p, 514)) // token='from' - && - (z = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ _tmp_76[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); - _res = z; - 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_76[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_77: '->' expression -static void * -_tmp_77_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> _tmp_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); - Token * _literal; - expr_ty z; - if ( - (_literal = _PyPegen_expect_token(p, 51)) // token='->' - && - (z = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ _tmp_77[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); - _res = z; - 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_77[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_78: '->' expression -static void * -_tmp_78_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> _tmp_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); - Token * _literal; - expr_ty z; - if ( - (_literal = _PyPegen_expect_token(p, 51)) // token='->' - && - (z = expression_rule(p)) // expression - ) - { - D(fprintf(stderr, "%*c+ _tmp_78[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); - _res = z; - 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_78[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_79: NEWLINE INDENT -static void * -_tmp_79_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // NEWLINE INDENT - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); - Token * indent_var; - Token * newline_var; - if ( - (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' - && - (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' - ) - { - D(fprintf(stderr, "%*c+ _tmp_79[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); - _res = _PyPegen_dummy_name(p, newline_var, indent_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_79[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _loop0_80: param_no_default -static asdl_seq * -_loop0_80_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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // param_no_default - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_80[%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 - ) - { - _res = param_no_default_var; + _res = param_with_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22362,8 +22218,8 @@ _loop0_80_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_80[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c%s _loop0_74[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -22375,14 +22231,14 @@ _loop0_80_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_80_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_74_type, _seq); D(p->level--); return _seq; } -// _loop0_81: param_with_default +// _loop1_75: param_with_default static asdl_seq * -_loop0_81_rule(Parser *p) +_loop1_75_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22406,7 +22262,7 @@ _loop0_81_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -22428,9 +22284,14 @@ _loop0_81_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_81[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_75[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; + } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { PyMem_Free(_children); @@ -22441,14 +22302,14 @@ _loop0_81_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_81_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_75_type, _seq); D(p->level--); return _seq; } -// _loop0_82: param_with_default +// _loop1_76: param_no_default static asdl_seq * -_loop0_82_rule(Parser *p) +_loop1_76_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22467,18 +22328,18 @@ _loop0_82_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // param_with_default + { // param_no_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); - NameDefaultPair* param_with_default_var; + D(fprintf(stderr, "%*c> _loop1_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + arg_ty param_no_default_var; while ( - (param_with_default_var = param_with_default_rule(p)) // param_with_default + (param_no_default_var = param_no_default_rule(p)) // param_no_default ) { - _res = param_with_default_var; + _res = param_no_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22494,8 +22355,13 @@ _loop0_82_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_82[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c%s _loop1_76[%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); + D(p->level--); + return NULL; } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -22507,14 +22373,14 @@ _loop0_82_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_82_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_76_type, _seq); D(p->level--); return _seq; } -// _loop1_83: param_no_default +// _loop1_77: param_no_default static asdl_seq * -_loop1_83_rule(Parser *p) +_loop1_77_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22538,7 +22404,7 @@ _loop1_83_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_77[%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 @@ -22560,7 +22426,7 @@ _loop1_83_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_77[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -22578,14 +22444,14 @@ _loop1_83_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_83_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_77_type, _seq); D(p->level--); return _seq; } -// _loop0_84: param_with_default +// _loop0_78: param_no_default static asdl_seq * -_loop0_84_rule(Parser *p) +_loop0_78_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22604,18 +22470,18 @@ _loop0_84_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // param_with_default + { // param_no_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); - NameDefaultPair* param_with_default_var; + D(fprintf(stderr, "%*c> _loop0_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + arg_ty param_no_default_var; while ( - (param_with_default_var = param_with_default_rule(p)) // param_with_default + (param_no_default_var = param_no_default_rule(p)) // param_no_default ) { - _res = param_with_default_var; + _res = param_no_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22631,8 +22497,8 @@ _loop0_84_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_84[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c%s _loop0_78[%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); if (!_seq) { @@ -22644,14 +22510,14 @@ _loop0_84_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_84_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_78_type, _seq); D(p->level--); return _seq; } -// _loop1_85: param_with_default +// _loop1_79: param_with_default static asdl_seq * -_loop1_85_rule(Parser *p) +_loop1_79_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22675,7 +22541,7 @@ _loop1_85_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -22697,7 +22563,7 @@ _loop1_85_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_85[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_79[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -22715,14 +22581,14 @@ _loop1_85_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_85_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_79_type, _seq); D(p->level--); return _seq; } -// _loop1_86: param_no_default +// _loop0_80: param_no_default static asdl_seq * -_loop1_86_rule(Parser *p) +_loop0_80_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22746,7 +22612,7 @@ _loop1_86_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_80[%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 @@ -22768,14 +22634,9 @@ _loop1_86_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_80[%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); - D(p->level--); - return NULL; - } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { PyMem_Free(_children); @@ -22786,14 +22647,14 @@ _loop1_86_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_86_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_80_type, _seq); D(p->level--); return _seq; } -// _loop1_87: param_no_default +// _loop1_81: param_with_default static asdl_seq * -_loop1_87_rule(Parser *p) +_loop1_81_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22812,18 +22673,18 @@ _loop1_87_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // param_no_default + { // param_with_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); - arg_ty param_no_default_var; + D(fprintf(stderr, "%*c> _loop1_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + NameDefaultPair* param_with_default_var; while ( - (param_no_default_var = param_no_default_rule(p)) // param_no_default + (param_with_default_var = param_with_default_rule(p)) // param_with_default ) { - _res = param_no_default_var; + _res = param_with_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22839,8 +22700,8 @@ _loop1_87_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { PyMem_Free(_children); @@ -22857,14 +22718,14 @@ _loop1_87_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_87_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq); D(p->level--); return _seq; } -// _loop0_88: param_no_default +// _loop0_82: param_maybe_default static asdl_seq * -_loop0_88_rule(Parser *p) +_loop0_82_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22883,18 +22744,18 @@ _loop0_88_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // param_no_default + { // param_maybe_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); - arg_ty param_no_default_var; + D(fprintf(stderr, "%*c> _loop0_82[%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 *)); @@ -22910,8 +22771,8 @@ _loop0_88_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_88[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c%s _loop0_82[%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) { @@ -22923,14 +22784,14 @@ _loop0_88_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_88_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_82_type, _seq); D(p->level--); return _seq; } -// _loop1_89: param_with_default +// _loop1_83: param_maybe_default static asdl_seq * -_loop1_89_rule(Parser *p) +_loop1_83_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22949,18 +22810,18 @@ _loop1_89_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // param_with_default + { // param_maybe_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); - NameDefaultPair* param_with_default_var; + D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + NameDefaultPair* param_maybe_default_var; while ( - (param_with_default_var = param_with_default_rule(p)) // param_with_default + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default ) { - _res = param_with_default_var; + _res = param_maybe_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22976,8 +22837,8 @@ _loop1_89_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } if (_n == 0 || p->error_indicator) { PyMem_Free(_children); @@ -22994,14 +22855,14 @@ _loop1_89_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_89_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); D(p->level--); return _seq; } -// _loop0_90: param_no_default +// _loop1_84: ('@' named_expression NEWLINE) static asdl_seq * -_loop0_90_rule(Parser *p) +_loop1_84_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23020,18 +22881,18 @@ _loop0_90_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // param_no_default + { // ('@' named_expression NEWLINE) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); - arg_ty param_no_default_var; + D(fprintf(stderr, "%*c> _loop1_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); + void *_tmp_158_var; while ( - (param_no_default_var = param_no_default_rule(p)) // param_no_default + (_tmp_158_var = _tmp_158_rule(p)) // '@' named_expression NEWLINE ) { - _res = param_no_default_var; + _res = _tmp_158_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23047,8 +22908,13 @@ _loop0_90_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_90[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -23060,85 +22926,61 @@ _loop0_90_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_90_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); D(p->level--); return _seq; } -// _loop1_91: param_with_default -static asdl_seq * -_loop1_91_rule(Parser *p) +// _tmp_85: '(' arguments? ')' +static void * +_tmp_85_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void *_res = 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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // param_with_default + { // '(' arguments? ')' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); - NameDefaultPair* param_with_default_var; - while ( - (param_with_default_var = param_with_default_rule(p)) // param_with_default + D(fprintf(stderr, "%*c> _tmp_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + Token * _literal; + Token * _literal_1; + void *z; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (z = arguments_rule(p), 1) // arguments? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - _res = param_with_default_var; - 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; + D(fprintf(stderr, "%*c+ _tmp_85[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; } - _children[_n++] = _res; - _mark = p->mark; + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - D(p->level--); - return NULL; - } - 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; + D(fprintf(stderr, "%*c%s _tmp_85[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); } - 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_91_type, _seq); + _res = NULL; + done: D(p->level--); - return _seq; + return _res; } -// _loop0_92: param_maybe_default +// _loop0_87: ',' star_expression static asdl_seq * -_loop0_92_rule(Parser *p) +_loop0_87_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23157,18 +22999,27 @@ _loop0_92_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // param_maybe_default + { // ',' star_expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); - NameDefaultPair* param_maybe_default_var; + D(fprintf(stderr, "%*c> _loop0_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + Token * _literal; + expr_ty elem; while ( - (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = star_expression_rule(p)) // star_expression ) { - _res = param_maybe_default_var; + _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 *)); @@ -23184,8 +23035,8 @@ _loop0_92_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_92[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c%s _loop0_87[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -23197,14 +23048,53 @@ _loop0_92_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_92_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_87_type, _seq); D(p->level--); return _seq; } -// _loop1_93: param_maybe_default +// _gather_86: star_expression _loop0_87 +static asdl_seq * +_gather_86_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // star_expression _loop0_87 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _gather_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_87")); + expr_ty elem; + asdl_seq * seq; + if ( + (elem = star_expression_rule(p)) // star_expression + && + (seq = _loop0_87_rule(p)) // _loop0_87 + ) + { + D(fprintf(stderr, "%*c+ _gather_86[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_87")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_86[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_87")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop1_88: (',' star_expression) static asdl_seq * -_loop1_93_rule(Parser *p) +_loop1_88_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23223,18 +23113,18 @@ _loop1_93_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // param_maybe_default + { // (',' star_expression) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); - NameDefaultPair* param_maybe_default_var; + D(fprintf(stderr, "%*c> _loop1_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); + void *_tmp_159_var; while ( - (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default + (_tmp_159_var = _tmp_159_rule(p)) // ',' star_expression ) { - _res = param_maybe_default_var; + _res = _tmp_159_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23250,8 +23140,8 @@ _loop1_93_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_93[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c%s _loop1_88[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); } if (_n == 0 || p->error_indicator) { PyMem_Free(_children); @@ -23268,14 +23158,14 @@ _loop1_93_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_93_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_88_type, _seq); D(p->level--); return _seq; } -// _loop1_94: ('@' named_expression NEWLINE) +// _loop0_90: ',' star_named_expression static asdl_seq * -_loop1_94_rule(Parser *p) +_loop0_90_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23294,18 +23184,27 @@ _loop1_94_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ('@' named_expression NEWLINE) + { // ',' star_named_expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); - void *_tmp_176_var; + D(fprintf(stderr, "%*c> _loop0_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); + Token * _literal; + expr_ty elem; while ( - (_tmp_176_var = _tmp_176_rule(p)) // '@' named_expression NEWLINE + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = star_named_expression_rule(p)) // star_named_expression ) { - _res = _tmp_176_var; + _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 *)); @@ -23321,13 +23220,8 @@ _loop1_94_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_94[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s _loop0_90[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -23339,51 +23233,43 @@ _loop1_94_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_94_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_90_type, _seq); D(p->level--); return _seq; } -// _tmp_95: '(' arguments? ')' -static void * -_tmp_95_rule(Parser *p) +// _gather_89: star_named_expression _loop0_90 +static asdl_seq * +_gather_89_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // '(' arguments? ')' + { // star_named_expression _loop0_90 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); - Token * _literal; - Token * _literal_1; - void *z; + D(fprintf(stderr, "%*c> _gather_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_90")); + expr_ty elem; + asdl_seq * seq; if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - && - (z = arguments_rule(p), 1) // arguments? + (elem = star_named_expression_rule(p)) // star_named_expression && - (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + (seq = _loop0_90_rule(p)) // _loop0_90 ) { - D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); - _res = z; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } + D(fprintf(stderr, "%*c+ _gather_89[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_90")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c%s _gather_89[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_90")); } _res = NULL; done: @@ -23391,9 +23277,9 @@ _tmp_95_rule(Parser *p) return _res; } -// _loop0_97: ',' star_expression +// _loop1_91: (',' expression) static asdl_seq * -_loop0_97_rule(Parser *p) +_loop1_91_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23412,27 +23298,18 @@ _loop0_97_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' star_expression + { // (',' expression) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); - Token * _literal; - expr_ty elem; + D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); + void *_tmp_160_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = star_expression_rule(p)) // star_expression + (_tmp_160_var = _tmp_160_rule(p)) // ',' expression ) { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - D(p->level--); - return NULL; - } + _res = _tmp_160_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23448,8 +23325,13 @@ _loop0_97_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_97[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -23461,53 +23343,14 @@ _loop0_97_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_97_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq); D(p->level--); return _seq; } -// _gather_96: star_expression _loop0_97 +// _loop0_92: lambda_param_no_default static asdl_seq * -_gather_96_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // star_expression _loop0_97 - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _gather_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_97")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = star_expression_rule(p)) // star_expression - && - (seq = _loop0_97_rule(p)) // _loop0_97 - ) - { - D(fprintf(stderr, "%*c+ _gather_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_97")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_96[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_97")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _loop1_98: (',' star_expression) -static asdl_seq * -_loop1_98_rule(Parser *p) +_loop0_92_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23526,18 +23369,18 @@ _loop1_98_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // (',' star_expression) + { // lambda_param_no_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); - void *_tmp_177_var; + D(fprintf(stderr, "%*c> _loop0_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + arg_ty lambda_param_no_default_var; while ( - (_tmp_177_var = _tmp_177_rule(p)) // ',' star_expression + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default ) { - _res = _tmp_177_var; + _res = lambda_param_no_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23553,13 +23396,8 @@ _loop1_98_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_98[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s _loop0_92[%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); if (!_seq) { @@ -23571,14 +23409,14 @@ _loop1_98_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_98_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_92_type, _seq); D(p->level--); return _seq; } -// _loop0_100: ',' star_named_expression +// _loop0_93: lambda_param_with_default static asdl_seq * -_loop0_100_rule(Parser *p) +_loop0_93_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23597,27 +23435,18 @@ _loop0_100_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' star_named_expression + { // lambda_param_with_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); - Token * _literal; - expr_ty elem; + D(fprintf(stderr, "%*c> _loop0_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + NameDefaultPair* lambda_param_with_default_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = star_named_expression_rule(p)) // star_named_expression + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default ) { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - D(p->level--); - return NULL; - } + _res = lambda_param_with_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23633,8 +23462,8 @@ _loop0_100_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_100[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); + D(fprintf(stderr, "%*c%s _loop0_93[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -23646,53 +23475,80 @@ _loop0_100_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_100_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_93_type, _seq); D(p->level--); return _seq; } -// _gather_99: star_named_expression _loop0_100 +// _loop0_94: lambda_param_with_default static asdl_seq * -_gather_99_rule(Parser *p) +_loop0_94_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - asdl_seq * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // star_named_expression _loop0_100 + int _start_mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // lambda_param_with_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_100")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = star_named_expression_rule(p)) // star_named_expression - && - (seq = _loop0_100_rule(p)) // _loop0_100 + D(fprintf(stderr, "%*c> _loop0_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + NameDefaultPair* lambda_param_with_default_var; + while ( + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default ) { - D(fprintf(stderr, "%*c+ _gather_99[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_100")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; + _res = lambda_param_with_default_var; + 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 _gather_99[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_100")); + D(fprintf(stderr, "%*c%s _loop0_94[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } - _res = NULL; - done: + 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_94_type, _seq); D(p->level--); - return _res; + return _seq; } -// _loop1_101: (',' expression) +// _loop1_95: lambda_param_no_default static asdl_seq * -_loop1_101_rule(Parser *p) +_loop1_95_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23711,18 +23567,18 @@ _loop1_101_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // (',' expression) + { // lambda_param_no_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); - void *_tmp_178_var; + D(fprintf(stderr, "%*c> _loop1_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + arg_ty lambda_param_no_default_var; while ( - (_tmp_178_var = _tmp_178_rule(p)) // ',' expression + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default ) { - _res = _tmp_178_var; + _res = lambda_param_no_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23738,8 +23594,8 @@ _loop1_101_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_101[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); + D(fprintf(stderr, "%*c%s _loop1_95[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { PyMem_Free(_children); @@ -23756,14 +23612,14 @@ _loop1_101_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_101_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_95_type, _seq); D(p->level--); return _seq; } -// _loop0_102: lambda_param_no_default +// _loop0_96: lambda_param_with_default static asdl_seq * -_loop0_102_rule(Parser *p) +_loop0_96_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23782,18 +23638,18 @@ _loop0_102_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // lambda_param_no_default + { // lambda_param_with_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_102[%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_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + NameDefaultPair* lambda_param_with_default_var; while ( - (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default ) { - _res = lambda_param_no_default_var; + _res = lambda_param_with_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23809,8 +23665,8 @@ _loop0_102_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_102[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c%s _loop0_96[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -23822,14 +23678,14 @@ _loop0_102_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_102_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_96_type, _seq); D(p->level--); return _seq; } -// _loop0_103: lambda_param_with_default +// _loop1_97: lambda_param_with_default static asdl_seq * -_loop0_103_rule(Parser *p) +_loop1_97_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23853,7 +23709,7 @@ _loop0_103_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -23875,9 +23731,14 @@ _loop0_103_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_97[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; + } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { PyMem_Free(_children); @@ -23888,14 +23749,14 @@ _loop0_103_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_103_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_97_type, _seq); D(p->level--); return _seq; } -// _loop0_104: lambda_param_with_default +// _loop1_98: lambda_param_no_default static asdl_seq * -_loop0_104_rule(Parser *p) +_loop1_98_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23914,18 +23775,18 @@ _loop0_104_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // lambda_param_with_default + { // lambda_param_no_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); - NameDefaultPair* lambda_param_with_default_var; + D(fprintf(stderr, "%*c> _loop1_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + arg_ty lambda_param_no_default_var; while ( - (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default ) { - _res = lambda_param_with_default_var; + _res = lambda_param_no_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23941,8 +23802,13 @@ _loop0_104_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_104[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c%s _loop1_98[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -23954,14 +23820,14 @@ _loop0_104_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_104_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_98_type, _seq); D(p->level--); return _seq; } -// _loop1_105: lambda_param_no_default +// _loop1_99: lambda_param_no_default static asdl_seq * -_loop1_105_rule(Parser *p) +_loop1_99_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23985,7 +23851,7 @@ _loop1_105_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_99[%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 @@ -24007,7 +23873,7 @@ _loop1_105_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_99[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -24025,14 +23891,14 @@ _loop1_105_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_105_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq); D(p->level--); return _seq; } -// _loop0_106: lambda_param_with_default +// _loop0_100: lambda_param_no_default static asdl_seq * -_loop0_106_rule(Parser *p) +_loop0_100_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24051,18 +23917,18 @@ _loop0_106_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // lambda_param_with_default + { // lambda_param_no_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); - NameDefaultPair* lambda_param_with_default_var; + D(fprintf(stderr, "%*c> _loop0_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + arg_ty lambda_param_no_default_var; while ( - (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default ) { - _res = lambda_param_with_default_var; + _res = lambda_param_no_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24078,8 +23944,8 @@ _loop0_106_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_106[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c%s _loop0_100[%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); if (!_seq) { @@ -24091,14 +23957,14 @@ _loop0_106_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_106_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_100_type, _seq); D(p->level--); return _seq; } -// _loop1_107: lambda_param_with_default +// _loop1_101: lambda_param_with_default static asdl_seq * -_loop1_107_rule(Parser *p) +_loop1_101_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24122,7 +23988,7 @@ _loop1_107_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -24144,7 +24010,7 @@ _loop1_107_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_107[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_101[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -24162,14 +24028,14 @@ _loop1_107_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_107_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_101_type, _seq); D(p->level--); return _seq; } -// _loop1_108: lambda_param_no_default +// _loop0_102: lambda_param_no_default static asdl_seq * -_loop1_108_rule(Parser *p) +_loop0_102_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24193,7 +24059,7 @@ _loop1_108_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_102[%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 @@ -24215,14 +24081,9 @@ _loop1_108_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_108[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_102[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - D(p->level--); - return NULL; - } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { PyMem_Free(_children); @@ -24233,14 +24094,14 @@ _loop1_108_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_108_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_102_type, _seq); D(p->level--); return _seq; } -// _loop1_109: lambda_param_no_default +// _loop1_103: lambda_param_with_default static asdl_seq * -_loop1_109_rule(Parser *p) +_loop1_103_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24259,18 +24120,18 @@ _loop1_109_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // lambda_param_no_default + { // lambda_param_with_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); - arg_ty lambda_param_no_default_var; + D(fprintf(stderr, "%*c> _loop1_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + NameDefaultPair* lambda_param_with_default_var; while ( - (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default ) { - _res = lambda_param_no_default_var; + _res = lambda_param_with_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24286,8 +24147,8 @@ _loop1_109_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_109[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c%s _loop1_103[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { PyMem_Free(_children); @@ -24304,14 +24165,14 @@ _loop1_109_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_109_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_103_type, _seq); D(p->level--); return _seq; } -// _loop0_110: lambda_param_no_default +// _loop0_104: lambda_param_maybe_default static asdl_seq * -_loop0_110_rule(Parser *p) +_loop0_104_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24330,18 +24191,18 @@ _loop0_110_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // lambda_param_no_default + { // lambda_param_maybe_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_110[%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_104[%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 *)); @@ -24357,8 +24218,8 @@ _loop0_110_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_110[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c%s _loop0_104[%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) { @@ -24370,14 +24231,14 @@ _loop0_110_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_110_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_104_type, _seq); D(p->level--); return _seq; } -// _loop1_111: lambda_param_with_default +// _loop1_105: lambda_param_maybe_default static asdl_seq * -_loop1_111_rule(Parser *p) +_loop1_105_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24396,18 +24257,18 @@ _loop1_111_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // lambda_param_with_default + { // lambda_param_maybe_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); - NameDefaultPair* lambda_param_with_default_var; + D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + NameDefaultPair* lambda_param_maybe_default_var; while ( - (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default + (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default ) { - _res = lambda_param_with_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 *)); @@ -24423,8 +24284,8 @@ _loop1_111_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_111[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } if (_n == 0 || p->error_indicator) { PyMem_Free(_children); @@ -24441,14 +24302,14 @@ _loop1_111_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_111_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq); D(p->level--); return _seq; } -// _loop0_112: lambda_param_no_default +// _loop1_106: ('or' conjunction) static asdl_seq * -_loop0_112_rule(Parser *p) +_loop1_106_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24467,18 +24328,18 @@ _loop0_112_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // lambda_param_no_default + { // ('or' conjunction) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); - arg_ty lambda_param_no_default_var; + D(fprintf(stderr, "%*c> _loop1_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); + void *_tmp_161_var; while ( - (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + (_tmp_161_var = _tmp_161_rule(p)) // 'or' conjunction ) { - _res = lambda_param_no_default_var; + _res = _tmp_161_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24494,8 +24355,13 @@ _loop0_112_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -24507,14 +24373,14 @@ _loop0_112_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_112_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_106_type, _seq); D(p->level--); return _seq; } -// _loop1_113: lambda_param_with_default +// _loop1_107: ('and' inversion) static asdl_seq * -_loop1_113_rule(Parser *p) +_loop1_107_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24533,18 +24399,18 @@ _loop1_113_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // lambda_param_with_default + { // ('and' inversion) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); - NameDefaultPair* lambda_param_with_default_var; + D(fprintf(stderr, "%*c> _loop1_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); + void *_tmp_162_var; while ( - (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default + (_tmp_162_var = _tmp_162_rule(p)) // 'and' inversion ) { - _res = lambda_param_with_default_var; + _res = _tmp_162_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24560,8 +24426,8 @@ _loop1_113_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_113[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c%s _loop1_107[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); } if (_n == 0 || p->error_indicator) { PyMem_Free(_children); @@ -24578,80 +24444,14 @@ _loop1_113_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_113_type, _seq); - D(p->level--); - return _seq; -} - -// _loop0_114: lambda_param_maybe_default -static asdl_seq * -_loop0_114_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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // lambda_param_maybe_default - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); - NameDefaultPair* lambda_param_maybe_default_var; - while ( - (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default - ) - { - _res = lambda_param_maybe_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - 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_114[%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) { - 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_114_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_107_type, _seq); D(p->level--); return _seq; } -// _loop1_115: lambda_param_maybe_default +// _loop1_108: compare_op_bitwise_or_pair static asdl_seq * -_loop1_115_rule(Parser *p) +_loop1_108_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24670,18 +24470,18 @@ _loop1_115_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // lambda_param_maybe_default + { // compare_op_bitwise_or_pair if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); - NameDefaultPair* lambda_param_maybe_default_var; + D(fprintf(stderr, "%*c> _loop1_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); + CmpopExprPair* compare_op_bitwise_or_pair_var; while ( - (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default + (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair ) { - _res = lambda_param_maybe_default_var; + _res = compare_op_bitwise_or_pair_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -24697,8 +24497,8 @@ _loop1_115_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c%s _loop1_108[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); } if (_n == 0 || p->error_indicator) { PyMem_Free(_children); @@ -24715,85 +24515,55 @@ _loop1_115_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_115_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_108_type, _seq); D(p->level--); return _seq; } -// _loop1_116: ('or' conjunction) -static asdl_seq * -_loop1_116_rule(Parser *p) +// _tmp_109: '!=' +static void * +_tmp_109_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void *_res = 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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ('or' conjunction) + { // '!=' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); - void *_tmp_179_var; - while ( - (_tmp_179_var = _tmp_179_rule(p)) // 'or' conjunction + D(fprintf(stderr, "%*c> _tmp_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); + Token * tok; + if ( + (tok = _PyPegen_expect_token(p, 28)) // token='!=' ) { - _res = _tmp_179_var; - 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; + D(fprintf(stderr, "%*c+ _tmp_109[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); + _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; } - _children[_n++] = _res; - _mark = p->mark; + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_116[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - D(p->level--); - return NULL; - } - 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; + D(fprintf(stderr, "%*c%s _tmp_109[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); } - 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_116_type, _seq); + _res = NULL; + done: D(p->level--); - return _seq; + return _res; } -// _loop1_117: ('and' inversion) +// _loop0_111: ',' slice static asdl_seq * -_loop1_117_rule(Parser *p) +_loop0_111_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24812,18 +24582,27 @@ _loop1_117_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ('and' inversion) + { // ',' slice if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); - void *_tmp_180_var; + D(fprintf(stderr, "%*c> _loop0_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); + Token * _literal; + expr_ty elem; while ( - (_tmp_180_var = _tmp_180_rule(p)) // 'and' inversion + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = slice_rule(p)) // slice ) { - _res = _tmp_180_var; + _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 *)); @@ -24839,13 +24618,8 @@ _loop1_117_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_117[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s _loop0_111[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' slice")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -24857,85 +24631,53 @@ _loop1_117_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_117_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_111_type, _seq); D(p->level--); return _seq; } -// _loop1_118: compare_op_bitwise_or_pair +// _gather_110: slice _loop0_111 static asdl_seq * -_loop1_118_rule(Parser *p) +_gather_110_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void *_res = NULL; + asdl_seq * _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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // compare_op_bitwise_or_pair + { // slice _loop0_111 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); - CmpopExprPair* compare_op_bitwise_or_pair_var; - while ( - (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair + D(fprintf(stderr, "%*c> _gather_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_111")); + expr_ty elem; + asdl_seq * seq; + if ( + (elem = slice_rule(p)) // slice + && + (seq = _loop0_111_rule(p)) // _loop0_111 ) { - _res = compare_op_bitwise_or_pair_var; - 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; + D(fprintf(stderr, "%*c+ _gather_110[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_111")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_118[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - D(p->level--); - return NULL; - } - 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; + D(fprintf(stderr, "%*c%s _gather_110[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_111")); } - 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_118_type, _seq); + _res = NULL; + done: D(p->level--); - return _seq; + return _res; } -// _tmp_119: '!=' +// _tmp_112: ':' expression? static void * -_tmp_119_rule(Parser *p) +_tmp_112_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24944,19 +24686,22 @@ _tmp_119_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '!=' + { // ':' expression? if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); - Token * tok; + D(fprintf(stderr, "%*c> _tmp_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); + Token * _literal; + void *d; if ( - (tok = _PyPegen_expect_token(p, 28)) // token='!=' + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (d = expression_rule(p), 1) // expression? ) { - D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); - _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; + D(fprintf(stderr, "%*c+ _tmp_112[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); + _res = d; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -24965,8 +24710,8 @@ _tmp_119_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c%s _tmp_112[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); } _res = NULL; done: @@ -24974,192 +24719,34 @@ _tmp_119_rule(Parser *p) return _res; } -// _loop0_121: ',' slice -static asdl_seq * -_loop0_121_rule(Parser *p) +// _tmp_113: tuple | group | genexp +static void * +_tmp_113_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void *_res = 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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ',' slice + { // tuple if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); - Token * _literal; - expr_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = slice_rule(p)) // slice - ) - { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - 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_121[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' slice")); - } - 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_121_type, _seq); - D(p->level--); - return _seq; -} - -// _gather_120: slice _loop0_121 -static asdl_seq * -_gather_120_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // slice _loop0_121 - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _gather_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_121")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = slice_rule(p)) // slice - && - (seq = _loop0_121_rule(p)) // _loop0_121 - ) - { - D(fprintf(stderr, "%*c+ _gather_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_121")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_120[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_121")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_122: ':' expression? -static void * -_tmp_122_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> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); - Token * _literal; - void *d; - if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - && - (d = expression_rule(p), 1) // expression? - ) - { - D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); - _res = d; - 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_122[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_123: tuple | group | genexp -static void * -_tmp_123_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // tuple - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); expr_ty tuple_var; if ( (tuple_var = tuple_rule(p)) // tuple ) { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); _res = tuple_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); } { // group @@ -25167,18 +24754,18 @@ _tmp_123_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); expr_ty group_var; if ( (group_var = group_rule(p)) // group ) { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); _res = group_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group")); } { // genexp @@ -25186,18 +24773,18 @@ _tmp_123_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); expr_ty genexp_var; if ( (genexp_var = genexp_rule(p)) // genexp ) { - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); _res = genexp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); } _res = NULL; @@ -25206,9 +24793,9 @@ _tmp_123_rule(Parser *p) return _res; } -// _tmp_124: list | listcomp +// _tmp_114: list | listcomp static void * -_tmp_124_rule(Parser *p) +_tmp_114_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25222,18 +24809,18 @@ _tmp_124_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c> _tmp_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); expr_ty list_var; if ( (list_var = list_rule(p)) // list ) { - D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c+ _tmp_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); _res = list_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_114[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); } { // listcomp @@ -25241,18 +24828,18 @@ _tmp_124_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c> _tmp_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); expr_ty listcomp_var; if ( (listcomp_var = listcomp_rule(p)) // listcomp ) { - D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c+ _tmp_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); _res = listcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_114[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp")); } _res = NULL; @@ -25261,9 +24848,9 @@ _tmp_124_rule(Parser *p) return _res; } -// _tmp_125: dict | set | dictcomp | setcomp +// _tmp_115: dict | set | dictcomp | setcomp static void * -_tmp_125_rule(Parser *p) +_tmp_115_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25277,18 +24864,18 @@ _tmp_125_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c> _tmp_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); expr_ty dict_var; if ( (dict_var = dict_rule(p)) // dict ) { - D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c+ _tmp_115[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); _res = dict_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_115[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict")); } { // set @@ -25296,18 +24883,18 @@ _tmp_125_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c> _tmp_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); expr_ty set_var; if ( (set_var = set_rule(p)) // set ) { - D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c+ _tmp_115[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); _res = set_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_115[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set")); } { // dictcomp @@ -25315,18 +24902,18 @@ _tmp_125_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c> _tmp_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); expr_ty dictcomp_var; if ( (dictcomp_var = dictcomp_rule(p)) // dictcomp ) { - D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c+ _tmp_115[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); _res = dictcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_115[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp")); } { // setcomp @@ -25334,18 +24921,18 @@ _tmp_125_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c> _tmp_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); expr_ty setcomp_var; if ( (setcomp_var = setcomp_rule(p)) // setcomp ) { - D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c+ _tmp_115[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); _res = setcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_115[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp")); } _res = NULL; @@ -25354,9 +24941,9 @@ _tmp_125_rule(Parser *p) return _res; } -// _loop1_126: STRING +// _loop1_116: STRING static asdl_seq * -_loop1_126_rule(Parser *p) +_loop1_116_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25380,7 +24967,7 @@ _loop1_126_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); + D(fprintf(stderr, "%*c> _loop1_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); expr_ty string_var; while ( (string_var = _PyPegen_string_token(p)) // STRING @@ -25402,7 +24989,7 @@ _loop1_126_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_126[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_116[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); } if (_n == 0 || p->error_indicator) { @@ -25420,14 +25007,14 @@ _loop1_126_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_126_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_116_type, _seq); D(p->level--); return _seq; } -// _tmp_127: star_named_expression ',' star_named_expressions? +// _tmp_117: star_named_expression ',' star_named_expressions? static void * -_tmp_127_rule(Parser *p) +_tmp_117_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25441,7 +25028,7 @@ _tmp_127_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); Token * _literal; expr_ty y; void *z; @@ -25453,7 +25040,7 @@ _tmp_127_rule(Parser *p) (z = star_named_expressions_rule(p), 1) // star_named_expressions? ) { - D(fprintf(stderr, "%*c+ _tmp_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); _res = _PyPegen_seq_insert_in_front ( p , y , z ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25463,7 +25050,7 @@ _tmp_127_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_127[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_117[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); } _res = NULL; @@ -25472,9 +25059,9 @@ _tmp_127_rule(Parser *p) return _res; } -// _tmp_128: yield_expr | named_expression +// _tmp_118: yield_expr | named_expression static void * -_tmp_128_rule(Parser *p) +_tmp_118_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25487,742 +25074,39 @@ _tmp_128_rule(Parser *p) if (p->error_indicator) { D(p->level--); return NULL; - } - D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); - expr_ty yield_expr_var; - if ( - (yield_expr_var = yield_expr_rule(p)) // yield_expr - ) - { - D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); - _res = yield_expr_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); - } - { // named_expression - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); - expr_ty named_expression_var; - if ( - (named_expression_var = named_expression_rule(p)) // named_expression - ) - { - D(fprintf(stderr, "%*c+ _tmp_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); - _res = named_expression_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_128[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _loop0_130: ',' double_starred_kvpair -static asdl_seq * -_loop0_130_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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ',' double_starred_kvpair - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_130[%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_130[%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_130_type, _seq); - D(p->level--); - return _seq; -} - -// _gather_129: double_starred_kvpair _loop0_130 -static asdl_seq * -_gather_129_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_130 - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _gather_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_130")); - KeyValuePair* elem; - asdl_seq * seq; - if ( - (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair - && - (seq = _loop0_130_rule(p)) // _loop0_130 - ) - { - D(fprintf(stderr, "%*c+ _gather_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_130")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_129[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_130")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _loop1_131: for_if_clause -static asdl_seq * -_loop1_131_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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // for_if_clause - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); - comprehension_ty for_if_clause_var; - while ( - (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause - ) - { - _res = for_if_clause_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - 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 _loop1_131[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - D(p->level--); - return NULL; - } - 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, _loop1_131_type, _seq); - D(p->level--); - return _seq; -} - -// _loop0_132: ('if' disjunction) -static asdl_seq * -_loop0_132_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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ('if' disjunction) - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_181_var; - while ( - (_tmp_181_var = _tmp_181_rule(p)) // 'if' disjunction - ) - { - _res = _tmp_181_var; - 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_132[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); - } - 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_132_type, _seq); - D(p->level--); - return _seq; -} - -// _loop0_133: ('if' disjunction) -static asdl_seq * -_loop0_133_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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ('if' disjunction) - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_182_var; - while ( - (_tmp_182_var = _tmp_182_rule(p)) // 'if' disjunction - ) - { - _res = _tmp_182_var; - 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_133[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); - } - 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_133_type, _seq); - D(p->level--); - return _seq; -} - -// _loop0_135: ',' (starred_expression | named_expression !'=') -static asdl_seq * -_loop0_135_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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ',' (starred_expression | named_expression !'=') - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression | named_expression !'=')")); - Token * _literal; - void *elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = _tmp_183_rule(p)) // starred_expression | named_expression !'=' - ) - { - _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_135[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (starred_expression | named_expression !'=')")); - } - 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_135_type, _seq); - D(p->level--); - return _seq; -} - -// _gather_134: (starred_expression | named_expression !'=') _loop0_135 -static asdl_seq * -_gather_134_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // (starred_expression | named_expression !'=') _loop0_135 - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _gather_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_135")); - void *elem; - asdl_seq * seq; - if ( - (elem = _tmp_183_rule(p)) // starred_expression | named_expression !'=' - && - (seq = _loop0_135_rule(p)) // _loop0_135 - ) - { - D(fprintf(stderr, "%*c+ _gather_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_135")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_134[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_135")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_136: ',' kwargs -static void * -_tmp_136_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // ',' kwargs - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwargs")); - Token * _literal; - asdl_seq* k; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (k = kwargs_rule(p)) // kwargs - ) - { - D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' kwargs")); - _res = k; - 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_136[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwargs")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _loop0_138: ',' kwarg_or_starred -static asdl_seq * -_loop0_138_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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ',' kwarg_or_starred - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); - Token * _literal; - KeywordOrStarred* elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred - ) - { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - 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_138[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); - } - 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_138_type, _seq); - D(p->level--); - return _seq; -} - -// _gather_137: kwarg_or_starred _loop0_138 -static asdl_seq * -_gather_137_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // kwarg_or_starred _loop0_138 - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _gather_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_138")); - KeywordOrStarred* elem; - asdl_seq * seq; - if ( - (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred - && - (seq = _loop0_138_rule(p)) // _loop0_138 - ) - { - D(fprintf(stderr, "%*c+ _gather_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_138")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_137[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_138")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _loop0_140: ',' kwarg_or_double_starred -static asdl_seq * -_loop0_140_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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ',' kwarg_or_double_starred - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); - Token * _literal; - KeywordOrStarred* elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred - ) - { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - 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_140[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); - } - 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_140_type, _seq); - D(p->level--); - return _seq; -} - -// _gather_139: kwarg_or_double_starred _loop0_140 -static asdl_seq * -_gather_139_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + } + D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + expr_ty yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + _res = yield_expr_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // kwarg_or_double_starred _loop0_140 + { // named_expression if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_140")); - KeywordOrStarred* elem; - asdl_seq * seq; + D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); + expr_ty named_expression_var; if ( - (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred - && - (seq = _loop0_140_rule(p)) // _loop0_140 + (named_expression_var = named_expression_rule(p)) // named_expression ) { - D(fprintf(stderr, "%*c+ _gather_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_140")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); + D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + _res = named_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_139[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_140")); + D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); } _res = NULL; done: @@ -26230,9 +25114,9 @@ _gather_139_rule(Parser *p) return _res; } -// _loop0_142: ',' kwarg_or_starred +// _loop0_120: ',' double_starred_kvpair static asdl_seq * -_loop0_142_rule(Parser *p) +_loop0_120_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26251,18 +25135,18 @@ _loop0_142_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' kwarg_or_starred + { // ',' double_starred_kvpair if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); Token * _literal; - KeywordOrStarred* elem; + KeyValuePair* elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred + (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair ) { _res = elem; @@ -26287,8 +25171,8 @@ _loop0_142_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_142[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c%s _loop0_120[%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) { @@ -26300,14 +25184,14 @@ _loop0_142_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_142_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_120_type, _seq); D(p->level--); return _seq; } -// _gather_141: kwarg_or_starred _loop0_142 +// _gather_119: double_starred_kvpair _loop0_120 static asdl_seq * -_gather_141_rule(Parser *p) +_gather_119_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26316,27 +25200,27 @@ _gather_141_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_142 + { // double_starred_kvpair _loop0_120 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_142")); - KeywordOrStarred* elem; + D(fprintf(stderr, "%*c> _gather_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_120")); + KeyValuePair* elem; asdl_seq * seq; if ( - (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred + (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair && - (seq = _loop0_142_rule(p)) // _loop0_142 + (seq = _loop0_120_rule(p)) // _loop0_120 ) { - D(fprintf(stderr, "%*c+ _gather_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_142")); + D(fprintf(stderr, "%*c+ _gather_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_120")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_141[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_142")); + D(fprintf(stderr, "%*c%s _gather_119[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_120")); } _res = NULL; done: @@ -26344,9 +25228,9 @@ _gather_141_rule(Parser *p) return _res; } -// _loop0_144: ',' kwarg_or_double_starred +// _loop1_121: for_if_clause static asdl_seq * -_loop0_144_rule(Parser *p) +_loop1_121_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26365,27 +25249,18 @@ _loop0_144_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' kwarg_or_double_starred + { // for_if_clause if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); - Token * _literal; - KeywordOrStarred* elem; + D(fprintf(stderr, "%*c> _loop1_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); + comprehension_ty for_if_clause_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred + (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause ) { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - D(p->level--); - return NULL; - } + _res = for_if_clause_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -26401,8 +25276,13 @@ _loop0_144_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_144[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c%s _loop1_121[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + D(p->level--); + return NULL; } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -26414,53 +25294,80 @@ _loop0_144_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_144_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_121_type, _seq); D(p->level--); return _seq; } -// _gather_143: kwarg_or_double_starred _loop0_144 +// _loop0_122: ('if' disjunction) static asdl_seq * -_gather_143_rule(Parser *p) +_loop0_122_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - asdl_seq * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_144 + int _start_mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + D(p->level--); + return NULL; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ('if' disjunction) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_144")); - KeywordOrStarred* elem; - asdl_seq * seq; - if ( - (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred - && - (seq = _loop0_144_rule(p)) // _loop0_144 + D(fprintf(stderr, "%*c> _loop0_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_163_var; + while ( + (_tmp_163_var = _tmp_163_rule(p)) // 'if' disjunction ) { - D(fprintf(stderr, "%*c+ _gather_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_144")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; + _res = _tmp_163_var; + 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 _gather_143[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_144")); + D(fprintf(stderr, "%*c%s _loop0_122[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } - _res = NULL; - done: + 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_122_type, _seq); D(p->level--); - return _res; + return _seq; } -// _loop0_145: (',' star_target) +// _loop0_123: ('if' disjunction) static asdl_seq * -_loop0_145_rule(Parser *p) +_loop0_123_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26479,18 +25386,18 @@ _loop0_145_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // (',' star_target) + { // ('if' disjunction) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_184_var; + D(fprintf(stderr, "%*c> _loop0_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_164_var; while ( - (_tmp_184_var = _tmp_184_rule(p)) // ',' star_target + (_tmp_164_var = _tmp_164_rule(p)) // 'if' disjunction ) { - _res = _tmp_184_var; + _res = _tmp_164_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -26506,8 +25413,8 @@ _loop0_145_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_145[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); + D(fprintf(stderr, "%*c%s _loop0_123[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -26519,14 +25426,14 @@ _loop0_145_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_145_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_123_type, _seq); D(p->level--); return _seq; } -// _loop0_147: ',' star_target +// _loop0_125: ',' (starred_expression | named_expression !'=') static asdl_seq * -_loop0_147_rule(Parser *p) +_loop0_125_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26545,18 +25452,18 @@ _loop0_147_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' star_target + { // ',' (starred_expression | named_expression !'=') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _loop0_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression | named_expression !'=')")); Token * _literal; - expr_ty elem; + void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = star_target_rule(p)) // star_target + (elem = _tmp_165_rule(p)) // starred_expression | named_expression !'=' ) { _res = elem; @@ -26581,8 +25488,8 @@ _loop0_147_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_147[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c%s _loop0_125[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (starred_expression | named_expression !'=')")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -26594,14 +25501,14 @@ _loop0_147_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_147_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_125_type, _seq); D(p->level--); return _seq; } -// _gather_146: star_target _loop0_147 +// _gather_124: (starred_expression | named_expression !'=') _loop0_125 static asdl_seq * -_gather_146_rule(Parser *p) +_gather_124_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26610,27 +25517,27 @@ _gather_146_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_target _loop0_147 + { // (starred_expression | named_expression !'=') _loop0_125 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_147")); - expr_ty elem; + D(fprintf(stderr, "%*c> _gather_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_125")); + void *elem; asdl_seq * seq; if ( - (elem = star_target_rule(p)) // star_target + (elem = _tmp_165_rule(p)) // starred_expression | named_expression !'=' && - (seq = _loop0_147_rule(p)) // _loop0_147 + (seq = _loop0_125_rule(p)) // _loop0_125 ) { - D(fprintf(stderr, "%*c+ _gather_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_147")); + D(fprintf(stderr, "%*c+ _gather_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_125")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_146[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_147")); + D(fprintf(stderr, "%*c%s _gather_124[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_125")); } _res = NULL; done: @@ -26638,9 +25545,9 @@ _gather_146_rule(Parser *p) return _res; } -// _tmp_148: !'*' star_target +// _tmp_126: ',' kwargs static void * -_tmp_148_rule(Parser *p) +_tmp_126_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26649,26 +25556,146 @@ _tmp_148_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // !'*' star_target + { // ',' kwargs if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); - expr_ty star_target_var; + D(fprintf(stderr, "%*c> _tmp_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwargs")); + Token * _literal; + asdl_seq* k; if ( - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (star_target_var = star_target_rule(p)) // star_target + (k = kwargs_rule(p)) // kwargs ) { - D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); - _res = star_target_var; + D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' kwargs")); + _res = k; + 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_126[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwargs")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_128: ',' kwarg_or_starred +static asdl_seq * +_loop0_128_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // ',' kwarg_or_starred + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + Token * _literal; + KeywordOrStarred* elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + 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_128[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); + } + 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_128_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_127: kwarg_or_starred _loop0_128 +static asdl_seq * +_gather_127_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // kwarg_or_starred _loop0_128 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _gather_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_128")); + KeywordOrStarred* elem; + asdl_seq * seq; + if ( + (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred + && + (seq = _loop0_128_rule(p)) // _loop0_128 + ) + { + D(fprintf(stderr, "%*c+ _gather_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_128")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c%s _gather_127[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_128")); } _res = NULL; done: @@ -26676,9 +25703,9 @@ _tmp_148_rule(Parser *p) return _res; } -// _loop0_150: ',' del_target +// _loop0_130: ',' kwarg_or_double_starred static asdl_seq * -_loop0_150_rule(Parser *p) +_loop0_130_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26697,18 +25724,18 @@ _loop0_150_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' del_target + { // ',' kwarg_or_double_starred if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); + D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; - expr_ty elem; + KeywordOrStarred* elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = del_target_rule(p)) // del_target + (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred ) { _res = elem; @@ -26733,8 +25760,8 @@ _loop0_150_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_150[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); + D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -26746,14 +25773,14 @@ _loop0_150_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_150_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq); D(p->level--); return _seq; } -// _gather_149: del_target _loop0_150 +// _gather_129: kwarg_or_double_starred _loop0_130 static asdl_seq * -_gather_149_rule(Parser *p) +_gather_129_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26762,27 +25789,27 @@ _gather_149_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // del_target _loop0_150 + { // kwarg_or_double_starred _loop0_130 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_150")); - expr_ty elem; + D(fprintf(stderr, "%*c> _gather_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_130")); + KeywordOrStarred* elem; asdl_seq * seq; if ( - (elem = del_target_rule(p)) // del_target + (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_150_rule(p)) // _loop0_150 + (seq = _loop0_130_rule(p)) // _loop0_130 ) { - D(fprintf(stderr, "%*c+ _gather_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_150")); + D(fprintf(stderr, "%*c+ _gather_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_130")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_149[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_150")); + D(fprintf(stderr, "%*c%s _gather_129[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_130")); } _res = NULL; done: @@ -26790,9 +25817,9 @@ _gather_149_rule(Parser *p) return _res; } -// _loop0_152: ',' target +// _loop0_132: ',' kwarg_or_starred static asdl_seq * -_loop0_152_rule(Parser *p) +_loop0_132_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26811,18 +25838,18 @@ _loop0_152_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' target + { // ',' kwarg_or_starred if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); + D(fprintf(stderr, "%*c> _loop0_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; - expr_ty elem; + KeywordOrStarred* elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = target_rule(p)) // target + (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred ) { _res = elem; @@ -26847,8 +25874,8 @@ _loop0_152_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_152[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' target")); + D(fprintf(stderr, "%*c%s _loop0_132[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -26860,14 +25887,14 @@ _loop0_152_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_152_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_132_type, _seq); D(p->level--); return _seq; } -// _gather_151: target _loop0_152 +// _gather_131: kwarg_or_starred _loop0_132 static asdl_seq * -_gather_151_rule(Parser *p) +_gather_131_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26876,85 +25903,27 @@ _gather_151_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // target _loop0_152 + { // kwarg_or_starred _loop0_132 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_152")); - expr_ty elem; + D(fprintf(stderr, "%*c> _gather_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_132")); + KeywordOrStarred* elem; asdl_seq * seq; if ( - (elem = target_rule(p)) // target + (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_152_rule(p)) // _loop0_152 + (seq = _loop0_132_rule(p)) // _loop0_132 ) { - D(fprintf(stderr, "%*c+ _gather_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_152")); + D(fprintf(stderr, "%*c+ _gather_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_132")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_151[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_152")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - -// _tmp_153: args | expression for_if_clauses -static void * -_tmp_153_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // args - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); - expr_ty args_var; - if ( - (args_var = args_rule(p)) // args - ) - { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); - _res = args_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); - } - { // expression for_if_clauses - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); - expr_ty expression_var; - asdl_comprehension_seq* for_if_clauses_var; - if ( - (expression_var = expression_rule(p)) // expression - && - (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses - ) - { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); - _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c%s _gather_131[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_132")); } _res = NULL; done: @@ -26962,9 +25931,9 @@ _tmp_153_rule(Parser *p) return _res; } -// _loop0_154: star_named_expressions +// _loop0_134: ',' kwarg_or_double_starred static asdl_seq * -_loop0_154_rule(Parser *p) +_loop0_134_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -26983,18 +25952,27 @@ _loop0_154_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // star_named_expressions + { // ',' kwarg_or_double_starred if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); - asdl_expr_seq* star_named_expressions_var; + D(fprintf(stderr, "%*c> _loop0_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + Token * _literal; + KeywordOrStarred* elem; while ( - (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred ) { - _res = star_named_expressions_var; + _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 *)); @@ -27010,8 +25988,8 @@ _loop0_154_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_154[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); + D(fprintf(stderr, "%*c%s _loop0_134[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -27023,14 +26001,53 @@ _loop0_154_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_154_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_134_type, _seq); D(p->level--); return _seq; } -// _loop0_155: (star_targets '=') +// _gather_133: kwarg_or_double_starred _loop0_134 +static asdl_seq * +_gather_133_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // kwarg_or_double_starred _loop0_134 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _gather_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_134")); + KeywordOrStarred* elem; + asdl_seq * seq; + if ( + (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred + && + (seq = _loop0_134_rule(p)) // _loop0_134 + ) + { + D(fprintf(stderr, "%*c+ _gather_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_134")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_133[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_134")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_135: (',' star_target) static asdl_seq * -_loop0_155_rule(Parser *p) +_loop0_135_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27049,18 +26066,18 @@ _loop0_155_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // (star_targets '=') + { // (',' star_target) if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_185_var; + D(fprintf(stderr, "%*c> _loop0_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_166_var; while ( - (_tmp_185_var = _tmp_185_rule(p)) // star_targets '=' + (_tmp_166_var = _tmp_166_rule(p)) // ',' star_target ) { - _res = _tmp_185_var; + _res = _tmp_166_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -27076,8 +26093,8 @@ _loop0_155_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_155[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); + D(fprintf(stderr, "%*c%s _loop0_135[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -27089,14 +26106,14 @@ _loop0_155_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_155_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_135_type, _seq); D(p->level--); return _seq; } -// _loop0_156: (star_targets '=') +// _loop0_137: ',' star_target static asdl_seq * -_loop0_156_rule(Parser *p) +_loop0_137_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27115,18 +26132,27 @@ _loop0_156_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // (star_targets '=') + { // ',' star_target if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_186_var; + D(fprintf(stderr, "%*c> _loop0_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + Token * _literal; + expr_ty elem; while ( - (_tmp_186_var = _tmp_186_rule(p)) // star_targets '=' + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = star_target_rule(p)) // star_target ) { - _res = _tmp_186_var; + _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 *)); @@ -27142,8 +26168,8 @@ _loop0_156_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_156[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); + D(fprintf(stderr, "%*c%s _loop0_137[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -27155,59 +26181,43 @@ _loop0_156_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_156_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_137_type, _seq); D(p->level--); return _seq; } -// _tmp_157: yield_expr | star_expressions -static void * -_tmp_157_rule(Parser *p) +// _gather_136: star_target _loop0_137 +static asdl_seq * +_gather_136_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // yield_expr - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); - expr_ty yield_expr_var; - if ( - (yield_expr_var = yield_expr_rule(p)) // yield_expr - ) - { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); - _res = yield_expr_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); - } - { // star_expressions + { // star_target _loop0_137 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); - expr_ty star_expressions_var; + D(fprintf(stderr, "%*c> _gather_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_137")); + expr_ty elem; + asdl_seq * seq; if ( - (star_expressions_var = star_expressions_rule(p)) // star_expressions + (elem = star_target_rule(p)) // star_target + && + (seq = _loop0_137_rule(p)) // _loop0_137 ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); - _res = star_expressions_var; + D(fprintf(stderr, "%*c+ _gather_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_137")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c%s _gather_136[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_137")); } _res = NULL; done: @@ -27215,9 +26225,9 @@ _tmp_157_rule(Parser *p) return _res; } -// _tmp_158: '[' | '(' | '{' +// _tmp_138: !'*' star_target static void * -_tmp_158_rule(Parser *p) +_tmp_138_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27226,62 +26236,26 @@ _tmp_158_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '[' - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - ) - { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%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_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - ) - { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); - } - { // '{' + { // !'*' star_target if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + expr_ty star_target_var; if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' + && + (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + _res = star_target_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c%s _tmp_138[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); } _res = NULL; done: @@ -27289,9 +26263,9 @@ _tmp_158_rule(Parser *p) return _res; } -// _loop0_159: param_no_default +// _loop0_140: ',' del_target static asdl_seq * -_loop0_159_rule(Parser *p) +_loop0_140_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27310,18 +26284,27 @@ _loop0_159_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // param_no_default + { // ',' del_target if (p->error_indicator) { D(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_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); + Token * _literal; + expr_ty elem; while ( - (param_no_default_var = param_no_default_rule(p)) // param_no_default + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = del_target_rule(p)) // del_target ) { - _res = param_no_default_var; + _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 *)); @@ -27337,8 +26320,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_140[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -27350,59 +26333,43 @@ _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_140_type, _seq); D(p->level--); return _seq; } -// _tmp_160: slash_with_default | param_with_default+ -static void * -_tmp_160_rule(Parser *p) +// _gather_139: del_target _loop0_140 +static asdl_seq * +_gather_139_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // slash_with_default - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_160[%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_160[%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_160[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); - } - { // param_with_default+ + { // del_target _loop0_140 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - asdl_seq * _loop1_187_var; + D(fprintf(stderr, "%*c> _gather_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_140")); + expr_ty elem; + asdl_seq * seq; if ( - (_loop1_187_var = _loop1_187_rule(p)) // param_with_default+ + (elem = del_target_rule(p)) // del_target + && + (seq = _loop0_140_rule(p)) // _loop0_140 ) { - D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - _res = _loop1_187_var; + D(fprintf(stderr, "%*c+ _gather_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_140")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+")); + D(fprintf(stderr, "%*c%s _gather_139[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_140")); } _res = NULL; done: @@ -27410,9 +26377,9 @@ _tmp_160_rule(Parser *p) return _res; } -// _loop0_161: lambda_param_no_default +// _loop0_142: ',' target static asdl_seq * -_loop0_161_rule(Parser *p) +_loop0_142_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27431,18 +26398,27 @@ _loop0_161_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // lambda_param_no_default + { // ',' target if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_161[%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_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); + Token * _literal; + expr_ty elem; while ( - (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = target_rule(p)) // target ) { - _res = lambda_param_no_default_var; + _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 *)); @@ -27458,8 +26434,8 @@ _loop0_161_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_161[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c%s _loop0_142[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' target")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -27471,59 +26447,43 @@ _loop0_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, _loop0_161_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_142_type, _seq); D(p->level--); return _seq; } -// _tmp_162: lambda_slash_with_default | lambda_param_with_default+ -static void * -_tmp_162_rule(Parser *p) +// _gather_141: target _loop0_142 +static asdl_seq * +_gather_141_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // lambda_slash_with_default - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_162[%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_162[%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_162[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default")); - } - { // lambda_param_with_default+ + { // target _loop0_142 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); - asdl_seq * _loop1_188_var; + D(fprintf(stderr, "%*c> _gather_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_142")); + expr_ty elem; + asdl_seq * seq; if ( - (_loop1_188_var = _loop1_188_rule(p)) // lambda_param_with_default+ + (elem = target_rule(p)) // target + && + (seq = _loop0_142_rule(p)) // _loop0_142 ) { - D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); - _res = _loop1_188_var; + D(fprintf(stderr, "%*c+ _gather_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_142")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); 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, "lambda_param_with_default+")); + D(fprintf(stderr, "%*c%s _gather_141[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_142")); } _res = NULL; done: @@ -27531,9 +26491,9 @@ _tmp_162_rule(Parser *p) return _res; } -// _tmp_163: ')' | ',' (')' | '**') +// _tmp_143: args | expression for_if_clauses static void * -_tmp_163_rule(Parser *p) +_tmp_143_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27542,46 +26502,46 @@ _tmp_163_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ')' + { // args if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); + expr_ty args_var; if ( - (_literal = _PyPegen_expect_token(p, 8)) // token=')' + (args_var = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); + _res = args_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); } - { // ',' (')' | '**') + { // expression for_if_clauses if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - Token * _literal; - void *_tmp_189_var; + D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + expr_ty expression_var; + asdl_comprehension_seq* for_if_clauses_var; if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + (expression_var = expression_rule(p)) // expression && - (_tmp_189_var = _tmp_189_rule(p)) // ')' | '**' + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses ) { - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_189_var); + D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); + D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); } _res = NULL; done: @@ -27589,111 +26549,207 @@ _tmp_163_rule(Parser *p) return _res; } -// _tmp_164: ':' | ',' (':' | '**') -static void * -_tmp_164_rule(Parser *p) +// _loop0_144: star_named_expressions +static asdl_seq * +_loop0_144_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = 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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // star_named_expressions if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' + D(fprintf(stderr, "%*c> _loop0_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); + asdl_expr_seq* star_named_expressions_var; + while ( + (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); - _res = _literal; - goto done; + _res = star_named_expressions_var; + 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 _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c%s _loop0_144[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); } - { // ',' (':' | '**') + 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_144_type, _seq); + D(p->level--); + return _seq; +} + +// _loop0_145: (star_targets '=') +static asdl_seq * +_loop0_145_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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // (star_targets '=') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - Token * _literal; - void *_tmp_190_var; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (_tmp_190_var = _tmp_190_rule(p)) // ':' | '**' + D(fprintf(stderr, "%*c> _loop0_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); + void *_tmp_167_var; + while ( + (_tmp_167_var = _tmp_167_rule(p)) // star_targets '=' ) { - D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_190_var); - goto done; + _res = _tmp_167_var; + 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 _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); + D(fprintf(stderr, "%*c%s _loop0_145[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); } - _res = NULL; - done: + 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_145_type, _seq); D(p->level--); - return _res; + return _seq; } -// _tmp_165: star_targets '=' -static void * -_tmp_165_rule(Parser *p) +// _loop0_146: (star_targets '=') +static asdl_seq * +_loop0_146_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void * _res = NULL; - int _mark = p->mark; - { // star_targets '=' + 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; + } + ssize_t _children_capacity = 1; + ssize_t _n = 0; + { // (star_targets '=') if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); - Token * _literal; - expr_ty z; - if ( - (z = star_targets_rule(p)) // star_targets - && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' + D(fprintf(stderr, "%*c> _loop0_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); + void *_tmp_168_var; + while ( + (_tmp_168_var = _tmp_168_rule(p)) // star_targets '=' ) { - D(fprintf(stderr, "%*c+ _tmp_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); - _res = z; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - D(p->level--); - return NULL; + _res = _tmp_168_var; + 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; } - goto done; + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_165[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c%s _loop0_146[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); } - _res = NULL; - done: + 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_146_type, _seq); D(p->level--); - return _res; + return _seq; } -// _tmp_166: '.' | '...' +// _tmp_147: yield_expr | star_expressions static void * -_tmp_166_rule(Parser *p) +_tmp_147_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27702,43 +26758,43 @@ _tmp_166_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '.' + { // yield_expr if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + expr_ty yield_expr_var; if ( - (_literal = _PyPegen_expect_token(p, 23)) // token='.' + (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } - { // '...' + { // star_expressions if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); - Token * _literal; + D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + expr_ty star_expressions_var; if ( - (_literal = _PyPegen_expect_token(p, 52)) // token='...' + (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; done: @@ -27746,9 +26802,9 @@ _tmp_166_rule(Parser *p) return _res; } -// _tmp_167: '.' | '...' +// _tmp_148: '[' | '(' | '{' static void * -_tmp_167_rule(Parser *p) +_tmp_148_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27757,43 +26813,62 @@ _tmp_167_rule(Parser *p) } 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, "'.'")); + D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( - (_literal = _PyPegen_expect_token(p, 23)) // token='.' + (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_148[%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, "'.'")); + D(fprintf(stderr, "%*c%s _tmp_148[%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, "'...'")); + D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); Token * _literal; if ( - (_literal = _PyPegen_expect_token(p, 52)) // token='...' + (_literal = _PyPegen_expect_token(p, 7)) // token='(' ) { - D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_148[%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, "'...'")); + D(fprintf(stderr, "%*c%s _tmp_148[%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_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + ) + { + D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); } _res = NULL; done: @@ -27801,9 +26876,9 @@ _tmp_167_rule(Parser *p) return _res; } -// _loop0_169: ',' pattern +// _loop0_149: param_no_default static asdl_seq * -_loop0_169_rule(Parser *p) +_loop0_149_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27822,27 +26897,18 @@ _loop0_169_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' pattern + { // param_no_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); - Token * _literal; - expr_ty elem; + D(fprintf(stderr, "%*c> _loop0_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + arg_ty param_no_default_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = pattern_rule(p)) // pattern + (param_no_default_var = param_no_default_rule(p)) // param_no_default ) { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - D(p->level--); - return NULL; - } + _res = param_no_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -27858,8 +26924,8 @@ _loop0_169_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_169[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); + D(fprintf(stderr, "%*c%s _loop0_149[%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); if (!_seq) { @@ -27871,43 +26937,59 @@ _loop0_169_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_169_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_149_type, _seq); D(p->level--); return _seq; } -// _gather_168: pattern _loop0_169 -static asdl_seq * -_gather_168_rule(Parser *p) +// _tmp_150: slash_with_default | param_with_default+ +static void * +_tmp_150_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - asdl_seq * _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // pattern _loop0_169 + { // slash_with_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_169")); - expr_ty elem; - asdl_seq * seq; + D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + SlashWithDefault* slash_with_default_var; if ( - (elem = pattern_rule(p)) // pattern - && - (seq = _loop0_169_rule(p)) // _loop0_169 + (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default ) { - D(fprintf(stderr, "%*c+ _gather_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_169")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); + D(fprintf(stderr, "%*c+ _tmp_150[%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_150[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); + } + { // param_with_default+ + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + asdl_seq * _loop1_169_var; + if ( + (_loop1_169_var = _loop1_169_rule(p)) // param_with_default+ + ) + { + D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); + _res = _loop1_169_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_168[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_169")); + D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+")); } _res = NULL; done: @@ -27915,9 +26997,9 @@ _gather_168_rule(Parser *p) return _res; } -// _loop0_171: ',' error_argument_pattern +// _loop0_151: lambda_param_no_default static asdl_seq * -_loop0_171_rule(Parser *p) +_loop0_151_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -27936,27 +27018,18 @@ _loop0_171_rule(Parser *p) } ssize_t _children_capacity = 1; ssize_t _n = 0; - { // ',' error_argument_pattern + { // lambda_param_no_default if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' error_argument_pattern")); - Token * _literal; - void *elem; + D(fprintf(stderr, "%*c> _loop0_151[%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 = error_argument_pattern_rule(p)) // error_argument_pattern + (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); - D(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 *)); @@ -27972,8 +27045,8 @@ _loop0_171_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_171[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' error_argument_pattern")); + D(fprintf(stderr, "%*c%s _loop0_151[%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); if (!_seq) { @@ -27983,45 +27056,177 @@ _loop0_171_rule(Parser *p) 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_171_type, _seq); + 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_151_type, _seq); + D(p->level--); + return _seq; +} + +// _tmp_152: lambda_slash_with_default | lambda_param_with_default+ +static void * +_tmp_152_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + void * _res = NULL; + int _mark = p->mark; + { // lambda_slash_with_default + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_152[%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_152[%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_152[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default")); + } + { // lambda_param_with_default+ + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); + asdl_seq * _loop1_170_var; + if ( + (_loop1_170_var = _loop1_170_rule(p)) // lambda_param_with_default+ + ) + { + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); + _res = _loop1_170_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_153: ')' | ',' (')' | '**') +static void * +_tmp_153_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_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_153[%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_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + Token * _literal; + void *_tmp_171_var; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (_tmp_171_var = _tmp_171_rule(p)) // ')' | '**' + ) + { + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_171_var); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); + } + _res = NULL; + done: D(p->level--); - return _seq; + return _res; } -// _gather_170: error_argument_pattern _loop0_171 -static asdl_seq * -_gather_170_rule(Parser *p) +// _tmp_154: ':' | ',' (':' | '**') +static void * +_tmp_154_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - asdl_seq * _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // error_argument_pattern _loop0_171 + { // ':' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_171")); - void *elem; - asdl_seq * seq; + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + ) + { + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_154[%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_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + Token * _literal; + void *_tmp_172_var; if ( - (elem = error_argument_pattern_rule(p)) // error_argument_pattern + (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (seq = _loop0_171_rule(p)) // _loop0_171 + (_tmp_172_var = _tmp_172_rule(p)) // ':' | '**' ) { - D(fprintf(stderr, "%*c+ _gather_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_171")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_172_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_170[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_argument_pattern _loop0_171")); + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); } _res = NULL; done: @@ -28029,113 +27234,98 @@ _gather_170_rule(Parser *p) return _res; } -// _loop0_173: ',' error_argument_pattern -static asdl_seq * -_loop0_173_rule(Parser *p) +// _tmp_155: star_targets '=' +static void * +_tmp_155_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void *_res = 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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ',' error_argument_pattern + { // star_targets '=' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' error_argument_pattern")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; - void *elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' + expr_ty z; + if ( + (z = star_targets_rule(p)) // star_targets && - (elem = error_argument_pattern_rule(p)) // error_argument_pattern + (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - _res = elem; + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + _res = z; 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; + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_173[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' error_argument_pattern")); - } - 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; + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } - 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_173_type, _seq); + _res = NULL; + done: D(p->level--); - return _seq; + return _res; } -// _gather_172: error_argument_pattern _loop0_173 -static asdl_seq * -_gather_172_rule(Parser *p) +// _tmp_156: '.' | '...' +static void * +_tmp_156_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - asdl_seq * _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // error_argument_pattern _loop0_173 + { // '.' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_173")); - void *elem; - asdl_seq * seq; + D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + Token * _literal; if ( - (elem = error_argument_pattern_rule(p)) // error_argument_pattern - && - (seq = _loop0_173_rule(p)) // _loop0_173 + (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _gather_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_argument_pattern _loop0_173")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); + D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_156[%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_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 52)) // token='...' + ) + { + D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_172[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_argument_pattern _loop0_173")); + D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; done: @@ -28143,113 +27333,54 @@ _gather_172_rule(Parser *p) return _res; } -// _loop0_175: ',' (error_argument_pattern | error_star) -static asdl_seq * -_loop0_175_rule(Parser *p) +// _tmp_157: '.' | '...' +static void * +_tmp_157_rule(Parser *p) { D(p->level++); if (p->error_indicator) { D(p->level--); return NULL; } - void *_res = 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; - } - ssize_t _children_capacity = 1; - ssize_t _n = 0; - { // ',' (error_argument_pattern | error_star) + { // '.' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (error_argument_pattern | error_star)")); + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; - void *elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = _tmp_191_rule(p)) // error_argument_pattern | error_star + if ( + (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - _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; + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + _res = _literal; + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_175[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (error_argument_pattern | error_star)")); - } - 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_175_type, _seq); - D(p->level--); - return _seq; -} - -// _gather_174: (error_argument_pattern | error_star) _loop0_175 -static asdl_seq * -_gather_174_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // (error_argument_pattern | error_star) _loop0_175 + { // '...' if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(error_argument_pattern | error_star) _loop0_175")); - void *elem; - asdl_seq * seq; + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + Token * _literal; if ( - (elem = _tmp_191_rule(p)) // error_argument_pattern | error_star - && - (seq = _loop0_175_rule(p)) // _loop0_175 + (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _gather_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(error_argument_pattern | error_star) _loop0_175")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_174[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(error_argument_pattern | error_star) _loop0_175")); + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; done: @@ -28257,9 +27388,9 @@ _gather_174_rule(Parser *p) return _res; } -// _tmp_176: '@' named_expression NEWLINE +// _tmp_158: '@' named_expression NEWLINE static void * -_tmp_176_rule(Parser *p) +_tmp_158_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28273,7 +27404,7 @@ _tmp_176_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); Token * _literal; expr_ty f; Token * newline_var; @@ -28285,7 +27416,7 @@ _tmp_176_rule(Parser *p) (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); _res = f; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28295,7 +27426,7 @@ _tmp_176_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); } _res = NULL; @@ -28304,9 +27435,9 @@ _tmp_176_rule(Parser *p) return _res; } -// _tmp_177: ',' star_expression +// _tmp_159: ',' star_expression static void * -_tmp_177_rule(Parser *p) +_tmp_159_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28320,7 +27451,7 @@ _tmp_177_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty c; if ( @@ -28329,7 +27460,7 @@ _tmp_177_rule(Parser *p) (c = star_expression_rule(p)) // star_expression ) { - D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28339,7 +27470,7 @@ _tmp_177_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } _res = NULL; @@ -28348,9 +27479,9 @@ _tmp_177_rule(Parser *p) return _res; } -// _tmp_178: ',' expression +// _tmp_160: ',' expression static void * -_tmp_178_rule(Parser *p) +_tmp_160_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28364,7 +27495,7 @@ _tmp_178_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty c; if ( @@ -28373,7 +27504,7 @@ _tmp_178_rule(Parser *p) (c = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28383,7 +27514,7 @@ _tmp_178_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } _res = NULL; @@ -28392,9 +27523,9 @@ _tmp_178_rule(Parser *p) return _res; } -// _tmp_179: 'or' conjunction +// _tmp_161: 'or' conjunction static void * -_tmp_179_rule(Parser *p) +_tmp_161_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28408,7 +27539,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, "'or' conjunction")); + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); Token * _keyword; expr_ty c; if ( @@ -28417,7 +27548,7 @@ _tmp_179_rule(Parser *p) (c = conjunction_rule(p)) // conjunction ) { - D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28427,7 +27558,7 @@ _tmp_179_rule(Parser *p) 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_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); } _res = NULL; @@ -28436,9 +27567,9 @@ _tmp_179_rule(Parser *p) return _res; } -// _tmp_180: 'and' inversion +// _tmp_162: 'and' inversion static void * -_tmp_180_rule(Parser *p) +_tmp_162_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28452,7 +27583,7 @@ _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, "'and' inversion")); + D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); Token * _keyword; expr_ty c; if ( @@ -28461,7 +27592,7 @@ _tmp_180_rule(Parser *p) (c = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28471,7 +27602,7 @@ _tmp_180_rule(Parser *p) 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_162[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); } _res = NULL; @@ -28480,9 +27611,9 @@ _tmp_180_rule(Parser *p) return _res; } -// _tmp_181: 'if' disjunction +// _tmp_163: 'if' disjunction static void * -_tmp_181_rule(Parser *p) +_tmp_163_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28496,7 +27627,7 @@ _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, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -28505,7 +27636,7 @@ _tmp_181_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28515,7 +27646,7 @@ _tmp_181_rule(Parser *p) 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_163[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -28524,9 +27655,9 @@ _tmp_181_rule(Parser *p) return _res; } -// _tmp_182: 'if' disjunction +// _tmp_164: 'if' disjunction static void * -_tmp_182_rule(Parser *p) +_tmp_164_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28540,7 +27671,7 @@ _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, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -28549,7 +27680,7 @@ _tmp_182_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28559,7 +27690,7 @@ _tmp_182_rule(Parser *p) 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_164[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -28568,9 +27699,9 @@ _tmp_182_rule(Parser *p) return _res; } -// _tmp_183: starred_expression | named_expression !'=' +// _tmp_165: starred_expression | named_expression !'=' static void * -_tmp_183_rule(Parser *p) +_tmp_165_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28584,18 +27715,18 @@ _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, "starred_expression")); + D(fprintf(stderr, "%*c> _tmp_165[%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_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); + D(fprintf(stderr, "%*c+ _tmp_165[%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_183[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_165[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); } { // named_expression !'=' @@ -28603,7 +27734,7 @@ _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, "named_expression !'='")); + D(fprintf(stderr, "%*c> _tmp_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression !'='")); expr_ty named_expression_var; if ( (named_expression_var = named_expression_rule(p)) // named_expression @@ -28611,12 +27742,12 @@ _tmp_183_rule(Parser *p) _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression !'='")); + D(fprintf(stderr, "%*c+ _tmp_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression !'='")); _res = named_expression_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_165[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression !'='")); } _res = NULL; @@ -28625,9 +27756,9 @@ _tmp_183_rule(Parser *p) return _res; } -// _tmp_184: ',' star_target +// _tmp_166: ',' star_target static void * -_tmp_184_rule(Parser *p) +_tmp_166_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28641,7 +27772,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, "',' star_target")); + D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty c; if ( @@ -28650,7 +27781,7 @@ _tmp_184_rule(Parser *p) (c = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_184[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -28660,7 +27791,7 @@ _tmp_184_rule(Parser *p) 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_166[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } _res = NULL; @@ -28669,9 +27800,9 @@ _tmp_184_rule(Parser *p) return _res; } -// _tmp_185: star_targets '=' +// _tmp_167: star_targets '=' static void * -_tmp_185_rule(Parser *p) +_tmp_167_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28685,7 +27816,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, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty star_targets_var; if ( @@ -28694,12 +27825,12 @@ _tmp_185_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_185[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_167[%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_185[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -28708,9 +27839,9 @@ _tmp_185_rule(Parser *p) return _res; } -// _tmp_186: star_targets '=' +// _tmp_168: star_targets '=' static void * -_tmp_186_rule(Parser *p) +_tmp_168_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28724,7 +27855,7 @@ _tmp_186_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_186[%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 star_targets_var; if ( @@ -28733,12 +27864,12 @@ _tmp_186_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_186[%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 = _PyPegen_dummy_name(p, star_targets_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_186[%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; @@ -28747,9 +27878,9 @@ _tmp_186_rule(Parser *p) return _res; } -// _loop1_187: param_with_default +// _loop1_169: param_with_default static asdl_seq * -_loop1_187_rule(Parser *p) +_loop1_169_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28773,7 +27904,7 @@ _loop1_187_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_187[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -28795,7 +27926,7 @@ _loop1_187_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_187[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_169[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -28813,14 +27944,14 @@ _loop1_187_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_187_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_169_type, _seq); D(p->level--); return _seq; } -// _loop1_188: lambda_param_with_default +// _loop1_170: lambda_param_with_default static asdl_seq * -_loop1_188_rule(Parser *p) +_loop1_170_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28844,7 +27975,7 @@ _loop1_188_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_188[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -28866,7 +27997,7 @@ _loop1_188_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_188[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_170[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -28884,14 +28015,14 @@ _loop1_188_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_188_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_170_type, _seq); D(p->level--); return _seq; } -// _tmp_189: ')' | '**' +// _tmp_171: ')' | '**' static void * -_tmp_189_rule(Parser *p) +_tmp_171_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28905,18 +28036,18 @@ _tmp_189_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_189[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_189[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_189[%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, "')'")); } { // '**' @@ -28924,18 +28055,18 @@ _tmp_189_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_189[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_189[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_189[%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, "'**'")); } _res = NULL; @@ -28944,9 +28075,9 @@ _tmp_189_rule(Parser *p) return _res; } -// _tmp_190: ':' | '**' +// _tmp_172: ':' | '**' static void * -_tmp_190_rule(Parser *p) +_tmp_172_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -28960,18 +28091,18 @@ _tmp_190_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_190[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_190[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_190[%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, "':'")); } { // '**' @@ -28979,18 +28110,18 @@ _tmp_190_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_190[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_190[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_190[%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, "'**'")); } _res = NULL; @@ -28999,61 +28130,6 @@ _tmp_190_rule(Parser *p) return _res; } -// _tmp_191: error_argument_pattern | error_star -static void * -_tmp_191_rule(Parser *p) -{ - D(p->level++); - if (p->error_indicator) { - D(p->level--); - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // error_argument_pattern - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_191[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_argument_pattern")); - void *error_argument_pattern_var; - if ( - (error_argument_pattern_var = error_argument_pattern_rule(p)) // error_argument_pattern - ) - { - D(fprintf(stderr, "%*c+ _tmp_191[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_argument_pattern")); - _res = error_argument_pattern_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_191[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_argument_pattern")); - } - { // error_star - if (p->error_indicator) { - D(p->level--); - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_191[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "error_star")); - expr_ty error_star_var; - if ( - (error_star_var = error_star_rule(p)) // error_star - ) - { - D(fprintf(stderr, "%*c+ _tmp_191[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "error_star")); - _res = error_star_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_191[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "error_star")); - } - _res = NULL; - done: - D(p->level--); - return _res; -} - void * _PyPegen_parse(Parser *p) { diff --git a/Python/compile.c b/Python/compile.c index df19167343b3d8..0e7a899d4b8785 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5497,11 +5497,7 @@ pattern_load_constant(struct compiler *c, expr_ty p, pattern_context *pc) static int pattern_store_name(struct compiler *c, identifier n, pattern_context *pc) { - if (_PyUnicode_EqualToASCIIString(n, "_")) { - const char *e = "can't assign to '_' here " - "(consider removing or renaming)"; - return compiler_error(c, e); - } + assert(!_PyUnicode_EqualToASCIIString(n, "_")); if (!pc->stores) { CHECK(pc->stores = PySet_New(NULL)); } @@ -5830,6 +5826,10 @@ compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); if (!pc->allow_irrefutable) { + if (WILDCARD_CHECK(p)) { + const char *e = "wildcard makes remaining patterns unreachable"; + return compiler_error(c, e); + } const char *e = "name capture %R makes remaining patterns unreachable"; return compiler_error(c, e, p->v.Name.id); } diff --git a/Python/symtable.c b/Python/symtable.c index 3521f3aa524aa6..93b0737f1b05ec 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1679,7 +1679,6 @@ symtable_visit_expr(struct symtable *st, expr_ty e) break; case MatchAs_kind: VISIT(st, expr, e->v.MatchAs.pattern); - // "_" is not actually valid, but it's the compiler's job to complain: symtable_add_def(st, e->v.MatchAs.name, DEF_LOCAL); break; case MatchOr_kind: From 77515ece9ec2d48f5e2ecd72d6ba52aee2c07f1f Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 22 Oct 2020 15:32:58 -0700 Subject: [PATCH 185/189] Clean up open_sequence_pattern usage --- Grammar/python.gram | 10 ++++---- Parser/parser.c | 57 ++++++++++++++++++++++++--------------------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 8db40e0c5e19cf..55bb3da31e0411 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -209,7 +209,8 @@ case_block[match_case_ty]: guard[expr_ty]: 'if' guard=named_expression { guard } patterns[expr_ty]: - | open_sequence_pattern + | values[asdl_expr_seq*]=open_sequence_pattern { + _Py_Tuple(values, Load, EXTRA) } | pattern pattern[expr_ty]: | as_pattern @@ -263,11 +264,10 @@ group_pattern[expr_ty]: sequence_pattern[expr_ty]: | '[' values=maybe_sequence_pattern? ']' { _Py_List(values, Load, EXTRA) } - | '(' values=open_sequence_pattern? ')' { - values ? values : _Py_Tuple(values, Load, EXTRA) } -open_sequence_pattern[expr_ty]: + | '(' values=open_sequence_pattern? ')' { _Py_Tuple(values, Load, EXTRA) } +open_sequence_pattern[asdl_seq*]: | value=maybe_star_pattern ',' values=maybe_sequence_pattern? { - _Py_Tuple(CHECK(_PyPegen_seq_insert_in_front(p, value, values)), Load, EXTRA) } + _PyPegen_seq_insert_in_front(p, value, values) } maybe_sequence_pattern[asdl_seq*]: | values=','.maybe_star_pattern+ ','? { values } maybe_star_pattern[expr_ty]: diff --git a/Parser/parser.c b/Parser/parser.c index 6683ca4ec1bf72..f384524d088306 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -486,7 +486,7 @@ static expr_ty attr_rule(Parser *p); static expr_ty name_or_attr_rule(Parser *p); static expr_ty group_pattern_rule(Parser *p); static expr_ty sequence_pattern_rule(Parser *p); -static expr_ty open_sequence_pattern_rule(Parser *p); +static asdl_seq* open_sequence_pattern_rule(Parser *p); static asdl_seq* maybe_sequence_pattern_rule(Parser *p); static expr_ty maybe_star_pattern_rule(Parser *p); static expr_ty star_pattern_rule(Parser *p); @@ -5041,19 +5041,42 @@ patterns_rule(Parser *p) } expr_ty _res = NULL; int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + UNUSED(_start_lineno); // Only used by EXTRA macro + int _start_col_offset = p->tokens[_mark]->col_offset; + UNUSED(_start_col_offset); // Only used by EXTRA macro { // open_sequence_pattern if (p->error_indicator) { D(p->level--); return NULL; } D(fprintf(stderr, "%*c> patterns[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "open_sequence_pattern")); - expr_ty open_sequence_pattern_var; + asdl_expr_seq* values; if ( - (open_sequence_pattern_var = open_sequence_pattern_rule(p)) // open_sequence_pattern + (values = (asdl_expr_seq*)open_sequence_pattern_rule(p)) // open_sequence_pattern ) { D(fprintf(stderr, "%*c+ patterns[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "open_sequence_pattern")); - _res = open_sequence_pattern_var; + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + D(p->level--); + return NULL; + } + int _end_lineno = _token->end_lineno; + UNUSED(_end_lineno); // Only used by EXTRA macro + int _end_col_offset = _token->end_col_offset; + UNUSED(_end_col_offset); // Only used by EXTRA macro + _res = _Py_Tuple ( values , Load , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } goto done; } p->mark = _mark; @@ -6203,7 +6226,7 @@ sequence_pattern_rule(Parser *p) UNUSED(_end_lineno); // Only used by EXTRA macro int _end_col_offset = _token->end_col_offset; UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = values ? values : _Py_Tuple ( values , Load , EXTRA ); + _res = _Py_Tuple ( values , Load , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); @@ -6222,7 +6245,7 @@ sequence_pattern_rule(Parser *p) } // open_sequence_pattern: maybe_star_pattern ',' maybe_sequence_pattern? -static expr_ty +static asdl_seq* open_sequence_pattern_rule(Parser *p) { D(p->level++); @@ -6230,17 +6253,8 @@ open_sequence_pattern_rule(Parser *p) D(p->level--); return NULL; } - expr_ty _res = NULL; + asdl_seq* _res = NULL; int _mark = p->mark; - if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { - p->error_indicator = 1; - D(p->level--); - return NULL; - } - int _start_lineno = p->tokens[_mark]->lineno; - UNUSED(_start_lineno); // Only used by EXTRA macro - int _start_col_offset = p->tokens[_mark]->col_offset; - UNUSED(_start_col_offset); // Only used by EXTRA macro { // maybe_star_pattern ',' maybe_sequence_pattern? if (p->error_indicator) { D(p->level--); @@ -6259,16 +6273,7 @@ open_sequence_pattern_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ open_sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern ',' maybe_sequence_pattern?")); - Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); - if (_token == NULL) { - D(p->level--); - return NULL; - } - int _end_lineno = _token->end_lineno; - UNUSED(_end_lineno); // Only used by EXTRA macro - int _end_col_offset = _token->end_col_offset; - UNUSED(_end_col_offset); // Only used by EXTRA macro - _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , value , values ) ) , Load , EXTRA ); + _res = _PyPegen_seq_insert_in_front ( p , value , values ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; D(p->level--); From c0a06d1459b34db2c13c3061936e04c64e900cb6 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 22 Oct 2020 17:03:16 -0700 Subject: [PATCH 186/189] More cleanup --- Doc/library/dis.rst | 28 +++++++++++--------------- Lib/importlib/_bootstrap_external.py | 4 ++-- Python/ceval.c | 30 +++++++++++++++------------- Python/importlib_external.h | 2 +- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 8dfa1fe38b88de..c63240f23a5040 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1239,31 +1239,27 @@ All of the following opcodes use their arguments. .. opcode:: MATCH_CLASS (count) - TODO + TOS is a tuple of keyword attribute names, TOS1 is the class being matched + against, and TOS2 is the match subject. *count* is the number of positional + sub-patterns. - TOS is a tuple of keyword attribute names. - TOS1 is the "class" being called. - TOS2 is the subject. - *oparg* is the number of positional sub-patterns. - - On match, replaces TOS1 with a tuple extracted attributes, and TOS with True. - On no match, replaces TOS with False. + If TOS2 is an instance of TOS1 and has the positional and keyword attributes + required by *count* and TOS, replace TOS with ``True`` and TOS1 with a tuple + of extracted attributes. Otherwise, replace TOS with ``False``. .. versionadded:: 3.10 .. opcode:: MATCH_KEYS (copy) - TODO - - TOS is a tuple of keys. - TOS1 is the match subject. + TOS is a tuple of mapping keys, and TOS1 is the match subject. If TOS1 + contains all of the keys in TOS, replace TOS with a tuple containing the + corresponding values and push ``True``. Otherwisem, push ``False``. - On failure, replaces TOS with None and pushes False. + TODO: This next bit is weird. Just make two non-arg opcodes? - On success, replaces TOS with a tuple of keys and pushes TRUE. If *oparg* is - non-zero, gather remaining items into a dict and put it on the stack where - the subject used to be. + If *copy* is non-zero, gather remaining items into a :class:`dict` and put it + on the stack where the subject used to be. .. versionadded:: 3.10 diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 2afa5b258eb973..b0e5544b1971df 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -278,7 +278,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) # Python 3.10a1 3430 (Make 'annotations' future by default) -# Python 3.10a1 3471 (add structural pattern matching) +# Python 3.10a1 3431 (PEP 634: Structural Pattern Matching) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -288,7 +288,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3471).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3431).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Python/ceval.c b/Python/ceval.c index e2b0b2771d3e91..d19f11b265cdbc 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -834,7 +834,7 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) // Need these for pattern matching: -static PyObject* +static PyObject* // TODO match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) { assert(PyTuple_CheckExact(keys)); @@ -890,9 +890,13 @@ match_map_items(PyThreadState *tstate, PyObject *map, PyObject *keys) return NULL; } -static PyObject * -match_map_copy(PyThreadState *tstate, PyObject *map, PyObject *keys) +static PyObject * // TODO +dict_without_keys(PyThreadState *tstate, PyObject *map, PyObject *keys) { + // copy = dict(map) + // for key in keys: + // del copy[key] + // return copy PyObject *copy; if (PyDict_CheckExact(map)) { copy = PyDict_Copy(map); @@ -907,13 +911,10 @@ match_map_copy(PyThreadState *tstate, PyObject *map, PyObject *keys) return NULL; } } - Py_ssize_t nkeys = PyTuple_GET_SIZE(keys); - for (Py_ssize_t i = 0; i < nkeys; i++) { + // This may seem a bit ineffient, but keys is rarely big enough to actually + // impact runtime. + for (Py_ssize_t i = 0; i < PyTuple_GET_SIZE(keys); i++) { if (PyDict_DelItem(copy, PyTuple_GET_ITEM(keys, i))) { - if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { - _PyErr_Clear(tstate); - continue; - } Py_DECREF(copy); return NULL; } @@ -924,6 +925,10 @@ match_map_copy(PyThreadState *tstate, PyObject *map, PyObject *keys) static PyObject * get_match_args(PyThreadState *tstate, PyObject *type) { + // match_args = getattr(type, "__match_args__", ()) + // if match_args.__class__ in (list, tuple): + // return tuple(match_args) + // raise TypeError PyObject *match_args = PyObject_GetAttrString(type, "__match_args__"); if (!match_args) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -947,7 +952,7 @@ get_match_args(PyThreadState *tstate, PyObject *type) return NULL; } -static PyObject * +static PyObject * // TODO do_match(PyThreadState *tstate, Py_ssize_t nargs, PyObject *kwargs, PyObject *type, PyObject *subject) { // TODO: Break this up! @@ -3634,15 +3639,12 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) if (_PyErr_Occurred(tstate)) { goto error; } - Py_INCREF(Py_None); - SET_TOP(Py_None); - Py_DECREF(keys); Py_INCREF(Py_False); PUSH(Py_False); DISPATCH(); } if (oparg) { - PyObject *rest = match_map_copy(tstate, subject, keys); + PyObject *rest = dict_without_keys(tstate, subject, keys); if (!rest) { goto error; } diff --git a/Python/importlib_external.h b/Python/importlib_external.h index bfe027cd6a128b..e148973fbec610 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -285,7 +285,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,218,13,95,119,114,105,116,101,95,97,116,111,109,105,99, 120,0,0,0,115,28,0,0,0,0,5,16,1,6,1,22, 255,4,2,2,3,14,1,40,1,16,1,12,1,2,1,14, - 1,12,1,6,1,114,69,0,0,0,105,143,13,0,0,114, + 1,12,1,6,1,114,69,0,0,0,105,103,13,0,0,114, 28,0,0,0,114,17,0,0,0,115,2,0,0,0,13,10, 90,11,95,95,112,121,99,97,99,104,101,95,95,122,4,111, 112,116,45,122,3,46,112,121,122,4,46,112,121,99,78,41, From 26d35e51806297121cd249697adf9da41543703a Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 22 Oct 2020 18:07:16 -0700 Subject: [PATCH 187/189] Raise remaining SyntaxErrors in compiler --- Python/compile.c | 75 ++++++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 0e7a899d4b8785..05a79af79c28d4 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5461,12 +5461,12 @@ compiler_slice(struct compiler *c, expr_ty s) static int -pattern_load_attribute(struct compiler *c, expr_ty p, pattern_context *pc) +pattern_helper_load_attr(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Attribute_kind); assert(p->v.Attribute.ctx == Load); if (p->v.Attribute.value->kind == Attribute_kind) { - CHECK(pattern_load_attribute(c, p->v.Attribute.value, pc)); + CHECK(pattern_helper_load_attr(c, p->v.Attribute.value, pc)); } else { assert(p->v.Attribute.value->kind == Name_kind); @@ -5479,7 +5479,7 @@ pattern_load_attribute(struct compiler *c, expr_ty p, pattern_context *pc) static int -pattern_load_constant(struct compiler *c, expr_ty p, pattern_context *pc) +pattern_helper_load_constant(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Constant_kind); assert(p->v.Constant.value == Py_None || @@ -5494,8 +5494,8 @@ pattern_load_constant(struct compiler *c, expr_ty p, pattern_context *pc) } -static int -pattern_store_name(struct compiler *c, identifier n, pattern_context *pc) +static int // TODO +pattern_helper_store_name(struct compiler *c, identifier n, pattern_context *pc) { assert(!_PyUnicode_EqualToASCIIString(n, "_")); if (!pc->stores) { @@ -5523,13 +5523,13 @@ compiler_pattern_attribute(struct compiler *c, expr_ty p, pattern_context *pc) assert(p->kind == Attribute_kind); assert(p->v.Attribute.ctx == Load); ADDOP(c, DUP_TOP); - CHECK(pattern_load_attribute(c, p, pc)); + CHECK(pattern_helper_load_attr(c, p, pc)); ADDOP_COMPARE(c, Eq); return 1; } -static int +static int // TODO compiler_pattern_match_or(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == MatchOr_kind); @@ -5587,22 +5587,21 @@ compiler_pattern_match_or(struct compiler *c, expr_ty p, pattern_context *pc) } -static int +static int // TODO compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { asdl_expr_seq *args = p->v.Call.args; asdl_keyword_seq *kwargs = p->v.Call.keywords; Py_ssize_t nargs = asdl_seq_LEN(args); Py_ssize_t nkwargs = asdl_seq_LEN(kwargs); - if (nargs + nkwargs > INT_MAX) { + if (INT_MAX < nargs || INT_MAX < nargs + nkwargs - 1) { const char *e = "too many sub-patterns in class pattern %R"; return compiler_error(c, e, p->v.Call.func); } - basicblock *block, *end; CHECK(!validate_keywords(c, kwargs)); - CHECK(block = compiler_new_block(c)); + basicblock *end; CHECK(end = compiler_new_block(c)); if (p->v.Call.func->kind == Attribute_kind) { - CHECK(pattern_load_attribute(c, p->v.Call.func, pc)); + CHECK(pattern_helper_load_attr(c, p->v.Call.func, pc)); } else { assert(p->v.Call.func->kind == Name_kind); @@ -5652,7 +5651,7 @@ compiler_pattern_constant(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Constant_kind); ADDOP(c, DUP_TOP); - CHECK(pattern_load_constant(c, p, pc)); + CHECK(pattern_helper_load_constant(c, p, pc)); PyObject *v = p->v.Constant.value; // Literal True, False, and None are compared by identity. // All others use equality. @@ -5661,17 +5660,16 @@ compiler_pattern_constant(struct compiler *c, expr_ty p, pattern_context *pc) } -static int +static int // TODO compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) { - basicblock *block, *end; - CHECK(block = compiler_new_block(c)); + basicblock *fail, *end; + CHECK(fail = compiler_new_block(c)); CHECK(end = compiler_new_block(c)); asdl_expr_seq *keys = p->v.Dict.keys; asdl_expr_seq *values = p->v.Dict.values; Py_ssize_t size = asdl_seq_LEN(values); int star = size ? !asdl_seq_GET(keys, size - 1) : 0; - // TODO: (i >= (1 << 8)) || (n-i-1 >= (INT_MAX >> 8)) ADDOP(c, MATCH_MAPPING); ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); NEXT_BLOCK(c); @@ -5682,6 +5680,9 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); NEXT_BLOCK(c); } + if (INT_MAX < size - star - 1) { + return compiler_error(c, "too many sub-patterns in mapping pattern"); + } if (size) { ADDOP(c, DUP_TOP); Py_ssize_t i; @@ -5693,16 +5694,16 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) return compiler_error(c, e); } if (key->kind == Attribute_kind) { - CHECK(pattern_load_attribute(c, key, pc)); + CHECK(pattern_helper_load_attr(c, key, pc)); } else { assert(key->kind == Constant_kind); - CHECK(pattern_load_constant(c, key, pc)); + CHECK(pattern_helper_load_constant(c, key, pc)); } } ADDOP_I(c, BUILD_TUPLE, size - star); ADDOP_I(c, MATCH_KEYS, star); - ADDOP_JUMP(c, POP_JUMP_IF_FALSE, block); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail); NEXT_BLOCK(c); for (i = 0; i < size - star; i++) { expr_ty value = asdl_seq_GET(values, i); @@ -5713,12 +5714,13 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) CHECK(compiler_subpattern(c, value, pc)); ADDOP(c, ROT_TWO); ADDOP(c, POP_TOP); - ADDOP_JUMP(c, POP_JUMP_IF_FALSE, block); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail); NEXT_BLOCK(c); } ADDOP(c, POP_TOP); if (star) { - CHECK(pattern_store_name(c, asdl_seq_GET(values, size - 1)->v.Name.id, pc)); + PyObject *id = asdl_seq_GET(values, size - 1)->v.Name.id; + CHECK(pattern_helper_store_name(c, id, pc)); } else { ADDOP(c, POP_TOP); @@ -5726,7 +5728,7 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) } ADDOP_LOAD_CONST(c, Py_True); ADDOP_JUMP(c, JUMP_FORWARD, end); - compiler_use_next_block(c, block); + compiler_use_next_block(c, fail); ADDOP(c, POP_TOP); ADDOP(c, POP_TOP); ADDOP_LOAD_CONST(c, Py_False); @@ -5735,7 +5737,7 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) } -static int +static int // TODO compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == List_kind || p->kind == Tuple_kind); @@ -5780,8 +5782,10 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP_JUMP(c, POP_JUMP_IF_FALSE, wrong_size); NEXT_BLOCK(c); ADDOP(c, ROT_TWO); + if (INT_MAX < size - 1) { + return compiler_error(c, "too many sub-patterns in sequence pattern"); + } for (Py_ssize_t i = 0; i < size; i++) { - // TODO: (i >= (1 << 8)) || (n-i-1 >= (INT_MAX >> 8)) expr_ty value = asdl_seq_GET(values, i); if (WILDCARD_CHECK(value)) { continue; @@ -5795,6 +5799,13 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) if (WILDCARD_CHECK(value)) { continue; } + if (0xFF <= i || INT_MAX <= ((size - 1 - i) << 8)) { + // Technical limits are 0xFF patterns to the left of the star, + // one starred pattern, and 0xFFFFFF patterns to the right of + // the star... same as UNPACK_EX. + const char* e = "too many sub-patterns in sequence pattern"; + return compiler_error(c, e); + } ADDOP_I(c, GET_INDEX_SLICE, ((size - 1 - i) << 8) + i); } else { @@ -5825,17 +5836,19 @@ compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Name_kind); assert(p->v.Name.ctx == Store); + int wildcard = WILDCARD_CHECK(p); if (!pc->allow_irrefutable) { - if (WILDCARD_CHECK(p)) { + // Whoops, can't have a name capture here! + if (wildcard) { const char *e = "wildcard makes remaining patterns unreachable"; return compiler_error(c, e); } const char *e = "name capture %R makes remaining patterns unreachable"; return compiler_error(c, e, p->v.Name.id); } - if (!WILDCARD_CHECK(p)) { + if (!wildcard) { ADDOP(c, DUP_TOP); - CHECK(pattern_store_name(c, p->v.Name.id, pc)); + CHECK(pattern_helper_store_name(c, p->v.Name.id, pc)); } ADDOP_LOAD_CONST(c, Py_True); return 1; @@ -5852,14 +5865,14 @@ compiler_pattern_match_as(struct compiler *c, expr_ty p, pattern_context *pc) ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); NEXT_BLOCK(c); ADDOP(c, DUP_TOP); - CHECK(pattern_store_name(c, p->v.MatchAs.name, pc)); + CHECK(pattern_helper_store_name(c, p->v.MatchAs.name, pc)); ADDOP_LOAD_CONST(c, Py_True); compiler_use_next_block(c, end); return 1; } -static int +static int // TODO compiler_subpattern(struct compiler *c, expr_ty p, pattern_context *pc) { int allow_irrefutable = pc->allow_irrefutable; @@ -5904,7 +5917,7 @@ compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc) } -static int +static int // TODO compiler_match(struct compiler *c, stmt_ty s) { VISIT(c, expr, s->v.Match.subject); From d43bb0b4e0243c53a3d65b601aeaa17db0a1e3d5 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 23 Oct 2020 08:03:11 -0700 Subject: [PATCH 188/189] Finish compiler cleanup --- Doc/library/dis.rst | 4 +- Lib/importlib/_bootstrap_external.py | 2 +- Lib/test/test_patma.py | 3 - Python/compile.c | 408 ++++++++++++++++----------- 4 files changed, 241 insertions(+), 176 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index c63240f23a5040..453ed0fd6a0843 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1254,9 +1254,7 @@ All of the following opcodes use their arguments. TOS is a tuple of mapping keys, and TOS1 is the match subject. If TOS1 contains all of the keys in TOS, replace TOS with a tuple containing the - corresponding values and push ``True``. Otherwisem, push ``False``. - - TODO: This next bit is weird. Just make two non-arg opcodes? + corresponding values and push ``True``. Otherwise, push ``False``. If *copy* is non-zero, gather remaining items into a :class:`dict` and put it on the stack where the subject used to be. diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index b0e5544b1971df..f1c5f214d71d87 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -278,7 +278,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.9a2 3424 (simplify bytecodes for *value unpacking) # Python 3.9a2 3425 (simplify bytecodes for **value unpacking) # Python 3.10a1 3430 (Make 'annotations' future by default) -# Python 3.10a1 3431 (PEP 634: Structural Pattern Matching) +# Python 3.10a2 3431 (PEP 634: Structural Pattern Matching) # # MAGIC must change whenever the bytecode emitted by the compiler may no diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index cb735efc8fcf65..ac53093f857f58 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2803,9 +2803,6 @@ def test_patma_277(self): self.assertEqual(y, 0) self.assertEqual(z, 0) - # TODO: Better use of assertIs - # TODO: Don't check side-effecty assignments - class PerfPatma(TestPatma): diff --git a/Python/compile.c b/Python/compile.c index 05a79af79c28d4..03663f168b1855 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -251,7 +251,6 @@ static int compiler_async_comprehension_generator( int depth, expr_ty elt, expr_ty val, int type); -static int compiler_subpattern(struct compiler *, expr_ty, pattern_context *); static int compiler_pattern(struct compiler *, expr_ty, pattern_context *); static int compiler_match(struct compiler *, stmt_ty); @@ -5494,10 +5493,11 @@ pattern_helper_load_constant(struct compiler *c, expr_ty p, pattern_context *pc) } -static int // TODO +static int pattern_helper_store_name(struct compiler *c, identifier n, pattern_context *pc) { assert(!_PyUnicode_EqualToASCIIString(n, "_")); + // Can't assign to the same name twice: if (!pc->stores) { CHECK(pc->stores = PySet_New(NULL)); } @@ -5518,77 +5518,55 @@ pattern_helper_store_name(struct compiler *c, identifier n, pattern_context *pc) static int -compiler_pattern_attribute(struct compiler *c, expr_ty p, pattern_context *pc) +compiler_pattern_subpattern(struct compiler *c, expr_ty p, pattern_context *pc) { - assert(p->kind == Attribute_kind); - assert(p->v.Attribute.ctx == Load); - ADDOP(c, DUP_TOP); - CHECK(pattern_helper_load_attr(c, p, pc)); - ADDOP_COMPARE(c, Eq); + // Like compiler_pattern, but turn off checks for irrefutability. + int allow_irrefutable = pc->allow_irrefutable; + pc->allow_irrefutable = 1; + CHECK(compiler_pattern(c, p, pc)); + pc->allow_irrefutable = allow_irrefutable; return 1; } -static int // TODO -compiler_pattern_match_or(struct compiler *c, expr_ty p, pattern_context *pc) +static int +compiler_pattern_as(struct compiler *c, expr_ty p, pattern_context *pc) { - assert(p->kind == MatchOr_kind); + assert(p->kind == MatchAs_kind); basicblock *end; - PyObject *control = NULL; - PyObject *diff; CHECK(end = compiler_new_block(c)); - Py_ssize_t size = asdl_seq_LEN(p->v.MatchOr.patterns); - assert(size > 1); - PyObject *stores_init = pc->stores; - int allow_irrefutable = pc->allow_irrefutable; - expr_ty alt; - for (Py_ssize_t i = 0; i < size; i++) { - // Can't use our helpful returning macros here: they'll leak sets! - alt = asdl_seq_GET(p->v.MatchOr.patterns, i); - pc->stores = PySet_New(stores_init); - // An irrefutable sub-pattern must be last, if it is allowed at all: - pc->allow_irrefutable = allow_irrefutable && (i == size - 1); - SET_LOC(c, alt); - if (!pc->stores || - !compiler_pattern(c, alt, pc) || - !compiler_addop_j(c, JUMP_IF_TRUE_OR_POP, end) || - !compiler_next_block(c)) - { - goto fail; - } - if (!i) { - control = pc->stores; - continue; - } - if (PySet_GET_SIZE(pc->stores) || PySet_GET_SIZE(control)) { - diff = PyNumber_InPlaceXor(pc->stores, control); - if (!diff) { - goto fail; - } - if (PySet_GET_SIZE(diff)) { - Py_DECREF(diff); - compiler_error(c, "alternate patterns bind different names"); - goto fail; - } - Py_DECREF(diff); - } - Py_DECREF(pc->stores); - } - Py_XDECREF(stores_init); - pc->stores = control; - pc->allow_irrefutable = allow_irrefutable; - ADDOP_LOAD_CONST(c, Py_False); + CHECK(compiler_pattern(c, p->v.MatchAs.pattern, pc)); + ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); + NEXT_BLOCK(c); + ADDOP(c, DUP_TOP); + CHECK(pattern_helper_store_name(c, p->v.MatchAs.name, pc)); + ADDOP_LOAD_CONST(c, Py_True); compiler_use_next_block(c, end); return 1; -fail: - Py_XDECREF(stores_init); - Py_XDECREF(control); - return 0; } -static int // TODO -compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { +static int +compiler_pattern_capture(struct compiler *c, expr_ty p, pattern_context *pc) +{ + assert(p->kind == Name_kind); + assert(p->v.Name.ctx == Store); + assert(!WILDCARD_CHECK(p)); + if (!pc->allow_irrefutable) { + // Whoops, can't have a name capture here! + const char *e = "name capture %R makes remaining patterns unreachable"; + return compiler_error(c, e, p->v.Name.id); + } + ADDOP(c, DUP_TOP); + CHECK(pattern_helper_store_name(c, p->v.Name.id, pc)); + ADDOP_LOAD_CONST(c, Py_True); + return 1; +} + + +static int +compiler_pattern_class(struct compiler *c, expr_ty p, pattern_context *pc) +{ asdl_expr_seq *args = p->v.Call.args; asdl_keyword_seq *kwargs = p->v.Call.keywords; Py_ssize_t nargs = asdl_seq_LEN(args); @@ -5600,6 +5578,7 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { CHECK(!validate_keywords(c, kwargs)); basicblock *end; CHECK(end = compiler_new_block(c)); + // The name of the class can only be an (optionally dotted) name: if (p->v.Call.func->kind == Attribute_kind) { CHECK(pattern_helper_load_attr(c, p->v.Call.func, pc)); } @@ -5608,11 +5587,11 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->v.Call.func->v.Name.ctx == Load); CHECK(compiler_nameop(c, p->v.Call.func->v.Name.id, Load)); } - PyObject *kwnames, *name; + PyObject *kwnames; CHECK(kwnames = PyTuple_New(nkwargs)); Py_ssize_t i; for (i = 0; i < nkwargs; i++) { - name = ((keyword_ty) asdl_seq_GET(kwargs, i))->arg; + PyObject *name = ((keyword_ty) asdl_seq_GET(kwargs, i))->arg; Py_INCREF(name); PyTuple_SET_ITEM(kwnames, i, name); } @@ -5620,26 +5599,35 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { ADDOP_I(c, MATCH_CLASS, nargs); ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); NEXT_BLOCK(c); - expr_ty arg; + // TOS is now a tuple of (nargs + nkwargs) attributes. for (i = 0; i < nargs + nkwargs; i++) { + expr_ty arg; if (i < nargs) { + // Positional: arg = asdl_seq_GET(args, i); } else { + // Keyword: arg = ((keyword_ty) asdl_seq_GET(kwargs, i - nargs))->value; } if (WILDCARD_CHECK(arg)) { continue; } + // Get the i-th attribute, and match it against the i-th pattern: ADDOP_I(c, GET_INDEX, i); - CHECK(compiler_subpattern(c, arg, pc)); + CHECK(compiler_pattern_subpattern(c, arg, pc)); + // TOS is True or False, with the attribute beneath. Pop the attribute, + // we're done with it: ADDOP(c, ROT_TWO); ADDOP(c, POP_TOP); ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); NEXT_BLOCK(c); } + // If we made it this far, it's a match! ADDOP_LOAD_CONST(c, Py_True); compiler_use_next_block(c, end); + // TOS is True or False, but we've still got either a class or a tuple of + // attributes beneath it. Pop it, we're done. ADDOP(c, ROT_TWO); ADDOP(c, POP_TOP); return 1; @@ -5647,21 +5635,21 @@ compiler_pattern_call(struct compiler *c, expr_ty p, pattern_context *pc) { static int -compiler_pattern_constant(struct compiler *c, expr_ty p, pattern_context *pc) +compiler_pattern_literal(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == Constant_kind); ADDOP(c, DUP_TOP); CHECK(pattern_helper_load_constant(c, p, pc)); PyObject *v = p->v.Constant.value; - // Literal True, False, and None are compared by identity. - // All others use equality. + // Literal True, False, and None are compared by identity. All others use + // equality: ADDOP_COMPARE(c, (v == Py_None || PyBool_Check(v)) ? Is : Eq); return 1; } -static int // TODO -compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) +static int +compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc) { basicblock *fail, *end; CHECK(fail = compiler_new_block(c)); @@ -5669,11 +5657,19 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) asdl_expr_seq *keys = p->v.Dict.keys; asdl_expr_seq *values = p->v.Dict.values; Py_ssize_t size = asdl_seq_LEN(values); + // A starred pattern will be a keyless value. It is guranteed to be last: int star = size ? !asdl_seq_GET(keys, size - 1) : 0; ADDOP(c, MATCH_MAPPING); ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); NEXT_BLOCK(c); + if (!size) { + // If the pattern is just "{}", we're done! + ADDOP_LOAD_CONST(c, Py_True); + compiler_use_next_block(c, end); + return 1; + } if (size - star) { + // If the pattern has any keys in it, perform a length check: ADDOP(c, GET_LEN); ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - star)); ADDOP_COMPARE(c, GtE); @@ -5683,52 +5679,62 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) if (INT_MAX < size - star - 1) { return compiler_error(c, "too many sub-patterns in mapping pattern"); } - if (size) { - ADDOP(c, DUP_TOP); - Py_ssize_t i; - for (i = 0; i < size - star; i++) { - expr_ty key = asdl_seq_GET(keys, i); - if (!key) { - const char *e = "can't use starred name here " - "(consider moving to end)"; - return compiler_error(c, e); - } - if (key->kind == Attribute_kind) { - CHECK(pattern_helper_load_attr(c, key, pc)); - } - else { - assert(key->kind == Constant_kind); - CHECK(pattern_helper_load_constant(c, key, pc)); - } - } - ADDOP_I(c, BUILD_TUPLE, size - star); - ADDOP_I(c, MATCH_KEYS, star); - ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail); - NEXT_BLOCK(c); - for (i = 0; i < size - star; i++) { - expr_ty value = asdl_seq_GET(values, i); - if (WILDCARD_CHECK(value)) { - continue; - } - ADDOP_I(c, GET_INDEX, i); - CHECK(compiler_subpattern(c, value, pc)); - ADDOP(c, ROT_TWO); - ADDOP(c, POP_TOP); - ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail); - NEXT_BLOCK(c); + // If we have a starred pattern, MATCH_KEYS *could* replace the subject on + // the stack with a dict of remaining keys. Duplicate it so we don't lose + // the subject: + ADDOP(c, DUP_TOP); + // Collect all of the keys into a tuple for MATCH_KEYS. They can either be + // dotted names or literals: + for (Py_ssize_t i = 0; i < size - star; i++) { + expr_ty key = asdl_seq_GET(keys, i); + if (!key) { + const char *e = "can't use starred name here " + "(consider moving to end)"; + return compiler_error(c, e); } - ADDOP(c, POP_TOP); - if (star) { - PyObject *id = asdl_seq_GET(values, size - 1)->v.Name.id; - CHECK(pattern_helper_store_name(c, id, pc)); + if (key->kind == Attribute_kind) { + CHECK(pattern_helper_load_attr(c, key, pc)); } else { - ADDOP(c, POP_TOP); + assert(key->kind == Constant_kind); + CHECK(pattern_helper_load_constant(c, key, pc)); + } + } + ADDOP_I(c, BUILD_TUPLE, size - star); + ADDOP_I(c, MATCH_KEYS, star); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail); + NEXT_BLOCK(c); + // So far so good. There's now a tuple of values on the stack to match + // sub-patterns against. Extract them using GET_INDEX: + for (Py_ssize_t i = 0; i < size - star; i++) { + expr_ty value = asdl_seq_GET(values, i); + if (WILDCARD_CHECK(value)) { + continue; } + ADDOP_I(c, GET_INDEX, i); + CHECK(compiler_pattern_subpattern(c, value, pc)); + // TOS is True or False. Don't care about the value underneath anymore: + ADDOP(c, ROT_TWO); + ADDOP(c, POP_TOP); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail); + NEXT_BLOCK(c); + } + // If we get this far, it's a match! We're done with that tuple of values. + ADDOP(c, POP_TOP); + if (star) { + // There's now one of two things on TOS. If we had a starred name, it's + // a dict of remaining items to bind: + PyObject *id = asdl_seq_GET(values, size - 1)->v.Name.id; + CHECK(pattern_helper_store_name(c, id, pc)); + } + else { + // Otherwise, it's just another reference to the subject underneath. + ADDOP(c, POP_TOP); } ADDOP_LOAD_CONST(c, Py_True); ADDOP_JUMP(c, JUMP_FORWARD, end); compiler_use_next_block(c, fail); + // The top two items are a tuple of values, and a mapping. Pop them both: ADDOP(c, POP_TOP); ADDOP(c, POP_TOP); ADDOP_LOAD_CONST(c, Py_False); @@ -5737,13 +5743,79 @@ compiler_pattern_dict(struct compiler *c, expr_ty p, pattern_context *pc) } -static int // TODO -compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) +static int +compiler_pattern_or(struct compiler *c, expr_ty p, pattern_context *pc) +{ + assert(p->kind == MatchOr_kind); + // control is the set of names bound by the first alternate. If all of the + // others bind the same names (they should), then this becomes pc->stores. + PyObject *control = NULL; + basicblock *end; + CHECK(end = compiler_new_block(c)); + Py_ssize_t size = asdl_seq_LEN(p->v.MatchOr.patterns); + assert(size > 1); + // We're going to be messing with pc. Keep the original info handy: + PyObject *stores_init = pc->stores; + int allow_irrefutable = pc->allow_irrefutable; + for (Py_ssize_t i = 0; i < size; i++) { + // NOTE: Can't use our nice returning macros in here: they'll leak sets! + expr_ty alt = asdl_seq_GET(p->v.MatchOr.patterns, i); + pc->stores = PySet_New(stores_init); + // An irrefutable sub-pattern must be last, if it is allowed at all: + pc->allow_irrefutable = allow_irrefutable && (i == size - 1); + SET_LOC(c, alt); + // The actual control flow is simple: + if (!pc->stores || + !compiler_pattern(c, alt, pc) || + !compiler_addop_j(c, JUMP_IF_TRUE_OR_POP, end) || + !compiler_next_block(c)) + { + goto fail; + } + if (!i) { + // If this is the first alternate, save its stores as a "control" + // for the others (they can't bind a different set names): + control = pc->stores; + continue; + } + if (PySet_GET_SIZE(pc->stores) || PySet_GET_SIZE(control)) { + // Otherwise, check to see if we differ from the control set: + PyObject *diff = PyNumber_InPlaceXor(pc->stores, control); + if (!diff) { + goto fail; + } + if (PySet_GET_SIZE(diff)) { + // The names differ! Raise. + Py_DECREF(diff); + compiler_error(c, "alternate patterns bind different names"); + goto fail; + } + Py_DECREF(diff); + } + Py_DECREF(pc->stores); + } + Py_XDECREF(stores_init); + // Update pc->stores and restore pc->allow_irrefutable: + pc->stores = control; + pc->allow_irrefutable = allow_irrefutable; + ADDOP_LOAD_CONST(c, Py_False); + compiler_use_next_block(c, end); + return 1; +fail: + Py_XDECREF(stores_init); + Py_XDECREF(control); + return 0; +} + + +static int +compiler_pattern_sequence(struct compiler *c, expr_ty p, pattern_context *pc) { assert(p->kind == List_kind || p->kind == Tuple_kind); asdl_expr_seq *values = (p->kind == Tuple_kind) ? p->v.Tuple.elts : p->v.List.elts; Py_ssize_t size = asdl_seq_LEN(values); + // Find a starred name, if it exists. There may be at most one: Py_ssize_t star = -1; for (Py_ssize_t i = 0; i < size; i++) { expr_ty value = asdl_seq_GET(values, i); @@ -5756,20 +5828,23 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) } star = i; } - basicblock *wrong_size, *end, *fail; + basicblock *end; CHECK(end = compiler_new_block(c)); ADDOP(c, MATCH_SEQUENCE); ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); NEXT_BLOCK(c); ADDOP(c, GET_LEN); if (!size) { - ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)); + // Empty sequences only require a length check: + ADDOP_LOAD_CONST(c, _PyLong_Zero); ADDOP_COMPARE(c, Eq); compiler_use_next_block(c, end); return 1; } - CHECK(fail = compiler_new_block(c)); + basicblock *wrong_size; CHECK(wrong_size = compiler_new_block(c)); + // Duplicate the length, since both the length check and the GET_INDEX_* + // instructions need it: ADDOP(c, DUP_TOP) if (star < 0) { ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)); @@ -5781,10 +5856,13 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) } ADDOP_JUMP(c, POP_JUMP_IF_FALSE, wrong_size); NEXT_BLOCK(c); - ADDOP(c, ROT_TWO); if (INT_MAX < size - 1) { return compiler_error(c, "too many sub-patterns in sequence pattern"); } + basicblock *fail; + CHECK(fail = compiler_new_block(c)); + ADDOP(c, ROT_TWO); + // TOS is subject, length underneath. for (Py_ssize_t i = 0; i < size; i++) { expr_ty value = asdl_seq_GET(values, i); if (WILDCARD_CHECK(value)) { @@ -5799,31 +5877,37 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) if (WILDCARD_CHECK(value)) { continue; } - if (0xFF <= i || INT_MAX <= ((size - 1 - i) << 8)) { + Py_ssize_t end_items = ((size - 1 - i) << 8); + if (0xFF <= i || INT_MAX <= end_items) { // Technical limits are 0xFF patterns to the left of the star, // one starred pattern, and 0xFFFFFF patterns to the right of // the star... same as UNPACK_EX. const char* e = "too many sub-patterns in sequence pattern"; return compiler_error(c, e); } - ADDOP_I(c, GET_INDEX_SLICE, ((size - 1 - i) << 8) + i); + ADDOP_I(c, GET_INDEX_SLICE, end_items + i); } else { + // Basically a negative index: ADDOP_I(c, GET_INDEX_END, size - 1 - i); } - CHECK(compiler_subpattern(c, value, pc)); + CHECK(compiler_pattern_subpattern(c, value, pc)); + // TOS is True or False. We're done with the item underneath: + ADDOP(c, ROT_TWO); + ADDOP(c, POP_TOP); ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail) NEXT_BLOCK(c); - ADDOP(c, POP_TOP); } + // Success! TOS is subject, length undeneath. Pop the length: ADDOP(c, ROT_TWO); ADDOP(c, POP_TOP); ADDOP_LOAD_CONST(c, Py_True); ADDOP_JUMP(c, JUMP_FORWARD, end); compiler_use_next_block(c, fail); - ADDOP(c, POP_TOP); + // TOS is subject, length undeneath. Pop the length: ADDOP(c, ROT_TWO); compiler_use_next_block(c, wrong_size); + // TOS is the subject's length. Pop it: ADDOP(c, POP_TOP); ADDOP_LOAD_CONST(c, Py_False); compiler_use_next_block(c, end); @@ -5832,53 +5916,29 @@ compiler_pattern_list_tuple(struct compiler *c, expr_ty p, pattern_context *pc) static int -compiler_pattern_name(struct compiler *c, expr_ty p, pattern_context *pc) +compiler_pattern_value(struct compiler *c, expr_ty p, pattern_context *pc) { - assert(p->kind == Name_kind); - assert(p->v.Name.ctx == Store); - int wildcard = WILDCARD_CHECK(p); - if (!pc->allow_irrefutable) { - // Whoops, can't have a name capture here! - if (wildcard) { - const char *e = "wildcard makes remaining patterns unreachable"; - return compiler_error(c, e); - } - const char *e = "name capture %R makes remaining patterns unreachable"; - return compiler_error(c, e, p->v.Name.id); - } - if (!wildcard) { - ADDOP(c, DUP_TOP); - CHECK(pattern_helper_store_name(c, p->v.Name.id, pc)); - } - ADDOP_LOAD_CONST(c, Py_True); + assert(p->kind == Attribute_kind); + assert(p->v.Attribute.ctx == Load); + ADDOP(c, DUP_TOP); + CHECK(pattern_helper_load_attr(c, p, pc)); + ADDOP_COMPARE(c, Eq); return 1; } static int -compiler_pattern_match_as(struct compiler *c, expr_ty p, pattern_context *pc) +compiler_pattern_wildcard(struct compiler *c, expr_ty p, pattern_context *pc) { - assert(p->kind == MatchAs_kind); - basicblock *end; - CHECK(end = compiler_new_block(c)); - CHECK(compiler_pattern(c, p->v.MatchAs.pattern, pc)); - ADDOP_JUMP(c, JUMP_IF_FALSE_OR_POP, end); - NEXT_BLOCK(c); - ADDOP(c, DUP_TOP); - CHECK(pattern_helper_store_name(c, p->v.MatchAs.name, pc)); + assert(p->kind == Name_kind); + assert(p->v.Name.ctx == Store); + assert(WILDCARD_CHECK(p)); + if (!pc->allow_irrefutable) { + // Whoops, can't have a wildcard here! + const char *e = "wildcard makes remaining patterns unreachable"; + return compiler_error(c, e); + } ADDOP_LOAD_CONST(c, Py_True); - compiler_use_next_block(c, end); - return 1; -} - - -static int // TODO -compiler_subpattern(struct compiler *c, expr_ty p, pattern_context *pc) -{ - int allow_irrefutable = pc->allow_irrefutable; - pc->allow_irrefutable = 1; - CHECK(compiler_pattern(c, p, pc)); - pc->allow_irrefutable = allow_irrefutable; return 1; } @@ -5889,35 +5949,38 @@ compiler_pattern(struct compiler *c, expr_ty p, pattern_context *pc) SET_LOC(c, p); switch (p->kind) { case Attribute_kind: - return compiler_pattern_attribute(c, p, pc); + return compiler_pattern_value(c, p, pc); case BinOp_kind: // Because we allow "2+2j", things like "2+2" make it this far: return compiler_error(c, "patterns cannot include operators"); case Call_kind: - return compiler_pattern_call(c, p, pc); + return compiler_pattern_class(c, p, pc); case Constant_kind: - return compiler_pattern_constant(c, p, pc); + return compiler_pattern_literal(c, p, pc); case Dict_kind: - return compiler_pattern_dict(c, p, pc); + return compiler_pattern_mapping(c, p, pc); case JoinedStr_kind: // Because we allow strings, f-strings make it this far: return compiler_error(c, "patterns cannot include f-strings"); case List_kind: case Tuple_kind: - return compiler_pattern_list_tuple(c, p, pc); + return compiler_pattern_sequence(c, p, pc); case MatchAs_kind: - return compiler_pattern_match_as(c, p, pc); + return compiler_pattern_as(c, p, pc); case MatchOr_kind: - return compiler_pattern_match_or(c, p, pc); + return compiler_pattern_or(c, p, pc); case Name_kind: - return compiler_pattern_name(c, p, pc); + if (WILDCARD_CHECK(p)) { + return compiler_pattern_wildcard(c, p, pc); + } + return compiler_pattern_capture(c, p, pc); default: Py_UNREACHABLE(); } } -static int // TODO +static int compiler_match(struct compiler *c, stmt_ty s) { VISIT(c, expr, s->v.Match.subject); @@ -5926,29 +5989,36 @@ compiler_match(struct compiler *c, stmt_ty s) Py_ssize_t cases = asdl_seq_LEN(s->v.Match.cases); assert(cases); pattern_context pc; + // We use pc.stores to track: + // - Repeated name assignments in the same pattern. + // - Different name assignments in alternates. + // It's a set of names, but we don't create it until it's needed: pc.stores = NULL; - int result; match_case_ty m = asdl_seq_GET(s->v.Match.cases, cases - 1); int has_default = WILDCARD_CHECK(m->pattern) && 1 < cases; for (Py_ssize_t i = 0; i < cases - has_default; i++) { m = asdl_seq_GET(s->v.Match.cases, i); SET_LOC(c, m->pattern); CHECK(next = compiler_new_block(c)); - // An irrefutable case must be either guarded, last, or both: + // If pc.allow_irrefutable is 0, any name captures against our subject + // will raise. Irrefutable cases must be either guarded, last, or both: pc.allow_irrefutable = !!m->guard || (i == cases - 1); - result = compiler_pattern(c, m->pattern, &pc); + int result = compiler_pattern(c, m->pattern, &pc); Py_CLEAR(pc.stores); CHECK(result); + // TOS is either True or False, with the subject still waiting beneath: ADDOP_JUMP(c, POP_JUMP_IF_FALSE, next); NEXT_BLOCK(c); if (m->guard) { CHECK(compiler_jump_if(c, m->guard, next, 0)); } + // Success! Pop the subject off, we're done with it: ADDOP(c, POP_TOP); VISIT_SEQ(c, stmt, m->body); ADDOP_JUMP(c, JUMP_FORWARD, end); compiler_use_next_block(c, next); } + // No matches. Done with the subject: ADDOP(c, POP_TOP); if (has_default) { // A trailing "case _" is common, and lets us save a bit of redundant From d5f32da3227f90ee9f95c8be2dc0ab930625815a Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Fri, 23 Oct 2020 08:54:16 -0700 Subject: [PATCH 189/189] Add NEWS entry --- .../Core and Builtins/2020-10-23-08-54-04.bpo-42128.SWmVEm.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2020-10-23-08-54-04.bpo-42128.SWmVEm.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-10-23-08-54-04.bpo-42128.SWmVEm.rst b/Misc/NEWS.d/next/Core and Builtins/2020-10-23-08-54-04.bpo-42128.SWmVEm.rst new file mode 100644 index 00000000000000..e779eb8ceb1926 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-10-23-08-54-04.bpo-42128.SWmVEm.rst @@ -0,0 +1 @@ +Implement :pep:`634` (structural pattern matching). Patch by Brandt Bucher.