diff options
author | Brandt Bucher <brandtbucher@gmail.com> | 2021-02-26 22:51:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-26 22:51:55 (GMT) |
commit | 145bf269df3530176f6ebeab1324890ef7070bf8 (patch) | |
tree | 4c4928d6250785372171a52be0b7269aa444511b | |
parent | cc02b4f2e810ab524d845daa18bc94df5b092dd8 (diff) | |
download | cpython-145bf269df3530176f6ebeab1324890ef7070bf8.zip cpython-145bf269df3530176f6ebeab1324890ef7070bf8.tar.gz cpython-145bf269df3530176f6ebeab1324890ef7070bf8.tar.bz2 |
bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917)
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Talin <viridia@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
43 files changed, 9704 insertions, 1444 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index dad8369..c21a667 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -752,6 +752,49 @@ iterations of the loop. .. versionadded:: 3.2 +.. opcode:: COPY_DICT_WITHOUT_KEYS + + TOS is a tuple of mapping keys, and TOS1 is the match subject. Replace TOS + with a :class:`dict` formed from the items of TOS1, but without any of the + keys in TOS. + + .. versionadded:: 3.10 + + +.. opcode:: GET_LEN + + 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` and is *not* an + instance of :class:`str`/:class:`bytes`/:class:`bytearray`, push ``True`` + onto the stack. Otherwise, push ``False``. + + .. versionadded:: 3.10 + + +.. opcode:: MATCH_KEYS + + TOS is a tuple of mapping keys, and TOS1 is the match subject. If TOS1 + contains all of the keys in TOS, push a :class:`tuple` containing the + corresponding values, followed by ``True``. Otherwise, push ``None``, + followed by ``False``. + + .. versionadded:: 3.10 + + All of the following opcodes use their arguments. .. opcode:: STORE_NAME (namei) @@ -1192,6 +1235,19 @@ All of the following opcodes use their arguments. .. versionadded:: 3.6 +.. opcode:: MATCH_CLASS (count) + + 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. + + Pop TOS. If TOS2 is an instance of TOS1 and has the positional and keyword + attributes required by *count* and TOS, set TOS to ``True`` and TOS1 to a + tuple of extracted attributes. Otherwise, set TOS to ``False``. + + .. versionadded:: 3.10 + + .. opcode:: HAVE_ARGUMENT This is not really an opcode. It identifies the dividing line between diff --git a/Doc/tools/susp-ignored.csv b/Doc/tools/susp-ignored.csv index fd27ab5..4dae6b6 100644 --- a/Doc/tools/susp-ignored.csv +++ b/Doc/tools/susp-ignored.csv @@ -365,3 +365,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/Grammar/python.gram b/Grammar/python.gram index bb70bbb..a225664 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -85,6 +85,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]: @@ -207,6 +208,114 @@ except_block[excepthandler_ty]: | invalid_except_block finally_block[asdl_stmt_seq*]: 'finally' ':' a=block { a } +match_stmt[stmt_ty]: + | "match" subject=subject_expr ':' NEWLINE INDENT cases[asdl_match_case_seq*]=case_block+ DEDENT { + CHECK_VERSION(stmt_ty, 10, "Pattern matching is", _Py_Match(subject, cases, EXTRA)) } +subject_expr[expr_ty]: + | value=star_named_expression ',' values=star_named_expressions? { + _Py_Tuple(CHECK(asdl_expr_seq*, _PyPegen_seq_insert_in_front(p, value, values)), Load, EXTRA) } + | named_expression +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 } + +patterns[expr_ty]: + | values[asdl_expr_seq*]=open_sequence_pattern { + _Py_Tuple(values, Load, EXTRA) } + | pattern +pattern[expr_ty]: + | 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]: + | patterns[asdl_expr_seq*]='|'.closed_pattern+ { + asdl_seq_LEN(patterns) == 1 ? asdl_seq_GET(patterns, 0) : _Py_MatchOr(patterns, EXTRA) } +closed_pattern[expr_ty]: + | literal_pattern + | capture_pattern + | wildcard_pattern + | value_pattern + | group_pattern + | sequence_pattern + | mapping_pattern + | class_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) } + | strings + | 'None' { _Py_Constant(Py_None, NULL, EXTRA) } + | 'True' { _Py_Constant(Py_True, NULL, EXTRA) } + | 'False' { _Py_Constant(Py_False, NULL, EXTRA) } +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(PyObject*, _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) } +name_or_attr[expr_ty]: + | attr + | NAME + +group_pattern[expr_ty]: + | '(' pattern=pattern ')' { pattern } + +sequence_pattern[expr_ty]: + | '[' values=maybe_sequence_pattern? ']' { _Py_List(values, Load, EXTRA) } + | '(' values=open_sequence_pattern? ')' { _Py_Tuple(values, Load, EXTRA) } +open_sequence_pattern[asdl_seq*]: + | value=maybe_star_pattern ',' values=maybe_sequence_pattern? { + _PyPegen_seq_insert_in_front(p, value, values) } +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(asdl_expr_seq*, _PyPegen_get_keys(p, items)), CHECK(asdl_expr_seq*, _PyPegen_get_values(p, items)), EXTRA) } +items_pattern[asdl_seq*]: + | items=','.key_value_pattern+ ','? { items } +key_value_pattern[KeyValuePair*]: + | key=(literal_pattern | value_pattern) ':' value=pattern { + _PyPegen_key_value_pair(p, key, 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) } @@ -676,7 +785,7 @@ invalid_assignment: RAISE_SYNTAX_ERROR_INVALID_TARGET(STAR_TARGETS, a) } | (star_targets '=')* a=yield_expr '=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "assignment to yield expression not possible") } | a=star_expressions augassign (yield_expr | star_expressions) { - RAISE_SYNTAX_ERROR_KNOWN_LOCATION( + RAISE_SYNTAX_ERROR_KNOWN_LOCATION( a, "'%s' is an illegal expression for augmented assignment", _PyPegen_get_expr_name(a) diff --git a/Include/Python-ast.h b/Include/Python-ast.h index fc9f65c..bd127ca 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; @@ -121,6 +123,14 @@ asdl_withitem_seq *_Py_asdl_withitem_seq_new(Py_ssize_t size, PyArena *arena); typedef struct { _ASDL_SEQ_HEAD + match_case_ty typed_elements[1]; +} asdl_match_case_seq; + +asdl_match_case_seq *_Py_asdl_match_case_seq_new(Py_ssize_t size, PyArena + *arena); + +typedef struct { + _ASDL_SEQ_HEAD type_ignore_ty typed_elements[1]; } asdl_type_ignore_seq; @@ -158,10 +168,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 { @@ -259,6 +269,11 @@ struct _stmt { } AsyncWith; struct { + expr_ty subject; + asdl_match_case_seq *cases; + } Match; + + struct { expr_ty exc; expr_ty cause; } Raise; @@ -311,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, MatchOr_kind=29}; struct _expr { enum _expr_kind kind; union { @@ -454,6 +470,15 @@ struct _expr { expr_ty step; } Slice; + struct { + expr_ty pattern; + identifier name; + } MatchAs; + + struct { + asdl_expr_seq *patterns; + } MatchOr; + } v; int lineno; int col_offset; @@ -524,6 +549,12 @@ struct _withitem { expr_ty optional_vars; }; +struct _match_case { + expr_ty pattern; + expr_ty guard; + asdl_stmt_seq *body; +}; + enum _type_ignore_kind {TypeIgnore_kind=1}; struct _type_ignore { enum _type_ignore_kind kind; @@ -607,6 +638,10 @@ stmt_ty _Py_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string stmt_ty _Py_AsyncWith(asdl_withitem_seq * items, asdl_stmt_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 subject, asdl_match_case_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); @@ -743,6 +778,13 @@ 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 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); @@ -769,6 +811,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_stmt_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/Include/internal/pycore_ast.h b/Include/internal/pycore_ast.h index 058fbc0..2d0c5fb 100644 --- a/Include/internal/pycore_ast.h +++ b/Include/internal/pycore_ast.h @@ -91,6 +91,9 @@ struct ast_state { PyObject *Lt_type; PyObject *MatMult_singleton; PyObject *MatMult_type; + PyObject *MatchAs_type; + PyObject *MatchOr_type; + PyObject *Match_type; PyObject *Mod_singleton; PyObject *Mod_type; PyObject *Module_type; @@ -137,6 +140,7 @@ struct ast_state { PyObject *Yield_type; PyObject *__dict__; PyObject *__doc__; + PyObject *__match_args__; PyObject *__module__; PyObject *_attributes; PyObject *_fields; @@ -153,6 +157,7 @@ struct ast_state { PyObject *bases; PyObject *body; PyObject *boolop_type; + PyObject *cases; PyObject *cause; PyObject *cmpop_type; PyObject *col_offset; @@ -175,6 +180,7 @@ struct ast_state { PyObject *format_spec; PyObject *func; PyObject *generators; + PyObject *guard; PyObject *handlers; PyObject *id; PyObject *ifs; @@ -193,6 +199,7 @@ struct ast_state { PyObject *level; PyObject *lineno; PyObject *lower; + PyObject *match_case_type; PyObject *mod_type; PyObject *module; PyObject *msg; @@ -204,6 +211,8 @@ struct ast_state { PyObject *ops; PyObject *optional_vars; PyObject *orelse; + PyObject *pattern; + PyObject *patterns; PyObject *posonlyargs; PyObject *returns; PyObject *right; @@ -211,6 +220,7 @@ struct ast_state { PyObject *slice; PyObject *step; PyObject *stmt_type; + PyObject *subject; PyObject *tag; PyObject *target; PyObject *targets; diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h index 58b1126..477cbf0 100644 --- a/Include/internal/pycore_interp.h +++ b/Include/internal/pycore_interp.h @@ -253,6 +253,10 @@ struct _is { // importlib module 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. @@ -347,4 +351,3 @@ PyAPI_FUNC(void) _PyInterpreterState_IDDecref(struct _is *); } #endif #endif /* !Py_INTERNAL_INTERP_H */ - diff --git a/Include/object.h b/Include/object.h index 0870e4c..1454583 100644 --- a/Include/object.h +++ b/Include/object.h @@ -359,6 +359,11 @@ given type object has a specified feature. #define Py_TPFLAGS_HAVE_AM_SEND (1UL << 21) #endif +// This undocumented flag gives certain built-ins their unique pattern-matching +// behavior, which allows a single positional subpattern to match against the +// subject itself (rather than a mapped attribute on it): +#define _Py_TPFLAGS_MATCH_SELF (1UL << 22) + /* 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/Include/opcode.h b/Include/opcode.h index 998a5ce..ea484c5 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -30,6 +30,11 @@ extern "C" { #define BINARY_TRUE_DIVIDE 27 #define INPLACE_FLOOR_DIVIDE 28 #define INPLACE_TRUE_DIVIDE 29 +#define GET_LEN 30 +#define MATCH_MAPPING 31 +#define MATCH_SEQUENCE 32 +#define MATCH_KEYS 33 +#define COPY_DICT_WITHOUT_KEYS 34 #define WITH_EXCEPT_START 49 #define GET_AITER 50 #define GET_ANEXT 51 @@ -117,6 +122,7 @@ extern "C" { #define SET_ADD 146 #define MAP_ADD 147 #define LOAD_CLASSDEREF 148 +#define MATCH_CLASS 152 #define SETUP_ASYNC_WITH 154 #define FORMAT_VALUE 155 #define BUILD_CONST_KEY_MAP 156 diff --git a/Include/symtable.h b/Include/symtable.h index abd19a7..6f0b7cb 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 { @@ -1478,6 +1478,13 @@ class _Unparser(NodeVisitor): self.write(":") self.traverse(node.step) + def visit_Match(self, node): + self.fill("match ") + self.traverse(node.subject) + with self.block(): + for case in node.cases: + self.traverse(case) + def visit_arg(self, node): self.write(node.arg) if node.annotation: @@ -1562,6 +1569,26 @@ class _Unparser(NodeVisitor): self.write(" as ") self.traverse(node.optional_vars) + def visit_match_case(self, node): + self.fill("case ") + self.traverse(node.pattern) + if node.guard: + self.write(" if ") + self.traverse(node.guard) + with self.block(): + self.traverse(node.body) + + def visit_MatchAs(self, node): + with self.require_parens(_Precedence.TEST, node): + self.set_precedence(_Precedence.BOR, node.pattern) + self.traverse(node.pattern) + self.write(f" as {node.name}") + + def visit_MatchOr(self, node): + with self.require_parens(_Precedence.BOR, node): + self.set_precedence(_Precedence.BOR.next(), *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/collections/__init__.py b/Lib/collections/__init__.py index 6fe3c4c..6404ea9 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -472,6 +472,7 @@ def namedtuple(typename, field_names, *, rename=False, defaults=None, module=Non '__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/dataclasses.py b/Lib/dataclasses.py index 0c4b475..422a95c 100644 --- a/Lib/dataclasses.py +++ b/Lib/dataclasses.py @@ -152,6 +152,15 @@ __all__ = ['dataclass', # # 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. 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. class FrozenInstanceError(AttributeError): pass @@ -1007,6 +1016,9 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen): cls.__doc__ = (cls.__name__ + str(inspect.signature(cls)).replace(' -> NoneType', '')) + if '__match_args__' not in cls.__dict__: + cls.__match_args__ = tuple(f.name for f in flds if f.init) + abc.update_abstractmethods(cls) return cls diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 3546500..3396d5d 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -313,6 +313,7 @@ _code_type = type(_write_atomic.__code__) # Python 3.10a1 3431 (New line number table format -- PEP 626) # Python 3.10a2 3432 (Function annotation for MAKE_FUNCTION is changed from dict to tuple bpo-42202) # Python 3.10a2 3433 (RERAISE restores f_lasti if oparg != 0) +# Python 3.10a6 3434 (PEP 634: Structural Pattern Matching) # # MAGIC must change whenever the bytecode emitted by the compiler may no @@ -322,7 +323,7 @@ _code_type = type(_write_atomic.__code__) # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3433).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3434).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/keyword.py b/Lib/keyword.py index 3186171..cc2b46b 100644 --- a/Lib/keyword.py +++ b/Lib/keyword.py @@ -54,7 +54,9 @@ kwlist = [ ] softkwlist = [ - + '_', + 'case', + 'match' ] iskeyword = frozenset(kwlist).__contains__ diff --git a/Lib/opcode.py b/Lib/opcode.py index cc32116..b119712 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -67,7 +67,6 @@ def_op('UNARY_NEGATIVE', 11) def_op('UNARY_NOT', 12) def_op('UNARY_INVERT', 15) - def_op('BINARY_MATRIX_MULTIPLY', 16) def_op('INPLACE_MATRIX_MULTIPLY', 17) @@ -82,6 +81,11 @@ def_op('BINARY_FLOOR_DIVIDE', 26) 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_MAPPING', 31) +def_op('MATCH_SEQUENCE', 32) +def_op('MATCH_KEYS', 33) +def_op('COPY_DICT_WITHOUT_KEYS', 34) def_op('WITH_EXCEPT_START', 49) def_op('GET_AITER', 50) @@ -104,7 +108,6 @@ def_op('BINARY_OR', 66) 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) @@ -136,6 +139,7 @@ name_op('STORE_ATTR', 95) # Index in name list 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 @@ -148,16 +152,13 @@ def_op('COMPARE_OP', 107) # Comparison operator 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('RERAISE', 119) @@ -176,6 +177,7 @@ def_op('RAISE_VARARGS', 130) # Number of raise arguments (1, 2, or 3) 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) @@ -187,28 +189,24 @@ hasfree.append(138) 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 +def_op('MATCH_CLASS', 152) 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) diff --git a/Lib/test/libregrtest/pgo.py b/Lib/test/libregrtest/pgo.py index 379ff05..582e812 100644 --- a/Lib/test/libregrtest/pgo.py +++ b/Lib/test/libregrtest/pgo.py @@ -35,6 +35,7 @@ PGO_TESTS = [ 'test_memoryview', 'test_operator', 'test_ordered_dict', + 'test_patma', 'test_pickle', 'test_pprint', 'test_re', diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index 451f40d..bddb3de 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -273,6 +273,7 @@ class AST_Tests(unittest.TestCase): 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/Lib/test/test_collections.py b/Lib/test/test_collections.py index 54a4cbe..d1c305a 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -687,6 +687,10 @@ class TestNamedTuple(unittest.TestCase): self.assertEqual(new_func.__globals__['__builtins__'], {}) self.assertEqual(new_func.__builtins__, {}) + def test_match_args(self): + Point = namedtuple('Point', 'x y') + self.assertEqual(Point.__match_args__, ('x', 'y')) + ################################################################################ ### Abstract Base Classes diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index 8887eb6..0bfed41 100644 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -3375,5 +3375,21 @@ class TestAbstract(unittest.TestCase): self.assertRaisesRegex(TypeError, msg, Date) +class TestMatchArgs(unittest.TestCase): + def test_match_args(self): + @dataclass + class C: + a: int + self.assertEqual(C(42).__match_args__, ('a',)) + + def test_explicit_match_args(self): + ma = [] + @dataclass + class C: + a: int + __match_args__ = ma + self.assertIs(C(42).__match_args__, ma) + + if __name__ == '__main__': unittest.main() diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py new file mode 100644 index 0000000..286b190 --- /dev/null +++ b/Lib/test/test_patma.py @@ -0,0 +1,2878 @@ +import array +import collections +import contextlib +import dataclasses +import enum +import inspect +import unittest +import warnings + + +def no_perf(f): + f.no_perf = None + return f + + +@dataclasses.dataclass +class MyClass: + x: int + y: str + __match_args__ = ["x", "y"] + + +@dataclasses.dataclass +class Point: + x: int + y: int + + +class TestPatma(unittest.TestCase): + + def assert_syntax_error(self, code: str): + with self.assertRaises(SyntaxError): + compile(inspect.cleandoc(code), "<test>", "exec") + + def test_patma_000(self): + match 0: + case 0: + x = True + self.assertIs(x, True) + + def test_patma_001(self): + match 0: + case 0 if False: + x = False + case 0 if True: + x = True + self.assertIs(x, True) + + def test_patma_002(self): + match 0: + case 0: + x = True + case 0: + x = False + self.assertIs(x, True) + + def test_patma_003(self): + x = False + match 0: + case 0 | 1 | 2 | 3: + x = True + self.assertIs(x, True) + + def test_patma_004(self): + x = False + match 1: + case 0 | 1 | 2 | 3: + x = True + self.assertIs(x, True) + + def test_patma_005(self): + x = False + match 2: + case 0 | 1 | 2 | 3: + x = True + self.assertIs(x, True) + + def test_patma_006(self): + x = False + match 3: + case 0 | 1 | 2 | 3: + x = True + self.assertIs(x, True) + + def test_patma_007(self): + x = False + match 4: + case 0 | 1 | 2 | 3: + x = True + self.assertIs(x, False) + + def test_patma_008(self): + x = 0 + class A: + y = 1 + match x: + case A.y as z: + pass + self.assertEqual(x, 0) + self.assertEqual(A.y, 1) + + def test_patma_009(self): + class A: + B = 0 + match 0: + case x if x: + z = 0 + case _ as y if y == x and 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) + + def test_patma_010(self): + match (): + case []: + x = 0 + self.assertEqual(x, 0) + + 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): + match (0, 1, 2): + case [0, *x]: + y = 0 + self.assertEqual(x, [1, 2]) + self.assertEqual(y, 0) + + 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): + match (0, 1, 2): + case [0, 1, 2, *x]: + y = 0 + self.assertEqual(x, []) + self.assertEqual(y, 0) + + 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): + match (0, 1, 2): + case [*x, 1, 2]: + y = 0 + self.assertEqual(x, [0]) + self.assertEqual(y, 0) + + 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): + match (0, 1, 2): + case [0, *x, 2]: + y = 0 + self.assertEqual(x, [1]) + self.assertEqual(y, 0) + + 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): + match (0, 1, 2): + case [0, *x, 1, 2]: + y = 0 + self.assertEqual(x, []) + self.assertEqual(y, 0) + + 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): + x = {} + match x: + case {}: + y = 0 + self.assertEqual(x, {}) + self.assertEqual(y, 0) + + def test_patma_023(self): + x = {0: 0} + match x: + case {}: + y = 0 + self.assertEqual(x, {0: 0}) + self.assertEqual(y, 0) + + def test_patma_024(self): + x = {} + y = None + match x: + case {0: 0}: + y = 0 + self.assertEqual(x, {}) + self.assertIs(y, None) + + def test_patma_025(self): + x = {0: 0} + match x: + case {0: (0 | 1 | 2 as z)}: + y = 0 + self.assertEqual(x, {0: 0}) + self.assertEqual(y, 0) + self.assertEqual(z, 0) + + def test_patma_026(self): + x = {0: 1} + match x: + case {0: (0 | 1 | 2 as z)}: + y = 0 + self.assertEqual(x, {0: 1}) + self.assertEqual(y, 0) + self.assertEqual(z, 1) + + def test_patma_027(self): + x = {0: 2} + match x: + case {0: (0 | 1 | 2 as z)}: + y = 0 + self.assertEqual(x, {0: 2}) + self.assertEqual(y, 0) + self.assertEqual(z, 2) + + def test_patma_028(self): + x = {0: 3} + y = None + match x: + case {0: (0 | 1 | 2 as z)}: + y = 0 + self.assertEqual(x, {0: 3}) + self.assertIs(y, None) + + def test_patma_029(self): + 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.assertIs(y, None) + + def test_patma_030(self): + 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): + 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): + 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): + 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): + 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): + 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): + x = 0 + match x: + case 0 | 1 | 2: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_037(self): + x = 1 + match x: + case 0 | 1 | 2: + y = 0 + self.assertEqual(x, 1) + self.assertEqual(y, 0) + + def test_patma_038(self): + x = 2 + match x: + case 0 | 1 | 2: + y = 0 + self.assertEqual(x, 2) + self.assertEqual(y, 0) + + def test_patma_039(self): + x = 3 + y = None + match x: + case 0 | 1 | 2: + y = 0 + self.assertEqual(x, 3) + self.assertIs(y, None) + + def test_patma_040(self): + x = 0 + match x: + case (0 as z) | (1 as z) | (2 as z) if z == x % 2: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertEqual(z, 0) + + def test_patma_041(self): + x = 1 + match x: + case (0 as z) | (1 as z) | (2 as z) if z == x % 2: + y = 0 + self.assertEqual(x, 1) + self.assertEqual(y, 0) + self.assertEqual(z, 1) + + def test_patma_042(self): + x = 2 + y = None + match x: + case (0 as z) | (1 as z) | (2 as z) if z == x % 2: + y = 0 + self.assertEqual(x, 2) + self.assertIs(y, None) + self.assertEqual(z, 2) + + def test_patma_043(self): + x = 3 + y = None + match x: + case (0 as z) | (1 as z) | (2 as z) if z == x % 2: + y = 0 + self.assertEqual(x, 3) + self.assertIs(y, None) + + def test_patma_044(self): + x = () + match x: + case []: + y = 0 + self.assertEqual(x, ()) + self.assertEqual(y, 0) + + def test_patma_045(self): + x = () + match x: + case (): + y = 0 + self.assertEqual(x, ()) + self.assertEqual(y, 0) + + def test_patma_046(self): + x = (0,) + match x: + case [0]: + y = 0 + self.assertEqual(x, (0,)) + self.assertEqual(y, 0) + + def test_patma_047(self): + x = ((),) + match x: + case [[]]: + y = 0 + self.assertEqual(x, ((),)) + self.assertEqual(y, 0) + + def test_patma_048(self): + 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): + 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): + x = [0, 0] + y = None + match x: + case [0, 1] | [1, 0]: + y = 0 + self.assertEqual(x, [0, 0]) + self.assertIs(y, None) + + def test_patma_051(self): + w = None + x = [1, 0] + match x: + case [(0 as w)]: + y = 0 + case [z] | [1, (0 | 1 as z)] | [z]: + y = 1 + self.assertIs(w, None) + self.assertEqual(x, [1, 0]) + self.assertEqual(y, 1) + self.assertEqual(z, 0) + + def test_patma_052(self): + 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): + x = {0} + y = None + match x: + case [0]: + y = 0 + self.assertEqual(x, {0}) + self.assertIs(y, None) + + def test_patma_054(self): + x = set() + y = None + match x: + case []: + y = 0 + self.assertEqual(x, set()) + self.assertIs(y, None) + + def test_patma_055(self): + x = iter([1, 2, 3]) + y = None + match x: + case []: + y = 0 + self.assertEqual([*x], [1, 2, 3]) + self.assertIs(y, None) + + def test_patma_056(self): + x = {} + y = None + match x: + case []: + y = 0 + self.assertEqual(x, {}) + self.assertIs(y, None) + + def test_patma_057(self): + x = {0: False, 1: True} + y = None + match x: + case [0, 1]: + y = 0 + self.assertEqual(x, {0: False, 1: True}) + self.assertIs(y, None) + + def test_patma_058(self): + x = 0 + match x: + case 0: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_059(self): + x = 0 + y = None + match x: + case False: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, None) + + def test_patma_060(self): + x = 0 + y = None + match x: + case 1: + y = 0 + self.assertEqual(x, 0) + self.assertIs(y, None) + + def test_patma_061(self): + x = 0 + y = None + match x: + case None: + y = 0 + self.assertEqual(x, 0) + self.assertIs(y, None) + + def test_patma_062(self): + 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): + x = 0 + y = None + match x: + case 1: + y = 0 + case 1: + y = 1 + self.assertEqual(x, 0) + self.assertIs(y, None) + + def test_patma_064(self): + 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): + 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): + x = "x" + match x: + case "": + y = 0 + case "x": + y = 1 + self.assertEqual(x, "x") + self.assertEqual(y, 1) + + def test_patma_067(self): + 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): + 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): + x = 0 + y = None + match x: + case 0 if 0: + y = 0 + case 0 if 0: + y = 1 + self.assertEqual(x, 0) + self.assertIs(y, None) + + def test_patma_070(self): + 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): + x = 0 + match x: + case 0 if 1: + y = 0 + case 0 if 1: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_072(self): + 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): + 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): + x = 0 + y = None + match x: + case 0 if not (x := 1): + y = 0 + case 1: + y = 1 + self.assertEqual(x, 1) + self.assertIs(y, None) + + def test_patma_075(self): + 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): + 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): + x = bytearray(b"x") + y = None + match x: + case [120]: + y = 0 + case 120: + y = 1 + self.assertEqual(x, b"x") + self.assertIs(y, None) + + def test_patma_078(self): + x = "" + match x: + case []: + y = 0 + case [""]: + y = 1 + case "": + y = 2 + self.assertEqual(x, "") + self.assertEqual(y, 2) + + def test_patma_079(self): + 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): + 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): + x = 0 + match x: + case 0 if not (x := 1): + y = 0 + case (0 as z): + y = 1 + self.assertEqual(x, 1) + self.assertEqual(y, 1) + self.assertEqual(z, 0) + + def test_patma_082(self): + x = 0 + match x: + case (1 as z) if not (x := 1): + y = 0 + case 0: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 1) + + def test_patma_083(self): + x = 0 + match x: + case (0 as z): + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + self.assertEqual(z, 0) + + def test_patma_084(self): + x = 0 + y = None + match x: + case (1 as z): + y = 0 + self.assertEqual(x, 0) + self.assertIs(y, None) + + def test_patma_085(self): + x = 0 + y = None + match x: + case (0 as z) if (w := 0): + y = 0 + self.assertEqual(w, 0) + self.assertEqual(x, 0) + self.assertIs(y, None) + self.assertEqual(z, 0) + + def test_patma_086(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_087(self): + x = 0 + match x: + case (0 | 1) | 2: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_088(self): + x = 1 + match x: + case (0 | 1) | 2: + y = 0 + self.assertEqual(x, 1) + self.assertEqual(y, 0) + + def test_patma_089(self): + x = 2 + match x: + case (0 | 1) | 2: + y = 0 + self.assertEqual(x, 2) + self.assertEqual(y, 0) + + def test_patma_090(self): + x = 3 + y = None + match x: + case (0 | 1) | 2: + y = 0 + self.assertEqual(x, 3) + self.assertIs(y, None) + + def test_patma_091(self): + x = 0 + match x: + case 0 | (1 | 2): + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_092(self): + x = 1 + match x: + case 0 | (1 | 2): + y = 0 + self.assertEqual(x, 1) + self.assertEqual(y, 0) + + def test_patma_093(self): + x = 2 + match x: + case 0 | (1 | 2): + y = 0 + self.assertEqual(x, 2) + self.assertEqual(y, 0) + + def test_patma_094(self): + x = 3 + y = None + match x: + case 0 | (1 | 2): + y = 0 + self.assertEqual(x, 3) + self.assertIs(y, None) + + def test_patma_095(self): + x = 0 + match x: + case -0: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_096(self): + x = 0 + match x: + case -0.0: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_097(self): + x = 0 + match x: + case -0j: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_098(self): + x = 0 + match x: + case -0.0j: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_099(self): + x = -1 + match x: + case -1: + y = 0 + self.assertEqual(x, -1) + self.assertEqual(y, 0) + + def test_patma_100(self): + x = -1.5 + match x: + case -1.5: + y = 0 + self.assertEqual(x, -1.5) + self.assertEqual(y, 0) + + def test_patma_101(self): + x = -1j + match x: + case -1j: + y = 0 + self.assertEqual(x, -1j) + self.assertEqual(y, 0) + + def test_patma_102(self): + x = -1.5j + match x: + case -1.5j: + y = 0 + self.assertEqual(x, -1.5j) + self.assertEqual(y, 0) + + def test_patma_103(self): + x = 0 + match x: + case 0 + 0j: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_104(self): + x = 0 + match x: + case 0 - 0j: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_105(self): + x = 0 + match x: + case -0 + 0j: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_106(self): + x = 0 + match x: + case -0 - 0j: + y = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 0) + + def test_patma_107(self): + 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): + 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): + 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): + 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_111(self): + 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): + 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): + class A: + class B: + C = 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(A.B.D, 1) + self.assertEqual(x, 1) + self.assertEqual(y, 1) + + def test_patma_114(self): + 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): + class A: + class B: + class C: + D = 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(A.B.C.E, 1) + self.assertEqual(x, 1) + self.assertEqual(y, 1) + + def test_patma_116(self): + 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): + 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): + x = [] + match x: + case [*_, _]: + y = 0 + case []: + y = 1 + self.assertEqual(x, []) + self.assertEqual(y, 1) + + def test_patma_119(self): + x = collections.defaultdict(int) + match x: + case {0: 0}: + y = 0 + case {}: + y = 1 + self.assertEqual(x, {}) + self.assertEqual(y, 1) + + def test_patma_120(self): + x = collections.defaultdict(int) + match x: + case {0: 0}: + y = 0 + case {**z}: + y = 1 + self.assertEqual(x, {}) + self.assertEqual(y, 1) + self.assertEqual(z, {}) + + def test_patma_121(self): + match (): + case (): + x = 0 + self.assertEqual(x, 0) + + 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): + match (0, 1, 2): + case 0, *x: + y = 0 + self.assertEqual(x, [1, 2]) + self.assertEqual(y, 0) + + 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): + match (0, 1, 2): + case 0, 1, 2, *x: + y = 0 + self.assertEqual(x, []) + self.assertEqual(y, 0) + + 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): + match (0, 1, 2): + case (*x, 1, 2): + y = 0 + self.assertEqual(x, [0]) + self.assertEqual(y, 0) + + 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): + match (0, 1, 2): + case (0, *x, 2): + y = 0 + self.assertEqual(x, [1]) + self.assertEqual(y, 0) + + 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): + match (0, 1, 2): + case (0, *x, 1, 2): + y = 0 + self.assertEqual(x, []) + self.assertEqual(y, 0) + + 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): + x = collections.defaultdict(int, {0: 1}) + match x: + case {1: 0}: + y = 0 + case {0: 0}: + y = 1 + case {}: + y = 2 + self.assertEqual(x, {0: 1}) + self.assertEqual(y, 2) + + def test_patma_134(self): + x = collections.defaultdict(int, {0: 1}) + match x: + case {1: 0}: + y = 0 + case {0: 0}: + y = 1 + case {**z}: + y = 2 + self.assertEqual(x, {0: 1}) + self.assertEqual(y, 2) + self.assertEqual(z, {0: 1}) + + def test_patma_135(self): + x = collections.defaultdict(int, {0: 1}) + match x: + case {1: 0}: + y = 0 + case {0: 0}: + y = 1 + case {0: _, **z}: + y = 2 + self.assertEqual(x, {0: 1}) + self.assertEqual(y, 2) + self.assertEqual(z, {}) + + def test_patma_136(self): + 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) + + def test_patma_137(self): + 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): + 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, {}) + + def test_patma_139(self): + 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): + 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): + 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): + 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): + x = {} + match x: + case dict(z): + y = 0 + self.assertEqual(x, {}) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_144(self): + 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): + 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): + 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): + x = [] + match x: + case list(z): + y = 0 + self.assertEqual(x, []) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_148(self): + 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): + x = "" + match x: + case str(z): + y = 0 + self.assertEqual(x, "") + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_150(self): + x = () + match x: + case tuple(z): + y = 0 + self.assertEqual(x, ()) + self.assertEqual(y, 0) + self.assertIs(z, x) + + def test_patma_151(self): + 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): + 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_153(self): + x = 0 + match w := x,: + case y as v,: + z = 0 + self.assertEqual(x, 0) + self.assertIs(y, x) + self.assertEqual(z, 0) + 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 1e1000: + 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 -1e1000: + y = 0 + case 0: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 1) + + 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) + + 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 + + @no_perf + 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): + 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): + 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): + 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): + 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): + 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): + 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): + 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) + + 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) + + 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 = 0 + self.assertEqual(x, 0) + self.assertEqual(y, 41) + self.assertEqual(z, 0) + + 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): + w = [Point(-1, 0), Point(1, 2)] + match w: + 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) + 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.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): + 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.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.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.assertIs(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() + 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() + 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() + 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() + 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() + 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() + 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() + 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.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) + + def test_patma_211(self): + def f(w): + match w: + case {"x": x, "y": "y", "z": z}: + out = locals() + 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): + def f(w): + match w: + case MyClass(int(xx), y="hello"): + out = locals() + del out["w"] + return out + self.assertEqual(f(MyClass(42, "hello")), {"xx": 42}) + + def test_patma_213(self): + def f(w): + match w: + case (p, q) as x: + out = locals() + 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) + + 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"}) + + @no_perf + def test_patma_218(self): + self.assert_syntax_error(""" + match ...: + case "a" | a: + pass + """) + + @no_perf + def test_patma_219(self): + self.assert_syntax_error(""" + match ...: + case a | "a": + pass + """) + + def test_patma_220(self): + def f(): + match ..., ...: + case a, b: + return locals() + self.assertEqual(set(f()), {"a", "b"}) + + @no_perf + def test_patma_221(self): + self.assert_syntax_error(""" + match ...: + case a, a: + pass + """) + + def test_patma_222(self): + def f(): + match {"k": ..., "l": ...}: + case {"k": a, "l": b}: + return locals() + self.assertEqual(set(f()), {"a", "b"}) + + @no_perf + def test_patma_223(self): + self.assert_syntax_error(""" + match ...: + case {"k": a, "l": a}: + pass + """) + + def test_patma_224(self): + def f(): + match MyClass(..., ...): + case MyClass(x, y=y): + return locals() + self.assertEqual(set(f()), {"x", "y"}) + + @no_perf + def test_patma_225(self): + self.assert_syntax_error(""" + match ...: + case MyClass(x, x): + pass + """) + + @no_perf + def test_patma_226(self): + self.assert_syntax_error(""" + match ...: + case MyClass(x=x, y=x): + pass + """) + + @no_perf + def test_patma_227(self): + self.assert_syntax_error(""" + match ...: + case MyClass(x, y=x): + pass + """) + + def test_patma_228(self): + def f(): + match ...: + case b as a: + return locals() + self.assertEqual(set(f()), {"a", "b"}) + + @no_perf + def test_patma_229(self): + self.assert_syntax_error(""" + match ...: + case a as a: + pass + """) + + 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) + + @no_perf + def test_patma_236(self): + self.assert_syntax_error(""" + match ...: + case {**rest, "key": value}: + pass + """) + + @no_perf + def test_patma_237(self): + self.assert_syntax_error(""" + match ...: + case {"first": first, **rest, "last": last}: + pass + """) + + @no_perf + def test_patma_238(self): + self.assert_syntax_error(""" + match ...: + case *a, b, *c, d, *e: + pass + """) + + @no_perf + def test_patma_239(self): + self.assert_syntax_error(""" + match ...: + case a, *b, c, *d, e: + pass + """) + + @no_perf + def test_patma_240(self): + self.assert_syntax_error(""" + match ...: + case 0+0: + pass + """) + + @no_perf + def test_patma_241(self): + self.assert_syntax_error(""" + match ...: + case f"": + pass + """) + + @no_perf + def test_patma_242(self): + self.assert_syntax_error(""" + match ...: + case f"{x}": + pass + """) + + @no_perf + def test_patma_243(self): + self.assert_syntax_error(""" + match 42: + case x: + pass + case y: + pass + """) + + @no_perf + def test_patma_244(self): + self.assert_syntax_error(""" + match ...: + case {**_}: + pass + """) + + @no_perf + def test_patma_245(self): + self.assert_syntax_error(""" + match ...: + case 42 as _: + pass + """) + + @no_perf + 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) + + @no_perf + 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) + + @no_perf + 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) + + @no_perf + 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) + + @no_perf + def test_patma_250(self): + self.assert_syntax_error(""" + match ...: + case Class(a=_, a=_): + pass + """) + + @no_perf + 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) + + @no_perf + 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) + + @no_perf + 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) + + @no_perf + 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) + + 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) + + def test_patma_257(self): + x = 0 + match x: + case False: + y = 0 + case 0: + y = 1 + self.assertEqual(x, 0) + self.assertEqual(y, 1) + + def test_patma_258(self): + x = 1 + match x: + case True: + y = 0 + case 1: + y = 1 + self.assertEqual(x, 1) + self.assertEqual(y, 1) + + def test_patma_259(self): + class Eq: + def __eq__(self, other): + return True + x = eq = Eq() + y = None + match x: + case None: + 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) + + 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) + + 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)) + + @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 + """) + + 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}) + + 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) + + def test_patma_278(self): + x = range(3) + match x: + case [y, *_, z]: + w = 0 + self.assertEqual(w, 0) + self.assertEqual(x, range(3)) + self.assertEqual(y, 0) + self.assertEqual(z, 2) + + def test_patma_279(self): + x = range(3) + match x: + case [_, *_, y]: + z = 0 + self.assertEqual(x, range(3)) + self.assertEqual(y, 2) + self.assertEqual(z, 0) + + def test_patma_280(self): + x = range(3) + match x: + case [*_, y]: + z = 0 + self.assertEqual(x, range(3)) + self.assertEqual(y, 2) + self.assertEqual(z, 0) + + @no_perf + def test_patma_281(self): + x = range(10) + y = None + with self.assertRaises(TypeError): + match x: + case range(10): + y = 0 + self.assertEqual(x, range(10)) + self.assertIs(y, None) + + +class PerfPatma(TestPatma): + + def assertEqual(*_, **__): + pass + + def assertIs(*_, **__): + pass + + def assertRaises(*_, **__): + assert False, "this test should be decorated with @no_perf!" + + def assertWarns(*_, **__): + 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_") and not hasattr(attr, "no_perf") + ] + for _ in range(1 << 8): + for test in tests: + test(self) + + @staticmethod + def setUpClass(): + raise unittest.SkipTest("performance testing") + + +""" +sudo ./python -m pyperf system tune && \ + ./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/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 0000000..e779eb8 --- /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. diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index a4c10d6..1ab9621 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -2337,7 +2337,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_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 5814e8a..eaedb0b 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2912,7 +2912,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_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 6ca82a7..179cb30 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -3549,7 +3549,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_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 fdeb189..178f7b2 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -1945,7 +1945,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_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 415f9a2..e7987a6 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3052,7 +3052,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_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 02b3603..d5037a7 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -5639,7 +5639,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_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 bfe6917..e8912ff 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -2093,7 +2093,8 @@ PyTypeObject PySet_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_MATCH_SELF, /* tp_flags */ set_doc, /* tp_doc */ (traverseproc)set_traverse, /* tp_traverse */ (inquiry)set_clear_internal, /* tp_clear */ @@ -2193,7 +2194,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_MATCH_SELF, /* tp_flags */ frozenset_doc, /* tp_doc */ (traverseproc)set_traverse, /* tp_traverse */ (inquiry)set_clear_internal, /* tp_clear */ @@ -2504,4 +2506,3 @@ static PyObject _dummy_struct = { _PyObject_EXTRA_INIT 2, &_PySetDummy_Type }; - diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index becdf70..89c393c 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -917,7 +917,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_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 8b11522..9e71214 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -5261,6 +5261,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_MATCH_SELF)) { + type->tp_flags |= _Py_TPFLAGS_MATCH_SELF; + } } static int diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 5e1b6b0..0b08b0e 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -15657,7 +15657,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_MATCH_SELF, /* tp_flags */ unicode_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ diff --git a/Parser/Python.asdl b/Parser/Python.asdl index 889712b..ddc019d 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 subject, match_case* cases) + | Raise(expr? exc, expr? cause) | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody) | Assert(expr test, expr? msg) @@ -87,6 +89,10 @@ module Python -- can appear only in Subscript | Slice(expr? lower, expr? upper, expr? step) + -- 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) @@ -121,5 +127,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/asdl_c.py b/Parser/asdl_c.py index 34bd701..8c167bc 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -872,9 +872,10 @@ make_type(struct ast_state *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); @@ -1005,6 +1006,7 @@ static int add_ast_fields(struct ast_state *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; @@ -1405,6 +1407,7 @@ def generate_module_def(mod, f, internal_h): state_strings = { "ast", "_fields", + "__match_args__", "__doc__", "__dict__", "__module__", diff --git a/Parser/parser.c b/Parser/parser.c index 3f0d06f..4ab0401 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -15,7 +15,7 @@ static KeywordToken *reserved_keywords[] = { {"if", 510}, {"in", 518}, {"as", 520}, - {"is", 527}, + {"is", 530}, {"or", 531}, {NULL, -1}, }, @@ -23,8 +23,8 @@ static KeywordToken *reserved_keywords[] = { {"del", 503}, {"try", 511}, {"for", 517}, - {"def", 523}, - {"not", 526}, + {"def", 526}, + {"not", 529}, {"and", 532}, {NULL, -1}, }, @@ -34,8 +34,8 @@ static KeywordToken *reserved_keywords[] = { {"elif", 515}, {"else", 516}, {"with", 519}, - {"True", 528}, - {"None", 530}, + {"None", 523}, + {"True", 524}, {NULL, -1}, }, (KeywordToken[]) { @@ -43,8 +43,8 @@ static KeywordToken *reserved_keywords[] = { {"yield", 504}, {"break", 506}, {"while", 512}, - {"class", 524}, - {"False", 529}, + {"False", 525}, + {"class", 527}, {NULL, -1}, }, (KeywordToken[]) { @@ -53,7 +53,7 @@ static KeywordToken *reserved_keywords[] = { {"global", 508}, {"import", 513}, {"except", 521}, - {"lambda", 525}, + {"lambda", 528}, {NULL, -1}, }, (KeywordToken[]) { @@ -104,301 +104,347 @@ 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 star_expressions_type 1059 -#define star_expression_type 1060 -#define star_named_expressions_type 1061 -#define star_named_expression_type 1062 -#define named_expression_type 1063 -#define annotated_rhs_type 1064 -#define expressions_type 1065 -#define expression_type 1066 -#define lambdef_type 1067 -#define lambda_params_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_list_seq_type 1129 -#define star_targets_tuple_seq_type 1130 -#define star_target_type 1131 -#define target_with_star_atom_type 1132 -#define star_atom_type 1133 -#define single_target_type 1134 -#define single_subscript_attribute_target_type 1135 -#define del_targets_type 1136 -#define del_target_type 1137 -#define del_t_atom_type 1138 -#define targets_type 1139 -#define target_type 1140 -#define t_primary_type 1141 // Left-recursive -#define t_lookahead_type 1142 -#define t_atom_type 1143 -#define invalid_arguments_type 1144 -#define invalid_kwarg_type 1145 -#define invalid_named_expression_type 1146 -#define invalid_assignment_type 1147 -#define invalid_ann_assign_target_type 1148 -#define invalid_del_stmt_type 1149 -#define invalid_block_type 1150 -#define invalid_primary_type 1151 // Left-recursive -#define invalid_comprehension_type 1152 -#define invalid_dict_comprehension_type 1153 -#define invalid_parameters_type 1154 -#define invalid_parameters_helper_type 1155 -#define invalid_lambda_parameters_type 1156 -#define invalid_lambda_parameters_helper_type 1157 -#define invalid_star_etc_type 1158 -#define invalid_lambda_star_etc_type 1159 -#define invalid_double_type_comments_type 1160 -#define invalid_with_item_type 1161 -#define invalid_for_target_type 1162 -#define invalid_group_type 1163 -#define invalid_import_from_targets_type 1164 -#define invalid_with_stmt_type 1165 -#define invalid_except_block_type 1166 -#define _loop0_1_type 1167 -#define _loop0_2_type 1168 -#define _loop0_4_type 1169 -#define _gather_3_type 1170 -#define _loop0_6_type 1171 -#define _gather_5_type 1172 -#define _loop0_8_type 1173 -#define _gather_7_type 1174 -#define _loop0_10_type 1175 -#define _gather_9_type 1176 -#define _loop1_11_type 1177 -#define _loop0_13_type 1178 -#define _gather_12_type 1179 -#define _tmp_14_type 1180 -#define _tmp_15_type 1181 -#define _tmp_16_type 1182 -#define _tmp_17_type 1183 -#define _tmp_18_type 1184 -#define _tmp_19_type 1185 -#define _tmp_20_type 1186 -#define _tmp_21_type 1187 -#define _loop1_22_type 1188 -#define _tmp_23_type 1189 -#define _tmp_24_type 1190 -#define _loop0_26_type 1191 -#define _gather_25_type 1192 -#define _loop0_28_type 1193 -#define _gather_27_type 1194 -#define _tmp_29_type 1195 -#define _tmp_30_type 1196 -#define _loop0_31_type 1197 -#define _loop1_32_type 1198 -#define _loop0_34_type 1199 -#define _gather_33_type 1200 -#define _tmp_35_type 1201 -#define _loop0_37_type 1202 -#define _gather_36_type 1203 -#define _tmp_38_type 1204 -#define _loop0_40_type 1205 -#define _gather_39_type 1206 -#define _loop0_42_type 1207 -#define _gather_41_type 1208 -#define _loop0_44_type 1209 -#define _gather_43_type 1210 -#define _loop0_46_type 1211 -#define _gather_45_type 1212 -#define _tmp_47_type 1213 -#define _loop1_48_type 1214 -#define _tmp_49_type 1215 -#define _tmp_50_type 1216 -#define _tmp_51_type 1217 -#define _tmp_52_type 1218 -#define _tmp_53_type 1219 -#define _loop0_54_type 1220 -#define _loop0_55_type 1221 -#define _loop0_56_type 1222 -#define _loop1_57_type 1223 -#define _loop0_58_type 1224 -#define _loop1_59_type 1225 -#define _loop1_60_type 1226 -#define _loop1_61_type 1227 -#define _loop0_62_type 1228 -#define _loop1_63_type 1229 -#define _loop0_64_type 1230 -#define _loop1_65_type 1231 -#define _loop0_66_type 1232 -#define _loop1_67_type 1233 -#define _loop1_68_type 1234 -#define _tmp_69_type 1235 -#define _loop1_70_type 1236 -#define _loop0_72_type 1237 -#define _gather_71_type 1238 -#define _loop1_73_type 1239 -#define _loop0_74_type 1240 -#define _loop0_75_type 1241 -#define _loop0_76_type 1242 -#define _loop1_77_type 1243 -#define _loop0_78_type 1244 -#define _loop1_79_type 1245 -#define _loop1_80_type 1246 -#define _loop1_81_type 1247 -#define _loop0_82_type 1248 -#define _loop1_83_type 1249 -#define _loop0_84_type 1250 -#define _loop1_85_type 1251 -#define _loop0_86_type 1252 -#define _loop1_87_type 1253 -#define _loop1_88_type 1254 -#define _loop1_89_type 1255 -#define _loop1_90_type 1256 -#define _tmp_91_type 1257 -#define _loop0_93_type 1258 -#define _gather_92_type 1259 -#define _tmp_94_type 1260 -#define _tmp_95_type 1261 -#define _tmp_96_type 1262 -#define _tmp_97_type 1263 -#define _loop1_98_type 1264 -#define _tmp_99_type 1265 -#define _tmp_100_type 1266 -#define _loop0_102_type 1267 -#define _gather_101_type 1268 -#define _loop1_103_type 1269 -#define _loop0_104_type 1270 -#define _loop0_105_type 1271 -#define _loop0_107_type 1272 -#define _gather_106_type 1273 -#define _tmp_108_type 1274 -#define _loop0_110_type 1275 -#define _gather_109_type 1276 -#define _loop0_112_type 1277 -#define _gather_111_type 1278 -#define _loop0_114_type 1279 -#define _gather_113_type 1280 -#define _loop0_116_type 1281 -#define _gather_115_type 1282 -#define _loop0_117_type 1283 -#define _loop0_119_type 1284 -#define _gather_118_type 1285 -#define _loop1_120_type 1286 -#define _tmp_121_type 1287 -#define _loop0_123_type 1288 -#define _gather_122_type 1289 -#define _loop0_125_type 1290 -#define _gather_124_type 1291 -#define _tmp_126_type 1292 -#define _loop0_127_type 1293 -#define _loop0_128_type 1294 -#define _loop0_129_type 1295 -#define _tmp_130_type 1296 -#define _tmp_131_type 1297 -#define _tmp_132_type 1298 -#define _loop0_133_type 1299 -#define _loop1_134_type 1300 -#define _loop0_135_type 1301 -#define _loop1_136_type 1302 -#define _tmp_137_type 1303 -#define _tmp_138_type 1304 -#define _tmp_139_type 1305 -#define _loop0_141_type 1306 -#define _gather_140_type 1307 -#define _loop0_143_type 1308 -#define _gather_142_type 1309 -#define _tmp_144_type 1310 -#define _tmp_145_type 1311 -#define _tmp_146_type 1312 -#define _tmp_147_type 1313 -#define _tmp_148_type 1314 -#define _tmp_149_type 1315 -#define _tmp_150_type 1316 -#define _tmp_151_type 1317 -#define _tmp_152_type 1318 -#define _tmp_153_type 1319 -#define _tmp_154_type 1320 -#define _tmp_155_type 1321 -#define _tmp_156_type 1322 -#define _tmp_157_type 1323 -#define _tmp_158_type 1324 -#define _tmp_159_type 1325 -#define _tmp_160_type 1326 -#define _tmp_161_type 1327 -#define _tmp_162_type 1328 -#define _tmp_163_type 1329 -#define _tmp_164_type 1330 -#define _tmp_165_type 1331 -#define _tmp_166_type 1332 +#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 as_pattern_type 1044 +#define or_pattern_type 1045 +#define closed_pattern_type 1046 +#define literal_pattern_type 1047 +#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 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 star_expressions_type 1089 +#define star_expression_type 1090 +#define star_named_expressions_type 1091 +#define star_named_expression_type 1092 +#define named_expression_type 1093 +#define annotated_rhs_type 1094 +#define expressions_type 1095 +#define expression_type 1096 +#define lambdef_type 1097 +#define lambda_params_type 1098 +#define lambda_parameters_type 1099 +#define lambda_slash_no_default_type 1100 +#define lambda_slash_with_default_type 1101 +#define lambda_star_etc_type 1102 +#define lambda_kwds_type 1103 +#define lambda_param_no_default_type 1104 +#define lambda_param_with_default_type 1105 +#define lambda_param_maybe_default_type 1106 +#define lambda_param_type 1107 +#define disjunction_type 1108 +#define conjunction_type 1109 +#define inversion_type 1110 +#define comparison_type 1111 +#define compare_op_bitwise_or_pair_type 1112 +#define eq_bitwise_or_type 1113 +#define noteq_bitwise_or_type 1114 +#define lte_bitwise_or_type 1115 +#define lt_bitwise_or_type 1116 +#define gte_bitwise_or_type 1117 +#define gt_bitwise_or_type 1118 +#define notin_bitwise_or_type 1119 +#define in_bitwise_or_type 1120 +#define isnot_bitwise_or_type 1121 +#define is_bitwise_or_type 1122 +#define bitwise_or_type 1123 // Left-recursive +#define bitwise_xor_type 1124 // Left-recursive +#define bitwise_and_type 1125 // Left-recursive +#define shift_expr_type 1126 // Left-recursive +#define sum_type 1127 // Left-recursive +#define term_type 1128 // Left-recursive +#define factor_type 1129 +#define power_type 1130 +#define await_primary_type 1131 +#define primary_type 1132 // Left-recursive +#define slices_type 1133 +#define slice_type 1134 +#define atom_type 1135 +#define strings_type 1136 +#define list_type 1137 +#define listcomp_type 1138 +#define tuple_type 1139 +#define group_type 1140 +#define genexp_type 1141 +#define set_type 1142 +#define setcomp_type 1143 +#define dict_type 1144 +#define dictcomp_type 1145 +#define double_starred_kvpairs_type 1146 +#define double_starred_kvpair_type 1147 +#define kvpair_type 1148 +#define for_if_clauses_type 1149 +#define for_if_clause_type 1150 +#define yield_expr_type 1151 +#define arguments_type 1152 +#define args_type 1153 +#define kwargs_type 1154 +#define starred_expression_type 1155 +#define kwarg_or_starred_type 1156 +#define kwarg_or_double_starred_type 1157 +#define star_targets_type 1158 +#define star_targets_list_seq_type 1159 +#define star_targets_tuple_seq_type 1160 +#define star_target_type 1161 +#define target_with_star_atom_type 1162 +#define star_atom_type 1163 +#define single_target_type 1164 +#define single_subscript_attribute_target_type 1165 +#define del_targets_type 1166 +#define del_target_type 1167 +#define del_t_atom_type 1168 +#define targets_type 1169 +#define target_type 1170 +#define t_primary_type 1171 // Left-recursive +#define t_lookahead_type 1172 +#define t_atom_type 1173 +#define invalid_arguments_type 1174 +#define invalid_kwarg_type 1175 +#define invalid_named_expression_type 1176 +#define invalid_assignment_type 1177 +#define invalid_ann_assign_target_type 1178 +#define invalid_del_stmt_type 1179 +#define invalid_block_type 1180 +#define invalid_primary_type 1181 // Left-recursive +#define invalid_comprehension_type 1182 +#define invalid_dict_comprehension_type 1183 +#define invalid_parameters_type 1184 +#define invalid_parameters_helper_type 1185 +#define invalid_lambda_parameters_type 1186 +#define invalid_lambda_parameters_helper_type 1187 +#define invalid_star_etc_type 1188 +#define invalid_lambda_star_etc_type 1189 +#define invalid_double_type_comments_type 1190 +#define invalid_with_item_type 1191 +#define invalid_for_target_type 1192 +#define invalid_group_type 1193 +#define invalid_import_from_targets_type 1194 +#define invalid_with_stmt_type 1195 +#define invalid_except_block_type 1196 +#define _loop0_1_type 1197 +#define _loop0_2_type 1198 +#define _loop0_4_type 1199 +#define _gather_3_type 1200 +#define _loop0_6_type 1201 +#define _gather_5_type 1202 +#define _loop0_8_type 1203 +#define _gather_7_type 1204 +#define _loop0_10_type 1205 +#define _gather_9_type 1206 +#define _loop1_11_type 1207 +#define _loop0_13_type 1208 +#define _gather_12_type 1209 +#define _tmp_14_type 1210 +#define _tmp_15_type 1211 +#define _tmp_16_type 1212 +#define _tmp_17_type 1213 +#define _tmp_18_type 1214 +#define _tmp_19_type 1215 +#define _tmp_20_type 1216 +#define _tmp_21_type 1217 +#define _loop1_22_type 1218 +#define _tmp_23_type 1219 +#define _tmp_24_type 1220 +#define _loop0_26_type 1221 +#define _gather_25_type 1222 +#define _loop0_28_type 1223 +#define _gather_27_type 1224 +#define _tmp_29_type 1225 +#define _tmp_30_type 1226 +#define _loop0_31_type 1227 +#define _loop1_32_type 1228 +#define _loop0_34_type 1229 +#define _gather_33_type 1230 +#define _tmp_35_type 1231 +#define _loop0_37_type 1232 +#define _gather_36_type 1233 +#define _tmp_38_type 1234 +#define _loop0_40_type 1235 +#define _gather_39_type 1236 +#define _loop0_42_type 1237 +#define _gather_41_type 1238 +#define _loop0_44_type 1239 +#define _gather_43_type 1240 +#define _loop0_46_type 1241 +#define _gather_45_type 1242 +#define _tmp_47_type 1243 +#define _loop1_48_type 1244 +#define _tmp_49_type 1245 +#define _loop1_50_type 1246 +#define _loop0_52_type 1247 +#define _gather_51_type 1248 +#define _tmp_53_type 1249 +#define _tmp_54_type 1250 +#define _tmp_55_type 1251 +#define _loop0_57_type 1252 +#define _gather_56_type 1253 +#define _tmp_58_type 1254 +#define _loop0_60_type 1255 +#define _gather_59_type 1256 +#define _tmp_61_type 1257 +#define _loop0_63_type 1258 +#define _gather_62_type 1259 +#define _loop0_65_type 1260 +#define _gather_64_type 1261 +#define _tmp_66_type 1262 +#define _tmp_67_type 1263 +#define _tmp_68_type 1264 +#define _tmp_69_type 1265 +#define _loop0_70_type 1266 +#define _loop0_71_type 1267 +#define _loop0_72_type 1268 +#define _loop1_73_type 1269 +#define _loop0_74_type 1270 +#define _loop1_75_type 1271 +#define _loop1_76_type 1272 +#define _loop1_77_type 1273 +#define _loop0_78_type 1274 +#define _loop1_79_type 1275 +#define _loop0_80_type 1276 +#define _loop1_81_type 1277 +#define _loop0_82_type 1278 +#define _loop1_83_type 1279 +#define _loop1_84_type 1280 +#define _tmp_85_type 1281 +#define _loop1_86_type 1282 +#define _loop0_88_type 1283 +#define _gather_87_type 1284 +#define _loop1_89_type 1285 +#define _loop0_90_type 1286 +#define _loop0_91_type 1287 +#define _loop0_92_type 1288 +#define _loop1_93_type 1289 +#define _loop0_94_type 1290 +#define _loop1_95_type 1291 +#define _loop1_96_type 1292 +#define _loop1_97_type 1293 +#define _loop0_98_type 1294 +#define _loop1_99_type 1295 +#define _loop0_100_type 1296 +#define _loop1_101_type 1297 +#define _loop0_102_type 1298 +#define _loop1_103_type 1299 +#define _loop1_104_type 1300 +#define _loop1_105_type 1301 +#define _loop1_106_type 1302 +#define _tmp_107_type 1303 +#define _loop0_109_type 1304 +#define _gather_108_type 1305 +#define _tmp_110_type 1306 +#define _tmp_111_type 1307 +#define _tmp_112_type 1308 +#define _tmp_113_type 1309 +#define _loop1_114_type 1310 +#define _tmp_115_type 1311 +#define _tmp_116_type 1312 +#define _loop0_118_type 1313 +#define _gather_117_type 1314 +#define _loop1_119_type 1315 +#define _loop0_120_type 1316 +#define _loop0_121_type 1317 +#define _loop0_123_type 1318 +#define _gather_122_type 1319 +#define _tmp_124_type 1320 +#define _loop0_126_type 1321 +#define _gather_125_type 1322 +#define _loop0_128_type 1323 +#define _gather_127_type 1324 +#define _loop0_130_type 1325 +#define _gather_129_type 1326 +#define _loop0_132_type 1327 +#define _gather_131_type 1328 +#define _loop0_133_type 1329 +#define _loop0_135_type 1330 +#define _gather_134_type 1331 +#define _loop1_136_type 1332 +#define _tmp_137_type 1333 +#define _loop0_139_type 1334 +#define _gather_138_type 1335 +#define _loop0_141_type 1336 +#define _gather_140_type 1337 +#define _tmp_142_type 1338 +#define _loop0_143_type 1339 +#define _loop0_144_type 1340 +#define _loop0_145_type 1341 +#define _tmp_146_type 1342 +#define _tmp_147_type 1343 +#define _tmp_148_type 1344 +#define _loop0_149_type 1345 +#define _loop1_150_type 1346 +#define _loop0_151_type 1347 +#define _loop1_152_type 1348 +#define _tmp_153_type 1349 +#define _tmp_154_type 1350 +#define _tmp_155_type 1351 +#define _loop0_157_type 1352 +#define _gather_156_type 1353 +#define _loop0_159_type 1354 +#define _gather_158_type 1355 +#define _tmp_160_type 1356 +#define _tmp_161_type 1357 +#define _tmp_162_type 1358 +#define _tmp_163_type 1359 +#define _tmp_164_type 1360 +#define _tmp_165_type 1361 +#define _tmp_166_type 1362 +#define _tmp_167_type 1363 +#define _tmp_168_type 1364 +#define _tmp_169_type 1365 +#define _tmp_170_type 1366 +#define _tmp_171_type 1367 +#define _tmp_172_type 1368 +#define _tmp_173_type 1369 +#define _tmp_174_type 1370 +#define _tmp_175_type 1371 +#define _tmp_176_type 1372 +#define _tmp_177_type 1373 +#define _tmp_178_type 1374 +#define _tmp_179_type 1375 +#define _tmp_180_type 1376 +#define _tmp_181_type 1377 +#define _tmp_182_type 1378 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -438,6 +484,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 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 literal_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 expr_ty group_pattern_rule(Parser *p); +static expr_ty 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); +static expr_ty mapping_pattern_rule(Parser *p); +static asdl_seq* items_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); @@ -616,116 +692,116 @@ static asdl_seq *_gather_45_rule(Parser *p); static void *_tmp_47_rule(Parser *p); static asdl_seq *_loop1_48_rule(Parser *p); static void *_tmp_49_rule(Parser *p); -static void *_tmp_50_rule(Parser *p); -static void *_tmp_51_rule(Parser *p); -static void *_tmp_52_rule(Parser *p); +static asdl_seq *_loop1_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_54_rule(Parser *p); -static asdl_seq *_loop0_55_rule(Parser *p); -static asdl_seq *_loop0_56_rule(Parser *p); -static asdl_seq *_loop1_57_rule(Parser *p); -static asdl_seq *_loop0_58_rule(Parser *p); -static asdl_seq *_loop1_59_rule(Parser *p); -static asdl_seq *_loop1_60_rule(Parser *p); -static asdl_seq *_loop1_61_rule(Parser *p); -static asdl_seq *_loop0_62_rule(Parser *p); -static asdl_seq *_loop1_63_rule(Parser *p); -static asdl_seq *_loop0_64_rule(Parser *p); -static asdl_seq *_loop1_65_rule(Parser *p); -static asdl_seq *_loop0_66_rule(Parser *p); -static asdl_seq *_loop1_67_rule(Parser *p); -static asdl_seq *_loop1_68_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 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 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 *_loop1_70_rule(Parser *p); +static asdl_seq *_loop0_70_rule(Parser *p); +static asdl_seq *_loop0_71_rule(Parser *p); static asdl_seq *_loop0_72_rule(Parser *p); -static asdl_seq *_gather_71_rule(Parser *p); static asdl_seq *_loop1_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_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 *_loop1_80_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 *_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_88_rule(Parser *p); +static asdl_seq *_loop1_84_rule(Parser *p); +static void *_tmp_85_rule(Parser *p); +static asdl_seq *_loop1_86_rule(Parser *p); +static asdl_seq *_loop0_88_rule(Parser *p); +static asdl_seq *_gather_87_rule(Parser *p); static asdl_seq *_loop1_89_rule(Parser *p); -static asdl_seq *_loop1_90_rule(Parser *p); -static void *_tmp_91_rule(Parser *p); -static asdl_seq *_loop0_93_rule(Parser *p); -static asdl_seq *_gather_92_rule(Parser *p); -static void *_tmp_94_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 asdl_seq *_loop1_98_rule(Parser *p); -static void *_tmp_99_rule(Parser *p); -static void *_tmp_100_rule(Parser *p); +static asdl_seq *_loop0_90_rule(Parser *p); +static asdl_seq *_loop0_91_rule(Parser *p); +static asdl_seq *_loop0_92_rule(Parser *p); +static asdl_seq *_loop1_93_rule(Parser *p); +static asdl_seq *_loop0_94_rule(Parser *p); +static asdl_seq *_loop1_95_rule(Parser *p); +static asdl_seq *_loop1_96_rule(Parser *p); +static asdl_seq *_loop1_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 *_loop0_102_rule(Parser *p); -static asdl_seq *_gather_101_rule(Parser *p); static asdl_seq *_loop1_103_rule(Parser *p); -static asdl_seq *_loop0_104_rule(Parser *p); -static asdl_seq *_loop0_105_rule(Parser *p); -static asdl_seq *_loop0_107_rule(Parser *p); -static asdl_seq *_gather_106_rule(Parser *p); -static void *_tmp_108_rule(Parser *p); -static asdl_seq *_loop0_110_rule(Parser *p); -static asdl_seq *_gather_109_rule(Parser *p); -static asdl_seq *_loop0_112_rule(Parser *p); -static asdl_seq *_gather_111_rule(Parser *p); -static asdl_seq *_loop0_114_rule(Parser *p); -static asdl_seq *_gather_113_rule(Parser *p); -static asdl_seq *_loop0_116_rule(Parser *p); -static asdl_seq *_gather_115_rule(Parser *p); -static asdl_seq *_loop0_117_rule(Parser *p); -static asdl_seq *_loop0_119_rule(Parser *p); -static asdl_seq *_gather_118_rule(Parser *p); -static asdl_seq *_loop1_120_rule(Parser *p); -static void *_tmp_121_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 void *_tmp_107_rule(Parser *p); +static asdl_seq *_loop0_109_rule(Parser *p); +static asdl_seq *_gather_108_rule(Parser *p); +static void *_tmp_110_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 asdl_seq *_loop1_114_rule(Parser *p); +static void *_tmp_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 asdl_seq *_loop1_119_rule(Parser *p); +static asdl_seq *_loop0_120_rule(Parser *p); +static asdl_seq *_loop0_121_rule(Parser *p); static asdl_seq *_loop0_123_rule(Parser *p); static asdl_seq *_gather_122_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_127_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 *_loop0_129_rule(Parser *p); -static void *_tmp_130_rule(Parser *p); -static void *_tmp_131_rule(Parser *p); -static void *_tmp_132_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_133_rule(Parser *p); -static asdl_seq *_loop1_134_rule(Parser *p); static asdl_seq *_loop0_135_rule(Parser *p); +static asdl_seq *_gather_134_rule(Parser *p); static asdl_seq *_loop1_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 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_142_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 void *_tmp_145_rule(Parser *p); +static asdl_seq *_loop0_144_rule(Parser *p); +static asdl_seq *_loop0_145_rule(Parser *p); static void *_tmp_146_rule(Parser *p); static void *_tmp_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_149_rule(Parser *p); +static asdl_seq *_loop1_150_rule(Parser *p); +static asdl_seq *_loop0_151_rule(Parser *p); +static asdl_seq *_loop1_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 asdl_seq *_loop0_157_rule(Parser *p); +static asdl_seq *_gather_156_rule(Parser *p); +static asdl_seq *_loop0_159_rule(Parser *p); +static asdl_seq *_gather_158_rule(Parser *p); static void *_tmp_160_rule(Parser *p); static void *_tmp_161_rule(Parser *p); static void *_tmp_162_rule(Parser *p); @@ -733,6 +809,22 @@ 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 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 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); // file: statements? $ @@ -1891,6 +1983,7 @@ simple_stmt_rule(Parser *p) // | &('for' | ASYNC) for_stmt // | &'try' try_stmt // | &'while' while_stmt +// | match_stmt static stmt_ty compound_stmt_rule(Parser *p) { @@ -2048,6 +2141,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--); @@ -4736,6 +4848,2269 @@ finally_block_rule(Parser *p) return _res; } +// 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; + } + 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 + { // "match" subject_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\" subject_expr ':' NEWLINE INDENT case_block+ DEDENT")); + expr_ty _keyword; + Token * _literal; + asdl_match_case_seq* cases; + Token * dedent_var; + Token * indent_var; + Token * newline_var; + expr_ty subject; + if ( + (_keyword = _PyPegen_expect_soft_keyword(p, "match")) // soft_keyword='"match"' + && + (subject = subject_expr_rule(p)) // subject_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' + && + (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_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--); + 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 ( stmt_ty , 10 , "Pattern matching is" , _Py_Match ( subject , cases , 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_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: + D(p->level--); + return _res; +} + +// 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; + } + 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> subject_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+ 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--); + 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 ( asdl_expr_seq * , _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 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: + D(p->level--); + return _res; +} + +// case_block: "case" patterns guard? ':' block +static match_case_ty +case_block_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + match_case_ty _res = NULL; + int _mark = p->mark; + { // "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\" patterns guard? ':' block")); + expr_ty _keyword; + Token * _literal; + asdl_stmt_seq* body; + void *guard; + expr_ty pattern; + if ( + (_keyword = _PyPegen_expect_soft_keyword(p, "case")) // soft_keyword='"case"' + && + (pattern = patterns_rule(p)) // patterns + && + (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\" patterns guard? ':' 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\" patterns guard? ':' block")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// guard: 'if' named_expression +static expr_ty +guard_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _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; +} + +// patterns: open_sequence_pattern | pattern +static expr_ty +patterns_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 + { // 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")); + asdl_expr_seq* values; + if ( + (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")); + 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; + D(fprintf(stderr, "%*c%s patterns[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "open_sequence_pattern")); + } + { // pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + 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 + ) + { + 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 patterns[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// 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) { + 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 + { // or_pattern 'as' capture_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + 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; + if ( + (pattern = or_pattern_rule(p)) // or_pattern + && + (_keyword = _PyPegen_expect_token(p, 520)) // token='as' + && + (target = capture_pattern_rule(p)) // capture_pattern + ) + { + 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--); + 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_MatchAs ( pattern , target -> v . Name . id , 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 as_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "or_pattern 'as' capture_pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// or_pattern: '|'.closed_pattern+ +static expr_ty +or_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 + { // '|'.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_expr_seq* patterns; + if ( + (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+")); + 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 = 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--); + 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+")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// closed_pattern: +// | literal_pattern +// | capture_pattern +// | wildcard_pattern +// | value_pattern +// | group_pattern +// | sequence_pattern +// | mapping_pattern +// | class_pattern +static expr_ty +closed_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + { // 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, "literal_pattern")); + expr_ty literal_pattern_var; + if ( + (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, "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, "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, "capture_pattern")); + expr_ty capture_pattern_var; + if ( + (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, "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, "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")); + } + { // 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, "value_pattern")); + expr_ty value_pattern_var; + if ( + (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, "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, "value_pattern")); + } + { // 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")); + expr_ty 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")); + } + { // sequence_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, "sequence_pattern")); + expr_ty sequence_pattern_var; + if ( + (sequence_pattern_var = sequence_pattern_rule(p)) // sequence_pattern + ) + { + 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 closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sequence_pattern")); + } + { // mapping_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, "mapping_pattern")); + expr_ty mapping_pattern_var; + if ( + (mapping_pattern_var = mapping_pattern_rule(p)) // mapping_pattern + ) + { + 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 closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "mapping_pattern")); + } + { // class_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, "class_pattern")); + expr_ty class_pattern_var; + if ( + (class_pattern_var = class_pattern_rule(p)) // class_pattern + ) + { + 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 closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "class_pattern")); + } + _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_53_rule, p) + ) + { + 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, "signed_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; + expr_ty 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; + expr_ty real; + if ( + (real = signed_number_rule(p)) // signed_number + && + (_literal = _PyPegen_expect_token(p, 15)) // 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 , Sub , 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")); + } + { // strings + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "strings")); + expr_ty strings_var; + if ( + (strings_var = strings_rule(p)) // strings + ) + { + 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 literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "strings")); + } + { // 'None' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); + Token * _keyword; + if ( + (_keyword = _PyPegen_expect_token(p, 523)) // token='None' + ) + { + D(fprintf(stderr, "%*c+ literal_pattern[%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--); + 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; + D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); + } + { // 'True' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); + Token * _keyword; + if ( + (_keyword = _PyPegen_expect_token(p, 524)) // token='True' + ) + { + D(fprintf(stderr, "%*c+ literal_pattern[%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 literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); + } + { // 'False' + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); + Token * _keyword; + if ( + (_keyword = _PyPegen_expect_token(p, 525)) // token='False' + ) + { + D(fprintf(stderr, "%*c+ literal_pattern[%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; + } + 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, "'False'")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// signed_number: NUMBER | '-' NUMBER +static expr_ty +signed_number_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 + { // 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; +} + +// capture_pattern: !"_" NAME !('.' | '(' | '=') +static expr_ty +capture_pattern_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> capture_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!\"_\" NAME !('.' | '(' | '=')")); + expr_ty name; + if ( + _PyPegen_lookahead_with_string(0, _PyPegen_expect_soft_keyword, p, "_") + && + (name = _PyPegen_name_token(p)) // NAME + && + _PyPegen_lookahead(0, _tmp_54_rule, p) + ) + { + 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--); + return NULL; + } + goto done; + } + p->mark = _mark; + 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: + D(p->level--); + return _res; +} + +// wildcard_pattern: "_" +static expr_ty +wildcard_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 + { // "_" + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> wildcard_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"_\"")); + expr_ty _keyword; + if ( + (_keyword = _PyPegen_expect_soft_keyword(p, "_")) // soft_keyword='"_"' + ) + { + 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--); + 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_Name ( CHECK ( PyObject * , _PyPegen_new_identifier ( p , "_" ) ) , 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 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> value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "attr !('.' | '(' | '=')")); + expr_ty attr; + if ( + (attr = attr_rule(p)) // attr + && + _PyPegen_lookahead(0, _tmp_55_rule, p) + ) + { + 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--); + 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, "attr !('.' | '(' | '=')")); + } + _res = NULL; + done: + D(p->level--); + 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 (p->error_indicator) + return NULL; + 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) { + 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_or_attr '.' NAME + 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")); + Token * _literal; + expr_ty attr; + expr_ty value; + if ( + (value = name_or_attr_rule(p)) // name_or_attr + && + (_literal = _PyPegen_expect_token(p, 23)) // token='.' + && + (attr = _PyPegen_name_token(p)) // 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--); + 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--); + return NULL; + } + 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")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// Left-recursive +// name_or_attr: attr | NAME +static expr_ty +name_or_attr_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> 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; +} + +// group_pattern: '(' pattern ')' +static expr_ty +group_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> group_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' pattern ')'")); + Token * _literal; + Token * _literal_1; + expr_ty pattern; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (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 = 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 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; + } + 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> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' maybe_sequence_pattern? ']'")); + Token * _literal; + Token * _literal_1; + void *values; + if ( + (_literal = _PyPegen_expect_token(p, 9)) // token='[' + && + (values = maybe_sequence_pattern_rule(p), 1) // maybe_sequence_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, "'[' 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_List ( 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 sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' maybe_sequence_pattern? ']'")); + } + { // '(' open_sequence_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, "'(' open_sequence_pattern? ')'")); + Token * _literal; + Token * _literal_1; + void *values; + if ( + (_literal = _PyPegen_expect_token(p, 7)) // token='(' + && + (values = open_sequence_pattern_rule(p), 1) // open_sequence_pattern? + && + (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' + ) + { + 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--); + 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; + 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 asdl_seq* +open_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 ',' maybe_sequence_pattern? + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> open_sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern ',' maybe_sequence_pattern?")); + Token * _literal; + expr_ty value; + void *values; + if ( + (value = maybe_star_pattern_rule(p)) // maybe_star_pattern + && + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (values = maybe_sequence_pattern_rule(p), 1) // maybe_sequence_pattern? + ) + { + D(fprintf(stderr, "%*c+ open_sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern ',' maybe_sequence_pattern?")); + _res = _PyPegen_seq_insert_in_front ( p , value , values ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + D(p->level--); + return NULL; + } + goto done; + } + p->mark = _mark; + 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?")); + } + _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> maybe_sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.maybe_star_pattern+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_seq * values; + if ( + (values = _gather_56_rule(p)) // ','.maybe_star_pattern+ + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + ) + { + 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--); + return NULL; + } + goto done; + } + p->mark = _mark; + 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: + D(p->level--); + return _res; +} + +// maybe_star_pattern: star_pattern | pattern +static expr_ty +maybe_star_pattern_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + { // star_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> maybe_star_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_pattern")); + expr_ty star_pattern_var; + if ( + (star_pattern_var = star_pattern_rule(p)) // star_pattern + ) + { + 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 maybe_star_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_pattern")); + } + { // pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> maybe_star_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+ 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 maybe_star_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// star_pattern: '*' (capture_pattern | wildcard_pattern) +static expr_ty +star_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 + { // '*' (capture_pattern | wildcard_pattern) + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> star_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (capture_pattern | wildcard_pattern)")); + Token * _literal; + void *value; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (value = _tmp_58_rule(p)) // capture_pattern | wildcard_pattern + ) + { + 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--); + 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 ( value , 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_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (capture_pattern | wildcard_pattern)")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// mapping_pattern: '{' items_pattern? '}' +static expr_ty +mapping_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 + { // '{' 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? '}'")); + Token * _literal; + Token * _literal_1; + void *items; + if ( + (_literal = _PyPegen_expect_token(p, 25)) // token='{' + && + (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? '}'")); + 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 ( asdl_expr_seq * , _PyPegen_get_keys ( p , items ) ) , CHECK ( asdl_expr_seq * , _PyPegen_get_values ( p , items ) ) , 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 mapping_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' items_pattern? '}'")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// items_pattern: ','.key_value_pattern+ ','? +static asdl_seq* +items_pattern_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+ ','? + if (p->error_indicator) { + D(p->level--); + return NULL; + } + 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 ( + (items = _gather_59_rule(p)) // ','.key_value_pattern+ + && + (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? + ) + { + 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--); + return NULL; + } + goto done; + } + p->mark = _mark; + 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: + D(p->level--); + return _res; +} + +// 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; + } + KeyValuePair* _res = NULL; + int _mark = p->mark; + { // (literal_pattern | value_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 | value_pattern) ':' pattern")); + Token * _literal; + void *key; + expr_ty value; + if ( + (key = _tmp_61_rule(p)) // literal_pattern | value_pattern + && + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (value = pattern_rule(p)) // pattern + ) + { + 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--); + 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 | value_pattern) ':' pattern")); + } + { // double_star_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, "double_star_pattern")); + KeyValuePair* double_star_pattern_var; + if ( + (double_star_pattern_var = double_star_pattern_rule(p)) // double_star_pattern + ) + { + 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 key_value_pattern[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_star_pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// 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; + } + KeyValuePair* _res = NULL; + int _mark = p->mark; + { // '**' capture_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> double_star_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' capture_pattern")); + Token * _literal; + expr_ty value; + if ( + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + && + (value = capture_pattern_rule(p)) // capture_pattern + ) + { + 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--); + return NULL; + } + goto done; + } + p->mark = _mark; + 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: + D(p->level--); + return _res; +} + +// 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 +class_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 + { // name_or_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; + 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=')' + ) + { + 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; + } + 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 '(' ')'")); + } + { // name_or_attr '(' positional_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 ','? ')'")); + Token * _literal; + Token * _literal_1; + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + 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 = 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+ 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 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: + D(p->level--); + return _res; +} + +// positional_patterns: ','.pattern+ +static asdl_expr_seq* +positional_patterns_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_expr_seq* _res = NULL; + int _mark = p->mark; + { // ','.pattern+ + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> positional_patterns[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+")); + asdl_expr_seq* args; + if ( + (args = (asdl_expr_seq*)_gather_62_rule(p)) // ','.pattern+ + ) + { + 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--); + return NULL; + } + goto done; + } + p->mark = _mark; + 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; + } + 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> keyword_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' pattern")); + Token * _literal; + expr_ty arg; + expr_ty value; + if ( + (arg = _PyPegen_name_token(p)) // NAME + && + (_literal = _PyPegen_expect_token(p, 22)) // 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 ); + 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 '=' pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + // return_stmt: 'return' star_expressions? static stmt_ty return_stmt_rule(Parser *p) @@ -4832,7 +7207,7 @@ raise_stmt_rule(Parser *p) && (a = expression_rule(p)) // expression && - (b = _tmp_50_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]")); @@ -4997,7 +7372,7 @@ function_def_raw_rule(Parser *p) void *params; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 523)) // token='def' + (_keyword = _PyPegen_expect_token(p, 526)) // token='def' && (n = _PyPegen_name_token(p)) // NAME && @@ -5007,7 +7382,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_51_rule(p), 1) // ['->' expression] + (a = _tmp_67_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' && @@ -5057,7 +7432,7 @@ function_def_raw_rule(Parser *p) if ( (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' && - (_keyword = _PyPegen_expect_token(p, 523)) // token='def' + (_keyword = _PyPegen_expect_token(p, 526)) // token='def' && (n = _PyPegen_name_token(p)) // NAME && @@ -5067,7 +7442,7 @@ function_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (a = _tmp_52_rule(p), 1) // ['->' expression] + (a = _tmp_68_rule(p), 1) // ['->' expression] && (_literal_2 = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' && @@ -5131,7 +7506,7 @@ func_type_comment_rule(Parser *p) && (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' && - _PyPegen_lookahead(1, _tmp_53_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)")); @@ -5275,9 +7650,9 @@ parameters_rule(Parser *p) if ( (a = slash_no_default_rule(p)) // slash_no_default && - (b = (asdl_arg_seq*)_loop0_54_rule(p)) // param_no_default* + (b = (asdl_arg_seq*)_loop0_70_rule(p)) // param_no_default* && - (c = _loop0_55_rule(p)) // param_with_default* + (c = _loop0_71_rule(p)) // param_with_default* && (d = star_etc_rule(p), 1) // star_etc? ) @@ -5307,7 +7682,7 @@ parameters_rule(Parser *p) if ( (a = slash_with_default_rule(p)) // slash_with_default && - (b = _loop0_56_rule(p)) // param_with_default* + (b = _loop0_72_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -5335,9 +7710,9 @@ parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = (asdl_arg_seq*)_loop1_57_rule(p)) // param_no_default+ + (a = (asdl_arg_seq*)_loop1_73_rule(p)) // param_no_default+ && - (b = _loop0_58_rule(p)) // param_with_default* + (b = _loop0_74_rule(p)) // param_with_default* && (c = star_etc_rule(p), 1) // star_etc? ) @@ -5364,7 +7739,7 @@ parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_59_rule(p)) // param_with_default+ + (a = _loop1_75_rule(p)) // param_with_default+ && (b = star_etc_rule(p), 1) // star_etc? ) @@ -5433,7 +7808,7 @@ slash_no_default_rule(Parser *p) Token * _literal_1; asdl_arg_seq* a; if ( - (a = (asdl_arg_seq*)_loop1_60_rule(p)) // param_no_default+ + (a = (asdl_arg_seq*)_loop1_76_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -5462,7 +7837,7 @@ slash_no_default_rule(Parser *p) Token * _literal; asdl_arg_seq* a; if ( - (a = (asdl_arg_seq*)_loop1_61_rule(p)) // param_no_default+ + (a = (asdl_arg_seq*)_loop1_77_rule(p)) // param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -5512,9 +7887,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_62_rule(p)) // param_no_default* + (a = _loop0_78_rule(p)) // param_no_default* && - (b = _loop1_63_rule(p)) // param_with_default+ + (b = _loop1_79_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -5544,9 +7919,9 @@ slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_64_rule(p)) // param_no_default* + (a = _loop0_80_rule(p)) // param_no_default* && - (b = _loop1_65_rule(p)) // param_with_default+ + (b = _loop1_81_rule(p)) // param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -5602,7 +7977,7 @@ star_etc_rule(Parser *p) && (a = param_no_default_rule(p)) // param_no_default && - (b = _loop0_66_rule(p)) // param_maybe_default* + (b = _loop0_82_rule(p)) // param_maybe_default* && (c = kwds_rule(p), 1) // kwds? ) @@ -5635,7 +8010,7 @@ star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_67_rule(p)) // param_maybe_default+ + (b = _loop1_83_rule(p)) // param_maybe_default+ && (c = kwds_rule(p), 1) // kwds? ) @@ -6157,7 +8532,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_68_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))+")); @@ -6274,11 +8649,11 @@ class_def_raw_rule(Parser *p) void *b; asdl_stmt_seq* c; if ( - (_keyword = _PyPegen_expect_token(p, 524)) // token='class' + (_keyword = _PyPegen_expect_token(p, 527)) // token='class' && (a = _PyPegen_name_token(p)) // NAME && - (b = _tmp_69_rule(p), 1) // ['(' arguments? ')'] + (b = _tmp_85_rule(p), 1) // ['(' arguments? ')'] && (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' && @@ -6442,7 +8817,7 @@ star_expressions_rule(Parser *p) if ( (a = star_expression_rule(p)) // star_expression && - (b = _loop1_70_rule(p)) // ((',' star_expression))+ + (b = _loop1_86_rule(p)) // ((',' star_expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -6637,7 +9012,7 @@ star_named_expressions_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_71_rule(p)) // ','.star_named_expression+ + (a = (asdl_expr_seq*)_gather_87_rule(p)) // ','.star_named_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -6942,7 +9317,7 @@ expressions_rule(Parser *p) if ( (a = expression_rule(p)) // expression && - (b = _loop1_73_rule(p)) // ((',' expression))+ + (b = _loop1_89_rule(p)) // ((',' expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -7175,7 +9550,7 @@ lambdef_rule(Parser *p) void *a; expr_ty b; if ( - (_keyword = _PyPegen_expect_token(p, 525)) // token='lambda' + (_keyword = _PyPegen_expect_token(p, 528)) // token='lambda' && (a = lambda_params_rule(p), 1) // lambda_params? && @@ -7296,9 +9671,9 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default && - (b = (asdl_arg_seq*)_loop0_74_rule(p)) // lambda_param_no_default* + (b = (asdl_arg_seq*)_loop0_90_rule(p)) // lambda_param_no_default* && - (c = _loop0_75_rule(p)) // lambda_param_with_default* + (c = _loop0_91_rule(p)) // lambda_param_with_default* && (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -7328,7 +9703,7 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default && - (b = _loop0_76_rule(p)) // lambda_param_with_default* + (b = _loop0_92_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -7356,9 +9731,9 @@ lambda_parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = (asdl_arg_seq*)_loop1_77_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_93_rule(p)) // lambda_param_no_default+ && - (b = _loop0_78_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? ) @@ -7385,7 +9760,7 @@ lambda_parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_79_rule(p)) // lambda_param_with_default+ + (a = _loop1_95_rule(p)) // lambda_param_with_default+ && (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? ) @@ -7456,7 +9831,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal_1; asdl_arg_seq* a; if ( - (a = (asdl_arg_seq*)_loop1_80_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_96_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7485,7 +9860,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal; asdl_arg_seq* a; if ( - (a = (asdl_arg_seq*)_loop1_81_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_97_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7535,9 +9910,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_82_rule(p)) // lambda_param_no_default* + (a = _loop0_98_rule(p)) // lambda_param_no_default* && - (b = _loop1_83_rule(p)) // lambda_param_with_default+ + (b = _loop1_99_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7567,9 +9942,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_84_rule(p)) // lambda_param_no_default* + (a = _loop0_100_rule(p)) // lambda_param_no_default* && - (b = _loop1_85_rule(p)) // lambda_param_with_default+ + (b = _loop1_101_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -7625,7 +10000,7 @@ lambda_star_etc_rule(Parser *p) && (a = lambda_param_no_default_rule(p)) // lambda_param_no_default && - (b = _loop0_86_rule(p)) // lambda_param_maybe_default* + (b = _loop0_102_rule(p)) // lambda_param_maybe_default* && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -7658,7 +10033,7 @@ lambda_star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_87_rule(p)) // lambda_param_maybe_default+ + (b = _loop1_103_rule(p)) // lambda_param_maybe_default+ && (c = lambda_kwds_rule(p), 1) // lambda_kwds? ) @@ -8085,7 +10460,7 @@ disjunction_rule(Parser *p) if ( (a = conjunction_rule(p)) // conjunction && - (b = _loop1_88_rule(p)) // (('or' conjunction))+ + (b = _loop1_104_rule(p)) // (('or' conjunction))+ ) { D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); @@ -8171,7 +10546,7 @@ conjunction_rule(Parser *p) if ( (a = inversion_rule(p)) // inversion && - (b = _loop1_89_rule(p)) // (('and' inversion))+ + (b = _loop1_105_rule(p)) // (('and' inversion))+ ) { D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); @@ -8255,7 +10630,7 @@ inversion_rule(Parser *p) Token * _keyword; expr_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 526)) // token='not' + (_keyword = _PyPegen_expect_token(p, 529)) // token='not' && (a = inversion_rule(p)) // inversion ) @@ -8339,7 +10714,7 @@ comparison_rule(Parser *p) if ( (a = bitwise_or_rule(p)) // bitwise_or && - (b = _loop1_90_rule(p)) // compare_op_bitwise_or_pair+ + (b = _loop1_106_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+")); @@ -8667,10 +11042,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_91_var; + void *_tmp_107_var; expr_ty a; if ( - (_tmp_91_var = _tmp_91_rule(p)) // '!=' + (_tmp_107_var = _tmp_107_rule(p)) // '!=' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -8891,7 +11266,7 @@ notin_bitwise_or_rule(Parser *p) Token * _keyword_1; expr_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 526)) // token='not' + (_keyword = _PyPegen_expect_token(p, 529)) // token='not' && (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' && @@ -8982,9 +11357,9 @@ isnot_bitwise_or_rule(Parser *p) Token * _keyword_1; expr_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 527)) // token='is' + (_keyword = _PyPegen_expect_token(p, 530)) // token='is' && - (_keyword_1 = _PyPegen_expect_token(p, 526)) // token='not' + (_keyword_1 = _PyPegen_expect_token(p, 529)) // token='not' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -9028,7 +11403,7 @@ is_bitwise_or_rule(Parser *p) Token * _keyword; expr_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 527)) // token='is' + (_keyword = _PyPegen_expect_token(p, 530)) // token='is' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -9067,8 +11442,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; } @@ -9183,8 +11558,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; } @@ -9299,8 +11674,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; } @@ -9415,8 +11790,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; } @@ -9570,8 +11945,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; } @@ -9731,8 +12106,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; } @@ -10337,8 +12712,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; } @@ -10633,7 +13008,7 @@ slices_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_92_rule(p)) // ','.slice+ + (a = (asdl_expr_seq*)_gather_108_rule(p)) // ','.slice+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -10703,7 +13078,7 @@ slice_rule(Parser *p) && (b = expression_rule(p), 1) // expression? && - (c = _tmp_94_rule(p), 1) // [':' expression?] + (c = _tmp_110_rule(p), 1) // [':' expression?] ) { D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); @@ -10815,7 +13190,7 @@ atom_rule(Parser *p) D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 528)) // token='True' + (_keyword = _PyPegen_expect_token(p, 524)) // token='True' ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); @@ -10848,7 +13223,7 @@ atom_rule(Parser *p) D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 529)) // token='False' + (_keyword = _PyPegen_expect_token(p, 525)) // token='False' ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); @@ -10881,7 +13256,7 @@ atom_rule(Parser *p) D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 530)) // token='None' + (_keyword = _PyPegen_expect_token(p, 523)) // token='None' ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); @@ -10952,15 +13327,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_95_var; + void *_tmp_111_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' && - (_tmp_95_var = _tmp_95_rule(p)) // tuple | group | genexp + (_tmp_111_var = _tmp_111_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_95_var; + _res = _tmp_111_var; goto done; } p->mark = _mark; @@ -10973,15 +13348,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_96_var; + void *_tmp_112_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' && - (_tmp_96_var = _tmp_96_rule(p)) // list | listcomp + (_tmp_112_var = _tmp_112_rule(p)) // list | listcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - _res = _tmp_96_var; + _res = _tmp_112_var; goto done; } p->mark = _mark; @@ -10994,15 +13369,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_97_var; + void *_tmp_113_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' && - (_tmp_97_var = _tmp_97_rule(p)) // dict | set | dictcomp | setcomp + (_tmp_113_var = _tmp_113_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_97_var; + _res = _tmp_113_var; goto done; } p->mark = _mark; @@ -11071,7 +13446,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_98_rule(p)) // STRING+ + (a = _loop1_114_rule(p)) // STRING+ ) { D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+")); @@ -11278,7 +13653,7 @@ tuple_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_99_rule(p), 1) // [star_named_expression ',' star_named_expressions?] + (a = _tmp_115_rule(p), 1) // [star_named_expression ',' star_named_expressions?] && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -11334,7 +13709,7 @@ group_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_100_rule(p)) // yield_expr | named_expression + (a = _tmp_116_rule(p)) // yield_expr | named_expression && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -11789,7 +14164,7 @@ double_starred_kvpairs_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_101_rule(p)) // ','.double_starred_kvpair+ + (a = _gather_117_rule(p)) // ','.double_starred_kvpair+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -11942,7 +14317,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_103_rule(p)) // for_if_clause+ + (a = (asdl_comprehension_seq*)_loop1_119_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+")); @@ -12004,7 +14379,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = (asdl_expr_seq*)_loop0_104_rule(p)) // (('if' disjunction))* + (c = (asdl_expr_seq*)_loop0_120_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))*")); @@ -12047,7 +14422,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = (asdl_expr_seq*)_loop0_105_rule(p)) // (('if' disjunction))* + (c = (asdl_expr_seq*)_loop0_121_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))*")); @@ -12293,9 +14668,9 @@ args_rule(Parser *p) asdl_expr_seq* a; void *b; if ( - (a = (asdl_expr_seq*)_gather_106_rule(p)) // ','.(starred_expression | named_expression !'=')+ + (a = (asdl_expr_seq*)_gather_122_rule(p)) // ','.(starred_expression | named_expression !'=')+ && - (b = _tmp_108_rule(p), 1) // [',' kwargs] + (b = _tmp_124_rule(p), 1) // [',' kwargs] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.(starred_expression | named_expression !'=')+ [',' kwargs]")); @@ -12383,11 +14758,11 @@ kwargs_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _gather_109_rule(p)) // ','.kwarg_or_starred+ + (a = _gather_125_rule(p)) // ','.kwarg_or_starred+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _gather_111_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+")); @@ -12409,13 +14784,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_113_var; + asdl_seq * _gather_129_var; if ( - (_gather_113_var = _gather_113_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_113_var; + _res = _gather_129_var; goto done; } p->mark = _mark; @@ -12428,13 +14803,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_115_var; + asdl_seq * _gather_131_var; if ( - (_gather_115_var = _gather_115_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_115_var; + _res = _gather_131_var; goto done; } p->mark = _mark; @@ -12796,7 +15171,7 @@ star_targets_rule(Parser *p) if ( (a = star_target_rule(p)) // star_target && - (b = _loop0_117_rule(p)) // ((',' star_target))* + (b = _loop0_133_rule(p)) // ((',' star_target))* && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -12850,7 +15225,7 @@ star_targets_list_seq_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_118_rule(p)) // ','.star_target+ + (a = (asdl_expr_seq*)_gather_134_rule(p)) // ','.star_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -12898,7 +15273,7 @@ star_targets_tuple_seq_rule(Parser *p) if ( (a = star_target_rule(p)) // star_target && - (b = _loop1_120_rule(p)) // ((',' star_target))+ + (b = _loop1_136_rule(p)) // ((',' star_target))+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -12984,7 +15359,7 @@ star_target_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (a = _tmp_121_rule(p)) // !'*' star_target + (a = _tmp_137_rule(p)) // !'*' star_target ) { D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); @@ -13559,7 +15934,7 @@ del_targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_122_rule(p)) // ','.del_target+ + (a = (asdl_expr_seq*)_gather_138_rule(p)) // ','.del_target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -13900,7 +16275,7 @@ targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_124_rule(p)) // ','.target+ + (a = (asdl_expr_seq*)_gather_140_rule(p)) // ','.target+ && (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? ) @@ -14082,8 +16457,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; } @@ -14614,7 +16989,7 @@ invalid_arguments_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_opt_var = _tmp_126_rule(p), 1) // [args | expression for_if_clauses] + (_opt_var = _tmp_142_rule(p), 1) // [args | expression for_if_clauses] ) { D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); @@ -14872,7 +17247,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_127_var; + asdl_seq * _loop0_143_var; expr_ty a; expr_ty expression_var; if ( @@ -14880,7 +17255,7 @@ invalid_assignment_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_loop0_127_var = _loop0_127_rule(p)) // star_named_expressions* + (_loop0_143_var = _loop0_143_rule(p)) // star_named_expressions* && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -14937,10 +17312,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_128_var; + asdl_seq * _loop0_144_var; expr_ty a; if ( - (_loop0_128_var = _loop0_128_rule(p)) // ((star_targets '='))* + (_loop0_144_var = _loop0_144_rule(p)) // ((star_targets '='))* && (a = star_expressions_rule(p)) // star_expressions && @@ -14967,10 +17342,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_129_var; + asdl_seq * _loop0_145_var; expr_ty a; if ( - (_loop0_129_var = _loop0_129_rule(p)) // ((star_targets '='))* + (_loop0_145_var = _loop0_145_rule(p)) // ((star_targets '='))* && (a = yield_expr_rule(p)) // yield_expr && @@ -14996,7 +17371,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_130_var; + void *_tmp_146_var; expr_ty a; AugOperator* augassign_var; if ( @@ -15004,7 +17379,7 @@ invalid_assignment_rule(Parser *p) && (augassign_var = augassign_rule(p)) // augassign && - (_tmp_130_var = _tmp_130_rule(p)) // yield_expr | star_expressions + (_tmp_146_var = _tmp_146_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)")); @@ -15262,11 +17637,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_131_var; + void *_tmp_147_var; expr_ty a; asdl_comprehension_seq* for_if_clauses_var; if ( - (_tmp_131_var = _tmp_131_rule(p)) // '[' | '(' | '{' + (_tmp_147_var = _tmp_147_rule(p)) // '[' | '(' | '{' && (a = starred_expression_rule(p)) // starred_expression && @@ -15295,11 +17670,11 @@ invalid_comprehension_rule(Parser *p) Token * _literal; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings - void *_tmp_132_var; + void *_tmp_148_var; expr_ty a; asdl_comprehension_seq* for_if_clauses_var; if ( - (_tmp_132_var = _tmp_132_rule(p)) // '[' | '{' + (_tmp_148_var = _tmp_148_rule(p)) // '[' | '{' && (a = star_named_expression_rule(p)) // star_named_expression && @@ -15399,11 +17774,11 @@ 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* invalid_parameters_helper param_no_default")); - asdl_seq * _loop0_133_var; + asdl_seq * _loop0_149_var; void *invalid_parameters_helper_var; arg_ty param_no_default_var; if ( - (_loop0_133_var = _loop0_133_rule(p)) // param_no_default* + (_loop0_149_var = _loop0_149_rule(p)) // param_no_default* && (invalid_parameters_helper_var = invalid_parameters_helper_rule(p)) // invalid_parameters_helper && @@ -15470,13 +17845,13 @@ invalid_parameters_helper_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - asdl_seq * _loop1_134_var; + asdl_seq * _loop1_150_var; if ( - (_loop1_134_var = _loop1_134_rule(p)) // param_with_default+ + (_loop1_150_var = _loop1_150_rule(p)) // param_with_default+ ) { D(fprintf(stderr, "%*c+ invalid_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - _res = _loop1_134_var; + _res = _loop1_150_var; goto done; } p->mark = _mark; @@ -15507,11 +17882,11 @@ 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* invalid_lambda_parameters_helper lambda_param_no_default")); - asdl_seq * _loop0_135_var; + asdl_seq * _loop0_151_var; void *invalid_lambda_parameters_helper_var; arg_ty lambda_param_no_default_var; if ( - (_loop0_135_var = _loop0_135_rule(p)) // lambda_param_no_default* + (_loop0_151_var = _loop0_151_rule(p)) // lambda_param_no_default* && (invalid_lambda_parameters_helper_var = invalid_lambda_parameters_helper_rule(p)) // invalid_lambda_parameters_helper && @@ -15580,13 +17955,13 @@ invalid_lambda_parameters_helper_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_lambda_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); - asdl_seq * _loop1_136_var; + asdl_seq * _loop1_152_var; if ( - (_loop1_136_var = _loop1_136_rule(p)) // lambda_param_with_default+ + (_loop1_152_var = _loop1_152_rule(p)) // lambda_param_with_default+ ) { D(fprintf(stderr, "%*c+ invalid_lambda_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); - _res = _loop1_136_var; + _res = _loop1_152_var; goto done; } p->mark = _mark; @@ -15617,11 +17992,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_137_var; + void *_tmp_153_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_137_var = _tmp_137_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, "'*' (')' | ',' (')' | '**'))")); @@ -15691,11 +18066,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_138_var; + void *_tmp_154_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_138_var = _tmp_138_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, "'*' (':' | ',' (':' | '**'))")); @@ -15797,7 +18172,7 @@ invalid_with_item_rule(Parser *p) && (a = expression_rule(p)) // expression && - _PyPegen_lookahead(1, _tmp_139_rule, p) + _PyPegen_lookahead(1, _tmp_155_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_with_item[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression 'as' expression &(',' | ')' | ':')")); @@ -15977,7 +18352,7 @@ invalid_with_stmt_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' ','.(expression ['as' star_target])+ &&':'")); - asdl_seq * _gather_140_var; + asdl_seq * _gather_156_var; Token * _keyword; Token * _literal; void *_opt_var; @@ -15987,13 +18362,13 @@ invalid_with_stmt_rule(Parser *p) && (_keyword = _PyPegen_expect_token(p, 519)) // token='with' && - (_gather_140_var = _gather_140_rule(p)) // ','.(expression ['as' star_target])+ + (_gather_156_var = _gather_156_rule(p)) // ','.(expression ['as' star_target])+ && (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' ) { D(fprintf(stderr, "%*c+ invalid_with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' ','.(expression ['as' star_target])+ &&':'")); - _res = _PyPegen_dummy_name(p, _opt_var, _keyword, _gather_140_var, _literal); + _res = _PyPegen_dummy_name(p, _opt_var, _keyword, _gather_156_var, _literal); goto done; } p->mark = _mark; @@ -16006,7 +18381,7 @@ invalid_with_stmt_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' &&':'")); - asdl_seq * _gather_142_var; + asdl_seq * _gather_158_var; Token * _keyword; Token * _literal; Token * _literal_1; @@ -16022,7 +18397,7 @@ invalid_with_stmt_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_gather_142_var = _gather_142_rule(p)) // ','.(expressions ['as' star_target])+ + (_gather_158_var = _gather_158_rule(p)) // ','.(expressions ['as' star_target])+ && (_opt_var_1 = _PyPegen_expect_token(p, 12), 1) // ','? && @@ -16032,7 +18407,7 @@ invalid_with_stmt_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ invalid_with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' &&':'")); - _res = _PyPegen_dummy_name(p, _opt_var, _keyword, _literal, _gather_142_var, _opt_var_1, _literal_1, _literal_2); + _res = _PyPegen_dummy_name(p, _opt_var, _keyword, _literal, _gather_158_var, _opt_var_1, _literal_1, _literal_2); goto done; } p->mark = _mark; @@ -16081,7 +18456,7 @@ invalid_except_block_rule(Parser *p) && (expressions_var = expressions_rule(p)) // expressions && - (_opt_var = _tmp_144_rule(p), 1) // ['as' NAME] + (_opt_var = _tmp_160_rule(p), 1) // ['as' NAME] && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' ) @@ -16115,7 +18490,7 @@ invalid_except_block_rule(Parser *p) && (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_145_rule(p), 1) // ['as' NAME] + (_opt_var = _tmp_161_rule(p), 1) // ['as' NAME] && (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' ) @@ -17003,7 +19378,7 @@ _tmp_15_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 523)) // token='def' + (_keyword = _PyPegen_expect_token(p, 526)) // token='def' ) { D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def'")); @@ -17077,7 +19452,7 @@ _tmp_16_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 524)) // token='class' + (_keyword = _PyPegen_expect_token(p, 527)) // token='class' ) { D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class'")); @@ -17404,12 +19779,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_146_var; + void *_tmp_162_var; while ( - (_tmp_146_var = _tmp_146_rule(p)) // star_targets '=' + (_tmp_162_var = _tmp_162_rule(p)) // star_targets '=' ) { - _res = _tmp_146_var; + _res = _tmp_162_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -17912,12 +20287,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_147_var; + void *_tmp_163_var; while ( - (_tmp_147_var = _tmp_147_rule(p)) // '.' | '...' + (_tmp_163_var = _tmp_163_rule(p)) // '.' | '...' ) { - _res = _tmp_147_var; + _res = _tmp_163_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -17978,12 +20353,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_148_var; + void *_tmp_164_var; while ( - (_tmp_148_var = _tmp_148_rule(p)) // '.' | '...' + (_tmp_164_var = _tmp_164_rule(p)) // '.' | '...' ) { - _res = _tmp_148_var; + _res = _tmp_164_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -18983,9 +21358,963 @@ _tmp_49_rule(Parser *p) return _res; } -// _tmp_50: 'from' expression +// _loop1_50: case_block +static asdl_seq * +_loop1_50_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; + { // case_block + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_50[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "case_block")); + match_case_ty 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 *)); + 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_50[%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 = (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_50_type, _seq); + D(p->level--); + return _seq; +} + +// _loop0_52: '|' closed_pattern +static asdl_seq * +_loop0_52_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; + { // '|' closed_pattern + 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")); + Token * _literal; + expr_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 18)) // token='|' + && + (elem = closed_pattern_rule(p)) // closed_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_52[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|' closed_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_52_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_51: closed_pattern _loop0_52 +static asdl_seq * +_gather_51_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // closed_pattern _loop0_52 + 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")); + expr_ty elem; + asdl_seq * seq; + if ( + (elem = closed_pattern_rule(p)) // closed_pattern + && + (seq = _loop0_52_rule(p)) // _loop0_52 + ) + { + 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_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, 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; +} + +// _tmp_54: '.' | '(' | '=' +static void * +_tmp_54_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_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 23)) // 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, "'.'")); + } + { // '(' + 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, "'('")); + } + { // '=' + 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: + D(p->level--); + return _res; +} + +// _tmp_55: '.' | '(' | '=' +static void * +_tmp_55_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_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 23)) // 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, 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: ',' maybe_star_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; + { // ',' 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, "',' maybe_star_pattern")); + Token * _literal; + expr_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = maybe_star_pattern_rule(p)) // maybe_star_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_57[%d-%d]: %s failed!\n", p->level, ' ', + 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) { + 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_57_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_56: maybe_star_pattern _loop0_57 +static asdl_seq * +_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; + { // 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, "maybe_star_pattern _loop0_57")); + expr_ty elem; + asdl_seq * seq; + if ( + (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, "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, "maybe_star_pattern _loop0_57")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _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; + int _mark = p->mark; + { // capture_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + 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 + ) + { + 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 _tmp_58[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "capture_pattern")); + } + { // wildcard_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_58[%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+ _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 _tmp_58[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "wildcard_pattern")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_60: ',' key_value_pattern +static asdl_seq * +_loop0_60_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; + { // ',' key_value_pattern + if (p->error_indicator) { + D(p->level--); + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); + Token * _literal; + KeyValuePair* 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_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) { + 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_60_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_59: key_value_pattern _loop0_60 +static asdl_seq * +_gather_59_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_60 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + 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 = key_value_pattern_rule(p)) // key_value_pattern + && + (seq = _loop0_60_rule(p)) // _loop0_60 + ) + { + 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_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_50_rule(Parser *p) +_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: + D(p->level--); + return _res; +} + +// _loop0_63: ',' pattern +static asdl_seq * +_loop0_63_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_63[%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_63[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' 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_63_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_62: 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; + { // 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, "pattern _loop0_63")); + expr_ty elem; + asdl_seq * seq; + if ( + (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, "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, "pattern _loop0_63")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _loop0_65: ',' keyword_pattern +static asdl_seq * +_loop0_65_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; + { // ',' 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, "',' keyword_pattern")); + Token * _literal; + keyword_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = keyword_pattern_rule(p)) // 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_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); + 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_65_type, _seq); + D(p->level--); + return _seq; +} + +// _gather_64: keyword_pattern _loop0_65 +static asdl_seq * +_gather_64_rule(Parser *p) +{ + D(p->level++); + if (p->error_indicator) { + D(p->level--); + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // keyword_pattern _loop0_65 + if (p->error_indicator) { + D(p->level--); + return NULL; + } + 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_65_rule(p)) // _loop0_65 + ) + { + 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_64[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_65")); + } + _res = NULL; + done: + D(p->level--); + return _res; +} + +// _tmp_66: 'from' expression +static void * +_tmp_66_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -18999,7 +22328,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, "'from' expression")); + D(fprintf(stderr, "%*c> _tmp_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); Token * _keyword; expr_ty z; if ( @@ -19008,7 +22337,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, "'from' expression")); + 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; @@ -19018,7 +22347,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_66[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression")); } _res = NULL; @@ -19027,9 +22356,9 @@ _tmp_50_rule(Parser *p) return _res; } -// _tmp_51: '->' expression +// _tmp_67: '->' expression static void * -_tmp_51_rule(Parser *p) +_tmp_67_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19043,7 +22372,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_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -19052,7 +22381,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_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -19062,7 +22391,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_67[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -19071,9 +22400,9 @@ _tmp_51_rule(Parser *p) return _res; } -// _tmp_52: '->' expression +// _tmp_68: '->' expression static void * -_tmp_52_rule(Parser *p) +_tmp_68_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19087,7 +22416,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, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty z; if ( @@ -19096,7 +22425,7 @@ _tmp_52_rule(Parser *p) (z = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_52[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + 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; @@ -19106,7 +22435,7 @@ _tmp_52_rule(Parser *p) 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_68[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -19115,9 +22444,9 @@ _tmp_52_rule(Parser *p) return _res; } -// _tmp_53: NEWLINE INDENT +// _tmp_69: NEWLINE INDENT static void * -_tmp_53_rule(Parser *p) +_tmp_69_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19131,7 +22460,7 @@ _tmp_53_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); Token * indent_var; Token * newline_var; if ( @@ -19140,12 +22469,12 @@ _tmp_53_rule(Parser *p) (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' ) { - D(fprintf(stderr, "%*c+ _tmp_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + 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_53[%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, "NEWLINE INDENT")); } _res = NULL; @@ -19154,9 +22483,9 @@ _tmp_53_rule(Parser *p) return _res; } -// _loop0_54: param_no_default +// _loop0_70: param_no_default static asdl_seq * -_loop0_54_rule(Parser *p) +_loop0_70_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19180,7 +22509,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_no_default")); + 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 @@ -19202,7 +22531,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_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); @@ -19215,14 +22544,14 @@ _loop0_54_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_54_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_70_type, _seq); D(p->level--); return _seq; } -// _loop0_55: param_with_default +// _loop0_71: param_with_default static asdl_seq * -_loop0_55_rule(Parser *p) +_loop0_71_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19246,7 +22575,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_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 @@ -19268,7 +22597,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_71[%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); @@ -19281,14 +22610,14 @@ _loop0_55_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_55_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_71_type, _seq); D(p->level--); return _seq; } -// _loop0_56: param_with_default +// _loop0_72: param_with_default static asdl_seq * -_loop0_56_rule(Parser *p) +_loop0_72_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19312,7 +22641,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, "param_with_default")); + D(fprintf(stderr, "%*c> _loop0_72[%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 @@ -19334,7 +22663,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_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); @@ -19347,14 +22676,14 @@ _loop0_56_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_56_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_72_type, _seq); D(p->level--); return _seq; } -// _loop1_57: param_no_default +// _loop1_73: param_no_default static asdl_seq * -_loop1_57_rule(Parser *p) +_loop1_73_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19378,7 +22707,7 @@ _loop1_57_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + 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 @@ -19400,7 +22729,7 @@ _loop1_57_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_57[%d-%d]: %s failed!\n", p->level, ' ', + 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 (_n == 0 || p->error_indicator) { @@ -19418,14 +22747,14 @@ _loop1_57_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_57_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_73_type, _seq); D(p->level--); return _seq; } -// _loop0_58: param_with_default +// _loop0_74: param_with_default static asdl_seq * -_loop0_58_rule(Parser *p) +_loop0_74_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19449,7 +22778,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, "param_with_default")); + 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 @@ -19471,7 +22800,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_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); @@ -19484,14 +22813,14 @@ _loop0_58_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_58_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_74_type, _seq); D(p->level--); return _seq; } -// _loop1_59: param_with_default +// _loop1_75: param_with_default static asdl_seq * -_loop1_59_rule(Parser *p) +_loop1_75_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19515,7 +22844,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_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 @@ -19537,7 +22866,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_75[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -19555,14 +22884,14 @@ _loop1_59_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_59_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_75_type, _seq); D(p->level--); return _seq; } -// _loop1_60: param_no_default +// _loop1_76: param_no_default static asdl_seq * -_loop1_60_rule(Parser *p) +_loop1_76_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19586,7 +22915,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_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 @@ -19608,7 +22937,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_76[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -19626,14 +22955,14 @@ _loop1_60_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_60_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_76_type, _seq); D(p->level--); return _seq; } -// _loop1_61: param_no_default +// _loop1_77: param_no_default static asdl_seq * -_loop1_61_rule(Parser *p) +_loop1_77_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19657,7 +22986,7 @@ _loop1_61_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_61[%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 @@ -19679,7 +23008,7 @@ _loop1_61_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_61[%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) { @@ -19697,14 +23026,14 @@ _loop1_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, _loop1_61_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_77_type, _seq); D(p->level--); return _seq; } -// _loop0_62: param_no_default +// _loop0_78: param_no_default static asdl_seq * -_loop0_62_rule(Parser *p) +_loop0_78_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19728,7 +23057,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, "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 @@ -19750,7 +23079,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_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); @@ -19763,14 +23092,14 @@ _loop0_62_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_62_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_78_type, _seq); D(p->level--); return _seq; } -// _loop1_63: param_with_default +// _loop1_79: param_with_default static asdl_seq * -_loop1_63_rule(Parser *p) +_loop1_79_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19794,7 +23123,7 @@ _loop1_63_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_63[%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 @@ -19816,7 +23145,7 @@ _loop1_63_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_63[%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) { @@ -19834,14 +23163,14 @@ _loop1_63_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_63_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_79_type, _seq); D(p->level--); return _seq; } -// _loop0_64: param_no_default +// _loop0_80: param_no_default static asdl_seq * -_loop0_64_rule(Parser *p) +_loop0_80_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19865,7 +23194,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, "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 @@ -19887,7 +23216,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_80[%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); @@ -19900,14 +23229,14 @@ _loop0_64_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_64_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_80_type, _seq); D(p->level--); return _seq; } -// _loop1_65: param_with_default +// _loop1_81: param_with_default static asdl_seq * -_loop1_65_rule(Parser *p) +_loop1_81_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -19931,7 +23260,7 @@ _loop1_65_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + 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_with_default_var = param_with_default_rule(p)) // param_with_default @@ -19953,7 +23282,7 @@ _loop1_65_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_65[%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_with_default")); } if (_n == 0 || p->error_indicator) { @@ -19971,14 +23300,14 @@ _loop1_65_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_65_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq); D(p->level--); return _seq; } -// _loop0_66: param_maybe_default +// _loop0_82: param_maybe_default static asdl_seq * -_loop0_66_rule(Parser *p) +_loop0_82_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20002,7 +23331,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, "param_maybe_default")); + 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_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -20024,7 +23353,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_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); @@ -20037,14 +23366,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_82_type, _seq); D(p->level--); return _seq; } -// _loop1_67: param_maybe_default +// _loop1_83: param_maybe_default static asdl_seq * -_loop1_67_rule(Parser *p) +_loop1_83_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20068,7 +23397,7 @@ _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, "param_maybe_default")); + 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_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -20090,7 +23419,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_83[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -20108,14 +23437,14 @@ _loop1_67_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_67_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); D(p->level--); return _seq; } -// _loop1_68: ('@' named_expression NEWLINE) +// _loop1_84: ('@' named_expression NEWLINE) static asdl_seq * -_loop1_68_rule(Parser *p) +_loop1_84_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20139,13 +23468,13 @@ _loop1_68_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); - void *_tmp_149_var; + D(fprintf(stderr, "%*c> _loop1_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); + void *_tmp_165_var; while ( - (_tmp_149_var = _tmp_149_rule(p)) // '@' named_expression NEWLINE + (_tmp_165_var = _tmp_165_rule(p)) // '@' named_expression NEWLINE ) { - _res = _tmp_149_var; + _res = _tmp_165_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -20161,7 +23490,7 @@ _loop1_68_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_68[%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, "('@' named_expression NEWLINE)")); } if (_n == 0 || p->error_indicator) { @@ -20179,14 +23508,14 @@ _loop1_68_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_68_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); D(p->level--); return _seq; } -// _tmp_69: '(' arguments? ')' +// _tmp_85: '(' arguments? ')' static void * -_tmp_69_rule(Parser *p) +_tmp_85_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20200,7 +23529,7 @@ _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, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c> _tmp_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); Token * _literal; Token * _literal_1; void *z; @@ -20212,7 +23541,7 @@ _tmp_69_rule(Parser *p) (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + 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; @@ -20222,7 +23551,7 @@ _tmp_69_rule(Parser *p) 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_85[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); } _res = NULL; @@ -20231,9 +23560,9 @@ _tmp_69_rule(Parser *p) return _res; } -// _loop1_70: (',' star_expression) +// _loop1_86: (',' star_expression) static asdl_seq * -_loop1_70_rule(Parser *p) +_loop1_86_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20257,13 +23586,13 @@ _loop1_70_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); - void *_tmp_150_var; + D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); + void *_tmp_166_var; while ( - (_tmp_150_var = _tmp_150_rule(p)) // ',' star_expression + (_tmp_166_var = _tmp_166_rule(p)) // ',' star_expression ) { - _res = _tmp_150_var; + _res = _tmp_166_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -20279,7 +23608,7 @@ _loop1_70_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_70[%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, "(',' star_expression)")); } if (_n == 0 || p->error_indicator) { @@ -20297,14 +23626,14 @@ _loop1_70_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_70_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_86_type, _seq); D(p->level--); return _seq; } -// _loop0_72: ',' star_named_expression +// _loop0_88: ',' star_named_expression static asdl_seq * -_loop0_72_rule(Parser *p) +_loop0_88_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20328,7 +23657,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, "',' star_named_expression")); + D(fprintf(stderr, "%*c> _loop0_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); Token * _literal; expr_ty elem; while ( @@ -20359,7 +23688,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_88[%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); @@ -20372,14 +23701,14 @@ _loop0_72_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_72_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_88_type, _seq); D(p->level--); return _seq; } -// _gather_71: star_named_expression _loop0_72 +// _gather_87: star_named_expression _loop0_88 static asdl_seq * -_gather_71_rule(Parser *p) +_gather_87_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20388,27 +23717,27 @@ _gather_71_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_named_expression _loop0_72 + { // star_named_expression _loop0_88 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_72")); + D(fprintf(stderr, "%*c> _gather_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_88")); expr_ty elem; asdl_seq * seq; if ( (elem = star_named_expression_rule(p)) // star_named_expression && - (seq = _loop0_72_rule(p)) // _loop0_72 + (seq = _loop0_88_rule(p)) // _loop0_88 ) { - D(fprintf(stderr, "%*c+ _gather_71[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_72")); + D(fprintf(stderr, "%*c+ _gather_87[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_88")); _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, "star_named_expression _loop0_72")); + D(fprintf(stderr, "%*c%s _gather_87[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_88")); } _res = NULL; done: @@ -20416,9 +23745,9 @@ _gather_71_rule(Parser *p) return _res; } -// _loop1_73: (',' expression) +// _loop1_89: (',' expression) static asdl_seq * -_loop1_73_rule(Parser *p) +_loop1_89_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20442,13 +23771,13 @@ _loop1_73_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); - void *_tmp_151_var; + D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); + void *_tmp_167_var; while ( - (_tmp_151_var = _tmp_151_rule(p)) // ',' expression + (_tmp_167_var = _tmp_167_rule(p)) // ',' expression ) { - _res = _tmp_151_var; + _res = _tmp_167_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -20464,7 +23793,7 @@ _loop1_73_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_73[%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, "(',' expression)")); } if (_n == 0 || p->error_indicator) { @@ -20482,14 +23811,14 @@ _loop1_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, _loop1_73_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq); D(p->level--); return _seq; } -// _loop0_74: lambda_param_no_default +// _loop0_90: lambda_param_no_default static asdl_seq * -_loop0_74_rule(Parser *p) +_loop0_90_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20513,7 +23842,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, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_90[%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 @@ -20535,7 +23864,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_90[%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); @@ -20548,14 +23877,14 @@ _loop0_74_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_74_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_90_type, _seq); D(p->level--); return _seq; } -// _loop0_75: lambda_param_with_default +// _loop0_91: lambda_param_with_default static asdl_seq * -_loop0_75_rule(Parser *p) +_loop0_91_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20579,7 +23908,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_with_default")); + D(fprintf(stderr, "%*c> _loop0_91[%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 @@ -20601,7 +23930,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_91[%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); @@ -20614,14 +23943,14 @@ _loop0_75_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_75_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_91_type, _seq); D(p->level--); return _seq; } -// _loop0_76: lambda_param_with_default +// _loop0_92: lambda_param_with_default static asdl_seq * -_loop0_76_rule(Parser *p) +_loop0_92_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20645,7 +23974,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_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 @@ -20667,7 +23996,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_92[%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); @@ -20680,14 +24009,14 @@ _loop0_76_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_76_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_92_type, _seq); D(p->level--); return _seq; } -// _loop1_77: lambda_param_no_default +// _loop1_93: lambda_param_no_default static asdl_seq * -_loop1_77_rule(Parser *p) +_loop1_93_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20711,7 +24040,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, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_93[%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 @@ -20733,7 +24062,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_93[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -20751,14 +24080,14 @@ _loop1_77_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_77_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_93_type, _seq); D(p->level--); return _seq; } -// _loop0_78: lambda_param_with_default +// _loop0_94: lambda_param_with_default static asdl_seq * -_loop0_78_rule(Parser *p) +_loop0_94_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20782,7 +24111,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, "lambda_param_with_default")); + 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 @@ -20804,7 +24133,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_94[%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); @@ -20817,14 +24146,14 @@ _loop0_78_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_78_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_94_type, _seq); D(p->level--); return _seq; } -// _loop1_79: lambda_param_with_default +// _loop1_95: lambda_param_with_default static asdl_seq * -_loop1_79_rule(Parser *p) +_loop1_95_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20848,7 +24177,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, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_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 @@ -20870,7 +24199,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_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -20888,14 +24217,14 @@ _loop1_79_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_79_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_95_type, _seq); D(p->level--); return _seq; } -// _loop1_80: lambda_param_no_default +// _loop1_96: lambda_param_no_default static asdl_seq * -_loop1_80_rule(Parser *p) +_loop1_96_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20919,7 +24248,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_no_default")); + D(fprintf(stderr, "%*c> _loop1_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 @@ -20941,7 +24270,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_96[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -20959,14 +24288,14 @@ _loop1_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, _loop1_80_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_96_type, _seq); D(p->level--); return _seq; } -// _loop1_81: lambda_param_no_default +// _loop1_97: lambda_param_no_default static asdl_seq * -_loop1_81_rule(Parser *p) +_loop1_97_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -20990,7 +24319,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_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 @@ -21012,7 +24341,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_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) { @@ -21030,14 +24359,14 @@ _loop1_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, _loop1_81_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_97_type, _seq); D(p->level--); return _seq; } -// _loop0_82: lambda_param_no_default +// _loop0_98: lambda_param_no_default static asdl_seq * -_loop0_82_rule(Parser *p) +_loop0_98_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21061,7 +24390,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, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_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 @@ -21083,7 +24412,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_98[%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); @@ -21096,14 +24425,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, _loop0_98_type, _seq); D(p->level--); return _seq; } -// _loop1_83: lambda_param_with_default +// _loop1_99: lambda_param_with_default static asdl_seq * -_loop1_83_rule(Parser *p) +_loop1_99_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21127,7 +24456,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, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_99[%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 @@ -21149,7 +24478,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_99[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -21167,14 +24496,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_99_type, _seq); D(p->level--); return _seq; } -// _loop0_84: lambda_param_no_default +// _loop0_100: lambda_param_no_default static asdl_seq * -_loop0_84_rule(Parser *p) +_loop0_100_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21198,7 +24527,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, "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 @@ -21220,7 +24549,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_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); @@ -21233,14 +24562,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_100_type, _seq); D(p->level--); return _seq; } -// _loop1_85: lambda_param_with_default +// _loop1_101: lambda_param_with_default static asdl_seq * -_loop1_85_rule(Parser *p) +_loop1_101_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21264,7 +24593,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, "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 @@ -21286,7 +24615,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_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) { @@ -21304,14 +24633,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_101_type, _seq); D(p->level--); return _seq; } -// _loop0_86: lambda_param_maybe_default +// _loop0_102: lambda_param_maybe_default static asdl_seq * -_loop0_86_rule(Parser *p) +_loop0_102_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21335,7 +24664,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, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_102[%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 @@ -21357,7 +24686,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_102[%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); @@ -21370,14 +24699,14 @@ _loop0_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, _loop0_86_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_102_type, _seq); D(p->level--); return _seq; } -// _loop1_87: lambda_param_maybe_default +// _loop1_103: lambda_param_maybe_default static asdl_seq * -_loop1_87_rule(Parser *p) +_loop1_103_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21401,7 +24730,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, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_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 @@ -21423,7 +24752,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_103[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -21441,14 +24770,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_103_type, _seq); D(p->level--); return _seq; } -// _loop1_88: ('or' conjunction) +// _loop1_104: ('or' conjunction) static asdl_seq * -_loop1_88_rule(Parser *p) +_loop1_104_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21472,13 +24801,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, "('or' conjunction)")); - void *_tmp_152_var; + D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); + void *_tmp_168_var; while ( - (_tmp_152_var = _tmp_152_rule(p)) // 'or' conjunction + (_tmp_168_var = _tmp_168_rule(p)) // 'or' conjunction ) { - _res = _tmp_152_var; + _res = _tmp_168_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -21494,7 +24823,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_104[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); } if (_n == 0 || p->error_indicator) { @@ -21512,14 +24841,14 @@ _loop1_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, _loop1_88_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_104_type, _seq); D(p->level--); return _seq; } -// _loop1_89: ('and' inversion) +// _loop1_105: ('and' inversion) static asdl_seq * -_loop1_89_rule(Parser *p) +_loop1_105_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21543,13 +24872,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, "('and' inversion)")); - void *_tmp_153_var; + D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); + void *_tmp_169_var; while ( - (_tmp_153_var = _tmp_153_rule(p)) // 'and' inversion + (_tmp_169_var = _tmp_169_rule(p)) // 'and' inversion ) { - _res = _tmp_153_var; + _res = _tmp_169_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -21565,7 +24894,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_105[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); } if (_n == 0 || p->error_indicator) { @@ -21583,14 +24912,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_105_type, _seq); D(p->level--); return _seq; } -// _loop1_90: compare_op_bitwise_or_pair +// _loop1_106: compare_op_bitwise_or_pair static asdl_seq * -_loop1_90_rule(Parser *p) +_loop1_106_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21614,7 +24943,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, "compare_op_bitwise_or_pair")); + D(fprintf(stderr, "%*c> _loop1_106[%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 @@ -21636,7 +24965,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_106[%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) { @@ -21654,14 +24983,14 @@ _loop1_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, _loop1_90_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_106_type, _seq); D(p->level--); return _seq; } -// _tmp_91: '!=' +// _tmp_107: '!=' static void * -_tmp_91_rule(Parser *p) +_tmp_107_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21675,13 +25004,13 @@ _tmp_91_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c> _tmp_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); Token * tok; if ( (tok = _PyPegen_expect_token(p, 28)) // token='!=' ) { - D(fprintf(stderr, "%*c+ _tmp_91[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c+ _tmp_107[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); _res = _PyPegen_check_barry_as_flufl ( p , tok ) ? NULL : tok; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21691,7 +25020,7 @@ _tmp_91_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_91[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_107[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); } _res = NULL; @@ -21700,9 +25029,9 @@ _tmp_91_rule(Parser *p) return _res; } -// _loop0_93: ',' slice +// _loop0_109: ',' slice static asdl_seq * -_loop0_93_rule(Parser *p) +_loop0_109_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21726,7 +25055,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, "',' slice")); + D(fprintf(stderr, "%*c> _loop0_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); Token * _literal; expr_ty elem; while ( @@ -21757,7 +25086,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_109[%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); @@ -21770,14 +25099,14 @@ _loop0_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, _loop0_93_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_109_type, _seq); D(p->level--); return _seq; } -// _gather_92: slice _loop0_93 +// _gather_108: slice _loop0_109 static asdl_seq * -_gather_92_rule(Parser *p) +_gather_108_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21786,27 +25115,27 @@ _gather_92_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // slice _loop0_93 + { // slice _loop0_109 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_93")); + D(fprintf(stderr, "%*c> _gather_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_109")); expr_ty elem; asdl_seq * seq; if ( (elem = slice_rule(p)) // slice && - (seq = _loop0_93_rule(p)) // _loop0_93 + (seq = _loop0_109_rule(p)) // _loop0_109 ) { - D(fprintf(stderr, "%*c+ _gather_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_93")); + D(fprintf(stderr, "%*c+ _gather_108[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_109")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_92[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_93")); + D(fprintf(stderr, "%*c%s _gather_108[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_109")); } _res = NULL; done: @@ -21814,9 +25143,9 @@ _gather_92_rule(Parser *p) return _res; } -// _tmp_94: ':' expression? +// _tmp_110: ':' expression? static void * -_tmp_94_rule(Parser *p) +_tmp_110_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21830,7 +25159,7 @@ _tmp_94_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c> _tmp_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); Token * _literal; void *d; if ( @@ -21839,7 +25168,7 @@ _tmp_94_rule(Parser *p) (d = expression_rule(p), 1) // expression? ) { - D(fprintf(stderr, "%*c+ _tmp_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c+ _tmp_110[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); _res = d; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -21849,7 +25178,7 @@ _tmp_94_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_94[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_110[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); } _res = NULL; @@ -21858,9 +25187,9 @@ _tmp_94_rule(Parser *p) return _res; } -// _tmp_95: tuple | group | genexp +// _tmp_111: tuple | group | genexp static void * -_tmp_95_rule(Parser *p) +_tmp_111_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21874,18 +25203,18 @@ _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, "tuple")); + D(fprintf(stderr, "%*c> _tmp_111[%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_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c+ _tmp_111[%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_95[%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, "tuple")); } { // group @@ -21893,18 +25222,18 @@ _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, "group")); + D(fprintf(stderr, "%*c> _tmp_111[%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_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c+ _tmp_111[%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_95[%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, "group")); } { // genexp @@ -21912,18 +25241,18 @@ _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, "genexp")); + D(fprintf(stderr, "%*c> _tmp_111[%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_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c+ _tmp_111[%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_95[%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, "genexp")); } _res = NULL; @@ -21932,9 +25261,9 @@ _tmp_95_rule(Parser *p) return _res; } -// _tmp_96: list | listcomp +// _tmp_112: list | listcomp static void * -_tmp_96_rule(Parser *p) +_tmp_112_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -21948,18 +25277,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, "list")); + D(fprintf(stderr, "%*c> _tmp_112[%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_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c+ _tmp_112[%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_96[%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, "list")); } { // listcomp @@ -21967,18 +25296,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, "listcomp")); + D(fprintf(stderr, "%*c> _tmp_112[%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_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c+ _tmp_112[%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_96[%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, "listcomp")); } _res = NULL; @@ -21987,9 +25316,9 @@ _tmp_96_rule(Parser *p) return _res; } -// _tmp_97: dict | set | dictcomp | setcomp +// _tmp_113: dict | set | dictcomp | setcomp static void * -_tmp_97_rule(Parser *p) +_tmp_113_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22003,18 +25332,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, "dict")); + D(fprintf(stderr, "%*c> _tmp_113[%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_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c+ _tmp_113[%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_97[%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, "dict")); } { // set @@ -22022,18 +25351,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, "set")); + D(fprintf(stderr, "%*c> _tmp_113[%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_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c+ _tmp_113[%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_97[%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, "set")); } { // dictcomp @@ -22041,18 +25370,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, "dictcomp")); + D(fprintf(stderr, "%*c> _tmp_113[%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_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c+ _tmp_113[%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_97[%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, "dictcomp")); } { // setcomp @@ -22060,18 +25389,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, "setcomp")); + D(fprintf(stderr, "%*c> _tmp_113[%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_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c+ _tmp_113[%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_97[%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, "setcomp")); } _res = NULL; @@ -22080,9 +25409,9 @@ _tmp_97_rule(Parser *p) return _res; } -// _loop1_98: STRING +// _loop1_114: STRING static asdl_seq * -_loop1_98_rule(Parser *p) +_loop1_114_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22106,7 +25435,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, "STRING")); + D(fprintf(stderr, "%*c> _loop1_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); expr_ty string_var; while ( (string_var = _PyPegen_string_token(p)) // STRING @@ -22128,7 +25457,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_114[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); } if (_n == 0 || p->error_indicator) { @@ -22146,14 +25475,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, _loop1_114_type, _seq); D(p->level--); return _seq; } -// _tmp_99: star_named_expression ',' star_named_expressions? +// _tmp_115: star_named_expression ',' star_named_expressions? static void * -_tmp_99_rule(Parser *p) +_tmp_115_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22167,7 +25496,7 @@ _tmp_99_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _tmp_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c> _tmp_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); Token * _literal; expr_ty y; void *z; @@ -22179,7 +25508,7 @@ _tmp_99_rule(Parser *p) (z = star_named_expressions_rule(p), 1) // star_named_expressions? ) { - D(fprintf(stderr, "%*c+ _tmp_99[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c+ _tmp_115[%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; @@ -22189,7 +25518,7 @@ _tmp_99_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_99[%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, "star_named_expression ',' star_named_expressions?")); } _res = NULL; @@ -22198,9 +25527,9 @@ _tmp_99_rule(Parser *p) return _res; } -// _tmp_100: yield_expr | named_expression +// _tmp_116: yield_expr | named_expression static void * -_tmp_100_rule(Parser *p) +_tmp_116_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22214,18 +25543,18 @@ _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, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_116[%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_100[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_116[%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_100[%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, "yield_expr")); } { // named_expression @@ -22233,18 +25562,18 @@ _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, "named_expression")); + D(fprintf(stderr, "%*c> _tmp_116[%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_100[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c+ _tmp_116[%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_100[%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, "named_expression")); } _res = NULL; @@ -22253,9 +25582,9 @@ _tmp_100_rule(Parser *p) return _res; } -// _loop0_102: ',' double_starred_kvpair +// _loop0_118: ',' double_starred_kvpair static asdl_seq * -_loop0_102_rule(Parser *p) +_loop0_118_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22279,7 +25608,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, "',' double_starred_kvpair")); + D(fprintf(stderr, "%*c> _loop0_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); Token * _literal; KeyValuePair* elem; while ( @@ -22310,7 +25639,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_118[%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); @@ -22323,14 +25652,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_118_type, _seq); D(p->level--); return _seq; } -// _gather_101: double_starred_kvpair _loop0_102 +// _gather_117: double_starred_kvpair _loop0_118 static asdl_seq * -_gather_101_rule(Parser *p) +_gather_117_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22339,27 +25668,27 @@ _gather_101_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // double_starred_kvpair _loop0_102 + { // double_starred_kvpair _loop0_118 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_102")); + D(fprintf(stderr, "%*c> _gather_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_118")); KeyValuePair* elem; asdl_seq * seq; if ( (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair && - (seq = _loop0_102_rule(p)) // _loop0_102 + (seq = _loop0_118_rule(p)) // _loop0_118 ) { - D(fprintf(stderr, "%*c+ _gather_101[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_102")); + D(fprintf(stderr, "%*c+ _gather_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_118")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_101[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_102")); + D(fprintf(stderr, "%*c%s _gather_117[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_118")); } _res = NULL; done: @@ -22367,9 +25696,9 @@ _gather_101_rule(Parser *p) return _res; } -// _loop1_103: for_if_clause +// _loop1_119: for_if_clause static asdl_seq * -_loop1_103_rule(Parser *p) +_loop1_119_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22393,7 +25722,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, "for_if_clause")); + D(fprintf(stderr, "%*c> _loop1_119[%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 @@ -22415,7 +25744,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_119[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); } if (_n == 0 || p->error_indicator) { @@ -22433,14 +25762,14 @@ _loop1_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, _loop1_103_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_119_type, _seq); D(p->level--); return _seq; } -// _loop0_104: ('if' disjunction) +// _loop0_120: ('if' disjunction) static asdl_seq * -_loop0_104_rule(Parser *p) +_loop0_120_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22464,13 +25793,13 @@ _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, "('if' disjunction)")); - void *_tmp_154_var; + D(fprintf(stderr, "%*c> _loop0_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_170_var; while ( - (_tmp_154_var = _tmp_154_rule(p)) // 'if' disjunction + (_tmp_170_var = _tmp_170_rule(p)) // 'if' disjunction ) { - _res = _tmp_154_var; + _res = _tmp_170_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22486,7 +25815,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_120[%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); @@ -22499,14 +25828,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, _loop0_120_type, _seq); D(p->level--); return _seq; } -// _loop0_105: ('if' disjunction) +// _loop0_121: ('if' disjunction) static asdl_seq * -_loop0_105_rule(Parser *p) +_loop0_121_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22530,13 +25859,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_155_var; + D(fprintf(stderr, "%*c> _loop0_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_171_var; while ( - (_tmp_155_var = _tmp_155_rule(p)) // 'if' disjunction + (_tmp_171_var = _tmp_171_rule(p)) // 'if' disjunction ) { - _res = _tmp_155_var; + _res = _tmp_171_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -22552,7 +25881,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_121[%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); @@ -22565,14 +25894,14 @@ _loop0_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, _loop0_105_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_121_type, _seq); D(p->level--); return _seq; } -// _loop0_107: ',' (starred_expression | named_expression !'=') +// _loop0_123: ',' (starred_expression | named_expression !'=') static asdl_seq * -_loop0_107_rule(Parser *p) +_loop0_123_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22596,13 +25925,13 @@ _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, "',' (starred_expression | named_expression !'=')")); + D(fprintf(stderr, "%*c> _loop0_123[%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_156_rule(p)) // starred_expression | named_expression !'=' + (elem = _tmp_172_rule(p)) // starred_expression | named_expression !'=' ) { _res = elem; @@ -22627,7 +25956,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_123[%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); @@ -22640,14 +25969,14 @@ _loop0_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, _loop0_107_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_123_type, _seq); D(p->level--); return _seq; } -// _gather_106: (starred_expression | named_expression !'=') _loop0_107 +// _gather_122: (starred_expression | named_expression !'=') _loop0_123 static asdl_seq * -_gather_106_rule(Parser *p) +_gather_122_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22656,27 +25985,27 @@ _gather_106_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (starred_expression | named_expression !'=') _loop0_107 + { // (starred_expression | named_expression !'=') _loop0_123 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_107")); + D(fprintf(stderr, "%*c> _gather_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_123")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_156_rule(p)) // starred_expression | named_expression !'=' + (elem = _tmp_172_rule(p)) // starred_expression | named_expression !'=' && - (seq = _loop0_107_rule(p)) // _loop0_107 + (seq = _loop0_123_rule(p)) // _loop0_123 ) { - D(fprintf(stderr, "%*c+ _gather_106[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_107")); + D(fprintf(stderr, "%*c+ _gather_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_123")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_106[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_107")); + D(fprintf(stderr, "%*c%s _gather_122[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_123")); } _res = NULL; done: @@ -22684,9 +26013,9 @@ _gather_106_rule(Parser *p) return _res; } -// _tmp_108: ',' kwargs +// _tmp_124: ',' kwargs static void * -_tmp_108_rule(Parser *p) +_tmp_124_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22700,7 +26029,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, "',' kwargs")); + D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwargs")); Token * _literal; asdl_seq* k; if ( @@ -22709,7 +26038,7 @@ _tmp_108_rule(Parser *p) (k = kwargs_rule(p)) // kwargs ) { - D(fprintf(stderr, "%*c+ _tmp_108[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' kwargs")); + D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' kwargs")); _res = k; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -22719,7 +26048,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_124[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwargs")); } _res = NULL; @@ -22728,9 +26057,9 @@ _tmp_108_rule(Parser *p) return _res; } -// _loop0_110: ',' kwarg_or_starred +// _loop0_126: ',' kwarg_or_starred static asdl_seq * -_loop0_110_rule(Parser *p) +_loop0_126_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22754,7 +26083,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_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -22785,7 +26114,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_126[%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); @@ -22798,14 +26127,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_126_type, _seq); D(p->level--); return _seq; } -// _gather_109: kwarg_or_starred _loop0_110 +// _gather_125: kwarg_or_starred _loop0_126 static asdl_seq * -_gather_109_rule(Parser *p) +_gather_125_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22814,27 +26143,27 @@ _gather_109_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_110 + { // kwarg_or_starred _loop0_126 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_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_110_rule(p)) // _loop0_110 + (seq = _loop0_126_rule(p)) // _loop0_126 ) { - 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_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_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_125[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_126")); } _res = NULL; done: @@ -22842,9 +26171,9 @@ _gather_109_rule(Parser *p) return _res; } -// _loop0_112: ',' kwarg_or_double_starred +// _loop0_128: ',' kwarg_or_double_starred static asdl_seq * -_loop0_112_rule(Parser *p) +_loop0_128_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22868,7 +26197,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_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -22899,7 +26228,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_128[%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); @@ -22912,14 +26241,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, _loop0_128_type, _seq); D(p->level--); return _seq; } -// _gather_111: kwarg_or_double_starred _loop0_112 +// _gather_127: kwarg_or_double_starred _loop0_128 static asdl_seq * -_gather_111_rule(Parser *p) +_gather_127_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22928,27 +26257,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_128 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_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_112_rule(p)) // _loop0_112 + (seq = _loop0_128_rule(p)) // _loop0_128 ) { - 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_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_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_127[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_128")); } _res = NULL; done: @@ -22956,9 +26285,9 @@ _gather_111_rule(Parser *p) return _res; } -// _loop0_114: ',' kwarg_or_starred +// _loop0_130: ',' kwarg_or_starred static asdl_seq * -_loop0_114_rule(Parser *p) +_loop0_130_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -22982,7 +26311,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_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -23013,7 +26342,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_130[%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); @@ -23026,14 +26355,14 @@ _loop0_114_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_114_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq); D(p->level--); return _seq; } -// _gather_113: kwarg_or_starred _loop0_114 +// _gather_129: kwarg_or_starred _loop0_130 static asdl_seq * -_gather_113_rule(Parser *p) +_gather_129_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23042,27 +26371,27 @@ _gather_113_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_114 + { // kwarg_or_starred _loop0_130 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_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_114_rule(p)) // _loop0_114 + (seq = _loop0_130_rule(p)) // _loop0_130 ) { - 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_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_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_129[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_130")); } _res = NULL; done: @@ -23070,9 +26399,9 @@ _gather_113_rule(Parser *p) return _res; } -// _loop0_116: ',' kwarg_or_double_starred +// _loop0_132: ',' kwarg_or_double_starred static asdl_seq * -_loop0_116_rule(Parser *p) +_loop0_132_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23096,7 +26425,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_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -23127,7 +26456,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_132[%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); @@ -23140,14 +26469,14 @@ _loop0_116_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_116_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_132_type, _seq); D(p->level--); return _seq; } -// _gather_115: kwarg_or_double_starred _loop0_116 +// _gather_131: kwarg_or_double_starred _loop0_132 static asdl_seq * -_gather_115_rule(Parser *p) +_gather_131_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23156,27 +26485,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_132 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_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_116_rule(p)) // _loop0_116 + (seq = _loop0_132_rule(p)) // _loop0_132 ) { - 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_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_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_131[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_132")); } _res = NULL; done: @@ -23184,9 +26513,9 @@ _gather_115_rule(Parser *p) return _res; } -// _loop0_117: (',' star_target) +// _loop0_133: (',' star_target) static asdl_seq * -_loop0_117_rule(Parser *p) +_loop0_133_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23210,13 +26539,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_157_var; + D(fprintf(stderr, "%*c> _loop0_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_173_var; while ( - (_tmp_157_var = _tmp_157_rule(p)) // ',' star_target + (_tmp_173_var = _tmp_173_rule(p)) // ',' star_target ) { - _res = _tmp_157_var; + _res = _tmp_173_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23232,7 +26561,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_133[%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); @@ -23245,14 +26574,14 @@ _loop0_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, _loop0_117_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_133_type, _seq); D(p->level--); return _seq; } -// _loop0_119: ',' star_target +// _loop0_135: ',' star_target static asdl_seq * -_loop0_119_rule(Parser *p) +_loop0_135_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23276,7 +26605,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_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty elem; while ( @@ -23307,7 +26636,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_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); @@ -23320,14 +26649,14 @@ _loop0_119_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_119_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_135_type, _seq); D(p->level--); return _seq; } -// _gather_118: star_target _loop0_119 +// _gather_134: star_target _loop0_135 static asdl_seq * -_gather_118_rule(Parser *p) +_gather_134_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23336,27 +26665,27 @@ _gather_118_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_target _loop0_119 + { // star_target _loop0_135 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_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_119_rule(p)) // _loop0_119 + (seq = _loop0_135_rule(p)) // _loop0_135 ) { - 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_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_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_134[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_135")); } _res = NULL; done: @@ -23364,9 +26693,9 @@ _gather_118_rule(Parser *p) return _res; } -// _loop1_120: (',' star_target) +// _loop1_136: (',' star_target) static asdl_seq * -_loop1_120_rule(Parser *p) +_loop1_136_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23390,13 +26719,13 @@ _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, "(',' star_target)")); - void *_tmp_158_var; + D(fprintf(stderr, "%*c> _loop1_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_174_var; while ( - (_tmp_158_var = _tmp_158_rule(p)) // ',' star_target + (_tmp_174_var = _tmp_174_rule(p)) // ',' star_target ) { - _res = _tmp_158_var; + _res = _tmp_174_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23412,7 +26741,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_136[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); } if (_n == 0 || p->error_indicator) { @@ -23430,14 +26759,14 @@ _loop1_120_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_120_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_136_type, _seq); D(p->level--); return _seq; } -// _tmp_121: !'*' star_target +// _tmp_137: !'*' star_target static void * -_tmp_121_rule(Parser *p) +_tmp_137_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23451,7 +26780,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_target")); + D(fprintf(stderr, "%*c> _tmp_137[%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='*' @@ -23459,12 +26788,12 @@ _tmp_121_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c+ _tmp_137[%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_121[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_137[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); } _res = NULL; @@ -23473,9 +26802,9 @@ _tmp_121_rule(Parser *p) return _res; } -// _loop0_123: ',' del_target +// _loop0_139: ',' del_target static asdl_seq * -_loop0_123_rule(Parser *p) +_loop0_139_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23499,7 +26828,7 @@ _loop0_123_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); + D(fprintf(stderr, "%*c> _loop0_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); Token * _literal; expr_ty elem; while ( @@ -23530,7 +26859,7 @@ _loop0_123_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_123[%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, "',' del_target")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -23543,14 +26872,14 @@ _loop0_123_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_123_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_139_type, _seq); D(p->level--); return _seq; } -// _gather_122: del_target _loop0_123 +// _gather_138: del_target _loop0_139 static asdl_seq * -_gather_122_rule(Parser *p) +_gather_138_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23559,27 +26888,27 @@ _gather_122_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // del_target _loop0_123 + { // del_target _loop0_139 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_123")); + D(fprintf(stderr, "%*c> _gather_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_139")); expr_ty elem; asdl_seq * seq; if ( (elem = del_target_rule(p)) // del_target && - (seq = _loop0_123_rule(p)) // _loop0_123 + (seq = _loop0_139_rule(p)) // _loop0_139 ) { - D(fprintf(stderr, "%*c+ _gather_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_123")); + D(fprintf(stderr, "%*c+ _gather_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_139")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_122[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_123")); + D(fprintf(stderr, "%*c%s _gather_138[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_139")); } _res = NULL; done: @@ -23587,9 +26916,9 @@ _gather_122_rule(Parser *p) return _res; } -// _loop0_125: ',' target +// _loop0_141: ',' target static asdl_seq * -_loop0_125_rule(Parser *p) +_loop0_141_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23613,7 +26942,7 @@ _loop0_125_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop0_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); + D(fprintf(stderr, "%*c> _loop0_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); Token * _literal; expr_ty elem; while ( @@ -23644,7 +26973,7 @@ _loop0_125_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_125[%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, "',' target")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -23657,14 +26986,14 @@ _loop0_125_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_125_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_141_type, _seq); D(p->level--); return _seq; } -// _gather_124: target _loop0_125 +// _gather_140: target _loop0_141 static asdl_seq * -_gather_124_rule(Parser *p) +_gather_140_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23673,27 +27002,27 @@ _gather_124_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // target _loop0_125 + { // target _loop0_141 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_125")); + D(fprintf(stderr, "%*c> _gather_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_141")); expr_ty elem; asdl_seq * seq; if ( (elem = target_rule(p)) // target && - (seq = _loop0_125_rule(p)) // _loop0_125 + (seq = _loop0_141_rule(p)) // _loop0_141 ) { - D(fprintf(stderr, "%*c+ _gather_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_125")); + D(fprintf(stderr, "%*c+ _gather_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_141")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_124[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_125")); + D(fprintf(stderr, "%*c%s _gather_140[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_141")); } _res = NULL; done: @@ -23701,9 +27030,9 @@ _gather_124_rule(Parser *p) return _res; } -// _tmp_126: args | expression for_if_clauses +// _tmp_142: args | expression for_if_clauses static void * -_tmp_126_rule(Parser *p) +_tmp_142_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23717,18 +27046,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, "args")); + D(fprintf(stderr, "%*c> _tmp_142[%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_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c+ _tmp_142[%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_126[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_142[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); } { // expression for_if_clauses @@ -23736,7 +27065,7 @@ _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, "expression for_if_clauses")); + D(fprintf(stderr, "%*c> _tmp_142[%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 ( @@ -23745,12 +27074,12 @@ _tmp_126_rule(Parser *p) (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses ) { - D(fprintf(stderr, "%*c+ _tmp_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c+ _tmp_142[%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_126[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_142[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); } _res = NULL; @@ -23759,9 +27088,9 @@ _tmp_126_rule(Parser *p) return _res; } -// _loop0_127: star_named_expressions +// _loop0_143: star_named_expressions static asdl_seq * -_loop0_127_rule(Parser *p) +_loop0_143_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23785,7 +27114,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, "star_named_expressions")); + D(fprintf(stderr, "%*c> _loop0_143[%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 @@ -23807,7 +27136,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_143[%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); @@ -23820,14 +27149,14 @@ _loop0_127_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_127_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_143_type, _seq); D(p->level--); return _seq; } -// _loop0_128: (star_targets '=') +// _loop0_144: (star_targets '=') static asdl_seq * -_loop0_128_rule(Parser *p) +_loop0_144_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23851,13 +27180,13 @@ _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, "(star_targets '=')")); - void *_tmp_159_var; + D(fprintf(stderr, "%*c> _loop0_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); + void *_tmp_175_var; while ( - (_tmp_159_var = _tmp_159_rule(p)) // star_targets '=' + (_tmp_175_var = _tmp_175_rule(p)) // star_targets '=' ) { - _res = _tmp_159_var; + _res = _tmp_175_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23873,7 +27202,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_144[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -23886,14 +27215,14 @@ _loop0_128_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_128_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_144_type, _seq); D(p->level--); return _seq; } -// _loop0_129: (star_targets '=') +// _loop0_145: (star_targets '=') static asdl_seq * -_loop0_129_rule(Parser *p) +_loop0_145_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23917,13 +27246,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, "(star_targets '=')")); - void *_tmp_160_var; + D(fprintf(stderr, "%*c> _loop0_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); + void *_tmp_176_var; while ( - (_tmp_160_var = _tmp_160_rule(p)) // star_targets '=' + (_tmp_176_var = _tmp_176_rule(p)) // star_targets '=' ) { - _res = _tmp_160_var; + _res = _tmp_176_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -23939,7 +27268,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_145[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -23952,14 +27281,14 @@ _loop0_129_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_129_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_145_type, _seq); D(p->level--); return _seq; } -// _tmp_130: yield_expr | star_expressions +// _tmp_146: yield_expr | star_expressions static void * -_tmp_130_rule(Parser *p) +_tmp_146_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -23973,18 +27302,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, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_146[%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_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_146[%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_130[%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, "yield_expr")); } { // star_expressions @@ -23992,18 +27321,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, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_146[%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_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_146[%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_130[%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, "star_expressions")); } _res = NULL; @@ -24012,9 +27341,9 @@ _tmp_130_rule(Parser *p) return _res; } -// _tmp_131: '[' | '(' | '{' +// _tmp_147: '[' | '(' | '{' static void * -_tmp_131_rule(Parser *p) +_tmp_147_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24028,18 +27357,18 @@ _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, "'['")); + D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); _res = _literal; 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_147[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); } { // '(' @@ -24047,18 +27376,18 @@ _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, "'('")); + D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' ) { - D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); _res = _literal; 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_147[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } { // '{' @@ -24066,18 +27395,18 @@ _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, "'{'")); + D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' ) { - D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); _res = _literal; 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_147[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); } _res = NULL; @@ -24086,9 +27415,9 @@ _tmp_131_rule(Parser *p) return _res; } -// _tmp_132: '[' | '{' +// _tmp_148: '[' | '{' static void * -_tmp_132_rule(Parser *p) +_tmp_148_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24102,18 +27431,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, "'['")); + D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_132[%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_132[%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, "'['")); } { // '{' @@ -24121,18 +27450,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, "'{'")); + 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_132[%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_132[%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, "'{'")); } _res = NULL; @@ -24141,9 +27470,9 @@ _tmp_132_rule(Parser *p) return _res; } -// _loop0_133: param_no_default +// _loop0_149: param_no_default static asdl_seq * -_loop0_133_rule(Parser *p) +_loop0_149_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24167,7 +27496,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, "param_no_default")); + 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 ( (param_no_default_var = param_no_default_rule(p)) // param_no_default @@ -24189,7 +27518,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_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); @@ -24202,14 +27531,14 @@ _loop0_133_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_133_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_149_type, _seq); D(p->level--); return _seq; } -// _loop1_134: param_with_default +// _loop1_150: param_with_default static asdl_seq * -_loop1_134_rule(Parser *p) +_loop1_150_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24233,7 +27562,7 @@ _loop1_134_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_150[%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 @@ -24255,7 +27584,7 @@ _loop1_134_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_134[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_150[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -24273,14 +27602,14 @@ _loop1_134_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_134_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_150_type, _seq); D(p->level--); return _seq; } -// _loop0_135: lambda_param_no_default +// _loop0_151: lambda_param_no_default static asdl_seq * -_loop0_135_rule(Parser *p) +_loop0_151_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24304,7 +27633,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, "lambda_param_no_default")); + 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 ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -24326,7 +27655,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_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); @@ -24339,14 +27668,14 @@ _loop0_135_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_135_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_151_type, _seq); D(p->level--); return _seq; } -// _loop1_136: lambda_param_with_default +// _loop1_152: lambda_param_with_default static asdl_seq * -_loop1_136_rule(Parser *p) +_loop1_152_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24370,7 +27699,7 @@ _loop1_136_rule(Parser *p) D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _loop1_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_152[%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 @@ -24392,7 +27721,7 @@ _loop1_136_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_136[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -24410,14 +27739,14 @@ _loop1_136_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_136_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop1_152_type, _seq); D(p->level--); return _seq; } -// _tmp_137: ')' | ',' (')' | '**') +// _tmp_153: ')' | ',' (')' | '**') static void * -_tmp_137_rule(Parser *p) +_tmp_153_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24431,18 +27760,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_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_137[%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_137[%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, "')'")); } { // ',' (')' | '**') @@ -24450,21 +27779,21 @@ _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_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); Token * _literal; - void *_tmp_161_var; + void *_tmp_177_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_161_var = _tmp_161_rule(p)) // ')' | '**' + (_tmp_177_var = _tmp_177_rule(p)) // ')' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_161_var); + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_177_var); 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_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); } _res = NULL; @@ -24473,9 +27802,9 @@ _tmp_137_rule(Parser *p) return _res; } -// _tmp_138: ':' | ',' (':' | '**') +// _tmp_154: ':' | ',' (':' | '**') static void * -_tmp_138_rule(Parser *p) +_tmp_154_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24489,18 +27818,18 @@ _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, "':'")); + 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_138[%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_138[%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, "':'")); } { // ',' (':' | '**') @@ -24508,21 +27837,21 @@ _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, "',' (':' | '**')")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); Token * _literal; - void *_tmp_162_var; + void *_tmp_178_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_162_var = _tmp_162_rule(p)) // ':' | '**' + (_tmp_178_var = _tmp_178_rule(p)) // ':' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_162_var); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_178_var); 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_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); } _res = NULL; @@ -24531,9 +27860,9 @@ _tmp_138_rule(Parser *p) return _res; } -// _tmp_139: ',' | ')' | ':' +// _tmp_155: ',' | ')' | ':' static void * -_tmp_139_rule(Parser *p) +_tmp_155_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24547,18 +27876,18 @@ _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, "','")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_139[%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_139[%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, "','")); } { // ')' @@ -24566,18 +27895,18 @@ _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, "')'")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_139[%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_139[%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, "')'")); } { // ':' @@ -24585,18 +27914,18 @@ _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, "':'")); + 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_139[%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_139[%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; @@ -24605,9 +27934,9 @@ _tmp_139_rule(Parser *p) return _res; } -// _loop0_141: ',' (expression ['as' star_target]) +// _loop0_157: ',' (expression ['as' star_target]) static asdl_seq * -_loop0_141_rule(Parser *p) +_loop0_157_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24631,13 +27960,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, "',' (expression ['as' star_target])")); + D(fprintf(stderr, "%*c> _loop0_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expression ['as' star_target])")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_163_rule(p)) // expression ['as' star_target] + (elem = _tmp_179_rule(p)) // expression ['as' star_target] ) { _res = elem; @@ -24662,7 +27991,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_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expression ['as' star_target])")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -24675,14 +28004,14 @@ _loop0_141_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_141_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_157_type, _seq); D(p->level--); return _seq; } -// _gather_140: (expression ['as' star_target]) _loop0_141 +// _gather_156: (expression ['as' star_target]) _loop0_157 static asdl_seq * -_gather_140_rule(Parser *p) +_gather_156_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24691,27 +28020,27 @@ _gather_140_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (expression ['as' star_target]) _loop0_141 + { // (expression ['as' star_target]) _loop0_157 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_141")); + D(fprintf(stderr, "%*c> _gather_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_157")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_163_rule(p)) // expression ['as' star_target] + (elem = _tmp_179_rule(p)) // expression ['as' star_target] && - (seq = _loop0_141_rule(p)) // _loop0_141 + (seq = _loop0_157_rule(p)) // _loop0_157 ) { - D(fprintf(stderr, "%*c+ _gather_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_141")); + D(fprintf(stderr, "%*c+ _gather_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_157")); _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, "(expression ['as' star_target]) _loop0_141")); + D(fprintf(stderr, "%*c%s _gather_156[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expression ['as' star_target]) _loop0_157")); } _res = NULL; done: @@ -24719,9 +28048,9 @@ _gather_140_rule(Parser *p) return _res; } -// _loop0_143: ',' (expressions ['as' star_target]) +// _loop0_159: ',' (expressions ['as' star_target]) static asdl_seq * -_loop0_143_rule(Parser *p) +_loop0_159_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24745,13 +28074,13 @@ _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, "',' (expressions ['as' star_target])")); + D(fprintf(stderr, "%*c> _loop0_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expressions ['as' star_target])")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_164_rule(p)) // expressions ['as' star_target] + (elem = _tmp_180_rule(p)) // expressions ['as' star_target] ) { _res = elem; @@ -24776,7 +28105,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_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expressions ['as' star_target])")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -24789,14 +28118,14 @@ _loop0_143_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_143_type, _seq); + _PyPegen_insert_memo(p, _start_mark, _loop0_159_type, _seq); D(p->level--); return _seq; } -// _gather_142: (expressions ['as' star_target]) _loop0_143 +// _gather_158: (expressions ['as' star_target]) _loop0_159 static asdl_seq * -_gather_142_rule(Parser *p) +_gather_158_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24805,27 +28134,27 @@ _gather_142_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (expressions ['as' star_target]) _loop0_143 + { // (expressions ['as' star_target]) _loop0_159 if (p->error_indicator) { D(p->level--); return NULL; } - D(fprintf(stderr, "%*c> _gather_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_143")); + D(fprintf(stderr, "%*c> _gather_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_159")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_164_rule(p)) // expressions ['as' star_target] + (elem = _tmp_180_rule(p)) // expressions ['as' star_target] && - (seq = _loop0_143_rule(p)) // _loop0_143 + (seq = _loop0_159_rule(p)) // _loop0_159 ) { - D(fprintf(stderr, "%*c+ _gather_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_143")); + D(fprintf(stderr, "%*c+ _gather_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_159")); _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, "(expressions ['as' star_target]) _loop0_143")); + D(fprintf(stderr, "%*c%s _gather_158[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expressions ['as' star_target]) _loop0_159")); } _res = NULL; done: @@ -24833,9 +28162,9 @@ _gather_142_rule(Parser *p) return _res; } -// _tmp_144: 'as' NAME +// _tmp_160: 'as' NAME static void * -_tmp_144_rule(Parser *p) +_tmp_160_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24849,7 +28178,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, "'as' NAME")); + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; expr_ty name_var; if ( @@ -24858,12 +28187,12 @@ _tmp_144_rule(Parser *p) (name_var = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); _res = _PyPegen_dummy_name(p, _keyword, name_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_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; @@ -24872,9 +28201,9 @@ _tmp_144_rule(Parser *p) return _res; } -// _tmp_145: 'as' NAME +// _tmp_161: 'as' NAME static void * -_tmp_145_rule(Parser *p) +_tmp_161_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24888,7 +28217,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, "'as' NAME")); + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; expr_ty name_var; if ( @@ -24897,12 +28226,12 @@ _tmp_145_rule(Parser *p) (name_var = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); _res = _PyPegen_dummy_name(p, _keyword, name_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_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; @@ -24911,9 +28240,9 @@ _tmp_145_rule(Parser *p) return _res; } -// _tmp_146: star_targets '=' +// _tmp_162: star_targets '=' static void * -_tmp_146_rule(Parser *p) +_tmp_162_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24927,7 +28256,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, "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 ( @@ -24936,7 +28265,7 @@ _tmp_146_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_146[%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; @@ -24946,7 +28275,7 @@ _tmp_146_rule(Parser *p) 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_162[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -24955,9 +28284,9 @@ _tmp_146_rule(Parser *p) return _res; } -// _tmp_147: '.' | '...' +// _tmp_163: '.' | '...' static void * -_tmp_147_rule(Parser *p) +_tmp_163_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -24971,18 +28300,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_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_147[%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_147[%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, "'.'")); } { // '...' @@ -24990,18 +28319,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_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_147[%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_147[%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; @@ -25010,9 +28339,9 @@ _tmp_147_rule(Parser *p) return _res; } -// _tmp_148: '.' | '...' +// _tmp_164: '.' | '...' static void * -_tmp_148_rule(Parser *p) +_tmp_164_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25026,18 +28355,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_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_148[%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_148[%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, "'.'")); } { // '...' @@ -25045,18 +28374,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_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_148[%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_148[%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; @@ -25065,9 +28394,9 @@ _tmp_148_rule(Parser *p) return _res; } -// _tmp_149: '@' named_expression NEWLINE +// _tmp_165: '@' named_expression NEWLINE static void * -_tmp_149_rule(Parser *p) +_tmp_165_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25081,7 +28410,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, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c> _tmp_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); Token * _literal; expr_ty f; Token * newline_var; @@ -25093,7 +28422,7 @@ _tmp_149_rule(Parser *p) (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c+ _tmp_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); _res = f; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25103,7 +28432,7 @@ _tmp_149_rule(Parser *p) 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_165[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); } _res = NULL; @@ -25112,9 +28441,9 @@ _tmp_149_rule(Parser *p) return _res; } -// _tmp_150: ',' star_expression +// _tmp_166: ',' star_expression static void * -_tmp_150_rule(Parser *p) +_tmp_166_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25128,7 +28457,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, "',' star_expression")); + D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty c; if ( @@ -25137,7 +28466,7 @@ _tmp_150_rule(Parser *p) (c = star_expression_rule(p)) // star_expression ) { - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25147,7 +28476,7 @@ _tmp_150_rule(Parser *p) 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_166[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } _res = NULL; @@ -25156,9 +28485,9 @@ _tmp_150_rule(Parser *p) return _res; } -// _tmp_151: ',' expression +// _tmp_167: ',' expression static void * -_tmp_151_rule(Parser *p) +_tmp_167_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25172,7 +28501,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, "',' expression")); + D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty c; if ( @@ -25181,7 +28510,7 @@ _tmp_151_rule(Parser *p) (c = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25191,7 +28520,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_167[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } _res = NULL; @@ -25200,9 +28529,9 @@ _tmp_151_rule(Parser *p) return _res; } -// _tmp_152: 'or' conjunction +// _tmp_168: 'or' conjunction static void * -_tmp_152_rule(Parser *p) +_tmp_168_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25216,7 +28545,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, "'or' conjunction")); + D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); Token * _keyword; expr_ty c; if ( @@ -25225,7 +28554,7 @@ _tmp_152_rule(Parser *p) (c = conjunction_rule(p)) // conjunction ) { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25235,7 +28564,7 @@ _tmp_152_rule(Parser *p) 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_168[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); } _res = NULL; @@ -25244,9 +28573,9 @@ _tmp_152_rule(Parser *p) return _res; } -// _tmp_153: 'and' inversion +// _tmp_169: 'and' inversion static void * -_tmp_153_rule(Parser *p) +_tmp_169_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25260,7 +28589,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, "'and' inversion")); + D(fprintf(stderr, "%*c> _tmp_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); Token * _keyword; expr_ty c; if ( @@ -25269,7 +28598,7 @@ _tmp_153_rule(Parser *p) (c = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c+ _tmp_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25279,7 +28608,7 @@ _tmp_153_rule(Parser *p) 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_169[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); } _res = NULL; @@ -25288,9 +28617,9 @@ _tmp_153_rule(Parser *p) return _res; } -// _tmp_154: 'if' disjunction +// _tmp_170: 'if' disjunction static void * -_tmp_154_rule(Parser *p) +_tmp_170_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25304,7 +28633,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, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -25313,7 +28642,7 @@ _tmp_154_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25323,7 +28652,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_170[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -25332,9 +28661,9 @@ _tmp_154_rule(Parser *p) return _res; } -// _tmp_155: 'if' disjunction +// _tmp_171: 'if' disjunction static void * -_tmp_155_rule(Parser *p) +_tmp_171_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25348,7 +28677,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, "'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 ( @@ -25357,7 +28686,7 @@ _tmp_155_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_155[%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; @@ -25367,7 +28696,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_171[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -25376,9 +28705,9 @@ _tmp_155_rule(Parser *p) return _res; } -// _tmp_156: starred_expression | named_expression !'=' +// _tmp_172: starred_expression | named_expression !'=' static void * -_tmp_156_rule(Parser *p) +_tmp_172_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25392,18 +28721,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, "starred_expression")); + D(fprintf(stderr, "%*c> _tmp_172[%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_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); + D(fprintf(stderr, "%*c+ _tmp_172[%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_156[%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, "starred_expression")); } { // named_expression !'=' @@ -25411,7 +28740,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, "named_expression !'='")); + D(fprintf(stderr, "%*c> _tmp_172[%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 @@ -25419,12 +28748,12 @@ _tmp_156_rule(Parser *p) _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression !'='")); + D(fprintf(stderr, "%*c+ _tmp_172[%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_156[%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, "named_expression !'='")); } _res = NULL; @@ -25433,9 +28762,9 @@ _tmp_156_rule(Parser *p) return _res; } -// _tmp_157: ',' star_target +// _tmp_173: ',' star_target static void * -_tmp_157_rule(Parser *p) +_tmp_173_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25449,7 +28778,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, "',' 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 ( @@ -25458,7 +28787,7 @@ _tmp_157_rule(Parser *p) (c = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_157[%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; @@ -25468,7 +28797,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_173[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } _res = NULL; @@ -25477,9 +28806,9 @@ _tmp_157_rule(Parser *p) return _res; } -// _tmp_158: ',' star_target +// _tmp_174: ',' star_target static void * -_tmp_158_rule(Parser *p) +_tmp_174_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25493,7 +28822,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, "',' star_target")); + D(fprintf(stderr, "%*c> _tmp_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty c; if ( @@ -25502,7 +28831,7 @@ _tmp_158_rule(Parser *p) (c = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -25512,7 +28841,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_174[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } _res = NULL; @@ -25521,9 +28850,9 @@ _tmp_158_rule(Parser *p) return _res; } -// _tmp_159: star_targets '=' +// _tmp_175: star_targets '=' static void * -_tmp_159_rule(Parser *p) +_tmp_175_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25537,7 +28866,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_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty star_targets_var; if ( @@ -25546,12 +28875,12 @@ _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_175[%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_159[%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, "star_targets '='")); } _res = NULL; @@ -25560,9 +28889,9 @@ _tmp_159_rule(Parser *p) return _res; } -// _tmp_160: star_targets '=' +// _tmp_176: star_targets '=' static void * -_tmp_160_rule(Parser *p) +_tmp_176_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25576,7 +28905,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_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty star_targets_var; if ( @@ -25585,12 +28914,12 @@ _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_176[%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_160[%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_targets '='")); } _res = NULL; @@ -25599,9 +28928,9 @@ _tmp_160_rule(Parser *p) return _res; } -// _tmp_161: ')' | '**' +// _tmp_177: ')' | '**' static void * -_tmp_161_rule(Parser *p) +_tmp_177_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25615,18 +28944,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_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_177[%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_177[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // '**' @@ -25634,18 +28963,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_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_177[%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_177[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -25654,9 +28983,9 @@ _tmp_161_rule(Parser *p) return _res; } -// _tmp_162: ':' | '**' +// _tmp_178: ':' | '**' static void * -_tmp_162_rule(Parser *p) +_tmp_178_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25670,18 +28999,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_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_178[%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_178[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // '**' @@ -25689,18 +29018,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_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_178[%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_178[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -25709,9 +29038,9 @@ _tmp_162_rule(Parser *p) return _res; } -// _tmp_163: expression ['as' star_target] +// _tmp_179: expression ['as' star_target] static void * -_tmp_163_rule(Parser *p) +_tmp_179_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25725,22 +29054,22 @@ _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, "expression ['as' star_target]")); + D(fprintf(stderr, "%*c> _tmp_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings expr_ty expression_var; if ( (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_165_rule(p), 1) // ['as' star_target] + (_opt_var = _tmp_181_rule(p), 1) // ['as' star_target] ) { - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); + D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); _res = _PyPegen_dummy_name(p, expression_var, _opt_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_163[%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, "expression ['as' star_target]")); } _res = NULL; @@ -25749,9 +29078,9 @@ _tmp_163_rule(Parser *p) return _res; } -// _tmp_164: expressions ['as' star_target] +// _tmp_180: expressions ['as' star_target] static void * -_tmp_164_rule(Parser *p) +_tmp_180_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25765,22 +29094,22 @@ _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, "expressions ['as' star_target]")); + D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings expr_ty expressions_var; if ( (expressions_var = expressions_rule(p)) // expressions && - (_opt_var = _tmp_166_rule(p), 1) // ['as' star_target] + (_opt_var = _tmp_182_rule(p), 1) // ['as' star_target] ) { - D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); + D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); _res = _PyPegen_dummy_name(p, expressions_var, _opt_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_164[%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, "expressions ['as' star_target]")); } _res = NULL; @@ -25789,9 +29118,9 @@ _tmp_164_rule(Parser *p) return _res; } -// _tmp_165: 'as' star_target +// _tmp_181: 'as' star_target static void * -_tmp_165_rule(Parser *p) +_tmp_181_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25805,7 +29134,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, "'as' star_target")); + D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); Token * _keyword; expr_ty star_target_var; if ( @@ -25814,12 +29143,12 @@ _tmp_165_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); _res = _PyPegen_dummy_name(p, _keyword, star_target_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_165[%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, "'as' star_target")); } _res = NULL; @@ -25828,9 +29157,9 @@ _tmp_165_rule(Parser *p) return _res; } -// _tmp_166: 'as' star_target +// _tmp_182: 'as' star_target static void * -_tmp_166_rule(Parser *p) +_tmp_182_rule(Parser *p) { D(p->level++); if (p->error_indicator) { @@ -25844,7 +29173,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, "'as' star_target")); + D(fprintf(stderr, "%*c> _tmp_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); Token * _keyword; expr_ty star_target_var; if ( @@ -25853,12 +29182,12 @@ _tmp_166_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); _res = _PyPegen_dummy_name(p, _keyword, star_target_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_166[%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, "'as' star_target")); } _res = NULL; diff --git a/Python/Python-ast.c b/Python/Python-ast.c index debd3e3..439da8f 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -91,6 +91,9 @@ struct ast_state { PyObject *Lt_type; PyObject *MatMult_singleton; PyObject *MatMult_type; + PyObject *MatchAs_type; + PyObject *MatchOr_type; + PyObject *Match_type; PyObject *Mod_singleton; PyObject *Mod_type; PyObject *Module_type; @@ -137,6 +140,7 @@ struct ast_state { PyObject *Yield_type; PyObject *__dict__; PyObject *__doc__; + PyObject *__match_args__; PyObject *__module__; PyObject *_attributes; PyObject *_fields; @@ -153,6 +157,7 @@ struct ast_state { PyObject *bases; PyObject *body; PyObject *boolop_type; + PyObject *cases; PyObject *cause; PyObject *cmpop_type; PyObject *col_offset; @@ -175,6 +180,7 @@ struct ast_state { PyObject *format_spec; PyObject *func; PyObject *generators; + PyObject *guard; PyObject *handlers; PyObject *id; PyObject *ifs; @@ -193,6 +199,7 @@ struct ast_state { PyObject *level; PyObject *lineno; PyObject *lower; + PyObject *match_case_type; PyObject *mod_type; PyObject *module; PyObject *msg; @@ -204,6 +211,8 @@ struct ast_state { PyObject *ops; PyObject *optional_vars; PyObject *orelse; + PyObject *pattern; + PyObject *patterns; PyObject *posonlyargs; PyObject *returns; PyObject *right; @@ -211,6 +220,7 @@ struct ast_state { PyObject *slice; PyObject *step; PyObject *stmt_type; + PyObject *subject; PyObject *tag; PyObject *target; PyObject *targets; @@ -348,6 +358,9 @@ void _PyAST_Fini(PyInterpreterState *interp) Py_CLEAR(state->Lt_type); 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); Py_CLEAR(state->Module_type); @@ -394,6 +407,7 @@ void _PyAST_Fini(PyInterpreterState *interp) 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); @@ -410,6 +424,7 @@ void _PyAST_Fini(PyInterpreterState *interp) Py_CLEAR(state->bases); Py_CLEAR(state->body); Py_CLEAR(state->boolop_type); + Py_CLEAR(state->cases); Py_CLEAR(state->cause); Py_CLEAR(state->cmpop_type); Py_CLEAR(state->col_offset); @@ -432,6 +447,7 @@ void _PyAST_Fini(PyInterpreterState *interp) Py_CLEAR(state->format_spec); Py_CLEAR(state->func); Py_CLEAR(state->generators); + Py_CLEAR(state->guard); Py_CLEAR(state->handlers); Py_CLEAR(state->id); Py_CLEAR(state->ifs); @@ -450,6 +466,7 @@ void _PyAST_Fini(PyInterpreterState *interp) Py_CLEAR(state->level); Py_CLEAR(state->lineno); Py_CLEAR(state->lower); + Py_CLEAR(state->match_case_type); Py_CLEAR(state->mod_type); Py_CLEAR(state->module); Py_CLEAR(state->msg); @@ -461,6 +478,8 @@ void _PyAST_Fini(PyInterpreterState *interp) Py_CLEAR(state->ops); 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); @@ -468,6 +487,7 @@ void _PyAST_Fini(PyInterpreterState *interp) 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); @@ -494,6 +514,7 @@ static int init_identifiers(struct ast_state *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; @@ -506,6 +527,7 @@ static int init_identifiers(struct ast_state *state) 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; @@ -523,6 +545,7 @@ static int init_identifiers(struct ast_state *state) 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; @@ -549,12 +572,15 @@ static int init_identifiers(struct ast_state *state) 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->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; 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; @@ -579,6 +605,7 @@ GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty) GENERATE_ASDL_SEQ_CONSTRUCTOR(keyword, keyword_ty) GENERATE_ASDL_SEQ_CONSTRUCTOR(alias, alias_ty) GENERATE_ASDL_SEQ_CONSTRUCTOR(withitem, withitem_ty) +GENERATE_ASDL_SEQ_CONSTRUCTOR(match_case, match_case_ty) GENERATE_ASDL_SEQ_CONSTRUCTOR(type_ignore, type_ignore_ty) static PyObject* ast2obj_mod(struct ast_state *state, void*); @@ -682,6 +709,10 @@ static const char * const AsyncWith_fields[]={ "body", "type_comment", }; +static const char * const Match_fields[]={ + "subject", + "cases", +}; static const char * const Raise_fields[]={ "exc", "cause", @@ -832,6 +863,13 @@ static const char * const Slice_fields[]={ "upper", "step", }; +static const char * const MatchAs_fields[]={ + "pattern", + "name", +}; +static const char * const MatchOr_fields[]={ + "patterns", +}; static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty); static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty); static PyObject* ast2obj_operator(struct ast_state *state, operator_ty); @@ -899,6 +937,12 @@ static const char * const withitem_fields[]={ "context_expr", "optional_vars", }; +static PyObject* ast2obj_match_case(struct ast_state *state, void*); +static const char * const match_case_fields[]={ + "pattern", + "guard", + "body", +}; static PyObject* ast2obj_type_ignore(struct ast_state *state, void*); static const char * const TypeIgnore_fields[]={ "lineno", @@ -1089,9 +1133,10 @@ make_type(struct ast_state *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); @@ -1222,6 +1267,7 @@ static int add_ast_fields(struct ast_state *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; @@ -1291,6 +1337,7 @@ init_types(struct ast_state *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 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" @@ -1393,6 +1440,10 @@ init_types(struct ast_state *state) if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None) == -1) return 0; + state->Match_type = make_type(state, "Match", state->stmt_type, + Match_fields, 2, + "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, "Raise(expr? exc, expr? cause)"); @@ -1471,7 +1522,9 @@ init_types(struct ast_state *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)\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) @@ -1604,6 +1657,14 @@ init_types(struct ast_state *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->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"); @@ -1910,6 +1971,13 @@ init_types(struct ast_state *state) if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None) == -1) return 0; + state->match_case_type = make_type(state, "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, 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(state, "type_ignore", state->AST_type, NULL, 0, "type_ignore = TypeIgnore(int lineno, string tag)"); @@ -1955,6 +2023,8 @@ static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena* arena); static int obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out, PyArena* arena); +static int obj2ast_match_case(struct ast_state *state, PyObject* obj, + match_case_ty* out, PyArena* arena); static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty* out, PyArena* arena); @@ -2389,6 +2459,29 @@ AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, string type_comment, } stmt_ty +Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, int col_offset, + int end_lineno, int end_col_offset, PyArena *arena) +{ + stmt_ty p; + if (!subject) { + PyErr_SetString(PyExc_ValueError, + "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.subject = subject; + 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) { @@ -3263,6 +3356,51 @@ 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; +} + +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) @@ -3406,6 +3544,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_stmt_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) { @@ -3847,6 +4003,22 @@ ast2obj_stmt(struct ast_state *state, void* _o) goto failed; Py_DECREF(value); break; + case Match_kind: + tp = (PyTypeObject *)state->Match_type; + result = PyType_GenericNew(tp, NULL, NULL); + if (!result) goto failed; + value = ast2obj_expr(state, o->v.Match.subject); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->subject, value) == -1) + goto failed; + Py_DECREF(value); + value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases, + ast2obj_match_case); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->cases, value) == -1) + goto failed; + Py_DECREF(value); + break; case Raise_kind: tp = (PyTypeObject *)state->Raise_type; result = PyType_GenericNew(tp, NULL, NULL); @@ -4460,6 +4632,32 @@ ast2obj_expr(struct ast_state *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; + 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; @@ -4928,6 +5126,40 @@ failed: } PyObject* +ast2obj_match_case(struct ast_state *state, void* _o) +{ + match_case_ty o = (match_case_ty)_o; + PyObject *result = NULL, *value = NULL; + PyTypeObject *tp; + if (!o) { + Py_RETURN_NONE; + } + tp = (PyTypeObject *)state->match_case_type; + result = PyType_GenericNew(tp, NULL, NULL); + if (!result) return NULL; + value = ast2obj_expr(state, o->pattern); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->pattern, value) == -1) + goto failed; + Py_DECREF(value); + value = ast2obj_expr(state, o->guard); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->guard, value) == -1) + goto failed; + Py_DECREF(value); + value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->body, value) == -1) + goto failed; + Py_DECREF(value); + return result; +failed: + Py_XDECREF(value); + Py_XDECREF(result); + return NULL; +} + +PyObject* ast2obj_type_ignore(struct ast_state *state, void* _o) { type_ignore_ty o = (type_ignore_ty)_o; @@ -6581,6 +6813,66 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena* if (*out == NULL) goto failed; return 0; } + tp = state->Match_type; + isinstance = PyObject_IsInstance(obj, tp); + if (isinstance == -1) { + return 1; + } + if (isinstance) { + expr_ty subject; + asdl_match_case_seq* cases; + + if (_PyObject_LookupAttr(obj, state->subject, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match"); + return 1; + } + else { + int res; + res = obj2ast_expr(state, tmp, &subject, arena); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + if (_PyObject_LookupAttr(obj, state->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_match_case_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(state, 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(subject, cases, lineno, col_offset, end_lineno, + end_col_offset, arena); + if (*out == NULL) goto failed; + return 0; + } tp = state->Raise_type; isinstance = PyObject_IsInstance(obj, tp); if (isinstance == -1) { @@ -8591,6 +8883,92 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena* 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; + } + 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: @@ -9652,6 +10030,81 @@ failed: } int +obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out, + PyArena* arena) +{ + PyObject* tmp = NULL; + expr_ty pattern; + expr_ty guard; + asdl_stmt_seq* body; + + if (_PyObject_LookupAttr(obj, state->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(state, tmp, &pattern, arena); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + if (_PyObject_LookupAttr(obj, state->guard, &tmp) < 0) { + return 1; + } + if (tmp == NULL || tmp == Py_None) { + Py_CLEAR(tmp); + guard = NULL; + } + else { + int res; + res = obj2ast_expr(state, tmp, &guard, arena); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + if (_PyObject_LookupAttr(obj, state->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_stmt_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(state, 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(struct ast_state *state, PyObject* obj, type_ignore_ty* out, PyArena* arena) { @@ -9792,6 +10245,9 @@ astmodule_exec(PyObject *m) if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) { return -1; } + if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) { + return -1; + } if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) { return -1; } @@ -9911,6 +10367,12 @@ astmodule_exec(PyObject *m) if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) { return -1; } + if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) { + return -1; + } + if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) { + return -1; + } if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0) { return -1; @@ -10050,6 +10512,9 @@ astmodule_exec(PyObject *m) if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) { return -1; } + if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) { + return -1; + } if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) { return -1; } diff --git a/Python/ast.c b/Python/ast.c index 5e74f65..c58b4a6 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -309,6 +309,14 @@ 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 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; @@ -318,6 +326,13 @@ validate_expr(expr_ty exp, expr_context_ty ctx) } static int +validate_pattern(expr_ty p) +{ + // Coming soon (thanks Batuhan)! + return 1; +} + +static int _validate_nonempty_seq(asdl_seq *seq, const char *what, const char *owner) { if (asdl_seq_LEN(seq)) @@ -415,6 +430,20 @@ validate_stmt(stmt_ty stmt) return 0; } return validate_body(stmt->v.AsyncWith.body, "AsyncWith"); + case Match_kind: + if (!validate_expr(stmt->v.Match.subject, Load) + || !validate_nonempty_seq(stmt->v.Match.cases, "cases", "Match")) { + return 0; + } + 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")) { + return 0; + } + } + return 1; case Raise_kind: if (stmt->v.Raise.exc) { return validate_expr(stmt->v.Raise.exc, Load) && diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 8c958ca..6ad00dc 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -408,6 +408,9 @@ static int astfold_comprehension(comprehension_ty node_, PyArena *ctx_, _PyASTOp static int astfold_keyword(keyword_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); +static int astfold_pattern(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state); + #define CALL(FUNC, TYPE, ARG) \ if (!FUNC((ARG), ctx_, state)) \ return 0; @@ -590,6 +593,10 @@ astfold_expr(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) case Constant_kind: // Already a constant, nothing further to do break; + case MatchAs_kind: + case MatchOr_kind: + // These can't occur outside of patterns. + Py_UNREACHABLE(); // No default case, so the compiler will emit a warning if new expression // kinds are added without being handled here } @@ -709,6 +716,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.subject); + CALL_SEQ(astfold_match_case, match_case, node_->v.Match.cases); + break; // The following statements don't contain any subexpressions to be folded case Import_kind: case ImportFrom_kind: @@ -746,6 +757,125 @@ 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 == NULL) { + return 0; + } + assert(PyComplex_CheckExact(negated) || + PyFloat_CheckExact(negated) || + PyLong_CheckExact(negated)); + 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; + expr_ty right = node_->v.BinOp.right; + if (left->kind == UnaryOp_kind) { + CALL(astfold_pattern_negative, expr_ty, left); + } + 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)) + { + // Not actually valid, but it's the compiler's job to complain: + 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 == NULL) { + return 0; + } + assert(PyComplex_CheckExact(new)); + 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! + // Currently, this is only used to form complex/negative numeric constants. + switch (node_->kind) { + case Attribute_kind: + break; + case BinOp_kind: + CALL(astfold_pattern_complex, expr_ty, node_); + 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: + CALL_SEQ(astfold_pattern, expr, node_->v.Tuple.elts); + break; + case UnaryOp_kind: + CALL(astfold_pattern_negative, expr_ty, node_); + break; + default: + Py_UNREACHABLE(); + } + return 1; +} + +static int +astfold_match_case(match_case_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) +{ + CALL(astfold_pattern, expr_ty, node_->pattern); + CALL_OPT(astfold_expr, expr_ty, node_->guard); + CALL_SEQ(astfold_stmt, stmt, node_->body); + return 1; +} + #undef CALL #undef CALL_OPT #undef CALL_SEQ diff --git a/Python/ceval.c b/Python/ceval.c index e1a8f15..7862643 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -880,6 +880,230 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where) return 0; } + +// PEP 634: Structural Pattern Matching + + +// Return a tuple of values corresponding to keys, with error checks for +// duplicate/missing keys. +static PyObject* +match_keys(PyThreadState *tstate, PyObject *map, PyObject *keys) +{ + assert(PyTuple_CheckExact(keys)); + Py_ssize_t nkeys = PyTuple_GET_SIZE(keys); + if (!nkeys) { + // No keys means no items. + return PyTuple_New(0); + } + PyObject *seen = NULL; + PyObject *dummy = NULL; + PyObject *values = NULL; + // We use the two argument form of map.get(key, default) for two reasons: + // - Atomically check for a key and get its value without error handling. + // - Don't cause key creation or resizing in dict subclasses like + // collections.defaultdict that define __missing__ (or similar). + _Py_IDENTIFIER(get); + PyObject *get = _PyObject_GetAttrId(map, &PyId_get); + if (get == NULL) { + goto fail; + } + seen = PySet_New(NULL); + if (seen == NULL) { + goto fail; + } + // dummy = object() + dummy = _PyObject_CallNoArg((PyObject *)&PyBaseObject_Type); + if (dummy == NULL) { + goto fail; + } + values = PyList_New(0); + if (values == NULL) { + goto fail; + } + for (Py_ssize_t i = 0; i < nkeys; i++) { + PyObject *key = PyTuple_GET_ITEM(keys, i); + if (PySet_Contains(seen, key) || PySet_Add(seen, key)) { + if (!_PyErr_Occurred(tstate)) { + // Seen it before! + _PyErr_Format(tstate, PyExc_ValueError, + "mapping pattern checks duplicate key (%R)", key); + } + goto fail; + } + PyObject *value = PyObject_CallFunctionObjArgs(get, key, dummy, NULL); + if (value == NULL) { + goto fail; + } + if (value == dummy) { + // key not in map! + Py_DECREF(value); + Py_DECREF(values); + // Return None: + Py_INCREF(Py_None); + values = Py_None; + goto done; + } + PyList_Append(values, value); + Py_DECREF(value); + } + Py_SETREF(values, PyList_AsTuple(values)); + // Success: +done: + Py_DECREF(get); + Py_DECREF(seen); + Py_DECREF(dummy); + return values; +fail: + Py_XDECREF(get); + Py_XDECREF(seen); + Py_XDECREF(dummy); + Py_XDECREF(values); + return NULL; +} + +// Extract a named attribute from the subject, with additional bookkeeping to +// raise TypeErrors for repeated lookups. On failure, return NULL (with no +// error set). Use _PyErr_Occurred(tstate) to disambiguate. +static PyObject* +match_class_attr(PyThreadState *tstate, PyObject *subject, PyObject *type, + PyObject *name, PyObject *seen) +{ + assert(PyUnicode_CheckExact(name)); + assert(PySet_CheckExact(seen)); + if (PySet_Contains(seen, name) || PySet_Add(seen, name)) { + if (!_PyErr_Occurred(tstate)) { + // Seen it before! + _PyErr_Format(tstate, PyExc_TypeError, + "%s() got multiple sub-patterns for attribute %R", + ((PyTypeObject*)type)->tp_name, name); + } + return NULL; + } + PyObject *attr = PyObject_GetAttr(subject, name); + if (attr == NULL && _PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { + _PyErr_Clear(tstate); + } + return attr; +} + +// On success (match), return a tuple of extracted attributes. On failure (no +// match), return NULL. Use _PyErr_Occurred(tstate) to disambiguate. +static PyObject* +match_class(PyThreadState *tstate, PyObject *subject, PyObject *type, + Py_ssize_t nargs, PyObject *kwargs) +{ + if (!PyType_Check(type)) { + const char *e = "called match pattern must be a type"; + _PyErr_Format(tstate, PyExc_TypeError, e); + return NULL; + } + assert(PyTuple_CheckExact(kwargs)); + // First, an isinstance check: + if (PyObject_IsInstance(subject, type) <= 0) { + return NULL; + } + // So far so good: + PyObject *seen = PySet_New(NULL); + if (seen == NULL) { + return NULL; + } + PyObject *attrs = PyList_New(0); + if (attrs == NULL) { + Py_DECREF(seen); + return NULL; + } + // NOTE: From this point on, goto fail on failure: + PyObject *match_args = NULL; + // First, the positional subpatterns: + if (nargs) { + int match_self = 0; + match_args = PyObject_GetAttrString(type, "__match_args__"); + if (match_args) { + if (PyList_CheckExact(match_args)) { + Py_SETREF(match_args, PyList_AsTuple(match_args)); + } + if (match_args == NULL) { + goto fail; + } + if (!PyTuple_CheckExact(match_args)) { + const char *e = "%s.__match_args__ must be a list or tuple " + "(got %s)"; + _PyErr_Format(tstate, PyExc_TypeError, e, + ((PyTypeObject *)type)->tp_name, + Py_TYPE(match_args)->tp_name); + goto fail; + } + } + else if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { + _PyErr_Clear(tstate); + // _Py_TPFLAGS_MATCH_SELF is only acknowledged if the type does not + // define __match_args__. This is natural behavior for subclasses: + // it's as if __match_args__ is some "magic" value that is lost as + // soon as they redefine it. + match_args = PyTuple_New(0); + match_self = PyType_HasFeature((PyTypeObject*)type, + _Py_TPFLAGS_MATCH_SELF); + } + else { + goto fail; + } + assert(PyTuple_CheckExact(match_args)); + Py_ssize_t allowed = match_self ? 1 : PyTuple_GET_SIZE(match_args); + if (allowed < nargs) { + const char *plural = (allowed == 1) ? "" : "s"; + _PyErr_Format(tstate, PyExc_TypeError, + "%s() accepts %d positional sub-pattern%s (%d given)", + ((PyTypeObject*)type)->tp_name, + allowed, plural, nargs); + goto fail; + } + if (match_self) { + // Easy. Copy the subject itself, and move on to kwargs. + PyList_Append(attrs, subject); + } + else { + for (Py_ssize_t i = 0; i < nargs; i++) { + PyObject *name = PyTuple_GET_ITEM(match_args, i); + if (!PyUnicode_CheckExact(name)) { + _PyErr_Format(tstate, PyExc_TypeError, + "__match_args__ elements must be strings " + "(got %s)", Py_TYPE(name)->tp_name); + goto fail; + } + PyObject *attr = match_class_attr(tstate, subject, type, name, + seen); + if (attr == NULL) { + goto fail; + } + PyList_Append(attrs, attr); + Py_DECREF(attr); + } + } + Py_CLEAR(match_args); + } + // Finally, the keyword subpatterns: + for (Py_ssize_t i = 0; i < PyTuple_GET_SIZE(kwargs); i++) { + PyObject *name = PyTuple_GET_ITEM(kwargs, i); + PyObject *attr = match_class_attr(tstate, subject, type, name, seen); + if (attr == NULL) { + goto fail; + } + PyList_Append(attrs, attr); + Py_DECREF(attr); + } + Py_SETREF(attrs, PyList_AsTuple(attrs)); + Py_DECREF(seen); + return attrs; +fail: + // We really don't care whether an error was raised or not... that's our + // caller's problem. All we know is that the match failed. + Py_XDECREF(match_args); + Py_DECREF(seen); + Py_DECREF(attrs); + return NULL; +} + + static int do_raise(PyThreadState *tstate, PyObject *exc, PyObject *cause); static int unpack_iterable(PyThreadState *, PyObject *, int, int, PyObject **); @@ -3618,6 +3842,164 @@ main_loop: #endif } + case TARGET(GET_LEN): { + // PUSH(len(TOS)) + Py_ssize_t len_i = PyObject_Length(TOP()); + if (len_i < 0) { + goto error; + } + PyObject *len_o = PyLong_FromSsize_t(len_i); + if (len_o == NULL) { + goto error; + } + PUSH(len_o); + DISPATCH(); + } + + case TARGET(MATCH_CLASS): { + // Pop TOS. On success, set TOS to True and TOS1 to a tuple of + // attributes. On failure, set TOS to False. + PyObject *names = POP(); + PyObject *type = TOP(); + PyObject *subject = SECOND(); + assert(PyTuple_CheckExact(names)); + PyObject *attrs = match_class(tstate, subject, type, oparg, names); + Py_DECREF(names); + if (attrs) { + // Success! + assert(PyTuple_CheckExact(attrs)); + Py_DECREF(subject); + SET_SECOND(attrs); + } + else if (_PyErr_Occurred(tstate)) { + goto error; + } + Py_DECREF(type); + SET_TOP(PyBool_FromLong(!!attrs)); + DISPATCH(); + } + + case TARGET(MATCH_MAPPING): { + // PUSH(isinstance(TOS, _collections_abc.Mapping)) + PyObject *subject = TOP(); + // Fast path for dicts: + if (PyDict_Check(subject)) { + Py_INCREF(Py_True); + PUSH(Py_True); + DISPATCH(); + } + // 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 == NULL) { + PyObject *abc = PyImport_ImportModule("_collections_abc"); + if (abc == NULL) { + goto error; + } + interp->map_abc = PyObject_GetAttrString(abc, "Mapping"); + if (interp->map_abc == NULL) { + goto error; + } + } + int match = PyObject_IsInstance(subject, interp->map_abc); + if (match < 0) { + goto error; + } + PUSH(PyBool_FromLong(match)); + DISPATCH(); + } + + case TARGET(MATCH_SEQUENCE): { + // PUSH(not isinstance(TOS, (bytearray, bytes, str)) + // and isinstance(TOS, _collections_abc.Sequence)) + PyObject *subject = TOP(); + // Fast path for lists and tuples: + if (PyType_FastSubclass(Py_TYPE(subject), + Py_TPFLAGS_LIST_SUBCLASS | + Py_TPFLAGS_TUPLE_SUBCLASS)) + { + Py_INCREF(Py_True); + 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) || + PyByteArray_Check(subject)) + { + Py_INCREF(Py_False); + PUSH(Py_False); + DISPATCH(); + } + // 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 == NULL) { + PyObject *abc = PyImport_ImportModule("_collections_abc"); + if (abc == NULL) { + goto error; + } + interp->seq_abc = PyObject_GetAttrString(abc, "Sequence"); + if (interp->seq_abc == NULL) { + goto error; + } + } + int match = PyObject_IsInstance(subject, interp->seq_abc); + if (match < 0) { + goto error; + } + PUSH(PyBool_FromLong(match)); + DISPATCH(); + } + + case TARGET(MATCH_KEYS): { + // On successful match for all keys, PUSH(values) and PUSH(True). + // Otherwise, PUSH(None) and PUSH(False). + PyObject *keys = TOP(); + PyObject *subject = SECOND(); + PyObject *values_or_none = match_keys(tstate, subject, keys); + if (values_or_none == NULL) { + goto error; + } + PUSH(values_or_none); + if (values_or_none == Py_None) { + Py_INCREF(Py_False); + PUSH(Py_False); + DISPATCH(); + } + assert(PyTuple_CheckExact(values_or_none)); + Py_INCREF(Py_True); + PUSH(Py_True); + DISPATCH(); + } + + case TARGET(COPY_DICT_WITHOUT_KEYS): { + // rest = dict(TOS1) + // for key in TOS: + // del rest[key] + // SET_TOP(rest) + PyObject *keys = TOP(); + PyObject *subject = SECOND(); + PyObject *rest = PyDict_New(); + if (rest == NULL || PyDict_Update(rest, subject)) { + Py_XDECREF(rest); + goto error; + } + // This may seem a bit inefficient, but keys is rarely big enough to + // actually impact runtime. + assert(PyTuple_CheckExact(keys)); + for (Py_ssize_t i = 0; i < PyTuple_GET_SIZE(keys); i++) { + if (PyDict_DelItem(rest, PyTuple_GET_ITEM(keys, i))) { + Py_DECREF(rest); + goto error; + } + } + Py_DECREF(keys); + SET_TOP(rest); + DISPATCH(); + } + case TARGET(GET_ITER): { /* before: [obj]; after [getiter(obj)] */ PyObject *iterable = TOP(); diff --git a/Python/compile.c b/Python/compile.c index 386c552..454005e 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -202,6 +202,11 @@ struct compiler { PyArena *c_arena; /* pointer to memory allocation arena */ }; +typedef struct { + PyObject *stores; + int allow_irrefutable; +} 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 *); @@ -210,7 +215,7 @@ 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 *); static int compiler_addop_j_noline(struct compiler *, int, basicblock *); -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); @@ -248,6 +253,11 @@ 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_match(struct compiler *, stmt_ty); +static int compiler_pattern_subpattern(struct compiler *, expr_ty, + pattern_context *); + static PyCodeObject *assemble(struct compiler *, int addNone); static PyObject *__doc__, *__annotations__; @@ -1150,6 +1160,16 @@ stack_effect(int opcode, int oparg, int jump) case DICT_MERGE: case DICT_UPDATE: return -1; + case COPY_DICT_WITHOUT_KEYS: + return 0; + case MATCH_CLASS: + return -1; + case GET_LEN: + case MATCH_MAPPING: + case MATCH_SEQUENCE: + return 1; + case MATCH_KEYS: + return 2; default: return PY_INVALID_STACK_EFFECT; } @@ -1580,6 +1600,11 @@ compiler_addop_j_noline(struct compiler *c, int opcode, basicblock *b) } \ } +#define RETURN_IF_FALSE(X) \ + if (!(X)) { \ + return 0; \ + } + /* Search if variable annotations are present statically in a block. */ static int @@ -3414,6 +3439,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) { @@ -3758,12 +3785,11 @@ starunpack_helper(struct compiler *c, asdl_expr_seq *elts, int pushed, } static int -assignment_helper(struct compiler *c, asdl_expr_seq *elts) +unpack_helper(struct compiler *c, asdl_expr_seq *elts) { Py_ssize_t n = asdl_seq_LEN(elts); - Py_ssize_t i; int seen_star = 0; - for (i = 0; i < n; i++) { + for (Py_ssize_t i = 0; i < n; i++) { expr_ty elt = asdl_seq_GET(elts, i); if (elt->kind == Starred_kind && !seen_star) { if ((i >= (1 << 8)) || @@ -3782,7 +3808,15 @@ assignment_helper(struct compiler *c, asdl_expr_seq *elts) if (!seen_star) { ADDOP_I(c, UNPACK_SEQUENCE, n); } - for (i = 0; i < n; i++) { + return 1; +} + +static int +assignment_helper(struct compiler *c, asdl_expr_seq *elts) +{ + Py_ssize_t n = asdl_seq_LEN(elts); + RETURN_IF_FALSE(unpack_helper(c, elts)); + for (Py_ssize_t i = 0; i < n; i++) { expr_ty elt = asdl_seq_GET(elts, i); VISIT(c, expr, elt->kind != Starred_kind ? elt : elt->v.Starred.value); } @@ -4132,13 +4166,8 @@ validate_keywords(struct compiler *c, asdl_keyword_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; } } @@ -5119,6 +5148,10 @@ 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: + case MatchOr_kind: + // Can only occur in patterns, which are handled elsewhere. + Py_UNREACHABLE(); } return 1; } @@ -5305,28 +5338,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); - if (!loc) { + 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; + } + PyObject *loc = PyErr_ProgramTextObject(c->c_filename, c->u->u_lineno); + if (loc == NULL) { 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 == NULL) { 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; } @@ -5421,6 +5460,654 @@ compiler_slice(struct compiler *c, expr_ty s) return 1; } + +// PEP 634: 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. + + +#define WILDCARD_CHECK(N) \ + ((N)->kind == Name_kind && \ + _PyUnicode_EqualToASCIIString((N)->v.Name.id, "_")) + + +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 == NULL) { + RETURN_IF_FALSE(pc->stores = PySet_New(NULL)); + } + else { + 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, n); + } + } + RETURN_IF_FALSE(!PySet_Add(pc->stores, n)); + RETURN_IF_FALSE(compiler_nameop(c, n, Store)); + return 1; +} + + +static int +pattern_helper_sequence_unpack(struct compiler *c, asdl_expr_seq *values, + Py_ssize_t star, pattern_context *pc) +{ + RETURN_IF_FALSE(unpack_helper(c, values)); + // We've now got a bunch of new subjects on the stack. If any of them fail + // to match, we need to pop everything else off, then finally push False. + // fails is an array of blocks that correspond to the necessary amount of + // popping for each element: + basicblock **fails; + Py_ssize_t size = asdl_seq_LEN(values); + fails = (basicblock **)PyObject_Malloc(sizeof(basicblock*) * size); + if (fails == NULL) { + PyErr_NoMemory(); + return 0; + } + // NOTE: Can't use our nice returning macros anymore: they'll leak memory! + // goto error on error. + for (Py_ssize_t i = 0; i < size; i++) { + fails[i] = compiler_new_block(c); + if (fails[i] == NULL) { + goto error; + } + } + 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); + value = value->v.Starred.value; + } + if (!compiler_pattern_subpattern(c, value, pc) || + !compiler_addop_j(c, POP_JUMP_IF_FALSE, fails[i]) || + compiler_next_block(c) == NULL) + { + goto error; + } + } + // Success! + basicblock *end = compiler_new_block(c); + if (end == NULL || + !compiler_addop_load_const(c, Py_True) || + !compiler_addop_j(c, JUMP_FORWARD, end)) + { + goto error; + } + // This is where we handle failed sub-patterns. For a sequence pattern like + // [a, b, c, d], this will look like: + // fails[0]: POP_TOP + // fails[1]: POP_TOP + // fails[2]: POP_TOP + // fails[3]: LOAD_CONST False + for (Py_ssize_t i = 0; i < size - 1; i++) { + compiler_use_next_block(c, fails[i]); + if (!compiler_addop(c, POP_TOP)) { + goto error; + } + } + compiler_use_next_block(c, fails[size - 1]); + if (!compiler_addop_load_const(c, Py_False)) { + goto error; + } + compiler_use_next_block(c, end); + PyObject_Free(fails); + return 1; +error: + PyObject_Free(fails); + return 0; +} + +// Like pattern_helper_sequence_unpack, but uses BINARY_SUBSCR instead of +// UNPACK_SEQUENCE / UNPACK_EX. This is more efficient for patterns with a +// starred wildcard like [first, *_] / [first, *_, last] / [*_, last] / etc. +static int +pattern_helper_sequence_subscr(struct compiler *c, asdl_expr_seq *values, + Py_ssize_t star, pattern_context *pc) +{ + basicblock *end, *fail_pop_1; + RETURN_IF_FALSE(end = compiler_new_block(c)); + RETURN_IF_FALSE(fail_pop_1 = compiler_new_block(c)); + Py_ssize_t size = asdl_seq_LEN(values); + for (Py_ssize_t i = 0; i < size; i++) { + expr_ty value = asdl_seq_GET(values, i); + if (WILDCARD_CHECK(value)) { + continue; + } + if (i == star) { + assert(value->kind == Starred_kind); + assert(WILDCARD_CHECK(value->v.Starred.value)); + continue; + } + ADDOP(c, DUP_TOP); + if (i < star) { + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); + } + else { + // The subject may not support negative indexing! Compute a + // nonnegative index: + ADDOP(c, GET_LEN); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - i)); + ADDOP(c, BINARY_SUBTRACT); + } + ADDOP(c, BINARY_SUBSCR); + RETURN_IF_FALSE(compiler_pattern_subpattern(c, value, pc)); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail_pop_1); + NEXT_BLOCK(c); + } + ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_True); + ADDOP_JUMP(c, JUMP_FORWARD, end); + compiler_use_next_block(c, fail_pop_1); + ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_False); + compiler_use_next_block(c, end); + return 1; +} + + +// Like compiler_pattern, but turn off checks for irrefutability. +static int +compiler_pattern_subpattern(struct compiler *c, expr_ty p, pattern_context *pc) +{ + int allow_irrefutable = pc->allow_irrefutable; + pc->allow_irrefutable = 1; + RETURN_IF_FALSE(compiler_pattern(c, p, pc)); + pc->allow_irrefutable = allow_irrefutable; + return 1; +} + + +static int +compiler_pattern_as(struct compiler *c, expr_ty p, pattern_context *pc) +{ + assert(p->kind == MatchAs_kind); + basicblock *end, *fail_pop_1; + RETURN_IF_FALSE(end = compiler_new_block(c)); + RETURN_IF_FALSE(fail_pop_1 = compiler_new_block(c)); + // Need to make a copy for (possibly) storing later: + ADDOP(c, DUP_TOP); + RETURN_IF_FALSE(compiler_pattern(c, p->v.MatchAs.pattern, pc)); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail_pop_1); + NEXT_BLOCK(c); + RETURN_IF_FALSE(pattern_helper_store_name(c, p->v.MatchAs.name, pc)); + ADDOP_LOAD_CONST(c, Py_True); + ADDOP_JUMP(c, JUMP_FORWARD, end); + compiler_use_next_block(c, fail_pop_1); + // Need to pop that unused copy from before: + ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_False); + compiler_use_next_block(c, end); + return 1; +} + + +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); + } + RETURN_IF_FALSE(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); + Py_ssize_t nkwargs = asdl_seq_LEN(kwargs); + 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); + } + RETURN_IF_FALSE(!validate_keywords(c, kwargs)); + basicblock *end, *fail_pop_1; + RETURN_IF_FALSE(end = compiler_new_block(c)); + RETURN_IF_FALSE(fail_pop_1 = compiler_new_block(c)); + VISIT(c, expr, p->v.Call.func); + PyObject *kwnames; + RETURN_IF_FALSE(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_JUMP(c, POP_JUMP_IF_FALSE, fail_pop_1); + NEXT_BLOCK(c); + // 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(c, DUP_TOP); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); + ADDOP(c, BINARY_SUBSCR); + RETURN_IF_FALSE(compiler_pattern_subpattern(c, arg, pc)); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail_pop_1); + NEXT_BLOCK(c); + } + // Success! Pop the tuple of attributes: + ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_True); + ADDOP_JUMP(c, JUMP_FORWARD, end); + compiler_use_next_block(c, fail_pop_1); + ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_False); + compiler_use_next_block(c, end); + return 1; +} + + +static int +compiler_pattern_literal(struct compiler *c, expr_ty p, pattern_context *pc) +{ + assert(p->kind == Constant_kind); + PyObject *v = p->v.Constant.value; + ADDOP_LOAD_CONST(c, v); + // 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 +compiler_pattern_mapping(struct compiler *c, expr_ty p, pattern_context *pc) +{ + basicblock *end, *fail_pop_1, *fail_pop_3; + RETURN_IF_FALSE(end = compiler_new_block(c)); + RETURN_IF_FALSE(fail_pop_1 = compiler_new_block(c)); + RETURN_IF_FALSE(fail_pop_3 = 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); + // 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, POP_JUMP_IF_FALSE, fail_pop_1); + NEXT_BLOCK(c); + if (!size) { + // If the pattern is just "{}", we're done! + ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_True); + ADDOP_JUMP(c, JUMP_FORWARD, end); + compiler_use_next_block(c, fail_pop_1); + ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_False); + 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); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail_pop_1); + NEXT_BLOCK(c); + } + if (INT_MAX < size - star - 1) { + return compiler_error(c, "too many sub-patterns in mapping pattern"); + } + // Collect all of the keys into a tuple for MATCH_KEYS and + // COPY_DICT_WITHOUT_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 == NULL) { + const char *e = "can't use starred name here " + "(consider moving to end)"; + return compiler_error(c, e); + } + VISIT(c, expr, key); + } + ADDOP_I(c, BUILD_TUPLE, size - star); + ADDOP(c, MATCH_KEYS); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail_pop_3); + NEXT_BLOCK(c); + // So far so good. There's now a tuple of values on the stack to match + // sub-patterns against: + for (Py_ssize_t i = 0; i < size - star; i++) { + expr_ty value = asdl_seq_GET(values, i); + if (WILDCARD_CHECK(value)) { + continue; + } + ADDOP(c, DUP_TOP); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(i)); + ADDOP(c, BINARY_SUBSCR); + RETURN_IF_FALSE(compiler_pattern_subpattern(c, value, pc)); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail_pop_3); + 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) { + // If we had a starred name, bind a dict of remaining items to it: + ADDOP(c, COPY_DICT_WITHOUT_KEYS); + PyObject *id = asdl_seq_GET(values, size - 1)->v.Name.id; + RETURN_IF_FALSE(pattern_helper_store_name(c, id, pc)); + } + else { + // Otherwise, we don't care about this tuple of keys anymore: + ADDOP(c, POP_TOP); + } + // Pop the subject: + ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_True); + ADDOP_JUMP(c, JUMP_FORWARD, end); + // The top two items are a tuple of values or None, followed by a tuple of + // keys. Pop them both: + compiler_use_next_block(c, fail_pop_3); + ADDOP(c, POP_TOP); + ADDOP(c, POP_TOP); + compiler_use_next_block(c, fail_pop_1); + // Pop the subject: + ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_False); + 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 == MatchOr_kind); + // control is the set of names bound by the first alternative. If all of the + // others bind the same names (they should), then this becomes pc->stores. + PyObject *control = NULL; + basicblock *end, *pass_pop_1; + RETURN_IF_FALSE(end = compiler_new_block(c)); + RETURN_IF_FALSE(pass_pop_1 = 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: + int is_last = i == size - 1; + pc->allow_irrefutable = allow_irrefutable && is_last; + SET_LOC(c, alt); + if (pc->stores == NULL || + // Only copy the subject if we're *not* on the last alternative: + (!is_last && !compiler_addop(c, DUP_TOP)) || + !compiler_pattern(c, alt, pc) || + // Only jump if we're *not* on the last alternative: + (!is_last && !compiler_addop_j(c, POP_JUMP_IF_TRUE, pass_pop_1)) || + !compiler_next_block(c)) + { + goto fail; + } + if (!i) { + // If this is the first alternative, save its stores as a "control" + // for the others (they can't bind a different set of 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 == NULL) { + goto fail; + } + if (PySet_GET_SIZE(diff)) { + // The names differ! Raise. + Py_DECREF(diff); + compiler_error(c, "alternative 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_JUMP(c, JUMP_FORWARD, end); + compiler_use_next_block(c, pass_pop_1); + ADDOP(c, POP_TOP); + 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 +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); + Py_ssize_t star = -1; + int only_wildcard = 1; + int star_wildcard = 0; + // Find a starred name, if it exists. There may be at most one: + for (Py_ssize_t i = 0; i < size; i++) { + expr_ty value = asdl_seq_GET(values, i); + if (value->kind == Starred_kind) { + value = value->v.Starred.value; + if (star >= 0) { + const char *e = "multiple starred names in sequence pattern"; + return compiler_error(c, e); + } + star_wildcard = WILDCARD_CHECK(value); + star = i; + } + only_wildcard &= WILDCARD_CHECK(value); + } + basicblock *end, *fail_pop_1; + RETURN_IF_FALSE(end = compiler_new_block(c)); + RETURN_IF_FALSE(fail_pop_1 = compiler_new_block(c)); + ADDOP(c, MATCH_SEQUENCE); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail_pop_1); + NEXT_BLOCK(c); + if (star < 0) { + // No star: len(subject) == size + ADDOP(c, GET_LEN); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size)); + ADDOP_COMPARE(c, Eq); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail_pop_1); + NEXT_BLOCK(c); + } + else if (size > 1) { + // Star: len(subject) >= size - 1 + ADDOP(c, GET_LEN); + ADDOP_LOAD_CONST_NEW(c, PyLong_FromSsize_t(size - 1)); + ADDOP_COMPARE(c, GtE); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, fail_pop_1); + NEXT_BLOCK(c); + } + if (only_wildcard) { + // Patterns like: [] / [_] / [_, _] / [*_] / [_, *_] / [_, _, *_] / etc. + ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_True); + } + else if (star_wildcard) { + RETURN_IF_FALSE(pattern_helper_sequence_subscr(c, values, star, pc)); + } + else { + RETURN_IF_FALSE(pattern_helper_sequence_unpack(c, values, star, pc)); + } + ADDOP_JUMP(c, JUMP_FORWARD, end); + compiler_use_next_block(c, fail_pop_1); + ADDOP(c, POP_TOP) + ADDOP_LOAD_CONST(c, Py_False); + compiler_use_next_block(c, end); + return 1; +} + + +static int +compiler_pattern_value(struct compiler *c, expr_ty p, pattern_context *pc) +{ + assert(p->kind == Attribute_kind); + assert(p->v.Attribute.ctx == Load); + VISIT(c, expr, p); + ADDOP_COMPARE(c, Eq); + return 1; +} + + +static int +compiler_pattern_wildcard(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 wildcard here! + const char *e = "wildcard makes remaining patterns unreachable"; + return compiler_error(c, e); + } + ADDOP(c, POP_TOP); + ADDOP_LOAD_CONST(c, Py_True); + 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: + 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_class(c, p, pc); + case Constant_kind: + return compiler_pattern_literal(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 MatchAs_kind: + return compiler_pattern_as(c, p, pc); + case MatchOr_kind: + return compiler_pattern_or(c, p, pc); + case Name_kind: + if (WILDCARD_CHECK(p)) { + return compiler_pattern_wildcard(c, p, pc); + } + return compiler_pattern_capture(c, p, pc); + default: + Py_UNREACHABLE(); + } +} + + +static int +compiler_match(struct compiler *c, stmt_ty s) +{ + VISIT(c, expr, s->v.Match.subject); + basicblock *next, *end; + RETURN_IF_FALSE(end = compiler_new_block(c)); + 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 alternatives. + // It's a set of names, but we don't create it until it's needed: + pc.stores = NULL; + 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); + RETURN_IF_FALSE(next = compiler_new_block(c)); + // 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 != NULL || i == cases - 1; + // Only copy the subject if we're *not* on the last case: + if (i != cases - has_default - 1) { + ADDOP(c, DUP_TOP); + } + int result = compiler_pattern(c, m->pattern, &pc); + Py_CLEAR(pc.stores); + RETURN_IF_FALSE(result); + ADDOP_JUMP(c, POP_JUMP_IF_FALSE, next); + NEXT_BLOCK(c); + if (m->guard) { + RETURN_IF_FALSE(compiler_jump_if(c, m->guard, next, 0)); + } + // Success! Pop the subject off, we're done with it: + if (i != cases - has_default - 1) { + ADDOP(c, POP_TOP); + } + VISIT_SEQ(c, stmt, m->body); + ADDOP_JUMP(c, JUMP_FORWARD, end); + compiler_use_next_block(c, next); + } + if (has_default) { + if (cases == 1) { + // No matches. Done with the subject: + 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); + SET_LOC(c, m->pattern); + if (m->guard) { + RETURN_IF_FALSE(compiler_jump_if(c, m->guard, end, 0)); + } + VISIT_SEQ(c, stmt, m->body); + } + compiler_use_next_block(c, end); + return 1; +} + + +#undef WILDCARD_CHECK + + /* End of the compiler section, beginning of the assembler section */ /* do depth-first search of basic block graph, starting with block. diff --git a/Python/importlib_external.h b/Python/importlib_external.h index 32ed87d..6b4cd39 100644 --- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -315,7 +315,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,115,38,0,0,0,16,5,6,1,22,1,4,255, 2,2,14,3,24,1,16,128,18,1,12,1,2,1,12,1, 2,3,12,254,2,1,2,1,2,254,2,253,255,128,114,84, - 0,0,0,105,105,13,0,0,114,45,0,0,0,114,33,0, + 0,0,0,105,106,13,0,0,114,45,0,0,0,114,33,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,119,122,4,46,112,121,99,41,1,218, @@ -429,7 +429,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 90,15,97,108,109,111,115,116,95,102,105,108,101,110,97,109, 101,218,8,102,105,108,101,110,97,109,101,114,7,0,0,0, 114,7,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,85,1,0, + 101,95,102,114,111,109,95,115,111,117,114,99,101,86,1,0, 0,115,74,0,0,0,8,18,6,1,2,1,4,255,8,2, 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,1,8,2,8,1,8,1, @@ -510,7 +510,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,90,9,111,112,116,95,108,101,118,101,108,90,13,98, 97,115,101,95,102,105,108,101,110,97,109,101,114,7,0,0, 0,114,7,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,156,1, + 114,99,101,95,102,114,111,109,95,99,97,99,104,101,157,1, 0,0,115,62,0,0,0,12,9,8,1,10,1,12,1,4, 1,10,1,12,1,14,1,16,1,4,1,4,1,12,1,8, 1,8,1,2,1,8,255,10,2,8,1,14,1,10,1,16, @@ -546,7 +546,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,7,0,0,0,114,7,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,196,1,0,0,115,24,0,0,0,12,7, + 101,102,105,108,101,197,1,0,0,115,24,0,0,0,12,7, 4,1,16,1,24,1,4,1,2,1,12,1,16,1,14,1, 16,1,2,254,255,128,114,120,0,0,0,99,1,0,0,0, 0,0,0,0,0,0,0,0,1,0,0,0,8,0,0,0, @@ -559,7 +559,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 112,108,101,114,113,0,0,0,114,109,0,0,0,114,95,0, 0,0,114,101,0,0,0,41,1,114,108,0,0,0,114,7, 0,0,0,114,7,0,0,0,114,8,0,0,0,218,11,95, - 103,101,116,95,99,97,99,104,101,100,215,1,0,0,115,20, + 103,101,116,95,99,97,99,104,101,100,216,1,0,0,115,20, 0,0,0,14,1,2,1,10,1,12,1,6,1,14,1,4, 1,4,2,2,251,255,128,114,124,0,0,0,99,1,0,0, 0,0,0,0,0,0,0,0,0,2,0,0,0,8,0,0, @@ -574,7 +574,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,65,0,0,0,114,64,0,0,0,41,2,114, 58,0,0,0,114,66,0,0,0,114,7,0,0,0,114,7, 0,0,0,114,8,0,0,0,218,10,95,99,97,108,99,95, - 109,111,100,101,227,1,0,0,115,16,0,0,0,2,2,14, + 109,111,100,101,228,1,0,0,115,16,0,0,0,2,2,14, 1,12,1,6,1,8,3,4,1,2,251,255,128,114,126,0, 0,0,99,1,0,0,0,0,0,0,0,0,0,0,0,3, 0,0,0,4,0,0,0,3,0,0,0,115,52,0,0,0, @@ -611,7 +611,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,102,114,128,0,0,0,218,4,97,114,103,115,218,6,107, 119,97,114,103,115,169,1,218,6,109,101,116,104,111,100,114, 7,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,247,1, + 107,95,110,97,109,101,95,119,114,97,112,112,101,114,248,1, 0,0,115,20,0,0,0,8,1,8,1,10,1,4,1,8, 1,2,255,2,1,6,255,24,2,255,128,122,40,95,99,104, 101,99,107,95,110,97,109,101,46,60,108,111,99,97,108,115, @@ -630,14 +630,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 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,82,0,0,0,114,7,0, 0,0,114,7,0,0,0,114,8,0,0,0,218,5,95,119, - 114,97,112,4,2,0,0,115,12,0,0,0,8,1,10,1, + 114,97,112,5,2,0,0,115,12,0,0,0,8,1,10,1, 18,1,2,128,18,1,255,128,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,2,218,10,95,98,111,111,116, 115,116,114,97,112,114,145,0,0,0,41,3,114,134,0,0, 0,114,135,0,0,0,114,145,0,0,0,114,7,0,0,0, 114,133,0,0,0,114,8,0,0,0,218,11,95,99,104,101, - 99,107,95,110,97,109,101,239,1,0,0,115,14,0,0,0, + 99,107,95,110,97,109,101,240,1,0,0,115,14,0,0,0, 14,8,8,10,8,1,8,2,10,6,4,1,255,128,114,147, 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, @@ -665,7 +665,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,109,101,218,6,108,111,97,100,101,114,218,8,112,111,114, 116,105,111,110,115,218,3,109,115,103,114,7,0,0,0,114, 7,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,14,2,0,0, + 95,109,111,100,117,108,101,95,115,104,105,109,15,2,0,0, 115,12,0,0,0,14,10,16,1,4,1,22,1,4,1,255, 128,114,154,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, @@ -733,7 +733,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 115,90,5,109,97,103,105,99,114,105,0,0,0,114,17,0, 0,0,114,7,0,0,0,114,7,0,0,0,114,8,0,0, 0,218,13,95,99,108,97,115,115,105,102,121,95,112,121,99, - 31,2,0,0,115,30,0,0,0,12,16,8,1,16,1,12, + 32,2,0,0,115,30,0,0,0,12,16,8,1,16,1,12, 1,16,1,12,1,10,1,12,1,8,1,16,1,8,2,16, 1,16,1,4,1,255,128,114,163,0,0,0,99,5,0,0, 0,0,0,0,0,0,0,0,0,6,0,0,0,4,0,0, @@ -788,7 +788,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,114,162,0,0,0,114,105,0,0,0,114,7,0, 0,0,114,7,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,64,2,0,0,115,20,0,0,0,24,19, + 112,95,112,121,99,65,2,0,0,115,20,0,0,0,24,19, 10,1,12,1,16,1,8,1,22,1,2,255,22,2,8,254, 255,128,114,167,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, @@ -834,7 +834,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, 128,0,0,0,114,162,0,0,0,114,7,0,0,0,114,7, 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,92,2,0,0, + 97,116,101,95,104,97,115,104,95,112,121,99,93,2,0,0, 115,16,0,0,0,16,17,2,1,8,1,4,255,2,2,6, 254,4,255,255,128,114,169,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, @@ -858,7 +858,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,42,0,0,0,114,128,0,0,0,114,118,0,0,0,114, 119,0,0,0,218,4,99,111,100,101,114,7,0,0,0,114, 7,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,116,2,0,0, + 105,108,101,95,98,121,116,101,99,111,100,101,117,2,0,0, 115,20,0,0,0,10,2,10,1,12,1,8,1,12,1,4, 1,10,2,4,1,6,255,255,128,114,176,0,0,0,99,3, 0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,5, @@ -877,7 +877,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,166,0,0,0,114,42,0,0,0,114,7,0,0,0,114, 7,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,129,2,0,0,115,14,0,0,0,8,2,14,1,14,1, + 99,130,2,0,0,115,14,0,0,0,8,2,14,1,14,1, 14,1,16,1,4,1,255,128,114,181,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, @@ -895,7 +895,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,90,7,99,104,101,99,107,101,100,114,42,0,0,0, 114,17,0,0,0,114,7,0,0,0,114,7,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,139,2,0,0,115,16,0,0,0, + 97,115,104,95,112,121,99,140,2,0,0,115,16,0,0,0, 8,2,12,1,14,1,16,1,10,1,16,1,4,1,255,128, 114,182,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, @@ -923,7 +923,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 105,110,103,90,15,110,101,119,108,105,110,101,95,100,101,99, 111,100,101,114,114,7,0,0,0,114,7,0,0,0,114,8, 0,0,0,218,13,100,101,99,111,100,101,95,115,111,117,114, - 99,101,150,2,0,0,115,12,0,0,0,8,5,12,1,10, + 99,101,151,2,0,0,115,12,0,0,0,8,5,12,1,10, 1,12,1,20,1,255,128,114,187,0,0,0,169,2,114,151, 0,0,0,218,26,115,117,98,109,111,100,117,108,101,95,115, 101,97,114,99,104,95,108,111,99,97,116,105,111,110,115,99, @@ -984,7 +984,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 8,115,117,102,102,105,120,101,115,114,193,0,0,0,90,7, 100,105,114,110,97,109,101,114,7,0,0,0,114,7,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,167, + 109,95,102,105,108,101,95,108,111,99,97,116,105,111,110,168, 2,0,0,115,74,0,0,0,8,12,4,4,10,1,2,2, 14,1,14,1,4,1,2,251,10,7,16,8,6,1,8,3, 14,1,14,1,10,1,6,1,4,1,2,253,4,5,8,3, @@ -1023,7 +1023,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,114,20,0,0,0,114,7,0,0,0,114,7,0,0, 0,114,8,0,0,0,218,14,95,111,112,101,110,95,114,101, - 103,105,115,116,114,121,247,2,0,0,115,12,0,0,0,2, + 103,105,115,116,114,121,248,2,0,0,115,12,0,0,0,2, 2,16,1,12,1,18,1,2,255,255,128,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,115,116,114, @@ -1050,7 +1050,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 116,114,121,95,107,101,121,114,21,0,0,0,90,4,104,107, 101,121,218,8,102,105,108,101,112,97,116,104,114,7,0,0, 0,114,7,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,254,2,0, + 97,114,99,104,95,114,101,103,105,115,116,114,121,255,2,0, 0,115,30,0,0,0,6,2,8,1,6,2,6,1,16,1, 6,255,2,2,12,1,26,1,18,128,4,3,12,254,6,1, 2,255,255,128,122,38,87,105,110,100,111,119,115,82,101,103, @@ -1073,7 +1073,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,218,6,116,97,114,103,101,116,114,210,0,0,0, 114,151,0,0,0,114,200,0,0,0,114,198,0,0,0,114, 7,0,0,0,114,7,0,0,0,114,8,0,0,0,218,9, - 102,105,110,100,95,115,112,101,99,13,3,0,0,115,36,0, + 102,105,110,100,95,115,112,101,99,14,3,0,0,115,36,0, 0,0,10,2,8,1,4,1,2,1,12,1,12,1,6,1, 14,1,14,1,6,1,8,1,2,1,6,254,8,3,2,252, 4,255,2,254,255,128,122,31,87,105,110,100,111,119,115,82, @@ -1093,7 +1093,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 169,4,114,209,0,0,0,114,150,0,0,0,114,58,0,0, 0,114,198,0,0,0,114,7,0,0,0,114,7,0,0,0, 114,8,0,0,0,218,11,102,105,110,100,95,109,111,100,117, - 108,101,29,3,0,0,115,10,0,0,0,12,7,8,1,6, + 108,101,30,3,0,0,115,10,0,0,0,12,7,8,1,6, 1,4,2,255,128,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,101,41,2,78,78,41,1,78,41, @@ -1105,7 +1105,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 104,111,100,114,204,0,0,0,218,11,99,108,97,115,115,109, 101,116,104,111,100,114,211,0,0,0,114,214,0,0,0,114, 217,0,0,0,114,7,0,0,0,114,7,0,0,0,114,7, - 0,0,0,114,8,0,0,0,114,202,0,0,0,235,2,0, + 0,0,0,114,8,0,0,0,114,202,0,0,0,236,2,0, 0,115,32,0,0,0,8,0,4,2,2,3,2,255,2,4, 2,255,12,3,2,2,10,1,2,6,10,1,2,14,12,1, 2,15,16,1,255,128,114,202,0,0,0,99,0,0,0,0, @@ -1142,7 +1142,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,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,7, 0,0,0,114,7,0,0,0,114,8,0,0,0,114,193,0, - 0,0,48,3,0,0,115,10,0,0,0,18,3,16,1,14, + 0,0,49,3,0,0,115,10,0,0,0,18,3,16,1,14, 1,16,1,255,128,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,0,0,0, @@ -1152,7 +1152,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,32,99,114,101,97,116,105,111,110,46,78,114,7,0,0, 0,169,2,114,130,0,0,0,114,198,0,0,0,114,7,0, 0,0,114,7,0,0,0,114,8,0,0,0,218,13,99,114, - 101,97,116,101,95,109,111,100,117,108,101,56,3,0,0,243, + 101,97,116,101,95,109,111,100,117,108,101,57,3,0,0,243, 4,0,0,0,4,0,255,128,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, @@ -1172,7 +1172,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 111,118,101,100,218,4,101,120,101,99,114,143,0,0,0,41, 3,114,130,0,0,0,218,6,109,111,100,117,108,101,114,175, 0,0,0,114,7,0,0,0,114,7,0,0,0,114,8,0, - 0,0,218,11,101,120,101,99,95,109,111,100,117,108,101,59, + 0,0,218,11,101,120,101,99,95,109,111,100,117,108,101,60, 3,0,0,115,14,0,0,0,12,2,8,1,6,1,4,1, 6,255,20,2,255,128,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, @@ -1184,14 +1184,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,218,17,95,108,111,97,100,95,109,111,100,117,108,101,95, 115,104,105,109,169,2,114,130,0,0,0,114,150,0,0,0, 114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,218, - 11,108,111,97,100,95,109,111,100,117,108,101,67,3,0,0, + 11,108,111,97,100,95,109,111,100,117,108,101,68,3,0,0, 115,4,0,0,0,12,3,255,128,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,137,0,0,0,114,136,0,0, 0,114,138,0,0,0,114,139,0,0,0,114,193,0,0,0, 114,226,0,0,0,114,232,0,0,0,114,235,0,0,0,114, 7,0,0,0,114,7,0,0,0,114,7,0,0,0,114,8, - 0,0,0,114,222,0,0,0,43,3,0,0,115,14,0,0, + 0,0,0,114,222,0,0,0,44,3,0,0,115,14,0,0, 0,8,0,4,2,8,3,8,8,8,3,12,8,255,128,114, 222,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, @@ -1216,7 +1216,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,32,32,32,32,32,32,78,41,1,114,64,0,0,0,169, 2,114,130,0,0,0,114,58,0,0,0,114,7,0,0,0, 114,7,0,0,0,114,8,0,0,0,218,10,112,97,116,104, - 95,109,116,105,109,101,75,3,0,0,115,4,0,0,0,4, + 95,109,116,105,109,101,76,3,0,0,115,4,0,0,0,4, 6,255,128,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, @@ -1250,7 +1250,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 108,101,100,46,10,32,32,32,32,32,32,32,32,114,180,0, 0,0,78,41,1,114,238,0,0,0,114,237,0,0,0,114, 7,0,0,0,114,7,0,0,0,114,8,0,0,0,218,10, - 112,97,116,104,95,115,116,97,116,115,83,3,0,0,115,4, + 112,97,116,104,95,115,116,97,116,115,84,3,0,0,115,4, 0,0,0,14,12,255,128,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, @@ -1274,7 +1274,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 4,114,130,0,0,0,114,119,0,0,0,90,10,99,97,99, 104,101,95,112,97,116,104,114,42,0,0,0,114,7,0,0, 0,114,7,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,97,3,0,0, + 99,104,101,95,98,121,116,101,99,111,100,101,98,3,0,0, 115,4,0,0,0,12,8,255,128,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, @@ -1291,7 +1291,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 102,105,108,101,115,46,10,32,32,32,32,32,32,32,32,78, 114,7,0,0,0,41,3,114,130,0,0,0,114,58,0,0, 0,114,42,0,0,0,114,7,0,0,0,114,7,0,0,0, - 114,8,0,0,0,114,240,0,0,0,107,3,0,0,114,227, + 114,8,0,0,0,114,240,0,0,0,108,3,0,0,114,227, 0,0,0,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, @@ -1311,7 +1311,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,187,0,0,0,41,5,114,130,0,0,0,114,150,0,0, 0,114,58,0,0,0,114,185,0,0,0,218,3,101,120,99, 114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,218, - 10,103,101,116,95,115,111,117,114,99,101,114,3,0,0,115, + 10,103,101,116,95,115,111,117,114,99,101,115,3,0,0,115, 26,0,0,0,10,2,2,1,12,1,8,4,14,253,4,1, 2,1,4,255,2,1,2,255,8,128,2,255,255,128,122,23, 83,111,117,114,99,101,76,111,97,100,101,114,46,103,101,116, @@ -1334,7 +1334,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 112,105,108,101,41,4,114,130,0,0,0,114,42,0,0,0, 114,58,0,0,0,114,245,0,0,0,114,7,0,0,0,114, 7,0,0,0,114,8,0,0,0,218,14,115,111,117,114,99, - 101,95,116,111,95,99,111,100,101,124,3,0,0,115,8,0, + 101,95,116,111,95,99,111,100,101,125,3,0,0,115,8,0, 0,0,12,5,4,1,6,255,255,128,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,0,0,0, @@ -1412,7 +1412,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,17,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, 7,0,0,0,114,7,0,0,0,114,8,0,0,0,114,228, - 0,0,0,132,3,0,0,115,170,0,0,0,10,7,4,1, + 0,0,0,133,3,0,0,115,170,0,0,0,10,7,4,1, 4,1,4,1,4,1,4,1,2,1,12,1,14,1,10,1, 2,2,14,1,14,1,6,1,12,2,2,1,14,1,14,1, 4,1,2,3,2,1,6,254,2,4,12,1,16,1,12,1, @@ -1429,7 +1429,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 238,0,0,0,114,239,0,0,0,114,241,0,0,0,114,240, 0,0,0,114,244,0,0,0,114,248,0,0,0,114,228,0, 0,0,114,7,0,0,0,114,7,0,0,0,114,7,0,0, - 0,114,8,0,0,0,114,236,0,0,0,73,3,0,0,115, + 0,114,8,0,0,0,114,236,0,0,0,74,3,0,0,115, 18,0,0,0,8,0,8,2,8,8,8,14,8,10,8,7, 14,10,12,8,255,128,114,236,0,0,0,99,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0, @@ -1457,7 +1457,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,32,102,105,110,100,101,114,46,78,114,170,0,0,0,41, 3,114,130,0,0,0,114,150,0,0,0,114,58,0,0,0, 114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,114, - 223,0,0,0,222,3,0,0,115,6,0,0,0,6,3,10, + 223,0,0,0,223,3,0,0,115,6,0,0,0,6,3,10, 1,255,128,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,0, @@ -1466,7 +1466,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,169,2,218,9,95,95,99,108,97,115,115,95,95, 114,143,0,0,0,169,2,114,130,0,0,0,90,5,111,116, 104,101,114,114,7,0,0,0,114,7,0,0,0,114,8,0, - 0,0,218,6,95,95,101,113,95,95,228,3,0,0,243,8, + 0,0,218,6,95,95,101,113,95,95,229,3,0,0,243,8, 0,0,0,12,1,10,1,2,255,255,128,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, @@ -1475,7 +1475,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,121,0,0,0,169,3,218,4,104,97,115,104,114,128,0, 0,0,114,58,0,0,0,169,1,114,130,0,0,0,114,7, 0,0,0,114,7,0,0,0,114,8,0,0,0,218,8,95, - 95,104,97,115,104,95,95,232,3,0,0,243,4,0,0,0, + 95,104,97,115,104,95,95,233,3,0,0,243,4,0,0,0, 20,1,255,128,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, @@ -1489,7 +1489,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 116,101,97,100,46,10,10,32,32,32,32,32,32,32,32,78, 41,3,218,5,115,117,112,101,114,114,254,0,0,0,114,235, 0,0,0,114,234,0,0,0,169,1,114,1,1,0,0,114, - 7,0,0,0,114,8,0,0,0,114,235,0,0,0,235,3, + 7,0,0,0,114,8,0,0,0,114,235,0,0,0,236,3, 0,0,115,4,0,0,0,16,10,255,128,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, @@ -1500,7 +1500,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,102,111,117,110,100,32,98,121,32,116,104,101,32,102,105, 110,100,101,114,46,78,114,62,0,0,0,114,234,0,0,0, 114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,114, - 190,0,0,0,247,3,0,0,243,4,0,0,0,6,3,255, + 190,0,0,0,248,3,0,0,243,4,0,0,0,6,3,255, 128,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,0,0,8,0,0,0,67, @@ -1521,7 +1521,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 112,101,110,95,99,111,100,101,114,97,0,0,0,90,4,114, 101,97,100,114,80,0,0,0,41,3,114,130,0,0,0,114, 58,0,0,0,114,83,0,0,0,114,7,0,0,0,114,7, - 0,0,0,114,8,0,0,0,114,242,0,0,0,252,3,0, + 0,0,0,114,8,0,0,0,114,242,0,0,0,253,3,0, 0,115,16,0,0,0,14,2,16,1,22,1,20,128,14,2, 22,1,20,128,255,128,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, @@ -1534,7 +1534,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 130,0,0,0,114,231,0,0,0,114,18,1,0,0,114,7, 0,0,0,114,7,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,5,4,0,0,115,6,0,0,0,12,2,8,1,255, + 101,114,6,4,0,0,115,6,0,0,0,12,2,8,1,255, 128,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,41,13,114,137,0,0,0,114,136,0,0,0,114,138,0, @@ -1543,7 +1543,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,190,0,0,0,114,242,0,0,0,114,19,1,0,0,90, 13,95,95,99,108,97,115,115,99,101,108,108,95,95,114,7, 0,0,0,114,7,0,0,0,114,12,1,0,0,114,8,0, - 0,0,114,254,0,0,0,217,3,0,0,115,26,0,0,0, + 0,0,114,254,0,0,0,218,3,0,0,115,26,0,0,0, 8,0,4,2,8,3,8,6,8,4,2,3,14,1,2,11, 10,1,8,4,2,9,18,1,255,128,114,254,0,0,0,99, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -1566,7 +1566,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 95,109,116,105,109,101,90,7,115,116,95,115,105,122,101,41, 3,114,130,0,0,0,114,58,0,0,0,114,253,0,0,0, 114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,114, - 239,0,0,0,15,4,0,0,115,6,0,0,0,8,2,14, + 239,0,0,0,16,4,0,0,115,6,0,0,0,8,2,14, 1,255,128,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,0,0,0,5,0,0, @@ -1576,7 +1576,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,101,41,2,114,126,0,0,0,114,240,0,0,0,41,5, 114,130,0,0,0,114,119,0,0,0,114,118,0,0,0,114, 42,0,0,0,114,66,0,0,0,114,7,0,0,0,114,7, - 0,0,0,114,8,0,0,0,114,241,0,0,0,20,4,0, + 0,0,0,114,8,0,0,0,114,241,0,0,0,21,4,0, 0,115,6,0,0,0,8,2,16,1,255,128,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,75, @@ -1612,7 +1612,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,218,6,112,97,114,101,110,116,114,108,0,0,0,114,53, 0,0,0,114,49,0,0,0,114,243,0,0,0,114,7,0, 0,0,114,7,0,0,0,114,8,0,0,0,114,240,0,0, - 0,25,4,0,0,115,58,0,0,0,12,2,4,1,12,2, + 0,26,4,0,0,115,58,0,0,0,12,2,4,1,12,2, 12,1,10,1,12,254,12,4,10,1,2,1,14,1,12,1, 4,2,14,1,6,3,4,1,4,255,16,2,8,128,2,1, 12,1,18,1,14,1,8,2,2,1,18,255,8,128,2,254, @@ -1621,7 +1621,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 41,7,114,137,0,0,0,114,136,0,0,0,114,138,0,0, 0,114,139,0,0,0,114,239,0,0,0,114,241,0,0,0, 114,240,0,0,0,114,7,0,0,0,114,7,0,0,0,114, - 7,0,0,0,114,8,0,0,0,114,20,1,0,0,11,4, + 7,0,0,0,114,8,0,0,0,114,20,1,0,0,12,4, 0,0,115,12,0,0,0,8,0,4,2,8,2,8,5,18, 5,255,128,114,20,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, @@ -1644,7 +1644,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,0,41,5,114,130,0,0,0,114,150,0,0,0,114, 58,0,0,0,114,42,0,0,0,114,162,0,0,0,114,7, 0,0,0,114,7,0,0,0,114,8,0,0,0,114,228,0, - 0,0,60,4,0,0,115,24,0,0,0,10,1,10,1,2, + 0,0,61,4,0,0,115,24,0,0,0,10,1,10,1,2, 4,2,1,6,254,12,4,2,1,14,1,2,1,2,1,6, 253,255,128,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, @@ -1654,13 +1654,13 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 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,7,0,0, 0,114,234,0,0,0,114,7,0,0,0,114,7,0,0,0, - 114,8,0,0,0,114,244,0,0,0,76,4,0,0,114,25, + 114,8,0,0,0,114,244,0,0,0,77,4,0,0,114,25, 0,0,0,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,137,0,0,0,114,136,0,0, 0,114,138,0,0,0,114,139,0,0,0,114,228,0,0,0, 114,244,0,0,0,114,7,0,0,0,114,7,0,0,0,114, - 7,0,0,0,114,8,0,0,0,114,26,1,0,0,56,4, + 7,0,0,0,114,8,0,0,0,114,26,1,0,0,57,4, 0,0,115,10,0,0,0,8,0,4,2,8,2,12,16,255, 128,114,26,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, @@ -1682,20 +1682,20 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 100,0,83,0,114,121,0,0,0,114,170,0,0,0,41,3, 114,130,0,0,0,114,128,0,0,0,114,58,0,0,0,114, 7,0,0,0,114,7,0,0,0,114,8,0,0,0,114,223, - 0,0,0,89,4,0,0,115,6,0,0,0,6,1,10,1, + 0,0,0,90,4,0,0,115,6,0,0,0,6,1,10,1, 255,128,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,0,2,0,0, 0,2,0,0,0,67,0,0,0,114,255,0,0,0,114,121, 0,0,0,114,0,1,0,0,114,2,1,0,0,114,7,0, 0,0,114,7,0,0,0,114,8,0,0,0,114,3,1,0, - 0,93,4,0,0,114,4,1,0,0,122,26,69,120,116,101, + 0,94,4,0,0,114,4,1,0,0,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,0,0, 0,0,0,1,0,0,0,3,0,0,0,67,0,0,0,114, 5,1,0,0,114,121,0,0,0,114,6,1,0,0,114,8, 1,0,0,114,7,0,0,0,114,7,0,0,0,114,8,0, - 0,0,114,9,1,0,0,97,4,0,0,114,10,1,0,0, + 0,0,114,9,1,0,0,98,4,0,0,114,10,1,0,0, 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,0,0,0,3,0,0,0,5, @@ -1712,7 +1712,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,109,105,99,114,160,0,0,0,114,128,0,0,0,114,58, 0,0,0,41,3,114,130,0,0,0,114,198,0,0,0,114, 231,0,0,0,114,7,0,0,0,114,7,0,0,0,114,8, - 0,0,0,114,226,0,0,0,100,4,0,0,115,16,0,0, + 0,0,0,114,226,0,0,0,101,4,0,0,115,16,0,0, 0,4,2,6,1,4,255,6,2,8,1,4,255,4,2,255, 128,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,116,101,95,109,111, @@ -1730,7 +1730,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 105,99,114,160,0,0,0,114,128,0,0,0,114,58,0,0, 0,169,2,114,130,0,0,0,114,231,0,0,0,114,7,0, 0,0,114,7,0,0,0,114,8,0,0,0,114,232,0,0, - 0,108,4,0,0,115,10,0,0,0,14,2,6,1,8,1, + 0,109,4,0,0,115,10,0,0,0,14,2,6,1,8,1, 8,255,255,128,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,101,99,2,0,0,0,0,0,0,0,0,0, @@ -1748,14 +1748,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 78,114,7,0,0,0,169,2,114,5,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,7,0,0,0,114,8,0,0,0,114,9,0,0, - 0,117,4,0,0,115,8,0,0,0,4,0,2,1,20,255, + 0,118,4,0,0,115,8,0,0,0,4,0,2,1,20,255, 255,128,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,112,114,62,78,41,4,114,61,0,0,0,114,58,0, 0,0,218,3,97,110,121,114,219,0,0,0,114,234,0,0, 0,114,7,0,0,0,114,30,1,0,0,114,8,0,0,0, - 114,193,0,0,0,114,4,0,0,115,10,0,0,0,14,2, + 114,193,0,0,0,115,4,0,0,115,10,0,0,0,14,2, 12,1,2,1,8,255,255,128,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, @@ -1766,7 +1766,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 110,111,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,7,0,0,0,114, 234,0,0,0,114,7,0,0,0,114,7,0,0,0,114,8, - 0,0,0,114,228,0,0,0,120,4,0,0,114,25,0,0, + 0,0,0,114,228,0,0,0,121,4,0,0,114,25,0,0, 0,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, @@ -1776,13 +1776,13 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 115,32,104,97,118,101,32,110,111,32,115,111,117,114,99,101, 32,99,111,100,101,46,78,114,7,0,0,0,114,234,0,0, 0,114,7,0,0,0,114,7,0,0,0,114,8,0,0,0, - 114,244,0,0,0,124,4,0,0,114,25,0,0,0,122,30, + 114,244,0,0,0,125,4,0,0,114,25,0,0,0,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,114,13,1,0,0,114,14,1,0, 0,114,62,0,0,0,114,234,0,0,0,114,7,0,0,0, - 114,7,0,0,0,114,8,0,0,0,114,190,0,0,0,128, + 114,7,0,0,0,114,8,0,0,0,114,190,0,0,0,129, 4,0,0,114,15,1,0,0,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,137,0, @@ -1791,7 +1791,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,226,0,0,0,114,232,0,0,0,114,193,0,0,0,114, 228,0,0,0,114,244,0,0,0,114,147,0,0,0,114,190, 0,0,0,114,7,0,0,0,114,7,0,0,0,114,7,0, - 0,0,114,8,0,0,0,114,17,1,0,0,81,4,0,0, + 0,0,114,8,0,0,0,114,17,1,0,0,82,4,0,0, 115,26,0,0,0,8,0,4,2,8,6,8,4,8,4,8, 3,8,8,8,6,8,6,8,4,2,4,14,1,255,128,114, 17,1,0,0,99,0,0,0,0,0,0,0,0,0,0,0, @@ -1834,7 +1834,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 102,105,110,100,101,114,169,4,114,130,0,0,0,114,128,0, 0,0,114,58,0,0,0,90,11,112,97,116,104,95,102,105, 110,100,101,114,114,7,0,0,0,114,7,0,0,0,114,8, - 0,0,0,114,223,0,0,0,141,4,0,0,115,10,0,0, + 0,0,0,114,223,0,0,0,142,4,0,0,115,10,0,0, 0,6,1,6,1,14,1,10,1,255,128,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, @@ -1852,7 +1852,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,0,0,218,3,100,111,116,90,2,109,101,114,7,0,0, 0,114,7,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,147,4,0,0,115,10,0,0,0,18,2,8, + 97,109,101,115,148,4,0,0,115,10,0,0,0,18,2,8, 1,4,2,8,3,255,128,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,97,109,101,115,99, @@ -1865,7 +1865,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 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,7,0,0,0,114,7,0,0,0,114,8,0, - 0,0,114,35,1,0,0,157,4,0,0,115,6,0,0,0, + 0,0,114,35,1,0,0,158,4,0,0,115,6,0,0,0, 12,1,16,1,255,128,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,0,0,0, @@ -1881,7 +1881,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 34,1,0,0,41,3,114,130,0,0,0,90,11,112,97,114, 101,110,116,95,112,97,116,104,114,198,0,0,0,114,7,0, 0,0,114,7,0,0,0,114,8,0,0,0,218,12,95,114, - 101,99,97,108,99,117,108,97,116,101,161,4,0,0,115,18, + 101,99,97,108,99,117,108,97,116,101,162,4,0,0,115,18, 0,0,0,12,2,10,1,14,1,18,3,6,1,8,1,6, 1,6,1,255,128,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,97, @@ -1890,7 +1890,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 116,0,124,0,160,1,161,0,131,1,83,0,114,121,0,0, 0,41,2,218,4,105,116,101,114,114,42,1,0,0,114,8, 1,0,0,114,7,0,0,0,114,7,0,0,0,114,8,0, - 0,0,218,8,95,95,105,116,101,114,95,95,174,4,0,0, + 0,0,218,8,95,95,105,116,101,114,95,95,175,4,0,0, 243,4,0,0,0,12,1,255,128,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, @@ -1899,7 +1899,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,169,1,114,42,1,0,0,41,2,114,130,0,0,0,218, 5,105,110,100,101,120,114,7,0,0,0,114,7,0,0,0, 114,8,0,0,0,218,11,95,95,103,101,116,105,116,101,109, - 95,95,177,4,0,0,114,46,1,0,0,122,26,95,78,97, + 95,95,178,4,0,0,114,46,1,0,0,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, @@ -1907,7 +1907,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,83,0,114,121,0,0,0,41,1,114,34,1,0,0,41, 3,114,130,0,0,0,114,48,1,0,0,114,58,0,0,0, 114,7,0,0,0,114,7,0,0,0,114,8,0,0,0,218, - 11,95,95,115,101,116,105,116,101,109,95,95,180,4,0,0, + 11,95,95,115,101,116,105,116,101,109,95,95,181,4,0,0, 115,4,0,0,0,14,1,255,128,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, @@ -1915,7 +1915,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,0,0,114,121,0,0,0,41,2,114,4,0,0,0,114, 42,1,0,0,114,8,1,0,0,114,7,0,0,0,114,7, 0,0,0,114,8,0,0,0,218,7,95,95,108,101,110,95, - 95,183,4,0,0,114,46,1,0,0,122,22,95,78,97,109, + 95,184,4,0,0,114,46,1,0,0,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,0,0,0,67,0,0,0,243,12,0,0,0, @@ -1923,7 +1923,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 20,95,78,97,109,101,115,112,97,99,101,80,97,116,104,40, 123,33,114,125,41,41,2,114,77,0,0,0,114,34,1,0, 0,114,8,1,0,0,114,7,0,0,0,114,7,0,0,0, - 114,8,0,0,0,218,8,95,95,114,101,112,114,95,95,186, + 114,8,0,0,0,218,8,95,95,114,101,112,114,95,95,187, 4,0,0,114,46,1,0,0,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, @@ -1931,7 +1931,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 1,124,0,160,0,161,0,118,0,83,0,114,121,0,0,0, 114,47,1,0,0,169,2,114,130,0,0,0,218,4,105,116, 101,109,114,7,0,0,0,114,7,0,0,0,114,8,0,0, - 0,218,12,95,95,99,111,110,116,97,105,110,115,95,95,189, + 0,218,12,95,95,99,111,110,116,97,105,110,115,95,95,190, 4,0,0,114,46,1,0,0,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, @@ -1939,7 +1939,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,121,0,0,0,41,2,114,34,1,0,0,114, 197,0,0,0,114,54,1,0,0,114,7,0,0,0,114,7, - 0,0,0,114,8,0,0,0,114,197,0,0,0,192,4,0, + 0,0,0,114,8,0,0,0,114,197,0,0,0,193,4,0, 0,243,4,0,0,0,16,1,255,128,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,137,0,0,0,114,136,0,0,0,114,138, @@ -1948,7 +1948,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,114,49,1,0,0,114,50,1,0,0,114,51,1,0,0, 114,53,1,0,0,114,56,1,0,0,114,197,0,0,0,114, 7,0,0,0,114,7,0,0,0,114,7,0,0,0,114,8, - 0,0,0,114,32,1,0,0,134,4,0,0,115,28,0,0, + 0,0,0,114,32,1,0,0,135,4,0,0,115,28,0,0, 0,8,0,4,1,8,6,8,6,8,10,8,4,8,13,8, 3,8,3,8,3,8,3,8,3,12,3,255,128,114,32,1, 0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -1964,7 +1964,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,116,0,124,1,124,2,124,3,131,3,124,0,95,1, 100,0,83,0,114,121,0,0,0,41,2,114,32,1,0,0, 114,34,1,0,0,114,38,1,0,0,114,7,0,0,0,114, - 7,0,0,0,114,8,0,0,0,114,223,0,0,0,198,4, + 7,0,0,0,114,8,0,0,0,114,223,0,0,0,199,4, 0,0,115,4,0,0,0,18,1,255,128,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,1,0,0,0,0,0,0,0,0, @@ -1981,20 +1981,20 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 112,97,99,101,41,62,78,41,2,114,77,0,0,0,114,137, 0,0,0,41,1,114,231,0,0,0,114,7,0,0,0,114, 7,0,0,0,114,8,0,0,0,218,11,109,111,100,117,108, - 101,95,114,101,112,114,201,4,0,0,115,4,0,0,0,12, + 101,95,114,101,112,114,202,4,0,0,115,4,0,0,0,12, 7,255,128,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,114,24,0,0,0,41, 2,78,84,114,7,0,0,0,114,234,0,0,0,114,7,0, 0,0,114,7,0,0,0,114,8,0,0,0,114,193,0,0, - 0,210,4,0,0,243,4,0,0,0,4,1,255,128,122,27, + 0,211,4,0,0,243,4,0,0,0,4,1,255,128,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,114,24,0,0,0,41,2,78,114,10,0,0, 0,114,7,0,0,0,114,234,0,0,0,114,7,0,0,0, - 114,7,0,0,0,114,8,0,0,0,114,244,0,0,0,213, + 114,7,0,0,0,114,8,0,0,0,114,244,0,0,0,214, 4,0,0,114,60,1,0,0,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, @@ -2004,20 +2004,20 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,105,110,103,62,114,230,0,0,0,84,41,1,114,246,0, 0,0,41,1,114,247,0,0,0,114,234,0,0,0,114,7, 0,0,0,114,7,0,0,0,114,8,0,0,0,114,228,0, - 0,0,216,4,0,0,114,57,1,0,0,122,25,95,78,97, + 0,0,217,4,0,0,114,57,1,0,0,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,114, 24,0,0,0,114,224,0,0,0,114,7,0,0,0,114,225, 0,0,0,114,7,0,0,0,114,7,0,0,0,114,8,0, - 0,0,114,226,0,0,0,219,4,0,0,114,227,0,0,0, + 0,0,114,226,0,0,0,220,4,0,0,114,227,0,0,0, 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,121,0,0,0,114,7,0,0,0,114,27,1,0, 0,114,7,0,0,0,114,7,0,0,0,114,8,0,0,0, - 114,232,0,0,0,222,4,0,0,114,60,1,0,0,122,28, + 114,232,0,0,0,223,4,0,0,114,60,1,0,0,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,0,2,0,0,0,4,0,0, @@ -2035,7 +2035,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,125,78,41,4,114,146,0,0,0,114,160,0,0,0,114, 34,1,0,0,114,233,0,0,0,114,234,0,0,0,114,7, 0,0,0,114,7,0,0,0,114,8,0,0,0,114,235,0, - 0,0,225,4,0,0,115,10,0,0,0,6,7,4,1,4, + 0,0,226,4,0,0,115,10,0,0,0,6,7,4,1,4, 255,12,3,255,128,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,137,0,0,0,114,136,0,0,0, @@ -2043,7 +2043,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 59,1,0,0,114,193,0,0,0,114,244,0,0,0,114,228, 0,0,0,114,226,0,0,0,114,232,0,0,0,114,235,0, 0,0,114,7,0,0,0,114,7,0,0,0,114,7,0,0, - 0,114,8,0,0,0,114,58,1,0,0,197,4,0,0,115, + 0,114,8,0,0,0,114,58,1,0,0,198,4,0,0,115, 22,0,0,0,8,0,8,1,2,3,10,1,8,8,8,3, 8,3,8,3,8,3,12,3,255,128,114,58,1,0,0,99, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -2080,7 +2080,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 95,99,97,99,104,101,218,5,105,116,101,109,115,114,140,0, 0,0,114,62,1,0,0,41,2,114,128,0,0,0,218,6, 102,105,110,100,101,114,114,7,0,0,0,114,7,0,0,0, - 114,8,0,0,0,114,62,1,0,0,244,4,0,0,115,16, + 114,8,0,0,0,114,62,1,0,0,245,4,0,0,115,16, 0,0,0,22,4,8,1,10,1,10,1,8,1,2,128,4, 252,255,128,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, @@ -2100,7 +2100,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 89,0,0,0,114,149,0,0,0,114,129,0,0,0,41,2, 114,58,0,0,0,90,4,104,111,111,107,114,7,0,0,0, 114,7,0,0,0,114,8,0,0,0,218,11,95,112,97,116, - 104,95,104,111,111,107,115,254,4,0,0,115,20,0,0,0, + 104,95,104,111,111,107,115,255,4,0,0,115,20,0,0,0, 16,3,12,1,10,1,2,1,14,1,12,1,4,1,4,2, 2,253,255,128,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, @@ -2132,7 +2132,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,41,3,114,209,0,0,0,114,58,0,0,0,114,66, 1,0,0,114,7,0,0,0,114,7,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,11,5,0,0,115,30,0,0, + 101,114,95,99,97,99,104,101,12,5,0,0,115,30,0,0, 0,8,8,2,1,12,1,12,1,6,3,2,1,12,1,4, 4,12,253,10,1,12,1,4,1,2,253,2,250,255,128,122, 31,80,97,116,104,70,105,110,100,101,114,46,95,112,97,116, @@ -2150,7 +2150,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 209,0,0,0,114,150,0,0,0,114,66,1,0,0,114,151, 0,0,0,114,152,0,0,0,114,198,0,0,0,114,7,0, 0,0,114,7,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,33,5, + 101,103,97,99,121,95,103,101,116,95,115,112,101,99,34,5, 0,0,115,20,0,0,0,10,4,16,1,10,2,4,1,8, 1,12,1,12,1,6,1,4,1,255,128,122,27,80,97,116, 104,70,105,110,100,101,114,46,95,108,101,103,97,99,121,95, @@ -2182,7 +2182,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 101,95,112,97,116,104,90,5,101,110,116,114,121,114,66,1, 0,0,114,198,0,0,0,114,152,0,0,0,114,7,0,0, 0,114,7,0,0,0,114,8,0,0,0,218,9,95,103,101, - 116,95,115,112,101,99,48,5,0,0,115,44,0,0,0,4, + 116,95,115,112,101,99,49,5,0,0,115,44,0,0,0,4, 5,8,1,14,1,2,1,10,1,8,1,10,1,14,1,12, 2,8,1,2,1,10,1,8,1,6,1,8,1,8,1,10, 5,2,128,12,2,6,1,4,1,255,128,122,20,80,97,116, @@ -2209,7 +2209,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,1,0,0,41,6,114,209,0,0,0,114,150,0,0,0, 114,58,0,0,0,114,213,0,0,0,114,198,0,0,0,114, 74,1,0,0,114,7,0,0,0,114,7,0,0,0,114,8, - 0,0,0,114,214,0,0,0,80,5,0,0,115,28,0,0, + 0,0,0,114,214,0,0,0,81,5,0,0,115,28,0,0, 0,8,6,6,1,14,1,8,1,4,1,10,1,6,1,4, 1,6,3,16,1,4,1,4,2,4,2,255,128,122,20,80, 97,116,104,70,105,110,100,101,114,46,102,105,110,100,95,115, @@ -2229,7 +2229,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 105,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,215, 0,0,0,114,216,0,0,0,114,7,0,0,0,114,7,0, - 0,0,114,8,0,0,0,114,217,0,0,0,104,5,0,0, + 0,0,114,8,0,0,0,114,217,0,0,0,105,5,0,0, 115,10,0,0,0,12,8,8,1,4,1,6,1,255,128,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,0,0,0,0,0,0,0,0, @@ -2261,7 +2261,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 18,102,105,110,100,95,100,105,115,116,114,105,98,117,116,105, 111,110,115,41,3,114,131,0,0,0,114,132,0,0,0,114, 76,1,0,0,114,7,0,0,0,114,7,0,0,0,114,8, - 0,0,0,114,77,1,0,0,117,5,0,0,115,6,0,0, + 0,0,0,114,77,1,0,0,118,5,0,0,115,6,0,0, 0,12,10,16,1,255,128,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, @@ -2271,7 +2271,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 72,1,0,0,114,75,1,0,0,114,214,0,0,0,114,217, 0,0,0,114,77,1,0,0,114,7,0,0,0,114,7,0, 0,0,114,7,0,0,0,114,8,0,0,0,114,61,1,0, - 0,240,4,0,0,115,38,0,0,0,8,0,4,2,2,2, + 0,241,4,0,0,115,38,0,0,0,8,0,4,2,2,2, 10,1,2,9,10,1,2,12,10,1,2,21,10,1,2,14, 12,1,2,31,12,1,2,23,12,1,2,12,14,1,255,128, 114,61,1,0,0,99,0,0,0,0,0,0,0,0,0,0, @@ -2316,7 +2316,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,102,2,86,0,1,0,113,2,100,0,83,0,114,121,0, 0,0,114,7,0,0,0,114,28,1,0,0,169,1,114,151, 0,0,0,114,7,0,0,0,114,8,0,0,0,114,9,0, - 0,0,146,5,0,0,114,14,0,0,0,122,38,70,105,108, + 0,0,147,5,0,0,114,14,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,86,0,0,0,114,116,0,0,0,78,41,7, @@ -2328,7 +2328,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 58,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,200,0, 0,0,114,7,0,0,0,114,79,1,0,0,114,8,0,0, - 0,114,223,0,0,0,140,5,0,0,115,18,0,0,0,4, + 0,114,223,0,0,0,141,5,0,0,115,18,0,0,0,4, 4,12,1,26,1,6,1,10,2,6,1,8,1,12,1,255, 128,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,0,0,0,0, @@ -2338,7 +2338,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 32,100,105,114,101,99,116,111,114,121,32,109,116,105,109,101, 46,114,116,0,0,0,78,41,1,114,81,1,0,0,114,8, 1,0,0,114,7,0,0,0,114,7,0,0,0,114,8,0, - 0,0,114,62,1,0,0,154,5,0,0,114,69,0,0,0, + 0,0,114,62,1,0,0,155,5,0,0,114,69,0,0,0, 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,0,3,0,0,0,3, @@ -2361,7 +2361,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 41,3,114,214,0,0,0,114,151,0,0,0,114,189,0,0, 0,41,3,114,130,0,0,0,114,150,0,0,0,114,198,0, 0,0,114,7,0,0,0,114,7,0,0,0,114,8,0,0, - 0,114,148,0,0,0,160,5,0,0,115,10,0,0,0,10, + 0,114,148,0,0,0,161,5,0,0,115,10,0,0,0,10, 7,8,1,8,1,16,1,255,128,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,0,0,7,0, @@ -2372,7 +2372,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 199,0,0,0,114,150,0,0,0,114,58,0,0,0,90,4, 115,109,115,108,114,213,0,0,0,114,151,0,0,0,114,7, 0,0,0,114,7,0,0,0,114,8,0,0,0,114,75,1, - 0,0,172,5,0,0,115,10,0,0,0,10,1,8,1,2, + 0,0,173,5,0,0,115,10,0,0,0,10,1,8,1,2, 1,6,255,255,128,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,0,0, @@ -2427,7 +2427,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 110,105,116,95,102,105,108,101,110,97,109,101,90,9,102,117, 108,108,95,112,97,116,104,114,198,0,0,0,114,7,0,0, 0,114,7,0,0,0,114,8,0,0,0,114,214,0,0,0, - 177,5,0,0,115,80,0,0,0,4,5,14,1,2,1,24, + 178,5,0,0,115,80,0,0,0,4,5,14,1,2,1,24, 1,14,1,6,1,10,1,8,1,6,1,6,2,6,1,10, 1,6,2,4,1,8,2,12,1,14,1,8,1,10,1,8, 1,24,1,2,255,8,5,14,2,16,1,16,1,14,1,10, @@ -2458,7 +2458,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 104,0,124,0,93,12,125,1,124,1,160,0,161,0,146,2, 113,4,83,0,114,7,0,0,0,41,1,114,117,0,0,0, 41,2,114,5,0,0,0,90,2,102,110,114,7,0,0,0, - 114,7,0,0,0,114,8,0,0,0,114,13,0,0,0,254, + 114,7,0,0,0,114,8,0,0,0,114,13,0,0,0,255, 5,0,0,115,4,0,0,0,20,0,255,128,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, @@ -2476,7 +2476,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,55,1,0,0,114,128,0,0,0,114,39,1,0,0,114, 29,1,0,0,90,8,110,101,119,95,110,97,109,101,114,7, 0,0,0,114,7,0,0,0,114,8,0,0,0,114,86,1, - 0,0,225,5,0,0,115,40,0,0,0,6,2,2,1,22, + 0,0,226,5,0,0,115,40,0,0,0,6,2,2,1,22, 1,18,1,6,3,12,3,12,1,6,7,8,1,16,1,4, 1,18,1,4,2,12,1,6,1,12,1,20,1,4,255,2, 233,255,128,122,22,70,105,108,101,70,105,110,100,101,114,46, @@ -2515,14 +2515,14 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 169,2,114,209,0,0,0,114,85,1,0,0,114,7,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, - 10,6,0,0,115,8,0,0,0,8,2,12,1,16,1,255, + 11,6,0,0,115,8,0,0,0,8,2,12,1,16,1,255, 128,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,78,114,7,0,0,0,41, 3,114,209,0,0,0,114,85,1,0,0,114,91,1,0,0, 114,7,0,0,0,114,90,1,0,0,114,8,0,0,0,218, - 9,112,97,116,104,95,104,111,111,107,0,6,0,0,115,6, + 9,112,97,116,104,95,104,111,111,107,1,6,0,0,115,6, 0,0,0,14,10,4,6,255,128,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,0, @@ -2530,7 +2530,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 122,16,70,105,108,101,70,105,110,100,101,114,40,123,33,114, 125,41,41,2,114,77,0,0,0,114,58,0,0,0,114,8, 1,0,0,114,7,0,0,0,114,7,0,0,0,114,8,0, - 0,0,114,53,1,0,0,18,6,0,0,114,46,1,0,0, + 0,0,114,53,1,0,0,19,6,0,0,114,46,1,0,0, 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,137,0,0,0,114, 136,0,0,0,114,138,0,0,0,114,139,0,0,0,114,223, @@ -2538,7 +2538,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,114,148,0,0,0,114,75,1,0,0,114,214,0,0, 0,114,86,1,0,0,114,221,0,0,0,114,92,1,0,0, 114,53,1,0,0,114,7,0,0,0,114,7,0,0,0,114, - 7,0,0,0,114,8,0,0,0,114,78,1,0,0,131,5, + 7,0,0,0,114,8,0,0,0,114,78,1,0,0,132,5, 0,0,115,26,0,0,0,8,0,4,2,8,7,8,14,4, 4,8,2,8,12,10,5,8,48,2,31,10,1,12,17,255, 128,114,78,1,0,0,99,4,0,0,0,0,0,0,0,0, @@ -2562,7 +2562,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 97,109,101,90,9,99,112,97,116,104,110,97,109,101,114,151, 0,0,0,114,198,0,0,0,114,7,0,0,0,114,7,0, 0,0,114,8,0,0,0,218,14,95,102,105,120,95,117,112, - 95,109,111,100,117,108,101,24,6,0,0,115,38,0,0,0, + 95,109,111,100,117,108,101,25,6,0,0,115,38,0,0,0, 10,2,10,1,4,1,4,1,8,1,8,1,12,1,10,2, 4,1,14,1,2,1,8,1,8,1,8,1,14,1,12,1, 6,2,2,254,255,128,114,97,1,0,0,99,0,0,0,0, @@ -2582,7 +2582,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 0,0,114,101,0,0,0,41,3,90,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,7,0,0,0,114,7,0,0, - 0,114,8,0,0,0,114,195,0,0,0,47,6,0,0,115, + 0,114,8,0,0,0,114,195,0,0,0,48,6,0,0,115, 10,0,0,0,12,5,8,1,8,1,10,1,255,128,114,195, 0,0,0,99,1,0,0,0,0,0,0,0,0,0,0,0, 1,0,0,0,1,0,0,0,67,0,0,0,115,8,0,0, @@ -2591,7 +2591,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,97,112,95,109,111,100,117,108,101,114,7,0,0,0,114, 7,0,0,0,114,8,0,0,0,218,21,95,115,101,116,95, 98,111,111,116,115,116,114,97,112,95,109,111,100,117,108,101, - 58,6,0,0,115,4,0,0,0,8,2,255,128,114,100,1, + 59,6,0,0,115,4,0,0,0,8,2,255,128,114,100,1, 0,0,99,1,0,0,0,0,0,0,0,0,0,0,0,2, 0,0,0,4,0,0,0,67,0,0,0,115,50,0,0,0, 116,0,124,0,131,1,1,0,116,1,131,0,125,1,116,2, @@ -2606,7 +2606,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 114,197,0,0,0,114,61,1,0,0,41,2,114,99,1,0, 0,90,17,115,117,112,112,111,114,116,101,100,95,108,111,97, 100,101,114,115,114,7,0,0,0,114,7,0,0,0,114,8, - 0,0,0,218,8,95,105,110,115,116,97,108,108,63,6,0, + 0,0,0,218,8,95,105,110,115,116,97,108,108,64,6,0, 0,115,10,0,0,0,8,2,6,1,20,1,16,1,255,128, 114,102,1,0,0,41,1,114,75,0,0,0,41,1,78,41, 3,78,78,78,41,2,114,0,0,0,0,114,0,0,0,0, @@ -2649,7 +2649,7 @@ const unsigned char _Py_M__importlib_bootstrap_external[] = { 2,4,3,10,1,6,2,22,2,8,1,10,1,14,1,4, 4,4,1,2,1,2,1,4,255,8,4,6,16,8,3,8, 5,8,5,8,6,8,6,8,12,8,10,8,9,8,5,8, - 7,10,9,10,22,0,127,16,24,12,1,4,2,4,1,6, + 7,10,9,10,22,0,127,16,25,12,1,4,2,4,1,6, 2,6,1,10,1,8,2,6,2,8,2,16,2,8,71,8, 40,8,19,8,12,8,12,8,31,8,17,8,33,8,28,10, 24,10,13,10,10,8,11,6,14,4,3,2,1,12,255,14, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 8495871..692442a 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -29,11 +29,11 @@ static void *opcode_targets[256] = { &&TARGET_BINARY_TRUE_DIVIDE, &&TARGET_INPLACE_FLOOR_DIVIDE, &&TARGET_INPLACE_TRUE_DIVIDE, - &&_unknown_opcode, - &&_unknown_opcode, - &&_unknown_opcode, - &&_unknown_opcode, - &&_unknown_opcode, + &&TARGET_GET_LEN, + &&TARGET_MATCH_MAPPING, + &&TARGET_MATCH_SEQUENCE, + &&TARGET_MATCH_KEYS, + &&TARGET_COPY_DICT_WITHOUT_KEYS, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, @@ -151,7 +151,7 @@ static void *opcode_targets[256] = { &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, - &&_unknown_opcode, + &&TARGET_MATCH_CLASS, &&_unknown_opcode, &&TARGET_SETUP_ASYNC_WITH, &&TARGET_FORMAT_VALUE, diff --git a/Python/pystate.c b/Python/pystate.c index 1623bab..e7c085d 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -308,6 +308,8 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate) 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); diff --git a/Python/symtable.c b/Python/symtable.c index cce1b1b..10a47d1 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -207,6 +207,7 @@ static int symtable_visit_argannotations(struct symtable *st, asdl_arg_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, @@ -239,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); @@ -1294,6 +1296,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.subject); + 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); @@ -1648,6 +1654,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); @@ -1667,6 +1680,13 @@ 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; + case MatchOr_kind: + VISIT_SEQ(st, expr, e->v.MatchOr.patterns); + break; } VISIT_QUIT(st, 1); } @@ -1785,6 +1805,20 @@ symtable_visit_withitem(struct symtable *st, withitem_ty item) return 1; } +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); + } + VISIT_SEQ(st, stmt, m->body); + return 1; +} static int symtable_visit_alias(struct symtable *st, alias_ty a) |