From 217c36b3529d2d3160bfea150b1133863e6dc886 Mon Sep 17 00:00:00 2001 From: PierreQuentel Date: Fri, 19 Jan 2024 10:11:09 +0100 Subject: [PATCH] Improve generated PEG parser. Related to issue #2354 --- www/src/action_helpers_generated_version.js | 1041 + www/src/gen_parse.js | 30808 ++++++++++++++++++ www/src/pegen.js | 42 +- www/src/python_parser_peg_version.js | 6 +- www/src/python_tokenizer.js | 15 +- 5 files changed, 31871 insertions(+), 41 deletions(-) create mode 100644 www/src/action_helpers_generated_version.js create mode 100644 www/src/gen_parse.js diff --git a/www/src/action_helpers_generated_version.js b/www/src/action_helpers_generated_version.js new file mode 100644 index 000000000..a341de4eb --- /dev/null +++ b/www/src/action_helpers_generated_version.js @@ -0,0 +1,1041 @@ +// Adapted from CPython Parser/action_helpers.c +(function($B){ +"use strict"; + +var _b_ = $B.builtins, + NULL = undefined, + DOT = '.', + ELLIPSIS = '...', + DEL_TARGETS = 'del_targets' + +function EXTRA_EXPR(head, tail){ + return { + lineno: head.lineno, + col_offset: head.col_offset, + end_lineno: tail.end_lineno, + end_col_offset: tail.end_col_offset + } +} + +function set_list(list, other){ + for(var item of other){ + list.push(item) + } +} + +var positions = ['lineno', 'col_offset', 'end_lineno', 'end_col_offset'] + +function set_position_from_list(ast_obj, EXTRA){ + for(var i = 0; i < 4; i++){ + ast_obj[positions[i]] = EXTRA[i] + } +} + +function set_position_from_token(ast_obj, token){ + ast_obj.lineno = token.lineno + ast_obj.col_offset = token.col_offset + ast_obj.end_lineno = token.end_lineno + ast_obj.end_col_offset = token.end_col_offset +} + +function set_position_from_obj(ast_obj, obj){ + for(var position of positions){ + ast_obj[position] = obj[position] + } +} + +function _get_names(p, names_with_defaults){ + var seq = [] + for (var pair of names_with_defaults) { + seq.push(pair.arg) + } + return seq +} + +function _get_defaults(p, names_with_defaults){ + var seq = [] + for (var pair of names_with_defaults){ + seq.push(pair.value) + } + return seq +} + +function _make_posonlyargs(p, + slash_without_default, + slash_with_default, + posonlyargs) { + if (slash_without_default != NULL) { + set_list(posonlyargs, slash_without_default) + }else if (slash_with_default != NULL) { + var slash_with_default_names = + _get_names(p, slash_with_default.names_with_defaults); + if (!slash_with_default_names) { + return -1; + } + set_list(posonlyargs, $B._PyPegen.join_sequences( + p, + slash_with_default.plain_names, + slash_with_default_names)) + } + return posonlyargs == NULL ? -1 : 0; +} + +function _make_posargs(p, + plain_names, + names_with_default, + posargs) { + if (plain_names != NULL && names_with_default != NULL) { + var names_with_default_names = _get_names(p, names_with_default); + if (!names_with_default_names) { + return -1; + } + var seqs = $B._PyPegen.join_sequences( + p, plain_names, names_with_default_names) + set_list(posargs, seqs); + }else if (plain_names == NULL && names_with_default != NULL) { + set_list(posargs, _get_names(p, names_with_default)) + } + else if (plain_names != NULL && names_with_default == NULL) { + set_list(posargs, plain_names) + } + return posargs == NULL ? -1 : 0; +} + +function _make_posdefaults(p, + slash_with_default, + names_with_default, + posdefaults) { + if (slash_with_default != NULL && names_with_default != NULL) { + var slash_with_default_values = + _get_defaults(p, slash_with_default.names_with_defaults); + if (!slash_with_default_values) { + return -1; + } + var names_with_default_values = _get_defaults(p, names_with_default); + if (!names_with_default_values) { + return -1; + } + set_list(posdefaults, $B._PyPegen.join_sequences( + p, + slash_with_default_values, + names_with_default_values)) + }else if (slash_with_default == NULL && names_with_default != NULL) { + set_list(posdefaults, _get_defaults(p, names_with_default)) + } + else if (slash_with_default != NULL && names_with_default == NULL) { + set_list(posdefaults, + _get_defaults(p, slash_with_default.names_with_defaults)) + } + return posdefaults == NULL ? -1 : 0; +} + +function _make_kwargs(p, star_etc, + kwonlyargs, + kwdefaults) { + if (star_etc != NULL && star_etc.kwonlyargs != NULL) { + set_list(kwonlyargs, _get_names(p, star_etc.kwonlyargs)) + }else { + set_list(kwonlyargs, []) + } + + if (kwonlyargs == NULL) { + return -1; + } + + if (star_etc != NULL && star_etc.kwonlyargs != NULL) { + set_list(kwdefaults, _get_defaults(p, star_etc.kwonlyargs)) + } + else { + set_list(kwdefaults, []) + } + + if (kwdefaults == NULL) { + return -1; + } + + return 0; +} + +function _seq_number_of_starred_exprs(seq){ + var n = 0 + for(var k of seq){ + if(! k.is_keyword){ + n++; + } + } + return n +} + +$B._PyPegen = {} + +$B._PyPegen.constant_from_string = function(p, token){ + var prepared = $B.prepare_string(token) + var is_bytes = prepared.value.startsWith('b') + if(! is_bytes){ + var value = $B.make_string_for_ast_value(prepared.value) + }else{ + value = prepared.value.substr(2, prepared.value.length - 3) + try{ + value = _b_.bytes.$factory($B.encode_bytestring(value)) + }catch(err){ + $B._PyPegen.raise_error_known_location(p, + _b_.SyntaxError, + token.start[0], token.start[1], token.end[0], token.end[1], + 'bytes can only contain ASCII literal characters') + } + } + var ast_obj = new $B.ast.Constant(value) + set_position_from_token(ast_obj, token) + return ast_obj +} + +$B._PyPegen.constant_from_token = function(p, t){ + var ast_obj = new $B.ast.Constant(t.string) + set_position_from_token(ast_obj, t) + return ast_obj +} + +$B._PyPegen.decoded_constant_from_token = function(p, t){ + var ast_obj = new $B.ast.Constant(t.string) + set_position_from_token(ast_obj, t) + return ast_obj +} + +$B._PyPegen.formatted_value = function(p, + expression, debug, conversion, format, closing_brace, + arena){ + var conversion_val = -1 + if(conversion){ + var conversion_expr = conversion.result, + first = conversion_expr.id + if(first.length > 1 || ! 'sra'.includes(first)){ + $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION(conversion_expr, + `f-string: invalid conversion character {first}: ` + + "expected 's', 'r', or 'a'") + } + var conversion_val = first.charCodeAt(0) + } + var formatted_value = new $B.ast.FormattedValue(expression, + conversion_val, + format === undefined ? format : format.result) + set_position_from_obj(formatted_value, p.arena) + if(debug){ + var debug_end_line, + debug_end_offset, + debug_metadata + if(conversion){ + debug_end_line = conversion.result.lineno + debug_end_offset = conversion.result.col_offset + debug_metadata = conversion.metadata + }else if(format){ + debug_end_line = format.result.lineno + debug_end_offset = format.result.col_offset + 1 + debug_metadata = format.metadata + }else{ + debug_end_line = p.end_lineno + debug_end_offset = p.end_col_offset + debug_metadata = closing_brace.metadata + } + var debug = new $B.ast.Constant(debug_metadata) + debug.lineno = p.lineno + debug.col_offset = p.col_offset + 1 + debug.end_lineno = debug_end_line + debug.end_col_offset = debug_end_offset + var joined_str = new $B.ast.JoinedStr([debug, formatted_value]) + set_position_from_obj(joined_str, p.arena) + return joined_str + } + return formatted_value +} + +$B._PyPegen.joined_str = function(p, a, items, c){ + var ast_obj = new $B.ast.JoinedStr(items) + ast_obj.lineno = a.lineno + ast_obj.col_offset = a.col_offset + ast_obj.end_lineno = c.end_lineno + ast_obj.end_col_offset = c.end_col_offset + return ast_obj +} + +$B._PyPegen.setup_full_format_spec = function(p, colon, spec, arena){ + var ast_obj = new $B.ast.JoinedStr(spec) + set_position_from_obj(ast_obj, arena) + return result_token_with_metadata(p, ast_obj, colon.metadata) +} + +function result_token_with_metadata(p, result, metadata){ + return {result, metadata} +} + +$B._PyPegen.check_fstring_conversion = function(p, conv_token, conv){ + if(conv_token.lineno != conv.lineno || + conv_token.end_col_offset != conv.col_offset){ + $B._PyPegen.raise_error_known_location(p, _b_.SyntaxError, + conv.lineno, conv.col_offset, conv.end_lineno, conv.end_col_offset, + "f-string: conversion type must come right after the exclamanation mark" + ) + } + return result_token_with_metadata(p, conv, conv_token.metadata) +} + +$B._PyPegen.seq_count_dots = function(seq){ + if(seq === undefined){ + return 0 + } + var number_of_dots = 0; + for(var token of seq){ + if(token.type == 'OP'){ + number_of_dots += token.string.length + } + } + + return number_of_dots; +} + +/* Creates a new asdl_seq* with the identifiers of all the names in seq */ +$B._PyPegen.map_names_to_ids = function(p, seq){ + return seq.map(e => e.id) +} + +$B._PyPegen.alias_for_star = function(p, lineno, col_offset, end_lineno, + end_col_offset, arena) { + var str = "*" + return $B._PyAST.alias(str, NULL, lineno, col_offset, end_lineno, end_col_offset, arena); +} + +/* Constructs a CmpopExprPair */ +$B._PyPegen.cmpop_expr_pair = function(p, cmpop, expr){ + return {cmpop, expr} +} + +$B._PyPegen.get_cmpops = function(p, seq){ + var new_seq = [] + for (var pair of seq) { + new_seq.push(pair.cmpop) + } + return new_seq +} + +$B._PyPegen.get_exprs = function(p, seq){ + var new_seq = [] + for (var pair of seq) { + new_seq.push(pair.expr) + } + return new_seq +} + +/* Creates an asdl_seq* where all the elements have been changed to have ctx as context */ +function _set_seq_context(p, seq, ctx){ + var new_seq = [] + for (var e of seq) { + new_seq.push($B._PyPegen.set_expr_context(p, e, ctx)) + } + return new_seq +} + +function _set_name_context(p, e, ctx){ + return $B._PyAST.Name(e.id, ctx, EXTRA_EXPR(e, e)) +} + +function _set_tuple_context(p, e, ctx){ + return $B._PyAST.Tuple( + _set_seq_context(p, e.elts, ctx), + ctx, + EXTRA_EXPR(e, e)); +} + +function _set_list_context(p, e, ctx){ + return $B._PyAST.List( + _set_seq_context(p, e.elts, ctx), + ctx, + EXTRA_EXPR(e, e)); +} + +function _set_subscript_context(p, e, ctx){ + console.log('set subscritp cntext', p, e) + return $B._PyAST.Subscript(e.value, e.slice, + ctx, EXTRA_EXPR(e, e)); +} + +function _set_attribute_context(p, e, ctx){ + return $B._PyAST.Attribute(e.value, e.attr, + ctx, EXTRA_EXPR(e, e)); +} + +function _set_starred_context(p, e, ctx){ + return $B._PyAST.Starred($B._PyPegen.set_expr_context(p, e.value, ctx), + ctx, EXTRA_EXPR(e, e)); +} + +/* Creates an `expr_ty` equivalent to `expr` but with `ctx` as context */ +$B._PyPegen.set_expr_context = function(p, expr, ctx){ + var _new = NULL; + switch (expr.constructor) { + case $B.ast.Name: + _new = _set_name_context(p, expr, ctx); + break; + case $B.ast.Tuple: + _new = _set_tuple_context(p, expr, ctx); + break; + case $B.ast.List: + _new = _set_list_context(p, expr, ctx); + break; + case $B.ast.Subscript: + _new = _set_subscript_context(p, expr, ctx); + break; + case $B.ast.Attribute: + _new = _set_attribute_context(p, expr, ctx); + break; + case $B.ast.Starred: + _new = _set_starred_context(p, expr, ctx); + break; + default: + _new = expr; + } + return _new; +} + +/* Constructs a KeyValuePair that is used when parsing a dict's key value pairs */ +$B._PyPegen.key_value_pair = function(p, key, value){ + return {key, value} +} + +$B._PyPegen.get_expr_name = function(e){ + switch(e.constructor.$name){ + case 'Attribute': + case 'Subscript': + case 'Starred': + case 'Name': + case 'List': + case 'Tuple': + case 'Lambda': + return e.constructor.$name.toLowerCase() + case 'Call': + return "function call" + case 'BoolOp': + case 'BinOp': + case 'UnaryOp': + return "expression" + case 'GeneratorExp': + return "generator expression"; + case 'Yield': + case 'YieldFrom': + return "yield expression"; + case 'Await': + return "await expression"; + case 'ListComp': + return "list comprehension"; + case 'SetComp': + return "set comprehension"; + case 'DictComp': + return "dict comprehension"; + case 'Dict': + return "dict literal"; + case 'Set': + return "set display"; + case 'JoinedStr': + case 'FormattedValue': + return "f-string expression"; + case 'Constant': + var value = e.value + if (value === _b_.None) { + return "None"; + } + if (value === false) { + return "False"; + } + if (value === true) { + return "True"; + } + if (value.type == 'ellipsis') { + return "ellipsis"; + } + return "literal"; + case 'Compare': + return "comparison"; + case 'IfExp': + return "conditional expression"; + case 'NamedExpr': + return "named expression"; + default: + PyErr_Format(PyExc_SystemError, + "unexpected expression in assignment %d (line %d)", + e.kind, e.lineno); + return NULL; + } +} + +/* Extracts all keys from an asdl_seq* of KeyValuePair*'s */ +$B._PyPegen.get_keys = function(p, seq){ + return seq === undefined ? [] : seq.map(pair => pair.key) +} + +/* Extracts all values from an asdl_seq* of KeyValuePair*'s */ +$B._PyPegen.get_values = function(p, seq){ + return seq === undefined ? [] : seq.map(pair => pair.value) +} + +/* Constructs a KeyPatternPair that is used when parsing mapping & class patterns */ +$B._PyPegen.key_pattern_pair = function(p, key, pattern){ + return {key, pattern} +} + +/* Extracts all keys from an asdl_seq* of KeyPatternPair*'s */ +$B._PyPegen.get_pattern_keys = function(p, seq){ + return seq === undefined ? [] : seq.map(x => x.key) +} + +/* Extracts all patterns from an asdl_seq* of KeyPatternPair*'s */ +$B._PyPegen.get_patterns = function(p, seq){ + return seq === undefined ? [] : seq.map(x => x.pattern) +} + +$B._PyPegen.check_legacy_stmt = function(p, name){ + return ["print", "exec"].includes(name) +} + +$B._PyPegen.dummy_name = function(p){ + var cache = NULL; + + if (cache != NULL) { + return cache; + } + + var id = "", + ast_obj = new $B.ast.Name(id, new $B.ast.Load()) + set_position_from_list(ast_obj, [1, 0, 1, 0]) + return cache; +} + +$B._PyPegen.add_type_comment_to_arg = function(p, a, tc){ + if (tc == NULL) { + return a + } + var bytes = _b_.bytes.$factory(tc), + tco = $B._PyPegen.new_type_comment(p, bytes); + var ast_obj = $B._PyAST.arg(a.arg, a.annotation, tco, + a.lineno, a.col_offset, a.end_lineno, a.end_col_offset, + p.arena); + console.log('arg with type comment', ast_obj) + return ast_obj +} + +/* Checks if the NOTEQUAL token is valid given the current parser flags +0 indicates success and nonzero indicates failure (an exception may be set) */ +$B._PyPegen.check_barry_as_flufl = function(p, t){ + return false +} + +$B._PyPegen.empty_arguments = function(p){ + return $B._PyAST.arguments([], [], NULL, [], [], NULL, [], p.arena) +} + +/* Encapsulates the value of an operator_ty into an AugOperator struct */ +$B._PyPegen.augoperator = function(p, kind){ + return {kind} +} + +/* Construct a FunctionDef equivalent to function_def, but with decorators */ +$B._PyPegen.function_def_decorators = function(p, decorators, function_def){ + var constr = function_def instanceof $B.ast.AsyncFunctionDef ? + $B.ast.AsyncFunctionDef : $B.ast.FunctionDef + var ast_obj = new constr( + function_def.name, function_def.args, + function_def.body, decorators, function_def.returns, + function_def.type_comment) + for(var position of positions){ + ast_obj[position] = function_def[position] + } + return ast_obj +} + +/* Construct a ClassDef equivalent to class_def, but with decorators */ +$B._PyPegen.class_def_decorators = function(p, decorators, class_def){ + var ast_obj = $B._PyAST.ClassDef( + class_def.name, class_def.bases, + class_def.keywords, class_def.body, decorators) + set_position_from_obj(ast_obj, class_def) + return ast_obj +} + +/* Construct a KeywordOrStarred */ +$B._PyPegen.keyword_or_starred = function(p, element, is_keyword){ + return { + element, + is_keyword + } +} + +$B._PyPegen.make_arguments = function(p, slash_without_default, + slash_with_default, plain_names, + names_with_default, star_etc){ + /* Constructs an arguments_ty object out of all the parsed constructs in the parameters rule */ + var posonlyargs = [] + if (_make_posonlyargs(p, slash_without_default, slash_with_default, posonlyargs) == -1) { + return NULL; + } + + var posargs = [] + if (_make_posargs(p, plain_names, names_with_default, posargs) == -1) { + return NULL; + } + + var posdefaults = [] + if (_make_posdefaults(p,slash_with_default, names_with_default, posdefaults) == -1) { + return NULL; + } + + var vararg = NULL; + if (star_etc != NULL && star_etc.vararg != NULL) { + vararg = star_etc.vararg; + } + + var kwonlyargs = [], + kwdefaults = []; + if (_make_kwargs(p, star_etc, kwonlyargs, kwdefaults) == -1) { + return NULL; + } + + var kwarg = NULL; + if (star_etc != NULL && star_etc.kwarg != NULL) { + kwarg = star_etc.kwarg; + } + + var ast_obj = $B._PyAST.arguments(posonlyargs, posargs, vararg, kwonlyargs, + kwdefaults, kwarg, posdefaults, p.arena) + if(ast_obj.posonlyargs === undefined){ + console.log('pas de posonlyargs', ast_bj) + alert() + } + return ast_obj +} + +$B._PyPegen.name_default_pair = function(p, arg, value, tc){ + return { + arg: $B._PyPegen.add_type_comment_to_arg(p, arg, tc), + value: value + } +} + +$B._PyPegen.raise_error = function(p, errtype, errmsg){ + if(p.fill == 0){ + var va = [errmsg] + $B._PyPegen.raise_error_known_location(p, errtype, 0, 0, 0, -1, errmsg, va); + return NULL + } + + var t = p.known_err_token != NULL ? p.known_err_token : p.tokens[p.fill - 1]; + var va = errmsg + $B._PyPegen.raise_error_known_location(p, errtype, + t.start[0], t.start[1], t.end[0], t.end[1], errmsg, va); +} + +$B._PyPegen.raise_error_known_location = function(p, errtype, + lineno, col_offset, end_lineno, end_col_offset, errmsg, va){ + var exc = errtype.$factory(errmsg) + exc.filename = p.filename + if(p.known_err_token){ + var token = p.known_err_token + exc.lineno = token.start[0] + exc.offset = token.start[1] + 1 + exc.end_lineno = token.end[0] + exc.end_offset = token.end[1] + exc.text = token.line + }else{ + exc.lineno = lineno + exc.offset = col_offset + 1 + exc.end_lineno = end_lineno + exc.end_offset = end_col_offset + 1 + var src = $B.file_cache[p.filename] + if(src !== undefined){ + var lines = src.split('\n'), + line = lines[exc.lineno - 1] + exc.text = line + '\n' + }else{ + exc.text = _b_.None + } + } + exc.args[1] = $B.fast_tuple([p.filename, exc.lineno, exc.offset, exc.text, + exc.end_lineno, exc.end_offset]) + throw exc +} + +$B._PyPegen.seq_delete_starred_exprs = function(p, kwargs){ + var len = kwargs.length, + new_len = len - _seq_number_of_starred_exprs(kwargs) + if (new_len == 0) { + return NULL; + } + var new_seq = [] + + for (var k of kwargs){ + if (k.is_keyword) { + new_seq.push(k.element) + } + } + return new_seq +} + +$B._PyPegen.seq_extract_starred_exprs = function(p, kwargs){ + var new_len = _seq_number_of_starred_exprs(kwargs); + if (new_len == 0) { + return NULL; + } + var new_seq = [] + + var idx = 0; + for (var k of kwargs) { + if (! k.is_keyword) { + new_seq[idx++] = k.element + } + } + return new_seq +} + +/* Constructs a SlashWithDefault */ +$B._PyPegen.slash_with_default = function(p, plain_names, names_with_defaults){ + return {plain_names, names_with_defaults} +} + +$B._PyPegen.star_etc = function(p, vararg, kwonlyargs, kwarg){ + return {vararg, kwonlyargs, kwarg} +} + +$B._PyPegen.collect_call_seqs = function(p, a, b, + lineno, col_offset, end_lineno, + end_col_offset, arena) { + var args_len = a.length, + total_len = args_len; + + if (b == NULL) { + return $B._PyAST.Call($B._PyPegen.dummy_name(p), a, [], lineno, col_offset, + end_lineno, end_col_offset, arena); + } + + var starreds = $B._PyPegen.seq_extract_starred_exprs(p, b), + keywords = $B._PyPegen.seq_delete_starred_exprs(p, b); + + if (starreds) { + total_len += starreds.length + } + + var args = [] + + + for (var i = 0; i < args_len; i++) { + args[i] = a[i] + } + for (; i < total_len; i++) { + args[i] = starreds[i - args_len] + } + + return $B._PyAST.Call($B._PyPegen.dummy_name(p), args, keywords, lineno, + col_offset, end_lineno, end_col_offset, arena); +} + +$B._PyPegen.join_sequences = function(p, a, b){ + return a.concat(b) +} + +function make_conversion_code(conv){ + switch(conv){ + case null: + return -1 + case 'a': + return 97 + case 'r': + return 114 + case 's': + return 115 + } +} + +function make_formatted_value(p, fmt_values){ + // format is a sequence of strings and instances of fstring_expression + if(! fmt_values){ + return + } + var seq = [] + for(var item of fmt_values){ + if(typeof item == 'string'){ + var fmt_ast = new $B.ast.Constant(item) + set_position_from_obj(fmt_ast, p.arena) + }else{ + var src = item.expression.trimStart() // ignore leading whitespace + var _ast = new $B.Parser(src, p.filename, 'eval').parse() + var raw_value = _ast.body + var fmt_ast = new $B.ast.FormattedValue(raw_value, + make_conversion_code(item.conversion), + make_formatted_value(p, item.fmt)) + set_position_from_obj(fmt_ast, _ast) + } + seq.push(fmt_ast) + } + var ast_obj = new $B.ast.JoinedStr(seq) + set_position_from_obj(ast_obj, p.arena) + return ast_obj +} + +$B._PyPegen.concatenate_strings = function(p, strings){ + // console.log('concat', strings) + // strings is a list of tokens + var res = '', + first = strings[0], + last = $B.last(strings), + type + + var state = NULL, + value, + values = [] + + function error(message){ + var a = {lineno: first.start[0], + col_offset: first.start[1], + end_lineno : last.end[0], + end_col_offset: last.end[1] + } + $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, message) + } + + function set_position_from_list(ast_obj, items){ + var first = items[0], + last = items[items.length - 1] + ast_obj.lineno = first.lineno + ast_obj.col_offset = first.col_offset + ast_obj.end_lineno = last.end_lineno + ast_obj.end_col_offset = last.end_col_offset + } + + // make a single list with all the strings + var items = [], + has_fstring = false, + state + for(var token of strings){ + if(token instanceof $B.ast.JoinedStr){ // fstring + has_fstring = true + if(state == 'bytestring'){ + error('cannot mix bytes and nonbytes literals') + } + for(var fs_item of token.values){ + if(fs_item instanceof $B.ast.Constant){ + // escape single quotes not already escaped + var parts = fs_item.value.split('\\\'') + parts = parts.map(x => x.replace(new RegExp("'", "g"), "\\'")) + fs_item.value = parts.join('\\\'') + fs_item.value = fs_item.value.replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + } + items.push(fs_item) + } + state = 'string' + }else{ + items.push(token) + var is_bytes = token.value.__class__ === _b_.bytes + if((is_bytes && state == 'string') || + (state == 'bytestring' && ! is_bytes)){ + error('cannot mix bytes and nonbytes literals') + } + state = is_bytes ? 'bytestring' : 'string' + } + } + + if(state == 'bytestring'){ + // only bytestrings + var bytes = [] + for(var item of items){ + bytes = bytes.concat(item.value.source) + } + value = _b_.bytes.$factory(bytes) + var ast_obj = new $B.ast.Constant(value) + set_position_from_list(ast_obj, items) + return ast_obj + } + + // group consecutive strings + function group_consec_strings(items){ + if(items.length == 1){ + return items[0] + } + var values = items.map(x => x.value) + let ast_obj = new $B.ast.Constant(values.join('')) + set_position_from_list(ast_obj, items) + return ast_obj + } + + var items1 = [], + consec_strs = [], + item_type = null + for(var i = 0, len = items.length; i < len; i++){ + item = items[i] + if(item_type === null){ + item_type = Object.getPrototypeOf(item) + } + if(item instanceof $B.ast.Constant){ + consec_strs.push(item) + }else{ + if(consec_strs.length > 0){ + items1.push(group_consec_strings(consec_strs)) + } + consec_strs = [] + items1.push(item) + } + } + if(consec_strs.length > 0){ + items1.push(group_consec_strings(consec_strs)) + } + + if(! has_fstring){ + return items1[0] + } + + var jstr_values = items1 + + var ast_obj = new $B.ast.JoinedStr(jstr_values) + set_position_from_list(ast_obj, strings) + return ast_obj +} + +$B._PyPegen.ensure_imaginary = function(p, exp){ + if (! (exp instanceof $B.ast.Constant) || + exp.value.__class__ != _b_.complex) { + $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION(exp, + "imaginary number required in complex literal"); + return NULL + } + return exp +} + +$B._PyPegen.ensure_real = function(p, exp){ + if (! (exp instanceof $B.ast.Constant) || exp.value.type == 'imaginary') { + $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION( + exp, + "real number required in complex literal"); + return NULL + } + return exp +} + +$B._PyPegen.set_expr_context = function(p, a, ctx){ + a.ctx = ctx + return a +} + +$B._PyPegen.singleton_seq = function(p, a){ + return [a] +} + +/* Creates a copy of seq and prepends a to it */ +$B._PyPegen.seq_insert_in_front = function(p, a, seq){ + return seq ? [a].concat(seq) : [a] +} + +$B._PyPegen.seq_flatten = function(p, seqs){ + var res = [] + for(var seq of seqs){ + for(var item of seq){ + res.push(item) + } + } + return res +} + +/* Creates a new name of the form . */ +$B._PyPegen.join_names_with_dot = function(p, first_name, second_name){ + var str = first_name.id + '.' + second_name.id + return $B._PyAST.Name(str, new $B.ast.Load(), + EXTRA_EXPR(first_name, second_name)) +} + +$B._PyPegen.make_module = function(p, a){ + return new $B.ast.Module(a) +} + +$B._PyPegen.new_type_comment = function(p, s){ + if(s.length === 0){ + return NULL + } + return s +} + +$B._PyPegen.get_last_comprehension_item = function(comprehension) { + if (comprehension.ifs == NULL || comprehension.ifs.length == 0) { + return comprehension.iter; + } + return $B.last(comprehension.ifs); +} + +$B._PyPegen.nonparen_genexp_in_call = function(p, args, comprehensions){ + /* The rule that calls this function is 'args for_if_clauses'. + For the input f(L, x for x in y), L and x are in args and + the for is parsed as a for_if_clause. We have to check if + len <= 1, so that input like dict((a, b) for a, b in x) + gets successfully parsed and then we pass the last + argument (x in the above example) as the location of the + error */ + var len = args.args.length + if (len <= 1) { + return NULL; + } + + var last_comprehension = $B.last(comprehensions); + + return $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE( + args.args[len - 1], + $B._PyPegen.get_last_comprehension_item(last_comprehension), + "Generator expression must be parenthesized" + ); +} + +$B._PyPegen.get_invalid_target = function(e, targets_type){ + + if (e == NULL) { + return NULL; + } + + function VISIT_CONTAINER(CONTAINER, TYPE){ + for (var elt of CONTAINER.elts) { + var child = $B._PyPegen.get_invalid_target(elt, targets_type); + if (child != NULL) { + return child; + } + } + } + + // We only need to visit List and Tuple nodes recursively as those + // are the only ones that can contain valid names in targets when + // they are parsed as expressions. Any other kind of expression + // that is a container (like Sets or Dicts) is directly invalid and + // we don't need to visit it recursively. + + switch (e.constructor) { + case $B.ast.List: + case $B.ast.Tuple: + VISIT_CONTAINER(e, e.constructor); + return NULL; + case $B.ast.Starred: + if (targets_type == DEL_TARGETS) { + return e; + } + return _PyPegen_get_invalid_target(e.value, targets_type); + case $B.ast.Compare: + // This is needed, because the `a in b` in `for a in b` gets parsed + // as a comparison, and so we need to search the left side of the comparison + // for invalid targets. + if (targets_type == FOR_TARGETS) { + var cmpop = e.ops[0] + if (cmpop == $B.ast.In) { + return _PyPegen_get_invalid_target(e.left, targets_type); + } + return NULL; + } + return e; + case $B.ast.Name: + case $B.ast.Subscript: + case $B.ast.Attribute: + return NULL; + default: + return e; + } +} + +})(__BRYTHON__) \ No newline at end of file diff --git a/www/src/gen_parse.js b/www/src/gen_parse.js new file mode 100644 index 000000000..a846bec97 --- /dev/null +++ b/www/src/gen_parse.js @@ -0,0 +1,30808 @@ +// @generated by pegen from python3.12.gram +function fprintf(dest, format){ + var args = Array.from(arguments).slice(2) + for(var arg of args){ + format = format.replace(/%\*?[a-z]/, arg) + } + return format +} + +const stderr = null + +function D(x){ + console.log(x) +} + +function UNUSED(){ + // does nothing +} + +function strcmp(x, y){ + return x == y ? 0 : x < y ? -1 : 1 +} + +const MAXSTACK = 6000, + NULL = undefined + +const ENDMARKER = 0, + NAME = 1, + NUMBER = 2, + STRING = 3, + NEWLINE = 4, + INDENT = 5, + DEDENT = 6, + LPAR = 7, + RPAR = 8, + LSQB = 9, + RSQB = 10, + COLON = 11, + COMMA = 12, + SEMI = 13, + PLUS = 14, + MINUS = 15, + STAR = 16, + SLASH = 17, + VBAR = 18, + AMPER = 19, + LESS = 20, + GREATER = 21, + EQUAL = 22, + DOT = 23, + PERCENT = 24, + LBRACE = 25, + RBRACE = 26, + EQEQUAL = 27, + NOTEQUAL = 28, + LESSEQUAL = 29, + GREATEREQUAL = 30, + TILDE = 31, + CIRCUMFLEX = 32, + LEFTSHIFT = 33, + RIGHTSHIFT = 34, + DOUBLESTAR = 35, + PLUSEQUAL = 36, + MINEQUAL = 37, + STAREQUAL = 38, + SLASHEQUAL = 39, + PERCENTEQUAL = 40, + AMPEREQUAL = 41, + VBAREQUAL = 42, + CIRCUMFLEXEQUAL = 43, + LEFTSHIFTEQUAL = 44, + RIGHTSHIFTEQUAL = 45, + DOUBLESTAREQUAL = 46, + DOUBLESLASH = 47, + DOUBLESLASHEQUAL = 48, + AT = 49, + ATEQUAL = 50, + RARROW = 51, + ELLIPSIS = 52, + COLONEQUAL = 53, + EXCLAMATION = 54, + OP = 55, + AWAIT = 56, + ASYNC = 57, + TYPE_IGNORE = 58, + TYPE_COMMENT = 59, + SOFT_KEYWORD = 60, + FSTRING_START = 61, + FSTRING_MIDDLE = 62, + FSTRING_END = 63, + COMMENT = 64, + NL = 65, + ERRORTOKEN = 66, + N_TOKENS = 68 + + +function NEW_TYPE_COMMENT(){} + +const Store = new $B.ast.Store(), + Load = new $B.ast.Load + +const EXTRA = {} +const n_keyword_lists = 9; +const reserved_keywords = { + NULL: -1, + NULL: -1, + if: 642, + as: 640, + in: 651, + or: 574, + is: 582, + del: 604, + def: 652, + for: 650, + try: 624, + and: 575, + not: 581, + from: 608, + pass: 504, + with: 615, + elif: 644, + else: 645, + None: 602, + True: 601, + raise: 522, + yield: 573, + break: 508, + class: 654, + while: 647, + False: 603, + return: 519, + import: 607, + assert: 526, + global: 523, + except: 637, + lambda: 600, + finally: 633, + continue: 509, + nonlocal: 524, +}; +const soft_keywords = [ + "_", + "case", + "match", + "type", + NULL, +]; +const file_type = 1000, +interactive_type = 1001, +eval_type = 1002, +func_type_type = 1003, +statements_type = 1004, +statement_type = 1005, +statement_newline_type = 1006, +simple_stmts_type = 1007, +simple_stmt_type = 1008, +compound_stmt_type = 1009, +assignment_type = 1010, +annotated_rhs_type = 1011, +augassign_type = 1012, +return_stmt_type = 1013, +raise_stmt_type = 1014, +global_stmt_type = 1015, +nonlocal_stmt_type = 1016, +del_stmt_type = 1017, +yield_stmt_type = 1018, +assert_stmt_type = 1019, +import_stmt_type = 1020, +import_name_type = 1021, +import_from_type = 1022, +import_from_targets_type = 1023, +import_from_as_names_type = 1024, +import_from_as_name_type = 1025, +dotted_as_names_type = 1026, +dotted_as_name_type = 1027, +dotted_name_type = 1028, +block_type = 1029, +decorators_type = 1030, +class_def_type = 1031, +class_def_raw_type = 1032, +function_def_type = 1033, +function_def_raw_type = 1034, +params_type = 1035, +parameters_type = 1036, +slash_no_default_type = 1037, +slash_with_default_type = 1038, +star_etc_type = 1039, +kwds_type = 1040, +param_no_default_type = 1041, +param_no_default_star_annotation_type = 1042, +param_with_default_type = 1043, +param_maybe_default_type = 1044, +param_type = 1045, +param_star_annotation_type = 1046, +annotation_type = 1047, +star_annotation_type = 1048, +default_type = 1049, +if_stmt_type = 1050, +elif_stmt_type = 1051, +else_block_type = 1052, +while_stmt_type = 1053, +for_stmt_type = 1054, +with_stmt_type = 1055, +with_item_type = 1056, +try_stmt_type = 1057, +except_block_type = 1058, +except_star_block_type = 1059, +finally_block_type = 1060, +match_stmt_type = 1061, +subject_expr_type = 1062, +case_block_type = 1063, +guard_type = 1064, +patterns_type = 1065, +pattern_type = 1066, +as_pattern_type = 1067, +or_pattern_type = 1068, +closed_pattern_type = 1069, +literal_pattern_type = 1070, +literal_expr_type = 1071, +complex_number_type = 1072, +signed_number_type = 1073, +signed_real_number_type = 1074, +real_number_type = 1075, +imaginary_number_type = 1076, +capture_pattern_type = 1077, +pattern_capture_target_type = 1078, +wildcard_pattern_type = 1079, +value_pattern_type = 1080, +attr_type = 1081, +name_or_attr_type = 1082, +group_pattern_type = 1083, +sequence_pattern_type = 1084, +open_sequence_pattern_type = 1085, +maybe_sequence_pattern_type = 1086, +maybe_star_pattern_type = 1087, +star_pattern_type = 1088, +mapping_pattern_type = 1089, +items_pattern_type = 1090, +key_value_pattern_type = 1091, +double_star_pattern_type = 1092, +class_pattern_type = 1093, +positional_patterns_type = 1094, +keyword_patterns_type = 1095, +keyword_pattern_type = 1096, +type_alias_type = 1097, +type_params_type = 1098, +type_param_seq_type = 1099, +type_param_type = 1100, +type_param_bound_type = 1101, +expressions_type = 1102, +expression_type = 1103, +yield_expr_type = 1104, +star_expressions_type = 1105, +star_expression_type = 1106, +star_named_expressions_type = 1107, +star_named_expression_type = 1108, +assignment_expression_type = 1109, +named_expression_type = 1110, +disjunction_type = 1111, +conjunction_type = 1112, +inversion_type = 1113, +comparison_type = 1114, +compare_op_bitwise_or_pair_type = 1115, +eq_bitwise_or_type = 1116, +noteq_bitwise_or_type = 1117, +lte_bitwise_or_type = 1118, +lt_bitwise_or_type = 1119, +gte_bitwise_or_type = 1120, +gt_bitwise_or_type = 1121, +notin_bitwise_or_type = 1122, +in_bitwise_or_type = 1123, +isnot_bitwise_or_type = 1124, +is_bitwise_or_type = 1125, +bitwise_or_type = 1126, +bitwise_xor_type = 1127, +bitwise_and_type = 1128, +shift_expr_type = 1129, +sum_type = 1130, +term_type = 1131, +factor_type = 1132, +power_type = 1133, +await_primary_type = 1134, +primary_type = 1135, +slices_type = 1136, +slice_type = 1137, +atom_type = 1138, +group_type = 1139, +lambdef_type = 1140, +lambda_params_type = 1141, +lambda_parameters_type = 1142, +lambda_slash_no_default_type = 1143, +lambda_slash_with_default_type = 1144, +lambda_star_etc_type = 1145, +lambda_kwds_type = 1146, +lambda_param_no_default_type = 1147, +lambda_param_with_default_type = 1148, +lambda_param_maybe_default_type = 1149, +lambda_param_type = 1150, +fstring_middle_type = 1151, +fstring_replacement_field_type = 1152, +fstring_conversion_type = 1153, +fstring_full_format_spec_type = 1154, +fstring_format_spec_type = 1155, +fstring_type = 1156, +string_type = 1157, +strings_type = 1158, +list_type = 1159, +tuple_type = 1160, +set_type = 1161, +dict_type = 1162, +double_starred_kvpairs_type = 1163, +double_starred_kvpair_type = 1164, +kvpair_type = 1165, +for_if_clauses_type = 1166, +for_if_clause_type = 1167, +listcomp_type = 1168, +setcomp_type = 1169, +genexp_type = 1170, +dictcomp_type = 1171, +arguments_type = 1172, +args_type = 1173, +kwargs_type = 1174, +starred_expression_type = 1175, +kwarg_or_starred_type = 1176, +kwarg_or_double_starred_type = 1177, +star_targets_type = 1178, +star_targets_list_seq_type = 1179, +star_targets_tuple_seq_type = 1180, +star_target_type = 1181, +target_with_star_atom_type = 1182, +star_atom_type = 1183, +single_target_type = 1184, +single_subscript_attribute_target_type = 1185, +t_primary_type = 1186, +t_lookahead_type = 1187, +del_targets_type = 1188, +del_target_type = 1189, +del_t_atom_type = 1190, +type_expressions_type = 1191, +func_type_comment_type = 1192, +invalid_arguments_type = 1193, +invalid_kwarg_type = 1194, +expression_without_invalid_type = 1195, +invalid_legacy_expression_type = 1196, +invalid_expression_type = 1197, +invalid_named_expression_type = 1198, +invalid_assignment_type = 1199, +invalid_ann_assign_target_type = 1200, +invalid_del_stmt_type = 1201, +invalid_block_type = 1202, +invalid_comprehension_type = 1203, +invalid_dict_comprehension_type = 1204, +invalid_parameters_type = 1205, +invalid_default_type = 1206, +invalid_star_etc_type = 1207, +invalid_kwds_type = 1208, +invalid_parameters_helper_type = 1209, +invalid_lambda_parameters_type = 1210, +invalid_lambda_parameters_helper_type = 1211, +invalid_lambda_star_etc_type = 1212, +invalid_lambda_kwds_type = 1213, +invalid_double_type_comments_type = 1214, +invalid_with_item_type = 1215, +invalid_for_target_type = 1216, +invalid_group_type = 1217, +invalid_import_type = 1218, +invalid_import_from_targets_type = 1219, +invalid_with_stmt_type = 1220, +invalid_with_stmt_indent_type = 1221, +invalid_try_stmt_type = 1222, +invalid_except_stmt_type = 1223, +invalid_finally_stmt_type = 1224, +invalid_except_stmt_indent_type = 1225, +invalid_except_star_stmt_indent_type = 1226, +invalid_match_stmt_type = 1227, +invalid_case_block_type = 1228, +invalid_as_pattern_type = 1229, +invalid_class_pattern_type = 1230, +invalid_class_argument_pattern_type = 1231, +invalid_if_stmt_type = 1232, +invalid_elif_stmt_type = 1233, +invalid_else_stmt_type = 1234, +invalid_while_stmt_type = 1235, +invalid_for_stmt_type = 1236, +invalid_def_raw_type = 1237, +invalid_class_def_raw_type = 1238, +invalid_double_starred_kvpairs_type = 1239, +invalid_kvpair_type = 1240, +invalid_starred_expression_type = 1241, +invalid_replacement_field_type = 1242, +invalid_conversion_character_type = 1243, +_loop0_1_type = 1244, +_loop0_2_type = 1245, +_loop1_3_type = 1246, +_loop0_5_type = 1247, +_gather_4_type = 1248, +_tmp_6_type = 1249, +_tmp_7_type = 1250, +_tmp_8_type = 1251, +_tmp_9_type = 1252, +_tmp_10_type = 1253, +_tmp_11_type = 1254, +_tmp_12_type = 1255, +_tmp_13_type = 1256, +_loop1_14_type = 1257, +_tmp_15_type = 1258, +_tmp_16_type = 1259, +_tmp_17_type = 1260, +_loop0_19_type = 1261, +_gather_18_type = 1262, +_loop0_21_type = 1263, +_gather_20_type = 1264, +_tmp_22_type = 1265, +_tmp_23_type = 1266, +_loop0_24_type = 1267, +_loop1_25_type = 1268, +_loop0_27_type = 1269, +_gather_26_type = 1270, +_tmp_28_type = 1271, +_loop0_30_type = 1272, +_gather_29_type = 1273, +_tmp_31_type = 1274, +_loop1_32_type = 1275, +_tmp_33_type = 1276, +_tmp_34_type = 1277, +_tmp_35_type = 1278, +_loop0_36_type = 1279, +_loop0_37_type = 1280, +_loop0_38_type = 1281, +_loop1_39_type = 1282, +_loop0_40_type = 1283, +_loop1_41_type = 1284, +_loop1_42_type = 1285, +_loop1_43_type = 1286, +_loop0_44_type = 1287, +_loop1_45_type = 1288, +_loop0_46_type = 1289, +_loop1_47_type = 1290, +_loop0_48_type = 1291, +_loop0_49_type = 1292, +_loop1_50_type = 1293, +_loop0_52_type = 1294, +_gather_51_type = 1295, +_loop0_54_type = 1296, +_gather_53_type = 1297, +_loop0_56_type = 1298, +_gather_55_type = 1299, +_loop0_58_type = 1300, +_gather_57_type = 1301, +_tmp_59_type = 1302, +_loop1_60_type = 1303, +_loop1_61_type = 1304, +_tmp_62_type = 1305, +_tmp_63_type = 1306, +_loop1_64_type = 1307, +_loop0_66_type = 1308, +_gather_65_type = 1309, +_tmp_67_type = 1310, +_tmp_68_type = 1311, +_tmp_69_type = 1312, +_tmp_70_type = 1313, +_loop0_72_type = 1314, +_gather_71_type = 1315, +_loop0_74_type = 1316, +_gather_73_type = 1317, +_tmp_75_type = 1318, +_loop0_77_type = 1319, +_gather_76_type = 1320, +_loop0_79_type = 1321, +_gather_78_type = 1322, +_loop0_81_type = 1323, +_gather_80_type = 1324, +_loop1_82_type = 1325, +_loop1_83_type = 1326, +_loop0_85_type = 1327, +_gather_84_type = 1328, +_loop1_86_type = 1329, +_loop1_87_type = 1330, +_loop1_88_type = 1331, +_tmp_89_type = 1332, +_loop0_91_type = 1333, +_gather_90_type = 1334, +_tmp_92_type = 1335, +_tmp_93_type = 1336, +_tmp_94_type = 1337, +_tmp_95_type = 1338, +_tmp_96_type = 1339, +_tmp_97_type = 1340, +_loop0_98_type = 1341, +_loop0_99_type = 1342, +_loop0_100_type = 1343, +_loop1_101_type = 1344, +_loop0_102_type = 1345, +_loop1_103_type = 1346, +_loop1_104_type = 1347, +_loop1_105_type = 1348, +_loop0_106_type = 1349, +_loop1_107_type = 1350, +_loop0_108_type = 1351, +_loop1_109_type = 1352, +_loop0_110_type = 1353, +_loop1_111_type = 1354, +_tmp_112_type = 1355, +_loop0_113_type = 1356, +_loop0_114_type = 1357, +_loop1_115_type = 1358, +_tmp_116_type = 1359, +_loop0_118_type = 1360, +_gather_117_type = 1361, +_loop1_119_type = 1362, +_loop0_120_type = 1363, +_loop0_121_type = 1364, +_tmp_122_type = 1365, +_loop0_124_type = 1366, +_gather_123_type = 1367, +_tmp_125_type = 1368, +_loop0_127_type = 1369, +_gather_126_type = 1370, +_loop0_129_type = 1371, +_gather_128_type = 1372, +_loop0_131_type = 1373, +_gather_130_type = 1374, +_loop0_133_type = 1375, +_gather_132_type = 1376, +_loop0_134_type = 1377, +_loop0_136_type = 1378, +_gather_135_type = 1379, +_loop1_137_type = 1380, +_tmp_138_type = 1381, +_loop0_140_type = 1382, +_gather_139_type = 1383, +_loop0_142_type = 1384, +_gather_141_type = 1385, +_loop0_144_type = 1386, +_gather_143_type = 1387, +_loop0_146_type = 1388, +_gather_145_type = 1389, +_loop0_148_type = 1390, +_gather_147_type = 1391, +_tmp_149_type = 1392, +_tmp_150_type = 1393, +_tmp_151_type = 1394, +_tmp_152_type = 1395, +_tmp_153_type = 1396, +_tmp_154_type = 1397, +_tmp_155_type = 1398, +_tmp_156_type = 1399, +_tmp_157_type = 1400, +_tmp_158_type = 1401, +_tmp_159_type = 1402, +_tmp_160_type = 1403, +_loop0_161_type = 1404, +_loop0_162_type = 1405, +_loop0_163_type = 1406, +_tmp_164_type = 1407, +_tmp_165_type = 1408, +_tmp_166_type = 1409, +_tmp_167_type = 1410, +_tmp_168_type = 1411, +_loop0_169_type = 1412, +_loop0_170_type = 1413, +_loop0_171_type = 1414, +_loop1_172_type = 1415, +_tmp_173_type = 1416, +_loop0_174_type = 1417, +_tmp_175_type = 1418, +_loop0_176_type = 1419, +_loop1_177_type = 1420, +_tmp_178_type = 1421, +_tmp_179_type = 1422, +_tmp_180_type = 1423, +_loop0_181_type = 1424, +_tmp_182_type = 1425, +_tmp_183_type = 1426, +_loop1_184_type = 1427, +_tmp_185_type = 1428, +_loop0_186_type = 1429, +_loop0_187_type = 1430, +_loop0_188_type = 1431, +_loop0_190_type = 1432, +_gather_189_type = 1433, +_tmp_191_type = 1434, +_loop0_192_type = 1435, +_tmp_193_type = 1436, +_loop0_194_type = 1437, +_loop1_195_type = 1438, +_loop1_196_type = 1439, +_tmp_197_type = 1440, +_tmp_198_type = 1441, +_loop0_199_type = 1442, +_tmp_200_type = 1443, +_tmp_201_type = 1444, +_tmp_202_type = 1445, +_loop0_204_type = 1446, +_gather_203_type = 1447, +_loop0_206_type = 1448, +_gather_205_type = 1449, +_loop0_208_type = 1450, +_gather_207_type = 1451, +_loop0_210_type = 1452, +_gather_209_type = 1453, +_loop0_212_type = 1454, +_gather_211_type = 1455, +_tmp_213_type = 1456, +_loop0_214_type = 1457, +_loop1_215_type = 1458, +_tmp_216_type = 1459, +_loop0_217_type = 1460, +_loop1_218_type = 1461, +_tmp_219_type = 1462, +_tmp_220_type = 1463, +_tmp_221_type = 1464, +_tmp_222_type = 1465, +_tmp_223_type = 1466, +_tmp_224_type = 1467, +_tmp_225_type = 1468, +_tmp_226_type = 1469, +_tmp_227_type = 1470, +_tmp_228_type = 1471, +_loop0_230_type = 1472, +_gather_229_type = 1473, +_tmp_231_type = 1474, +_tmp_232_type = 1475, +_tmp_233_type = 1476, +_tmp_234_type = 1477, +_tmp_235_type = 1478, +_tmp_236_type = 1479, +_tmp_237_type = 1480, +_tmp_238_type = 1481, +_tmp_239_type = 1482, +_tmp_240_type = 1483, +_tmp_241_type = 1484, +_tmp_242_type = 1485, +_tmp_243_type = 1486, +_loop0_244_type = 1487, +_tmp_245_type = 1488, +_tmp_246_type = 1489, +_tmp_247_type = 1490, +_tmp_248_type = 1491, +_tmp_249_type = 1492, +_tmp_250_type = 1493, +_tmp_251_type = 1494, +_tmp_252_type = 1495, +_tmp_253_type = 1496, +_tmp_254_type = 1497, +_tmp_255_type = 1498, +_tmp_256_type = 1499, +_tmp_257_type = 1500, +_tmp_258_type = 1501, +_tmp_259_type = 1502, +_tmp_260_type = 1503, +_tmp_261_type = 1504, +_tmp_262_type = 1505, +_tmp_263_type = 1506, +_tmp_264_type = 1507, +_tmp_265_type = 1508, +_tmp_266_type = 1509, +_tmp_267_type = 1510, +_tmp_268_type = 1511, +_tmp_269_type = 1512, +_tmp_270_type = 1513, +_tmp_271_type = 1514, +_tmp_272_type = 1515, +_tmp_273_type = 1516, +_loop0_275_type = 1517, +_gather_274_type = 1518, +_tmp_276_type = 1519, +_tmp_277_type = 1520, +_tmp_278_type = 1521, +_tmp_279_type = 1522, +_tmp_280_type = 1523, +_tmp_281_type = 1524 + + +// file: statements? $ +function file_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // statements? $ + if (p.error_indicator) { + return NULL; + } + var a; + var endmarker_var; + if ( + (a = statements_rule(p), !p.error_indicator) // statements? + && + (endmarker_var = $B._PyPegen.expect_token(p, ENDMARKER)) // token='ENDMARKER' + ) + { + _res = $B._PyPegen.make_module (p, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// interactive: statement_newline +function interactive_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // statement_newline + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = statement_newline_rule(p)) // statement_newline + ) + { + _res = new $B._PyAST.Interactive (a, p.arena); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// eval: expressions NEWLINE* $ +function eval_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // expressions NEWLINE* $ + if (p.error_indicator) { + return NULL; + } + var _loop0_1_var; + var a; + var endmarker_var; + if ( + (a = expressions_rule(p)) // expressions + && + (_loop0_1_var = _loop0_1_rule(p)) // NEWLINE* + && + (endmarker_var = $B._PyPegen.expect_token(p, ENDMARKER)) // token='ENDMARKER' + ) + { + _res = new $B._PyAST.Expression (a, p.arena); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// func_type: '(' type_expressions? ')' '->' expression NEWLINE* $ +function func_type_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '(' type_expressions? ')' '->' expression NEWLINE* $ + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _literal_2; + var _loop0_2_var; + var a; + var b; + var endmarker_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = type_expressions_rule(p), !p.error_indicator) // type_expressions? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + && + (_literal_2 = $B._PyPegen.expect_token(p, 51)) // token='->' + && + (b = expression_rule(p)) // expression + && + (_loop0_2_var = _loop0_2_rule(p)) // NEWLINE* + && + (endmarker_var = $B._PyPegen.expect_token(p, ENDMARKER)) // token='ENDMARKER' + ) + { + _res = new $B._PyAST.FunctionType (a, b, p.arena); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// statements: statement+ +function statements_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // statement+ + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = _loop1_3_rule(p)) // statement+ + ) + { + _res = $B._PyPegen.seq_flatten (p, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// statement: compound_stmt | simple_stmts +function statement_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // compound_stmt + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = compound_stmt_rule(p)) // compound_stmt + ) + { + _res = $B._PyPegen.singleton_seq (p, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // simple_stmts + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = simple_stmts_rule(p)) // simple_stmts + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// statement_newline: compound_stmt NEWLINE | simple_stmts | NEWLINE | $ +function statement_newline_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // compound_stmt NEWLINE + if (p.error_indicator) { + return NULL; + } + var a; + var newline_var; + if ( + (a = compound_stmt_rule(p)) // compound_stmt + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = $B._PyPegen.singleton_seq (p, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // simple_stmts + if (p.error_indicator) { + return NULL; + } + var simple_stmts_var; + if ( + (simple_stmts_var = simple_stmts_rule(p)) // simple_stmts + ) + { + _res = simple_stmts_var; + return done(); + } + p.mark = _mark; + } + { // NEWLINE + if (p.error_indicator) { + return NULL; + } + var newline_var; + if ( + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B._PyPegen.singleton_seq (p, $B.helper_functions.CHECK ( $B.ast.stmt, new $B._PyAST.Pass ( EXTRA ) )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // $ + if (p.error_indicator) { + return NULL; + } + var endmarker_var; + if ( + (endmarker_var = $B._PyPegen.expect_token(p, ENDMARKER)) // token='ENDMARKER' + ) + { + _res = $B._PyPegen.interactive_exit (p); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// simple_stmts: simple_stmt !';' NEWLINE | ';'.simple_stmt+ ';'? NEWLINE +function simple_stmts_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // simple_stmt !';' NEWLINE + if (p.error_indicator) { + return NULL; + } + var a; + var newline_var; + if ( + (a = simple_stmt_rule(p)) // simple_stmt + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 13) // token=';' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = $B._PyPegen.singleton_seq (p, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ';'.simple_stmt+ ';'? NEWLINE + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var newline_var; + if ( + (a = _gather_4_rule(p)) // ';'.simple_stmt+ + && + (_opt_var = $B._PyPegen.expect_token(p, 13), !p.error_indicator) // ';'? + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// simple_stmt: +// | assignment +// | &"type" type_alias +// | star_expressions +// | &'return' return_stmt +// | &('import' | 'from') import_stmt +// | &'raise' raise_stmt +// | 'pass' +// | &'del' del_stmt +// | &'yield' yield_stmt +// | &'assert' assert_stmt +// | 'break' +// | 'continue' +// | &'global' global_stmt +// | &'nonlocal' nonlocal_stmt +function simple_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, simple_stmt_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // assignment + if (p.error_indicator) { + return NULL; + } + var assignment_var; + if ( + (assignment_var = assignment_rule(p)) // assignment + ) + { + _res = assignment_var; + return done(); + } + p.mark = _mark; + } + { // &"type" type_alias + if (p.error_indicator) { + return NULL; + } + var type_alias_var; + if ( + $B._PyPegen.lookahead_with_string(1, $B._PyPegen.expect_soft_keyword, p, "type") + && + (type_alias_var = type_alias_rule(p)) // type_alias + ) + { + _res = type_alias_var; + return done(); + } + p.mark = _mark; + } + { // star_expressions + if (p.error_indicator) { + return NULL; + } + var e; + if ( + (e = star_expressions_rule(p)) // star_expressions + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Expr (e, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // &'return' return_stmt + if (p.error_indicator) { + return NULL; + } + var return_stmt_var; + if ( + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 519) // token='return' + && + (return_stmt_var = return_stmt_rule(p)) // return_stmt + ) + { + _res = return_stmt_var; + return done(); + } + p.mark = _mark; + } + { // &('import' | 'from') import_stmt + if (p.error_indicator) { + return NULL; + } + var import_stmt_var; + if ( + $B._PyPegen.lookahead(1, _tmp_6_rule, p) + && + (import_stmt_var = import_stmt_rule(p)) // import_stmt + ) + { + _res = import_stmt_var; + return done(); + } + p.mark = _mark; + } + { // &'raise' raise_stmt + if (p.error_indicator) { + return NULL; + } + var raise_stmt_var; + if ( + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 522) // token='raise' + && + (raise_stmt_var = raise_stmt_rule(p)) // raise_stmt + ) + { + _res = raise_stmt_var; + return done(); + } + p.mark = _mark; + } + { // 'pass' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 504)) // token='pass' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Pass (EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // &'del' del_stmt + if (p.error_indicator) { + return NULL; + } + var del_stmt_var; + if ( + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 604) // token='del' + && + (del_stmt_var = del_stmt_rule(p)) // del_stmt + ) + { + _res = del_stmt_var; + return done(); + } + p.mark = _mark; + } + { // &'yield' yield_stmt + if (p.error_indicator) { + return NULL; + } + var yield_stmt_var; + if ( + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 573) // token='yield' + && + (yield_stmt_var = yield_stmt_rule(p)) // yield_stmt + ) + { + _res = yield_stmt_var; + return done(); + } + p.mark = _mark; + } + { // &'assert' assert_stmt + if (p.error_indicator) { + return NULL; + } + var assert_stmt_var; + if ( + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 526) // token='assert' + && + (assert_stmt_var = assert_stmt_rule(p)) // assert_stmt + ) + { + _res = assert_stmt_var; + return done(); + } + p.mark = _mark; + } + { // 'break' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 508)) // token='break' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Break (EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'continue' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 509)) // token='continue' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Continue (EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // &'global' global_stmt + if (p.error_indicator) { + return NULL; + } + var global_stmt_var; + if ( + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 523) // token='global' + && + (global_stmt_var = global_stmt_rule(p)) // global_stmt + ) + { + _res = global_stmt_var; + return done(); + } + p.mark = _mark; + } + { // &'nonlocal' nonlocal_stmt + if (p.error_indicator) { + return NULL; + } + var nonlocal_stmt_var; + if ( + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 524) // token='nonlocal' + && + (nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt + ) + { + _res = nonlocal_stmt_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, simple_stmt_type, _res); + return _res; + } +} + +// compound_stmt: +// | &('def' | '@' | ASYNC) function_def +// | &'if' if_stmt +// | &('class' | '@') class_def +// | &('with' | ASYNC) with_stmt +// | &('for' | ASYNC) for_stmt +// | &'try' try_stmt +// | &'while' while_stmt +// | match_stmt +function compound_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // &('def' | '@' | ASYNC) function_def + if (p.error_indicator) { + return NULL; + } + var function_def_var; + if ( + $B._PyPegen.lookahead(1, _tmp_7_rule, p) + && + (function_def_var = function_def_rule(p)) // function_def + ) + { + _res = function_def_var; + return done(); + } + p.mark = _mark; + } + { // &'if' if_stmt + if (p.error_indicator) { + return NULL; + } + var if_stmt_var; + if ( + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 642) // token='if' + && + (if_stmt_var = if_stmt_rule(p)) // if_stmt + ) + { + _res = if_stmt_var; + return done(); + } + p.mark = _mark; + } + { // &('class' | '@') class_def + if (p.error_indicator) { + return NULL; + } + var class_def_var; + if ( + $B._PyPegen.lookahead(1, _tmp_8_rule, p) + && + (class_def_var = class_def_rule(p)) // class_def + ) + { + _res = class_def_var; + return done(); + } + p.mark = _mark; + } + { // &('with' | ASYNC) with_stmt + if (p.error_indicator) { + return NULL; + } + var with_stmt_var; + if ( + $B._PyPegen.lookahead(1, _tmp_9_rule, p) + && + (with_stmt_var = with_stmt_rule(p)) // with_stmt + ) + { + _res = with_stmt_var; + return done(); + } + p.mark = _mark; + } + { // &('for' | ASYNC) for_stmt + if (p.error_indicator) { + return NULL; + } + var for_stmt_var; + if ( + $B._PyPegen.lookahead(1, _tmp_10_rule, p) + && + (for_stmt_var = for_stmt_rule(p)) // for_stmt + ) + { + _res = for_stmt_var; + return done(); + } + p.mark = _mark; + } + { // &'try' try_stmt + if (p.error_indicator) { + return NULL; + } + var try_stmt_var; + if ( + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 624) // token='try' + && + (try_stmt_var = try_stmt_rule(p)) // try_stmt + ) + { + _res = try_stmt_var; + return done(); + } + p.mark = _mark; + } + { // &'while' while_stmt + if (p.error_indicator) { + return NULL; + } + var while_stmt_var; + if ( + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 647) // token='while' + && + (while_stmt_var = while_stmt_rule(p)) // while_stmt + ) + { + _res = while_stmt_var; + return done(); + } + p.mark = _mark; + } + { // match_stmt + if (p.error_indicator) { + return NULL; + } + var match_stmt_var; + if ( + (match_stmt_var = match_stmt_rule(p)) // match_stmt + ) + { + _res = match_stmt_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// assignment: +// | NAME ':' expression ['=' annotated_rhs] +// | ('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs] +// | ((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT? +// | single_target augassign ~ (yield_expr | star_expressions) +// | invalid_assignment +function assignment_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // NAME ':' expression ['=' annotated_rhs] + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + var c; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = expression_rule(p)) // expression + && + (c = _tmp_11_rule(p), !p.error_indicator) // ['=' annotated_rhs] + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B.helper_functions.CHECK_VERSION ($B.ast.stmt, 6, "Variable annotation syntax is", new $B._PyAST.AnnAssign ( $B.helper_functions.CHECK ( $B.ast.expr, $B._PyPegen.set_expr_context ( p, a, $B.parser_constants.Store ) ), b, c, 1, EXTRA )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs] + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + var c; + if ( + (a = _tmp_12_rule(p)) // '(' single_target ')' | single_subscript_attribute_target + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = expression_rule(p)) // expression + && + (c = _tmp_13_rule(p), !p.error_indicator) // ['=' annotated_rhs] + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B.helper_functions.CHECK_VERSION ($B.ast.stmt, 6, "Variable annotations syntax is", new $B._PyAST.AnnAssign ( a, b, c, 0, EXTRA )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT? + if (p.error_indicator) { + return NULL; + } + var a; + var b; + var tc; + if ( + (a = _loop1_14_rule(p)) // ((star_targets '='))+ + && + (b = _tmp_15_rule(p)) // yield_expr | star_expressions + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 22) // token='=' + && + (tc = $B._PyPegen.expect_token(p, TYPE_COMMENT), !p.error_indicator) // TYPE_COMMENT? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Assign (a, b, $B.helper_functions.NEW_TYPE_COMMENT ( p, tc ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // single_target augassign ~ (yield_expr | star_expressions) + if (p.error_indicator) { + return NULL; + } + var _cut_var = 0; + var a; + var b; + var c; + if ( + (a = single_target_rule(p)) // single_target + && + (b = augassign_rule(p)) // augassign + && + (_cut_var = 1) + && + (c = _tmp_16_rule(p)) // yield_expr | star_expressions + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.AugAssign (a, b.kind, c, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + if (_cut_var) { + return NULL; + } + } + if (p.call_invalid_rules) { // invalid_assignment + if (p.error_indicator) { + return NULL; + } + var invalid_assignment_var; + if ( + (invalid_assignment_var = invalid_assignment_rule(p)) // invalid_assignment + ) + { + _res = invalid_assignment_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// annotated_rhs: yield_expr | star_expressions +function annotated_rhs_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // yield_expr + if (p.error_indicator) { + return NULL; + } + var yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + _res = yield_expr_var; + return done(); + } + p.mark = _mark; + } + { // star_expressions + if (p.error_indicator) { + return NULL; + } + var star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions + ) + { + _res = star_expressions_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// augassign: +// | '+=' +// | '-=' +// | '*=' +// | '@=' +// | '/=' +// | '%=' +// | '&=' +// | '|=' +// | '^=' +// | '<<=' +// | '>>=' +// | '**=' +// | '//=' +function augassign_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '+=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 36)) // token='+=' + ) + { + _res = $B._PyPegen.augoperator (p, new $B.ast.Add); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '-=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 37)) // token='-=' + ) + { + _res = $B._PyPegen.augoperator (p, new $B.ast.Sub); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '*=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 38)) // token='*=' + ) + { + _res = $B._PyPegen.augoperator (p, new $B.ast.Mult); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '@=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 50)) // token='@=' + ) + { + _res = $B.helper_functions.CHECK_VERSION ($B.parser_constants.AugOperator, 5, "The '@' operator is", $B._PyPegen.augoperator ( p, new $B.ast.MatMult )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '/=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 39)) // token='/=' + ) + { + _res = $B._PyPegen.augoperator (p, new $B.ast.Div); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '%=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 40)) // token='%=' + ) + { + _res = $B._PyPegen.augoperator (p, new $B.ast.Mod); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '&=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 41)) // token='&=' + ) + { + _res = $B._PyPegen.augoperator (p, new $B.ast.BitAnd); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '|=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 42)) // token='|=' + ) + { + _res = $B._PyPegen.augoperator (p, new $B.ast.BitOr); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '^=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 43)) // token='^=' + ) + { + _res = $B._PyPegen.augoperator (p, new $B.ast.BitXor); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '<<=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 44)) // token='<<=' + ) + { + _res = $B._PyPegen.augoperator (p, new $B.ast.LShift); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '>>=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 45)) // token='>>=' + ) + { + _res = $B._PyPegen.augoperator (p, new $B.ast.RShift); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '**=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 46)) // token='**=' + ) + { + _res = $B._PyPegen.augoperator (p, new $B.ast.Pow); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '//=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 48)) // token='//=' + ) + { + _res = $B._PyPegen.augoperator (p, new $B.ast.FloorDiv); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// return_stmt: 'return' star_expressions? +function return_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // 'return' star_expressions? + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 519)) // token='return' + && + (a = star_expressions_rule(p), !p.error_indicator) // star_expressions? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Return (a, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// raise_stmt: 'raise' expression ['from' expression] | 'raise' +function raise_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // 'raise' expression ['from' expression] + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + var b; + if ( + (_keyword = $B._PyPegen.expect_token(p, 522)) // token='raise' + && + (a = expression_rule(p)) // expression + && + (b = _tmp_17_rule(p), !p.error_indicator) // ['from' expression] + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Raise (a, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'raise' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 522)) // token='raise' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Raise ($B.parser_constants.NULL, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// global_stmt: 'global' ','.NAME+ +function global_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // 'global' ','.NAME+ + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 523)) // token='global' + && + (a = _gather_18_rule(p)) // ','.NAME+ + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Global ($B.helper_functions.CHECK ( $B.parser_constants.asdl_identifier_seq, $B._PyPegen.map_names_to_ids ( p, a ) ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// nonlocal_stmt: 'nonlocal' ','.NAME+ +function nonlocal_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // 'nonlocal' ','.NAME+ + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 524)) // token='nonlocal' + && + (a = _gather_20_rule(p)) // ','.NAME+ + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Nonlocal ($B.helper_functions.CHECK ( $B.parser_constants.asdl_identifier_seq, $B._PyPegen.map_names_to_ids ( p, a ) ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// del_stmt: 'del' del_targets &(';' | NEWLINE) | invalid_del_stmt +function del_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // 'del' del_targets &(';' | NEWLINE) + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 604)) // token='del' + && + (a = del_targets_rule(p)) // del_targets + && + $B._PyPegen.lookahead(1, _tmp_22_rule, p) + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Delete (a, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_del_stmt + if (p.error_indicator) { + return NULL; + } + var invalid_del_stmt_var; + if ( + (invalid_del_stmt_var = invalid_del_stmt_rule(p)) // invalid_del_stmt + ) + { + _res = invalid_del_stmt_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// yield_stmt: yield_expr +function yield_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // yield_expr + if (p.error_indicator) { + return NULL; + } + var y; + if ( + (y = yield_expr_rule(p)) // yield_expr + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Expr (y, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// assert_stmt: 'assert' expression [',' expression] +function assert_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // 'assert' expression [',' expression] + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + var b; + if ( + (_keyword = $B._PyPegen.expect_token(p, 526)) // token='assert' + && + (a = expression_rule(p)) // expression + && + (b = _tmp_23_rule(p), !p.error_indicator) // [',' expression] + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Assert (a, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// import_stmt: invalid_import | import_name | import_from +function import_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.call_invalid_rules) { // invalid_import + if (p.error_indicator) { + return NULL; + } + var invalid_import_var; + if ( + (invalid_import_var = invalid_import_rule(p)) // invalid_import + ) + { + _res = invalid_import_var; + return done(); + } + p.mark = _mark; + } + { // import_name + if (p.error_indicator) { + return NULL; + } + var import_name_var; + if ( + (import_name_var = import_name_rule(p)) // import_name + ) + { + _res = import_name_var; + return done(); + } + p.mark = _mark; + } + { // import_from + if (p.error_indicator) { + return NULL; + } + var import_from_var; + if ( + (import_from_var = import_from_rule(p)) // import_from + ) + { + _res = import_from_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// import_name: 'import' dotted_as_names +function import_name_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // 'import' dotted_as_names + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 607)) // token='import' + && + (a = dotted_as_names_rule(p)) // dotted_as_names + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Import (a, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// import_from: +// | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets +// | 'from' (('.' | '...'))+ 'import' import_from_targets +function import_from_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _keyword_1; + var a; + var b; + var c; + if ( + (_keyword = $B._PyPegen.expect_token(p, 608)) // token='from' + && + (a = _loop0_24_rule(p)) // (('.' | '...'))* + && + (b = dotted_name_rule(p)) // dotted_name + && + (_keyword_1 = $B._PyPegen.expect_token(p, 607)) // token='import' + && + (c = import_from_targets_rule(p)) // import_from_targets + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.ImportFrom (b. id, c, $B._PyPegen.seq_count_dots ( a ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'from' (('.' | '...'))+ 'import' import_from_targets + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _keyword_1; + var a; + var b; + if ( + (_keyword = $B._PyPegen.expect_token(p, 608)) // token='from' + && + (a = _loop1_25_rule(p)) // (('.' | '...'))+ + && + (_keyword_1 = $B._PyPegen.expect_token(p, 607)) // token='import' + && + (b = import_from_targets_rule(p)) // import_from_targets + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.ImportFrom ($B.parser_constants.NULL, b, $B._PyPegen.seq_count_dots ( a ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// import_from_targets: +// | '(' import_from_as_names ','? ')' +// | import_from_as_names !',' +// | '*' +// | invalid_import_from_targets +function import_from_targets_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '(' import_from_as_names ','? ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = import_from_as_names_rule(p)) // import_from_as_names + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // import_from_as_names !',' + if (p.error_indicator) { + return NULL; + } + var import_from_as_names_var; + if ( + (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 12) // token=',' + ) + { + _res = import_from_as_names_var; + return done(); + } + p.mark = _mark; + } + { // '*' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B._PyPegen.singleton_seq (p, $B.helper_functions.CHECK ( $B.ast.alias, $B._PyPegen.alias_for_star ( p, EXTRA ) )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_import_from_targets + if (p.error_indicator) { + return NULL; + } + var invalid_import_from_targets_var; + if ( + (invalid_import_from_targets_var = invalid_import_from_targets_rule(p)) // invalid_import_from_targets + ) + { + _res = invalid_import_from_targets_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// import_from_as_names: ','.import_from_as_name+ +function import_from_as_names_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.import_from_as_name+ + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = _gather_26_rule(p)) // ','.import_from_as_name+ + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// import_from_as_name: NAME ['as' NAME] +function import_from_as_name_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // NAME ['as' NAME] + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + && + (b = _tmp_28_rule(p), !p.error_indicator) // ['as' NAME] + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.alias (a. id, ( b ) ? ( b ). id : $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// dotted_as_names: ','.dotted_as_name+ +function dotted_as_names_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.dotted_as_name+ + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = _gather_29_rule(p)) // ','.dotted_as_name+ + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// dotted_as_name: dotted_name ['as' NAME] +function dotted_as_name_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // dotted_name ['as' NAME] + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = dotted_name_rule(p)) // dotted_name + && + (b = _tmp_31_rule(p), !p.error_indicator) // ['as' NAME] + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.alias (a. id, ( b ) ? ( b ). id : $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// Left-recursive +// dotted_name: dotted_name '.' NAME | NAME +function dotted_name_raw(){}; +function dotted_name_rule(p) +{ + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, dotted_name_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + var _resmark = p.mark; + while (1) { + var tmpvar_0 = $B._PyPegen.update_memo(p, _mark, dotted_name_type, _res); + if (tmpvar_0) { + return _res; + } + p.mark = _mark; + var _raw = dotted_name_raw(p); + if (p.error_indicator) { + return NULL; + } + if (_raw == NULL || p.mark <= _resmark) + break; + _resmark = p.mark; + _res = _raw; + } + p.mark = _resmark; + return _res; +} +function dotted_name_raw(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // dotted_name '.' NAME + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = dotted_name_rule(p)) // dotted_name + && + (_literal = $B._PyPegen.expect_token(p, 23)) // token='.' + && + (b = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = $B._PyPegen.join_names_with_dot (p, a, b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // NAME + if (p.error_indicator) { + return NULL; + } + var name_var; + if ( + (name_var = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = name_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// block: NEWLINE INDENT statements DEDENT | simple_stmts | invalid_block +function block_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, block_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + { // NEWLINE INDENT statements DEDENT + if (p.error_indicator) { + return NULL; + } + var a; + var dedent_var; + var indent_var; + var newline_var; + if ( + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + (indent_var = $B._PyPegen.expect_token(p, INDENT)) // token='INDENT' + && + (a = statements_rule(p)) // statements + && + (dedent_var = $B._PyPegen.expect_token(p, DEDENT)) // token='DEDENT' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // simple_stmts + if (p.error_indicator) { + return NULL; + } + var simple_stmts_var; + if ( + (simple_stmts_var = simple_stmts_rule(p)) // simple_stmts + ) + { + _res = simple_stmts_var; + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_block + if (p.error_indicator) { + return NULL; + } + var invalid_block_var; + if ( + (invalid_block_var = invalid_block_rule(p)) // invalid_block + ) + { + _res = invalid_block_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, block_type, _res); + return _res; + } +} + +// decorators: (('@' named_expression NEWLINE))+ +function decorators_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // (('@' named_expression NEWLINE))+ + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = _loop1_32_rule(p)) // (('@' named_expression NEWLINE))+ + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// class_def: decorators class_def_raw | class_def_raw +function class_def_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // decorators class_def_raw + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = decorators_rule(p)) // decorators + && + (b = class_def_raw_rule(p)) // class_def_raw + ) + { + _res = $B._PyPegen.class_def_decorators (p, a, b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // class_def_raw + if (p.error_indicator) { + return NULL; + } + var class_def_raw_var; + if ( + (class_def_raw_var = class_def_raw_rule(p)) // class_def_raw + ) + { + _res = class_def_raw_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// class_def_raw: +// | invalid_class_def_raw +// | 'class' NAME type_params? ['(' arguments? ')'] ':' block +function class_def_raw_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + if (p.call_invalid_rules) { // invalid_class_def_raw + if (p.error_indicator) { + return NULL; + } + var invalid_class_def_raw_var; + if ( + (invalid_class_def_raw_var = invalid_class_def_raw_rule(p)) // invalid_class_def_raw + ) + { + _res = invalid_class_def_raw_var; + return done(); + } + p.mark = _mark; + } + { // 'class' NAME type_params? ['(' arguments? ')'] ':' block + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var a; + var b; + var c; + var t; + if ( + (_keyword = $B._PyPegen.expect_token(p, 654)) // token='class' + && + (a = $B._PyPegen.name_token(p)) // NAME + && + (t = type_params_rule(p), !p.error_indicator) // type_params? + && + (b = _tmp_33_rule(p), !p.error_indicator) // ['(' arguments? ')'] + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (c = block_rule(p)) // block + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.ClassDef (a. id, ( b ) ? ( b ). args : $B.parser_constants.NULL, ( b ) ? ( b ). keywords : $B.parser_constants.NULL, c, $B.parser_constants.NULL, t, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// function_def: decorators function_def_raw | function_def_raw +function function_def_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // decorators function_def_raw + if (p.error_indicator) { + return NULL; + } + var d; + var f; + if ( + (d = decorators_rule(p)) // decorators + && + (f = function_def_raw_rule(p)) // function_def_raw + ) + { + _res = $B._PyPegen.function_def_decorators (p, d, f); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // function_def_raw + if (p.error_indicator) { + return NULL; + } + var function_def_raw_var; + if ( + (function_def_raw_var = function_def_raw_rule(p)) // function_def_raw + ) + { + _res = function_def_raw_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// function_def_raw: +// | invalid_def_raw +// | 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block +// | ASYNC 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block +function function_def_raw_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + if (p.call_invalid_rules) { // invalid_def_raw + if (p.error_indicator) { + return NULL; + } + var invalid_def_raw_var; + if ( + (invalid_def_raw_var = invalid_def_raw_rule(p)) // invalid_def_raw + ) + { + _res = invalid_def_raw_var; + return done(); + } + p.mark = _mark; + } + { // 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var _literal_1; + var _literal_2; + var a; + var b; + var n; + var params; + var t; + var tc; + if ( + (_keyword = $B._PyPegen.expect_token(p, 652)) // token='def' + && + (n = $B._PyPegen.name_token(p)) // NAME + && + (t = type_params_rule(p), !p.error_indicator) // type_params? + && + (_literal = $B._PyPegen.expect_forced_token(p, 7, "(")) // forced_token='(' + && + (params = params_rule(p), !p.error_indicator) // params? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + && + (a = _tmp_34_rule(p), !p.error_indicator) // ['->' expression] + && + (_literal_2 = $B._PyPegen.expect_forced_token(p, 11, ":")) // forced_token=':' + && + (tc = func_type_comment_rule(p), !p.error_indicator) // func_type_comment? + && + (b = block_rule(p)) // block + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.FunctionDef (n. id, ( params ) ? params : $B.helper_functions.CHECK ( $B.ast.arguments, $B._PyPegen.empty_arguments ( p ) ), b, $B.parser_constants.NULL, a, $B.helper_functions.NEW_TYPE_COMMENT ( p, tc ), t, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ASYNC 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var _literal_1; + var _literal_2; + var a; + var async_var; + var b; + var n; + var params; + var t; + var tc; + if ( + (async_var = $B._PyPegen.expect_token(p, ASYNC)) // token='ASYNC' + && + (_keyword = $B._PyPegen.expect_token(p, 652)) // token='def' + && + (n = $B._PyPegen.name_token(p)) // NAME + && + (t = type_params_rule(p), !p.error_indicator) // type_params? + && + (_literal = $B._PyPegen.expect_forced_token(p, 7, "(")) // forced_token='(' + && + (params = params_rule(p), !p.error_indicator) // params? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + && + (a = _tmp_35_rule(p), !p.error_indicator) // ['->' expression] + && + (_literal_2 = $B._PyPegen.expect_forced_token(p, 11, ":")) // forced_token=':' + && + (tc = func_type_comment_rule(p), !p.error_indicator) // func_type_comment? + && + (b = block_rule(p)) // block + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B.helper_functions.CHECK_VERSION ($B.ast.stmt, 5, "Async functions are", new $B._PyAST.AsyncFunctionDef ( n. id, ( params ) ? params : $B.helper_functions.CHECK ( $B.ast.arguments, $B._PyPegen.empty_arguments ( p ) ), b, $B.parser_constants.NULL, a, $B.helper_functions.NEW_TYPE_COMMENT ( p, tc ), t, EXTRA )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// params: invalid_parameters | parameters +function params_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.call_invalid_rules) { // invalid_parameters + if (p.error_indicator) { + return NULL; + } + var invalid_parameters_var; + if ( + (invalid_parameters_var = invalid_parameters_rule(p)) // invalid_parameters + ) + { + _res = invalid_parameters_var; + return done(); + } + p.mark = _mark; + } + { // parameters + if (p.error_indicator) { + return NULL; + } + var parameters_var; + if ( + (parameters_var = parameters_rule(p)) // parameters + ) + { + _res = parameters_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// parameters: +// | slash_no_default param_no_default* param_with_default* star_etc? +// | slash_with_default param_with_default* star_etc? +// | param_no_default+ param_with_default* star_etc? +// | param_with_default+ star_etc? +// | star_etc +function parameters_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // slash_no_default param_no_default* param_with_default* star_etc? + if (p.error_indicator) { + return NULL; + } + var a; + var b; + var c; + var d; + if ( + (a = slash_no_default_rule(p)) // slash_no_default + && + (b = _loop0_36_rule(p)) // param_no_default* + && + (c = _loop0_37_rule(p)) // param_with_default* + && + (d = star_etc_rule(p), !p.error_indicator) // star_etc? + ) + { + _res = $B.helper_functions.CHECK_VERSION ($B.ast.arguments, 8, "Positional-only parameters are", $B._PyPegen.make_arguments ( p, a, $B.parser_constants.NULL, b, c, d )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // slash_with_default param_with_default* star_etc? + if (p.error_indicator) { + return NULL; + } + var a; + var b; + var c; + if ( + (a = slash_with_default_rule(p)) // slash_with_default + && + (b = _loop0_38_rule(p)) // param_with_default* + && + (c = star_etc_rule(p), !p.error_indicator) // star_etc? + ) + { + _res = $B.helper_functions.CHECK_VERSION ($B.ast.arguments, 8, "Positional-only parameters are", $B._PyPegen.make_arguments ( p, $B.parser_constants.NULL, a, $B.parser_constants.NULL, b, c )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // param_no_default+ param_with_default* star_etc? + if (p.error_indicator) { + return NULL; + } + var a; + var b; + var c; + if ( + (a = _loop1_39_rule(p)) // param_no_default+ + && + (b = _loop0_40_rule(p)) // param_with_default* + && + (c = star_etc_rule(p), !p.error_indicator) // star_etc? + ) + { + _res = $B._PyPegen.make_arguments (p, $B.parser_constants.NULL, $B.parser_constants.NULL, a, b, c); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // param_with_default+ star_etc? + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = _loop1_41_rule(p)) // param_with_default+ + && + (b = star_etc_rule(p), !p.error_indicator) // star_etc? + ) + { + _res = $B._PyPegen.make_arguments (p, $B.parser_constants.NULL, $B.parser_constants.NULL, $B.parser_constants.NULL, a, b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // star_etc + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = star_etc_rule(p)) // star_etc + ) + { + _res = $B._PyPegen.make_arguments (p, $B.parser_constants.NULL, $B.parser_constants.NULL, $B.parser_constants.NULL, $B.parser_constants.NULL, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')' +function slash_no_default_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // param_no_default+ '/' ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (a = _loop1_42_rule(p)) // param_no_default+ + && + (_literal = $B._PyPegen.expect_token(p, 17)) // token='/' + && + (_literal_1 = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // param_no_default+ '/' &')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (a = _loop1_43_rule(p)) // param_no_default+ + && + (_literal = $B._PyPegen.expect_token(p, 17)) // token='/' + && + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 8) // token=')' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// slash_with_default: +// | param_no_default* param_with_default+ '/' ',' +// | param_no_default* param_with_default+ '/' &')' +function slash_with_default_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // param_no_default* param_with_default+ '/' ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (a = _loop0_44_rule(p)) // param_no_default* + && + (b = _loop1_45_rule(p)) // param_with_default+ + && + (_literal = $B._PyPegen.expect_token(p, 17)) // token='/' + && + (_literal_1 = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = $B._PyPegen.slash_with_default (p, a, b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // param_no_default* param_with_default+ '/' &')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = _loop0_46_rule(p)) // param_no_default* + && + (b = _loop1_47_rule(p)) // param_with_default+ + && + (_literal = $B._PyPegen.expect_token(p, 17)) // token='/' + && + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 8) // token=')' + ) + { + _res = $B._PyPegen.slash_with_default (p, a, b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// star_etc: +// | invalid_star_etc +// | '*' param_no_default param_maybe_default* kwds? +// | '*' param_no_default_star_annotation param_maybe_default* kwds? +// | '*' ',' param_maybe_default+ kwds? +// | kwds +function star_etc_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.call_invalid_rules) { // invalid_star_etc + if (p.error_indicator) { + return NULL; + } + var invalid_star_etc_var; + if ( + (invalid_star_etc_var = invalid_star_etc_rule(p)) // invalid_star_etc + ) + { + _res = invalid_star_etc_var; + return done(); + } + p.mark = _mark; + } + { // '*' param_no_default param_maybe_default* kwds? + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + var c; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (a = param_no_default_rule(p)) // param_no_default + && + (b = _loop0_48_rule(p)) // param_maybe_default* + && + (c = kwds_rule(p), !p.error_indicator) // kwds? + ) + { + _res = $B._PyPegen.star_etc (p, a, b, c); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '*' param_no_default_star_annotation param_maybe_default* kwds? + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + var c; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (a = param_no_default_star_annotation_rule(p)) // param_no_default_star_annotation + && + (b = _loop0_49_rule(p)) // param_maybe_default* + && + (c = kwds_rule(p), !p.error_indicator) // kwds? + ) + { + _res = $B._PyPegen.star_etc (p, a, b, c); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '*' ',' param_maybe_default+ kwds? + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var b; + var c; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (_literal_1 = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (b = _loop1_50_rule(p)) // param_maybe_default+ + && + (c = kwds_rule(p), !p.error_indicator) // kwds? + ) + { + _res = $B._PyPegen.star_etc (p, $B.parser_constants.NULL, b, c); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // kwds + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = kwds_rule(p)) // kwds + ) + { + _res = $B._PyPegen.star_etc (p, $B.parser_constants.NULL, $B.parser_constants.NULL, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// kwds: invalid_kwds | '**' param_no_default +function kwds_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.call_invalid_rules) { // invalid_kwds + if (p.error_indicator) { + return NULL; + } + var invalid_kwds_var; + if ( + (invalid_kwds_var = invalid_kwds_rule(p)) // invalid_kwds + ) + { + _res = invalid_kwds_var; + return done(); + } + p.mark = _mark; + } + { // '**' param_no_default + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (a = param_no_default_rule(p)) // param_no_default + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')' +function param_no_default_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // param ',' TYPE_COMMENT? + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var tc; + if ( + (a = param_rule(p)) // param + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (tc = $B._PyPegen.expect_token(p, TYPE_COMMENT), !p.error_indicator) // TYPE_COMMENT? + ) + { + _res = $B._PyPegen.add_type_comment_to_arg (p, a, tc); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // param TYPE_COMMENT? &')' + if (p.error_indicator) { + return NULL; + } + var a; + var tc; + if ( + (a = param_rule(p)) // param + && + (tc = $B._PyPegen.expect_token(p, TYPE_COMMENT), !p.error_indicator) // TYPE_COMMENT? + && + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 8) // token=')' + ) + { + _res = $B._PyPegen.add_type_comment_to_arg (p, a, tc); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// param_no_default_star_annotation: +// | param_star_annotation ',' TYPE_COMMENT? +// | param_star_annotation TYPE_COMMENT? &')' +function param_no_default_star_annotation_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // param_star_annotation ',' TYPE_COMMENT? + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var tc; + if ( + (a = param_star_annotation_rule(p)) // param_star_annotation + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (tc = $B._PyPegen.expect_token(p, TYPE_COMMENT), !p.error_indicator) // TYPE_COMMENT? + ) + { + _res = $B._PyPegen.add_type_comment_to_arg (p, a, tc); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // param_star_annotation TYPE_COMMENT? &')' + if (p.error_indicator) { + return NULL; + } + var a; + var tc; + if ( + (a = param_star_annotation_rule(p)) // param_star_annotation + && + (tc = $B._PyPegen.expect_token(p, TYPE_COMMENT), !p.error_indicator) // TYPE_COMMENT? + && + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 8) // token=')' + ) + { + _res = $B._PyPegen.add_type_comment_to_arg (p, a, tc); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')' +function param_with_default_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // param default ',' TYPE_COMMENT? + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var c; + var tc; + if ( + (a = param_rule(p)) // param + && + (c = default_rule(p)) // default + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (tc = $B._PyPegen.expect_token(p, TYPE_COMMENT), !p.error_indicator) // TYPE_COMMENT? + ) + { + _res = $B._PyPegen.name_default_pair (p, a, c, tc); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // param default TYPE_COMMENT? &')' + if (p.error_indicator) { + return NULL; + } + var a; + var c; + var tc; + if ( + (a = param_rule(p)) // param + && + (c = default_rule(p)) // default + && + (tc = $B._PyPegen.expect_token(p, TYPE_COMMENT), !p.error_indicator) // TYPE_COMMENT? + && + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 8) // token=')' + ) + { + _res = $B._PyPegen.name_default_pair (p, a, c, tc); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// param_maybe_default: +// | param default? ',' TYPE_COMMENT? +// | param default? TYPE_COMMENT? &')' +function param_maybe_default_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // param default? ',' TYPE_COMMENT? + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var c; + var tc; + if ( + (a = param_rule(p)) // param + && + (c = default_rule(p), !p.error_indicator) // default? + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (tc = $B._PyPegen.expect_token(p, TYPE_COMMENT), !p.error_indicator) // TYPE_COMMENT? + ) + { + _res = $B._PyPegen.name_default_pair (p, a, c, tc); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // param default? TYPE_COMMENT? &')' + if (p.error_indicator) { + return NULL; + } + var a; + var c; + var tc; + if ( + (a = param_rule(p)) // param + && + (c = default_rule(p), !p.error_indicator) // default? + && + (tc = $B._PyPegen.expect_token(p, TYPE_COMMENT), !p.error_indicator) // TYPE_COMMENT? + && + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 8) // token=')' + ) + { + _res = $B._PyPegen.name_default_pair (p, a, c, tc); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// param: NAME annotation? +function param_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // NAME annotation? + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + && + (b = annotation_rule(p), !p.error_indicator) // annotation? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.arg (a. id, b, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// param_star_annotation: NAME star_annotation +function param_star_annotation_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // NAME star_annotation + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + && + (b = star_annotation_rule(p)) // star_annotation + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.arg (a. id, b, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// annotation: ':' expression +function annotation_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ':' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (a = expression_rule(p)) // expression + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// star_annotation: ':' star_expression +function star_annotation_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ':' star_expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (a = star_expression_rule(p)) // star_expression + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// default: '=' expression | invalid_default +function default_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '=' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + && + (a = expression_rule(p)) // expression + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_default + if (p.error_indicator) { + return NULL; + } + var invalid_default_var; + if ( + (invalid_default_var = invalid_default_rule(p)) // invalid_default + ) + { + _res = invalid_default_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// if_stmt: +// | invalid_if_stmt +// | 'if' named_expression ':' block elif_stmt +// | 'if' named_expression ':' block else_block? +function if_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + if (p.call_invalid_rules) { // invalid_if_stmt + if (p.error_indicator) { + return NULL; + } + var invalid_if_stmt_var; + if ( + (invalid_if_stmt_var = invalid_if_stmt_rule(p)) // invalid_if_stmt + ) + { + _res = invalid_if_stmt_var; + return done(); + } + p.mark = _mark; + } + { // 'if' named_expression ':' block elif_stmt + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var a; + var b; + var c; + if ( + (_keyword = $B._PyPegen.expect_token(p, 642)) // token='if' + && + (a = named_expression_rule(p)) // named_expression + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = block_rule(p)) // block + && + (c = elif_stmt_rule(p)) // elif_stmt + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.If (a, b, $B.helper_functions.CHECK ( $B.parser_constants.asdl_stmt_seq, $B._PyPegen.singleton_seq ( p, c ) ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'if' named_expression ':' block else_block? + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var a; + var b; + var c; + if ( + (_keyword = $B._PyPegen.expect_token(p, 642)) // token='if' + && + (a = named_expression_rule(p)) // named_expression + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = block_rule(p)) // block + && + (c = else_block_rule(p), !p.error_indicator) // else_block? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.If (a, b, c, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// elif_stmt: +// | invalid_elif_stmt +// | 'elif' named_expression ':' block elif_stmt +// | 'elif' named_expression ':' block else_block? +function elif_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + if (p.call_invalid_rules) { // invalid_elif_stmt + if (p.error_indicator) { + return NULL; + } + var invalid_elif_stmt_var; + if ( + (invalid_elif_stmt_var = invalid_elif_stmt_rule(p)) // invalid_elif_stmt + ) + { + _res = invalid_elif_stmt_var; + return done(); + } + p.mark = _mark; + } + { // 'elif' named_expression ':' block elif_stmt + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var a; + var b; + var c; + if ( + (_keyword = $B._PyPegen.expect_token(p, 644)) // token='elif' + && + (a = named_expression_rule(p)) // named_expression + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = block_rule(p)) // block + && + (c = elif_stmt_rule(p)) // elif_stmt + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.If (a, b, $B.helper_functions.CHECK ( $B.parser_constants.asdl_stmt_seq, $B._PyPegen.singleton_seq ( p, c ) ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'elif' named_expression ':' block else_block? + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var a; + var b; + var c; + if ( + (_keyword = $B._PyPegen.expect_token(p, 644)) // token='elif' + && + (a = named_expression_rule(p)) // named_expression + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = block_rule(p)) // block + && + (c = else_block_rule(p), !p.error_indicator) // else_block? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.If (a, b, c, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// else_block: invalid_else_stmt | 'else' &&':' block +function else_block_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.call_invalid_rules) { // invalid_else_stmt + if (p.error_indicator) { + return NULL; + } + var invalid_else_stmt_var; + if ( + (invalid_else_stmt_var = invalid_else_stmt_rule(p)) // invalid_else_stmt + ) + { + _res = invalid_else_stmt_var; + return done(); + } + p.mark = _mark; + } + { // 'else' &&':' block + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var b; + if ( + (_keyword = $B._PyPegen.expect_token(p, 645)) // token='else' + && + (_literal = $B._PyPegen.expect_forced_token(p, 11, ":")) // forced_token=':' + && + (b = block_rule(p)) // block + ) + { + _res = b; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// while_stmt: invalid_while_stmt | 'while' named_expression ':' block else_block? +function while_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + if (p.call_invalid_rules) { // invalid_while_stmt + if (p.error_indicator) { + return NULL; + } + var invalid_while_stmt_var; + if ( + (invalid_while_stmt_var = invalid_while_stmt_rule(p)) // invalid_while_stmt + ) + { + _res = invalid_while_stmt_var; + return done(); + } + p.mark = _mark; + } + { // 'while' named_expression ':' block else_block? + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var a; + var b; + var c; + if ( + (_keyword = $B._PyPegen.expect_token(p, 647)) // token='while' + && + (a = named_expression_rule(p)) // named_expression + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = block_rule(p)) // block + && + (c = else_block_rule(p), !p.error_indicator) // else_block? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.While (a, b, c, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// for_stmt: +// | invalid_for_stmt +// | 'for' star_targets 'in' ~ star_expressions ':' TYPE_COMMENT? block else_block? +// | ASYNC 'for' star_targets 'in' ~ star_expressions ':' TYPE_COMMENT? block else_block? +// | invalid_for_target +function for_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + if (p.call_invalid_rules) { // invalid_for_stmt + if (p.error_indicator) { + return NULL; + } + var invalid_for_stmt_var; + if ( + (invalid_for_stmt_var = invalid_for_stmt_rule(p)) // invalid_for_stmt + ) + { + _res = invalid_for_stmt_var; + return done(); + } + p.mark = _mark; + } + { // 'for' star_targets 'in' ~ star_expressions ':' TYPE_COMMENT? block else_block? + if (p.error_indicator) { + return NULL; + } + var _cut_var = 0; + var _keyword; + var _keyword_1; + var _literal; + var b; + var el; + var ex; + var t; + var tc; + if ( + (_keyword = $B._PyPegen.expect_token(p, 650)) // token='for' + && + (t = star_targets_rule(p)) // star_targets + && + (_keyword_1 = $B._PyPegen.expect_token(p, 651)) // token='in' + && + (_cut_var = 1) + && + (ex = star_expressions_rule(p)) // star_expressions + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (tc = $B._PyPegen.expect_token(p, TYPE_COMMENT), !p.error_indicator) // TYPE_COMMENT? + && + (b = block_rule(p)) // block + && + (el = else_block_rule(p), !p.error_indicator) // else_block? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.For (t, ex, b, el, $B.helper_functions.NEW_TYPE_COMMENT ( p, tc ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + if (_cut_var) { + return NULL; + } + } + { // ASYNC 'for' star_targets 'in' ~ star_expressions ':' TYPE_COMMENT? block else_block? + if (p.error_indicator) { + return NULL; + } + var _cut_var = 0; + var _keyword; + var _keyword_1; + var _literal; + var async_var; + var b; + var el; + var ex; + var t; + var tc; + if ( + (async_var = $B._PyPegen.expect_token(p, ASYNC)) // token='ASYNC' + && + (_keyword = $B._PyPegen.expect_token(p, 650)) // token='for' + && + (t = star_targets_rule(p)) // star_targets + && + (_keyword_1 = $B._PyPegen.expect_token(p, 651)) // token='in' + && + (_cut_var = 1) + && + (ex = star_expressions_rule(p)) // star_expressions + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (tc = $B._PyPegen.expect_token(p, TYPE_COMMENT), !p.error_indicator) // TYPE_COMMENT? + && + (b = block_rule(p)) // block + && + (el = else_block_rule(p), !p.error_indicator) // else_block? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B.helper_functions.CHECK_VERSION ($B.ast.stmt, 5, "Async for loops are", new $B._PyAST.AsyncFor ( t, ex, b, el, $B.helper_functions.NEW_TYPE_COMMENT ( p, tc ), EXTRA )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + if (_cut_var) { + return NULL; + } + } + if (p.call_invalid_rules) { // invalid_for_target + if (p.error_indicator) { + return NULL; + } + var invalid_for_target_var; + if ( + (invalid_for_target_var = invalid_for_target_rule(p)) // invalid_for_target + ) + { + _res = invalid_for_target_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// with_stmt: +// | invalid_with_stmt_indent +// | 'with' '(' ','.with_item+ ','? ')' ':' block +// | 'with' ','.with_item+ ':' TYPE_COMMENT? block +// | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block +// | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block +// | invalid_with_stmt +function with_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + if (p.call_invalid_rules) { // invalid_with_stmt_indent + if (p.error_indicator) { + return NULL; + } + var invalid_with_stmt_indent_var; + if ( + (invalid_with_stmt_indent_var = invalid_with_stmt_indent_rule(p)) // invalid_with_stmt_indent + ) + { + _res = invalid_with_stmt_indent_var; + return done(); + } + p.mark = _mark; + } + { // 'with' '(' ','.with_item+ ','? ')' ':' block + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var _literal_1; + var _literal_2; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var b; + if ( + (_keyword = $B._PyPegen.expect_token(p, 615)) // token='with' + && + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = _gather_51_rule(p)) // ','.with_item+ + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + && + (_literal_2 = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = block_rule(p)) // block + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B.helper_functions.CHECK_VERSION ($B.ast.stmt, 9, "Parenthesized context managers are", new $B._PyAST.With ( a, b, $B.parser_constants.NULL, EXTRA )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'with' ','.with_item+ ':' TYPE_COMMENT? block + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var a; + var b; + var tc; + if ( + (_keyword = $B._PyPegen.expect_token(p, 615)) // token='with' + && + (a = _gather_53_rule(p)) // ','.with_item+ + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (tc = $B._PyPegen.expect_token(p, TYPE_COMMENT), !p.error_indicator) // TYPE_COMMENT? + && + (b = block_rule(p)) // block + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.With (a, b, $B.helper_functions.NEW_TYPE_COMMENT ( p, tc ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var _literal_1; + var _literal_2; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var async_var; + var b; + if ( + (async_var = $B._PyPegen.expect_token(p, ASYNC)) // token='ASYNC' + && + (_keyword = $B._PyPegen.expect_token(p, 615)) // token='with' + && + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = _gather_55_rule(p)) // ','.with_item+ + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + && + (_literal_2 = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = block_rule(p)) // block + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B.helper_functions.CHECK_VERSION ($B.ast.stmt, 5, "Async with statements are", new $B._PyAST.AsyncWith ( a, b, $B.parser_constants.NULL, EXTRA )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var a; + var async_var; + var b; + var tc; + if ( + (async_var = $B._PyPegen.expect_token(p, ASYNC)) // token='ASYNC' + && + (_keyword = $B._PyPegen.expect_token(p, 615)) // token='with' + && + (a = _gather_57_rule(p)) // ','.with_item+ + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (tc = $B._PyPegen.expect_token(p, TYPE_COMMENT), !p.error_indicator) // TYPE_COMMENT? + && + (b = block_rule(p)) // block + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B.helper_functions.CHECK_VERSION ($B.ast.stmt, 5, "Async with statements are", new $B._PyAST.AsyncWith ( a, b, $B.helper_functions.NEW_TYPE_COMMENT ( p, tc ), EXTRA )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_with_stmt + if (p.error_indicator) { + return NULL; + } + var invalid_with_stmt_var; + if ( + (invalid_with_stmt_var = invalid_with_stmt_rule(p)) // invalid_with_stmt + ) + { + _res = invalid_with_stmt_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// with_item: +// | expression 'as' star_target &(',' | ')' | ':') +// | invalid_with_item +// | expression +function with_item_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // expression 'as' star_target &(',' | ')' | ':') + if (p.error_indicator) { + return NULL; + } + var _keyword; + var e; + var t; + if ( + (e = expression_rule(p)) // expression + && + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (t = star_target_rule(p)) // star_target + && + $B._PyPegen.lookahead(1, _tmp_59_rule, p) + ) + { + _res = new $B._PyAST.withitem (e, t, p.arena); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_with_item + if (p.error_indicator) { + return NULL; + } + var invalid_with_item_var; + if ( + (invalid_with_item_var = invalid_with_item_rule(p)) // invalid_with_item + ) + { + _res = invalid_with_item_var; + return done(); + } + p.mark = _mark; + } + { // expression + if (p.error_indicator) { + return NULL; + } + var e; + if ( + (e = expression_rule(p)) // expression + ) + { + _res = new $B._PyAST.withitem (e, $B.parser_constants.NULL, p.arena); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// try_stmt: +// | invalid_try_stmt +// | 'try' &&':' block finally_block +// | 'try' &&':' block except_block+ else_block? finally_block? +// | 'try' &&':' block except_star_block+ else_block? finally_block? +function try_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + if (p.call_invalid_rules) { // invalid_try_stmt + if (p.error_indicator) { + return NULL; + } + var invalid_try_stmt_var; + if ( + (invalid_try_stmt_var = invalid_try_stmt_rule(p)) // invalid_try_stmt + ) + { + _res = invalid_try_stmt_var; + return done(); + } + p.mark = _mark; + } + { // 'try' &&':' block finally_block + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var b; + var f; + if ( + (_keyword = $B._PyPegen.expect_token(p, 624)) // token='try' + && + (_literal = $B._PyPegen.expect_forced_token(p, 11, ":")) // forced_token=':' + && + (b = block_rule(p)) // block + && + (f = finally_block_rule(p)) // finally_block + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Try (b, $B.parser_constants.NULL, $B.parser_constants.NULL, f, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'try' &&':' block except_block+ else_block? finally_block? + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var b; + var el; + var ex; + var f; + if ( + (_keyword = $B._PyPegen.expect_token(p, 624)) // token='try' + && + (_literal = $B._PyPegen.expect_forced_token(p, 11, ":")) // forced_token=':' + && + (b = block_rule(p)) // block + && + (ex = _loop1_60_rule(p)) // except_block+ + && + (el = else_block_rule(p), !p.error_indicator) // else_block? + && + (f = finally_block_rule(p), !p.error_indicator) // finally_block? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Try (b, ex, el, f, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'try' &&':' block except_star_block+ else_block? finally_block? + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var b; + var el; + var ex; + var f; + if ( + (_keyword = $B._PyPegen.expect_token(p, 624)) // token='try' + && + (_literal = $B._PyPegen.expect_forced_token(p, 11, ":")) // forced_token=':' + && + (b = block_rule(p)) // block + && + (ex = _loop1_61_rule(p)) // except_star_block+ + && + (el = else_block_rule(p), !p.error_indicator) // else_block? + && + (f = finally_block_rule(p), !p.error_indicator) // finally_block? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B.helper_functions.CHECK_VERSION ($B.ast.stmt, 11, "Exception groups are", new $B._PyAST.TryStar ( b, ex, el, f, EXTRA )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// except_block: +// | invalid_except_stmt_indent +// | 'except' expression ['as' NAME] ':' block +// | 'except' ':' block +// | invalid_except_stmt +function except_block_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + if (p.call_invalid_rules) { // invalid_except_stmt_indent + if (p.error_indicator) { + return NULL; + } + var invalid_except_stmt_indent_var; + if ( + (invalid_except_stmt_indent_var = invalid_except_stmt_indent_rule(p)) // invalid_except_stmt_indent + ) + { + _res = invalid_except_stmt_indent_var; + return done(); + } + p.mark = _mark; + } + { // 'except' expression ['as' NAME] ':' block + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var b; + var e; + var t; + if ( + (_keyword = $B._PyPegen.expect_token(p, 637)) // token='except' + && + (e = expression_rule(p)) // expression + && + (t = _tmp_62_rule(p), !p.error_indicator) // ['as' NAME] + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = block_rule(p)) // block + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.ExceptHandler (e, ( t ) ? ( t ). id : $B.parser_constants.NULL, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'except' ':' block + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var b; + if ( + (_keyword = $B._PyPegen.expect_token(p, 637)) // token='except' + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = block_rule(p)) // block + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.ExceptHandler ($B.parser_constants.NULL, $B.parser_constants.NULL, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_except_stmt + if (p.error_indicator) { + return NULL; + } + var invalid_except_stmt_var; + if ( + (invalid_except_stmt_var = invalid_except_stmt_rule(p)) // invalid_except_stmt + ) + { + _res = invalid_except_stmt_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// except_star_block: +// | invalid_except_star_stmt_indent +// | 'except' '*' expression ['as' NAME] ':' block +// | invalid_except_stmt +function except_star_block_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + if (p.call_invalid_rules) { // invalid_except_star_stmt_indent + if (p.error_indicator) { + return NULL; + } + var invalid_except_star_stmt_indent_var; + if ( + (invalid_except_star_stmt_indent_var = invalid_except_star_stmt_indent_rule(p)) // invalid_except_star_stmt_indent + ) + { + _res = invalid_except_star_stmt_indent_var; + return done(); + } + p.mark = _mark; + } + { // 'except' '*' expression ['as' NAME] ':' block + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var _literal_1; + var b; + var e; + var t; + if ( + (_keyword = $B._PyPegen.expect_token(p, 637)) // token='except' + && + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (e = expression_rule(p)) // expression + && + (t = _tmp_63_rule(p), !p.error_indicator) // ['as' NAME] + && + (_literal_1 = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = block_rule(p)) // block + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.ExceptHandler (e, ( t ) ? ( t ). id : $B.parser_constants.NULL, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_except_stmt + if (p.error_indicator) { + return NULL; + } + var invalid_except_stmt_var; + if ( + (invalid_except_stmt_var = invalid_except_stmt_rule(p)) // invalid_except_stmt + ) + { + _res = invalid_except_stmt_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// finally_block: invalid_finally_stmt | 'finally' &&':' block +function finally_block_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.call_invalid_rules) { // invalid_finally_stmt + if (p.error_indicator) { + return NULL; + } + var invalid_finally_stmt_var; + if ( + (invalid_finally_stmt_var = invalid_finally_stmt_rule(p)) // invalid_finally_stmt + ) + { + _res = invalid_finally_stmt_var; + return done(); + } + p.mark = _mark; + } + { // 'finally' &&':' block + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 633)) // token='finally' + && + (_literal = $B._PyPegen.expect_forced_token(p, 11, ":")) // forced_token=':' + && + (a = block_rule(p)) // block + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// match_stmt: +// | "match" subject_expr ':' NEWLINE INDENT case_block+ DEDENT +// | invalid_match_stmt +function match_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // "match" subject_expr ':' NEWLINE INDENT case_block+ DEDENT + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var cases; + var dedent_var; + var indent_var; + var newline_var; + var subject; + if ( + (_keyword = $B._PyPegen.expect_soft_keyword(p, "match")) // soft_keyword='"match"' + && + (subject = subject_expr_rule(p)) // subject_expr + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + (indent_var = $B._PyPegen.expect_token(p, INDENT)) // token='INDENT' + && + (cases = _loop1_64_rule(p)) // case_block+ + && + (dedent_var = $B._PyPegen.expect_token(p, DEDENT)) // token='DEDENT' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B.helper_functions.CHECK_VERSION ($B.ast.stmt, 10, "Pattern matching is", new $B._PyAST.Match ( subject, cases, EXTRA )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_match_stmt + if (p.error_indicator) { + return NULL; + } + var invalid_match_stmt_var; + if ( + (invalid_match_stmt_var = invalid_match_stmt_rule(p)) // invalid_match_stmt + ) + { + _res = invalid_match_stmt_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// subject_expr: star_named_expression ',' star_named_expressions? | named_expression +function subject_expr_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // star_named_expression ',' star_named_expressions? + if (p.error_indicator) { + return NULL; + } + var _literal; + var value; + var values; + if ( + (value = star_named_expression_rule(p)) // star_named_expression + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (values = star_named_expressions_rule(p), !p.error_indicator) // star_named_expressions? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Tuple ($B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.seq_insert_in_front ( p, value, values ) ), $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // named_expression + if (p.error_indicator) { + return NULL; + } + var named_expression_var; + if ( + (named_expression_var = named_expression_rule(p)) // named_expression + ) + { + _res = named_expression_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// case_block: invalid_case_block | "case" patterns guard? ':' block +function case_block_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.call_invalid_rules) { // invalid_case_block + if (p.error_indicator) { + return NULL; + } + var invalid_case_block_var; + if ( + (invalid_case_block_var = invalid_case_block_rule(p)) // invalid_case_block + ) + { + _res = invalid_case_block_var; + return done(); + } + p.mark = _mark; + } + { // "case" patterns guard? ':' block + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var body; + var guard; + var pattern; + if ( + (_keyword = $B._PyPegen.expect_soft_keyword(p, "case")) // soft_keyword='"case"' + && + (pattern = patterns_rule(p)) // patterns + && + (guard = guard_rule(p), !p.error_indicator) // guard? + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (body = block_rule(p)) // block + ) + { + _res = new $B._PyAST.match_case (pattern, guard, body, p.arena); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// guard: 'if' named_expression +function guard_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'if' named_expression + if (p.error_indicator) { + return NULL; + } + var _keyword; + var guard; + if ( + (_keyword = $B._PyPegen.expect_token(p, 642)) // token='if' + && + (guard = named_expression_rule(p)) // named_expression + ) + { + _res = guard; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// patterns: open_sequence_pattern | pattern +function patterns_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // open_sequence_pattern + if (p.error_indicator) { + return NULL; + } + var patterns; + if ( + (patterns = open_sequence_pattern_rule(p)) // open_sequence_pattern + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchSequence (patterns, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // pattern + if (p.error_indicator) { + return NULL; + } + var pattern_var; + if ( + (pattern_var = pattern_rule(p)) // pattern + ) + { + _res = pattern_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// pattern: as_pattern | or_pattern +function pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // as_pattern + if (p.error_indicator) { + return NULL; + } + var as_pattern_var; + if ( + (as_pattern_var = as_pattern_rule(p)) // as_pattern + ) + { + _res = as_pattern_var; + return done(); + } + p.mark = _mark; + } + { // or_pattern + if (p.error_indicator) { + return NULL; + } + var or_pattern_var; + if ( + (or_pattern_var = or_pattern_rule(p)) // or_pattern + ) + { + _res = or_pattern_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// as_pattern: or_pattern 'as' pattern_capture_target | invalid_as_pattern +function as_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // or_pattern 'as' pattern_capture_target + if (p.error_indicator) { + return NULL; + } + var _keyword; + var pattern; + var target; + if ( + (pattern = or_pattern_rule(p)) // or_pattern + && + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (target = pattern_capture_target_rule(p)) // pattern_capture_target + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchAs (pattern, target. id, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_as_pattern + if (p.error_indicator) { + return NULL; + } + var invalid_as_pattern_var; + if ( + (invalid_as_pattern_var = invalid_as_pattern_rule(p)) // invalid_as_pattern + ) + { + _res = invalid_as_pattern_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// or_pattern: '|'.closed_pattern+ +function or_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '|'.closed_pattern+ + if (p.error_indicator) { + return NULL; + } + var patterns; + if ( + (patterns = _gather_65_rule(p)) // '|'.closed_pattern+ + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B.helper_functions.asdl_seq_LEN (patterns ) == 1 ? $B.helper_functions.asdl_seq_GET ( patterns, 0 ) : new $B._PyAST.MatchOr ( patterns, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// closed_pattern: +// | literal_pattern +// | capture_pattern +// | wildcard_pattern +// | value_pattern +// | group_pattern +// | sequence_pattern +// | mapping_pattern +// | class_pattern +function closed_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, closed_pattern_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + { // literal_pattern + if (p.error_indicator) { + return NULL; + } + var literal_pattern_var; + if ( + (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern + ) + { + _res = literal_pattern_var; + return done(); + } + p.mark = _mark; + } + { // capture_pattern + if (p.error_indicator) { + return NULL; + } + var capture_pattern_var; + if ( + (capture_pattern_var = capture_pattern_rule(p)) // capture_pattern + ) + { + _res = capture_pattern_var; + return done(); + } + p.mark = _mark; + } + { // wildcard_pattern + if (p.error_indicator) { + return NULL; + } + var wildcard_pattern_var; + if ( + (wildcard_pattern_var = wildcard_pattern_rule(p)) // wildcard_pattern + ) + { + _res = wildcard_pattern_var; + return done(); + } + p.mark = _mark; + } + { // value_pattern + if (p.error_indicator) { + return NULL; + } + var value_pattern_var; + if ( + (value_pattern_var = value_pattern_rule(p)) // value_pattern + ) + { + _res = value_pattern_var; + return done(); + } + p.mark = _mark; + } + { // group_pattern + if (p.error_indicator) { + return NULL; + } + var group_pattern_var; + if ( + (group_pattern_var = group_pattern_rule(p)) // group_pattern + ) + { + _res = group_pattern_var; + return done(); + } + p.mark = _mark; + } + { // sequence_pattern + if (p.error_indicator) { + return NULL; + } + var sequence_pattern_var; + if ( + (sequence_pattern_var = sequence_pattern_rule(p)) // sequence_pattern + ) + { + _res = sequence_pattern_var; + return done(); + } + p.mark = _mark; + } + { // mapping_pattern + if (p.error_indicator) { + return NULL; + } + var mapping_pattern_var; + if ( + (mapping_pattern_var = mapping_pattern_rule(p)) // mapping_pattern + ) + { + _res = mapping_pattern_var; + return done(); + } + p.mark = _mark; + } + { // class_pattern + if (p.error_indicator) { + return NULL; + } + var class_pattern_var; + if ( + (class_pattern_var = class_pattern_rule(p)) // class_pattern + ) + { + _res = class_pattern_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, closed_pattern_type, _res); + return _res; + } +} + +// literal_pattern: +// | signed_number !('+' | '-') +// | complex_number +// | strings +// | 'None' +// | 'True' +// | 'False' +function literal_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // signed_number !('+' | '-') + if (p.error_indicator) { + return NULL; + } + var value; + if ( + (value = signed_number_rule(p)) // signed_number + && + $B._PyPegen.lookahead(0, _tmp_67_rule, p) + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchValue (value, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // complex_number + if (p.error_indicator) { + return NULL; + } + var value; + if ( + (value = complex_number_rule(p)) // complex_number + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchValue (value, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // strings + if (p.error_indicator) { + return NULL; + } + var value; + if ( + (value = strings_rule(p)) // strings + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchValue (value, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'None' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 602)) // token='None' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchSingleton ($B.parser_constants.Py_None, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'True' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 601)) // token='True' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchSingleton ($B.parser_constants.Py_True, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'False' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 603)) // token='False' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchSingleton ($B.parser_constants.Py_False, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// literal_expr: +// | signed_number !('+' | '-') +// | complex_number +// | strings +// | 'None' +// | 'True' +// | 'False' +function literal_expr_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // signed_number !('+' | '-') + if (p.error_indicator) { + return NULL; + } + var signed_number_var; + if ( + (signed_number_var = signed_number_rule(p)) // signed_number + && + $B._PyPegen.lookahead(0, _tmp_68_rule, p) + ) + { + _res = signed_number_var; + return done(); + } + p.mark = _mark; + } + { // complex_number + if (p.error_indicator) { + return NULL; + } + var complex_number_var; + if ( + (complex_number_var = complex_number_rule(p)) // complex_number + ) + { + _res = complex_number_var; + return done(); + } + p.mark = _mark; + } + { // strings + if (p.error_indicator) { + return NULL; + } + var strings_var; + if ( + (strings_var = strings_rule(p)) // strings + ) + { + _res = strings_var; + return done(); + } + p.mark = _mark; + } + { // 'None' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 602)) // token='None' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Constant ($B.parser_constants.Py_None, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'True' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 601)) // token='True' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Constant ($B.parser_constants.Py_True, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'False' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 603)) // token='False' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Constant ($B.parser_constants.Py_False, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// complex_number: +// | signed_real_number '+' imaginary_number +// | signed_real_number '-' imaginary_number +function complex_number_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // signed_real_number '+' imaginary_number + if (p.error_indicator) { + return NULL; + } + var _literal; + var imag; + var real; + if ( + (real = signed_real_number_rule(p)) // signed_real_number + && + (_literal = $B._PyPegen.expect_token(p, 14)) // token='+' + && + (imag = imaginary_number_rule(p)) // imaginary_number + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BinOp (real, new $B.ast.Add, imag, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // signed_real_number '-' imaginary_number + if (p.error_indicator) { + return NULL; + } + var _literal; + var imag; + var real; + if ( + (real = signed_real_number_rule(p)) // signed_real_number + && + (_literal = $B._PyPegen.expect_token(p, 15)) // token='-' + && + (imag = imaginary_number_rule(p)) // imaginary_number + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BinOp (real, new $B.ast.Sub, imag, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// signed_number: NUMBER | '-' NUMBER +function signed_number_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // NUMBER + if (p.error_indicator) { + return NULL; + } + var number_var; + if ( + (number_var = $B._PyPegen.number_token(p)) // NUMBER + ) + { + _res = number_var; + return done(); + } + p.mark = _mark; + } + { // '-' NUMBER + if (p.error_indicator) { + return NULL; + } + var _literal; + var number; + if ( + (_literal = $B._PyPegen.expect_token(p, 15)) // token='-' + && + (number = $B._PyPegen.number_token(p)) // NUMBER + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.UnaryOp (new $B.ast.USub, number, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// signed_real_number: real_number | '-' real_number +function signed_real_number_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // real_number + if (p.error_indicator) { + return NULL; + } + var real_number_var; + if ( + (real_number_var = real_number_rule(p)) // real_number + ) + { + _res = real_number_var; + return done(); + } + p.mark = _mark; + } + { // '-' real_number + if (p.error_indicator) { + return NULL; + } + var _literal; + var real; + if ( + (_literal = $B._PyPegen.expect_token(p, 15)) // token='-' + && + (real = real_number_rule(p)) // real_number + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.UnaryOp (new $B.ast.USub, real, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// real_number: NUMBER +function real_number_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // NUMBER + if (p.error_indicator) { + return NULL; + } + var real; + if ( + (real = $B._PyPegen.number_token(p)) // NUMBER + ) + { + _res = $B._PyPegen.ensure_real (p, real); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// imaginary_number: NUMBER +function imaginary_number_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // NUMBER + if (p.error_indicator) { + return NULL; + } + var imag; + if ( + (imag = $B._PyPegen.number_token(p)) // NUMBER + ) + { + _res = $B._PyPegen.ensure_imaginary (p, imag); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// capture_pattern: pattern_capture_target +function capture_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // pattern_capture_target + if (p.error_indicator) { + return NULL; + } + var target; + if ( + (target = pattern_capture_target_rule(p)) // pattern_capture_target + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchAs ($B.parser_constants.NULL, target. id, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// pattern_capture_target: !"_" NAME !('.' | '(' | '=') +function pattern_capture_target_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // !"_" NAME !('.' | '(' | '=') + if (p.error_indicator) { + return NULL; + } + var name; + if ( + $B._PyPegen.lookahead_with_string(0, $B._PyPegen.expect_soft_keyword, p, "_") + && + (name = $B._PyPegen.name_token(p)) // NAME + && + $B._PyPegen.lookahead(0, _tmp_69_rule, p) + ) + { + _res = $B._PyPegen.set_expr_context (p, name, $B.parser_constants.Store); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// wildcard_pattern: "_" +function wildcard_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // "_" + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_soft_keyword(p, "_")) // soft_keyword='"_"' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchAs ($B.parser_constants.NULL, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// value_pattern: attr !('.' | '(' | '=') +function value_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // attr !('.' | '(' | '=') + if (p.error_indicator) { + return NULL; + } + var attr; + if ( + (attr = attr_rule(p)) // attr + && + $B._PyPegen.lookahead(0, _tmp_70_rule, p) + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchValue (attr, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// Left-recursive +// attr: name_or_attr '.' NAME +function attr_raw(){}; +function attr_rule(p) +{ + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, attr_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + var _resmark = p.mark; + while (1) { + var tmpvar_1 = $B._PyPegen.update_memo(p, _mark, attr_type, _res); + if (tmpvar_1) { + return _res; + } + p.mark = _mark; + var _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; + return _res; +} +function attr_raw(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // name_or_attr '.' NAME + if (p.error_indicator) { + return NULL; + } + var _literal; + var attr; + var value; + if ( + (value = name_or_attr_rule(p)) // name_or_attr + && + (_literal = $B._PyPegen.expect_token(p, 23)) // token='.' + && + (attr = $B._PyPegen.name_token(p)) // NAME + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Attribute (value, attr. id, $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// Left-recursive +// name_or_attr: attr | NAME +function name_or_attr_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // attr + if (p.error_indicator) { + return NULL; + } + var attr_var; + if ( + (attr_var = attr_rule(p)) // attr + ) + { + _res = attr_var; + return done(); + } + p.mark = _mark; + } + { // NAME + if (p.error_indicator) { + return NULL; + } + var name_var; + if ( + (name_var = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = name_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// group_pattern: '(' pattern ')' +function group_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '(' pattern ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var pattern; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (pattern = pattern_rule(p)) // pattern + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = pattern; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// sequence_pattern: '[' maybe_sequence_pattern? ']' | '(' open_sequence_pattern? ')' +function sequence_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '[' maybe_sequence_pattern? ']' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var patterns; + if ( + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + && + (patterns = maybe_sequence_pattern_rule(p), !p.error_indicator) // maybe_sequence_pattern? + && + (_literal_1 = $B._PyPegen.expect_token(p, 10)) // token=']' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchSequence (patterns, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '(' open_sequence_pattern? ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var patterns; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (patterns = open_sequence_pattern_rule(p), !p.error_indicator) // open_sequence_pattern? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchSequence (patterns, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// open_sequence_pattern: maybe_star_pattern ',' maybe_sequence_pattern? +function open_sequence_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // maybe_star_pattern ',' maybe_sequence_pattern? + if (p.error_indicator) { + return NULL; + } + var _literal; + var pattern; + var patterns; + if ( + (pattern = maybe_star_pattern_rule(p)) // maybe_star_pattern + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (patterns = maybe_sequence_pattern_rule(p), !p.error_indicator) // maybe_sequence_pattern? + ) + { + _res = $B._PyPegen.seq_insert_in_front (p, pattern, patterns); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// maybe_sequence_pattern: ','.maybe_star_pattern+ ','? +function maybe_sequence_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.maybe_star_pattern+ ','? + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var patterns; + if ( + (patterns = _gather_71_rule(p)) // ','.maybe_star_pattern+ + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + ) + { + _res = patterns; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// maybe_star_pattern: star_pattern | pattern +function maybe_star_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // star_pattern + if (p.error_indicator) { + return NULL; + } + var star_pattern_var; + if ( + (star_pattern_var = star_pattern_rule(p)) // star_pattern + ) + { + _res = star_pattern_var; + return done(); + } + p.mark = _mark; + } + { // pattern + if (p.error_indicator) { + return NULL; + } + var pattern_var; + if ( + (pattern_var = pattern_rule(p)) // pattern + ) + { + _res = pattern_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// star_pattern: '*' pattern_capture_target | '*' wildcard_pattern +function star_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, star_pattern_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '*' pattern_capture_target + if (p.error_indicator) { + return NULL; + } + var _literal; + var target; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (target = pattern_capture_target_rule(p)) // pattern_capture_target + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchStar (target. id, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '*' wildcard_pattern + if (p.error_indicator) { + return NULL; + } + var _literal; + var wildcard_pattern_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (wildcard_pattern_var = wildcard_pattern_rule(p)) // wildcard_pattern + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchStar ($B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, star_pattern_type, _res); + return _res; + } +} + +// mapping_pattern: +// | '{' '}' +// | '{' double_star_pattern ','? '}' +// | '{' items_pattern ',' double_star_pattern ','? '}' +// | '{' items_pattern ','? '}' +function mapping_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '{' '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (_literal_1 = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchMapping ($B.parser_constants.NULL, $B.parser_constants.NULL, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '{' double_star_pattern ','? '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var rest; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (rest = double_star_pattern_rule(p)) // double_star_pattern + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + && + (_literal_1 = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchMapping ($B.parser_constants.NULL, $B.parser_constants.NULL, rest. id, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '{' items_pattern ',' double_star_pattern ','? '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _literal_2; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var items; + var rest; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (items = items_pattern_rule(p)) // items_pattern + && + (_literal_1 = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (rest = double_star_pattern_rule(p)) // double_star_pattern + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + && + (_literal_2 = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchMapping ($B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.get_pattern_keys ( p, items ) ), $B.helper_functions.CHECK ( $B.parser_constants.asdl_pattern_seq, $B._PyPegen.get_patterns ( p, items ) ), rest. id, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '{' items_pattern ','? '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var items; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (items = items_pattern_rule(p)) // items_pattern + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + && + (_literal_1 = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchMapping ($B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.get_pattern_keys ( p, items ) ), $B.helper_functions.CHECK ( $B.parser_constants.asdl_pattern_seq, $B._PyPegen.get_patterns ( p, items ) ), $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// items_pattern: ','.key_value_pattern+ +function items_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.key_value_pattern+ + if (p.error_indicator) { + return NULL; + } + var _gather_73_var; + if ( + (_gather_73_var = _gather_73_rule(p)) // ','.key_value_pattern+ + ) + { + _res = _gather_73_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// key_value_pattern: (literal_expr | attr) ':' pattern +function key_value_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // (literal_expr | attr) ':' pattern + if (p.error_indicator) { + return NULL; + } + var _literal; + var key; + var pattern; + if ( + (key = _tmp_75_rule(p)) // literal_expr | attr + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (pattern = pattern_rule(p)) // pattern + ) + { + _res = $B._PyPegen.key_pattern_pair (p, key, pattern); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// double_star_pattern: '**' pattern_capture_target +function double_star_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '**' pattern_capture_target + if (p.error_indicator) { + return NULL; + } + var _literal; + var target; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (target = pattern_capture_target_rule(p)) // pattern_capture_target + ) + { + _res = target; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// class_pattern: +// | name_or_attr '(' ')' +// | name_or_attr '(' positional_patterns ','? ')' +// | name_or_attr '(' keyword_patterns ','? ')' +// | name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')' +// | invalid_class_pattern +function class_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // name_or_attr '(' ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var cls; + if ( + (cls = name_or_attr_rule(p)) // name_or_attr + && + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchClass (cls, $B.parser_constants.NULL, $B.parser_constants.NULL, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // name_or_attr '(' positional_patterns ','? ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var cls; + var patterns; + if ( + (cls = name_or_attr_rule(p)) // name_or_attr + && + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (patterns = positional_patterns_rule(p)) // positional_patterns + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchClass (cls, patterns, $B.parser_constants.NULL, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // name_or_attr '(' keyword_patterns ','? ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var cls; + var keywords; + if ( + (cls = name_or_attr_rule(p)) // name_or_attr + && + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (keywords = keyword_patterns_rule(p)) // keyword_patterns + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchClass (cls, $B.parser_constants.NULL, $B.helper_functions.CHECK ( $B.parser_constants.asdl_identifier_seq, $B._PyPegen.map_names_to_ids ( p, $B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.get_pattern_keys ( p, keywords ) ) ) ), $B.helper_functions.CHECK ( $B.parser_constants.asdl_pattern_seq, $B._PyPegen.get_patterns ( p, keywords ) ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _literal_2; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var cls; + var keywords; + var patterns; + if ( + (cls = name_or_attr_rule(p)) // name_or_attr + && + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (patterns = positional_patterns_rule(p)) // positional_patterns + && + (_literal_1 = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (keywords = keyword_patterns_rule(p)) // keyword_patterns + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + && + (_literal_2 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.MatchClass (cls, patterns, $B.helper_functions.CHECK ( $B.parser_constants.asdl_identifier_seq, $B._PyPegen.map_names_to_ids ( p, $B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.get_pattern_keys ( p, keywords ) ) ) ), $B.helper_functions.CHECK ( $B.parser_constants.asdl_pattern_seq, $B._PyPegen.get_patterns ( p, keywords ) ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_class_pattern + if (p.error_indicator) { + return NULL; + } + var invalid_class_pattern_var; + if ( + (invalid_class_pattern_var = invalid_class_pattern_rule(p)) // invalid_class_pattern + ) + { + _res = invalid_class_pattern_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// positional_patterns: ','.pattern+ +function positional_patterns_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.pattern+ + if (p.error_indicator) { + return NULL; + } + var args; + if ( + (args = _gather_76_rule(p)) // ','.pattern+ + ) + { + _res = args; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// keyword_patterns: ','.keyword_pattern+ +function keyword_patterns_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.keyword_pattern+ + if (p.error_indicator) { + return NULL; + } + var _gather_78_var; + if ( + (_gather_78_var = _gather_78_rule(p)) // ','.keyword_pattern+ + ) + { + _res = _gather_78_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// keyword_pattern: NAME '=' pattern +function keyword_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // NAME '=' pattern + if (p.error_indicator) { + return NULL; + } + var _literal; + var arg; + var value; + if ( + (arg = $B._PyPegen.name_token(p)) // NAME + && + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + && + (value = pattern_rule(p)) // pattern + ) + { + _res = $B._PyPegen.key_pattern_pair (p, arg, value); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// type_alias: "type" NAME type_params? '=' expression +function type_alias_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // "type" NAME type_params? '=' expression + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var b; + var n; + var t; + if ( + (_keyword = $B._PyPegen.expect_soft_keyword(p, "type")) // soft_keyword='"type"' + && + (n = $B._PyPegen.name_token(p)) // NAME + && + (t = type_params_rule(p), !p.error_indicator) // type_params? + && + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + && + (b = expression_rule(p)) // expression + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B.helper_functions.CHECK_VERSION ($B.ast.stmt, 12, "Type statement is", new $B._PyAST.TypeAlias ( $B.helper_functions.CHECK ( $B.ast.expr, $B._PyPegen.set_expr_context ( p, n, $B.parser_constants.Store ) ), t, b, EXTRA )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// type_params: '[' type_param_seq ']' +function type_params_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '[' type_param_seq ']' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var t; + if ( + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + && + (t = type_param_seq_rule(p)) // type_param_seq + && + (_literal_1 = $B._PyPegen.expect_token(p, 10)) // token=']' + ) + { + _res = $B.helper_functions.CHECK_VERSION ($B.parser_constants.asdl_type_param_seq, 12, "Type parameter lists are", t); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// type_param_seq: ','.type_param+ ','? +function type_param_seq_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.type_param+ ','? + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + if ( + (a = _gather_80_rule(p)) // ','.type_param+ + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// type_param: +// | NAME type_param_bound? +// | '*' NAME ':' expression +// | '*' NAME +// | '**' NAME ':' expression +// | '**' NAME +function type_param_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, type_param_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // NAME type_param_bound? + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + && + (b = type_param_bound_rule(p), !p.error_indicator) // type_param_bound? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.TypeVar (a. id, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '*' NAME ':' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var colon; + var e; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (a = $B._PyPegen.name_token(p)) // NAME + && + (colon = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (e = expression_rule(p)) // expression + ) + { + _res = RAISE_SYNTAX_ERROR_STARTING_FROM (colon, e.kind == Tuple_kind ? "cannot use constraints with TypeVarTuple" : "cannot use bound with TypeVarTuple"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '*' NAME + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (a = $B._PyPegen.name_token(p)) // NAME + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.TypeVarTuple (a. id, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '**' NAME ':' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var colon; + var e; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (a = $B._PyPegen.name_token(p)) // NAME + && + (colon = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (e = expression_rule(p)) // expression + ) + { + _res = RAISE_SYNTAX_ERROR_STARTING_FROM (colon, e.kind == Tuple_kind ? "cannot use constraints with ParamSpec" : "cannot use bound with ParamSpec"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '**' NAME + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (a = $B._PyPegen.name_token(p)) // NAME + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.ParamSpec (a. id, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, type_param_type, _res); + return _res; + } +} + +// type_param_bound: ':' expression +function type_param_bound_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ':' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var e; + if ( + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (e = expression_rule(p)) // expression + ) + { + _res = e; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// expressions: expression ((',' expression))+ ','? | expression ',' | expression +function expressions_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // expression ((',' expression))+ ','? + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var b; + if ( + (a = expression_rule(p)) // expression + && + (b = _loop1_82_rule(p)) // ((',' expression))+ + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Tuple ($B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.seq_insert_in_front ( p, a, b ) ), $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // expression ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (a = expression_rule(p)) // expression + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Tuple ($B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.singleton_seq ( p, a ) ), $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // expression + if (p.error_indicator) { + return NULL; + } + var expression_var; + if ( + (expression_var = expression_rule(p)) // expression + ) + { + _res = expression_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// expression: +// | invalid_expression +// | invalid_legacy_expression +// | disjunction 'if' disjunction 'else' expression +// | disjunction +// | lambdef +function expression_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, expression_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + if (p.call_invalid_rules) { // invalid_expression + if (p.error_indicator) { + return NULL; + } + var invalid_expression_var; + if ( + (invalid_expression_var = invalid_expression_rule(p)) // invalid_expression + ) + { + _res = invalid_expression_var; + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_legacy_expression + if (p.error_indicator) { + return NULL; + } + var invalid_legacy_expression_var; + if ( + (invalid_legacy_expression_var = invalid_legacy_expression_rule(p)) // invalid_legacy_expression + ) + { + _res = invalid_legacy_expression_var; + return done(); + } + p.mark = _mark; + } + { // disjunction 'if' disjunction 'else' expression + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _keyword_1; + var a; + var b; + var c; + if ( + (a = disjunction_rule(p)) // disjunction + && + (_keyword = $B._PyPegen.expect_token(p, 642)) // token='if' + && + (b = disjunction_rule(p)) // disjunction + && + (_keyword_1 = $B._PyPegen.expect_token(p, 645)) // token='else' + && + (c = expression_rule(p)) // expression + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.IfExp (b, a, c, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // disjunction + if (p.error_indicator) { + return NULL; + } + var disjunction_var; + if ( + (disjunction_var = disjunction_rule(p)) // disjunction + ) + { + _res = disjunction_var; + return done(); + } + p.mark = _mark; + } + { // lambdef + if (p.error_indicator) { + return NULL; + } + var lambdef_var; + if ( + (lambdef_var = lambdef_rule(p)) // lambdef + ) + { + _res = lambdef_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, expression_type, _res); + return _res; + } +} + +// yield_expr: 'yield' 'from' expression | 'yield' star_expressions? +function yield_expr_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // 'yield' 'from' expression + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _keyword_1; + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 573)) // token='yield' + && + (_keyword_1 = $B._PyPegen.expect_token(p, 608)) // token='from' + && + (a = expression_rule(p)) // expression + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.YieldFrom (a, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'yield' star_expressions? + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 573)) // token='yield' + && + (a = star_expressions_rule(p), !p.error_indicator) // star_expressions? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Yield (a, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// star_expressions: +// | star_expression ((',' star_expression))+ ','? +// | star_expression ',' +// | star_expression +function star_expressions_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // star_expression ((',' star_expression))+ ','? + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var b; + if ( + (a = star_expression_rule(p)) // star_expression + && + (b = _loop1_83_rule(p)) // ((',' star_expression))+ + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Tuple ($B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.seq_insert_in_front ( p, a, b ) ), $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // star_expression ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (a = star_expression_rule(p)) // star_expression + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Tuple ($B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.singleton_seq ( p, a ) ), $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // star_expression + if (p.error_indicator) { + return NULL; + } + var star_expression_var; + if ( + (star_expression_var = star_expression_rule(p)) // star_expression + ) + { + _res = star_expression_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// star_expression: '*' bitwise_or | expression +function star_expression_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, star_expression_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '*' bitwise_or + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (a = bitwise_or_rule(p)) // bitwise_or + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Starred (a, $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // expression + if (p.error_indicator) { + return NULL; + } + var expression_var; + if ( + (expression_var = expression_rule(p)) // expression + ) + { + _res = expression_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, star_expression_type, _res); + return _res; + } +} + +// star_named_expressions: ','.star_named_expression+ ','? +function star_named_expressions_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.star_named_expression+ ','? + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + if ( + (a = _gather_84_rule(p)) // ','.star_named_expression+ + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// star_named_expression: '*' bitwise_or | named_expression +function star_named_expression_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '*' bitwise_or + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (a = bitwise_or_rule(p)) // bitwise_or + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Starred (a, $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // named_expression + if (p.error_indicator) { + return NULL; + } + var named_expression_var; + if ( + (named_expression_var = named_expression_rule(p)) // named_expression + ) + { + _res = named_expression_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// assignment_expression: NAME ':=' ~ expression +function assignment_expression_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // NAME ':=' ~ expression + if (p.error_indicator) { + return NULL; + } + var _cut_var = 0; + var _literal; + var a; + var b; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + && + (_literal = $B._PyPegen.expect_token(p, 53)) // token=':=' + && + (_cut_var = 1) + && + (b = expression_rule(p)) // expression + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B.helper_functions.CHECK_VERSION ($B.ast.expr, 8, "Assignment expressions are", new $B._PyAST.NamedExpr ( $B.helper_functions.CHECK ( $B.ast.expr, $B._PyPegen.set_expr_context ( p, a, $B.parser_constants.Store ) ), b, EXTRA )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + if (_cut_var) { + return NULL; + } + } + _res = NULL; + function done(){ + return _res; + } +} + +// named_expression: assignment_expression | invalid_named_expression | expression !':=' +function named_expression_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // assignment_expression + if (p.error_indicator) { + return NULL; + } + var assignment_expression_var; + if ( + (assignment_expression_var = assignment_expression_rule(p)) // assignment_expression + ) + { + _res = assignment_expression_var; + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_named_expression + if (p.error_indicator) { + return NULL; + } + var invalid_named_expression_var; + if ( + (invalid_named_expression_var = invalid_named_expression_rule(p)) // invalid_named_expression + ) + { + _res = invalid_named_expression_var; + return done(); + } + p.mark = _mark; + } + { // expression !':=' + if (p.error_indicator) { + return NULL; + } + var expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 53) // token=':=' + ) + { + _res = expression_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// disjunction: conjunction (('or' conjunction))+ | conjunction +function disjunction_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, disjunction_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // conjunction (('or' conjunction))+ + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = conjunction_rule(p)) // conjunction + && + (b = _loop1_86_rule(p)) // (('or' conjunction))+ + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BoolOp (new $B.ast.Or, $B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.seq_insert_in_front ( p, a, b ) ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // conjunction + if (p.error_indicator) { + return NULL; + } + var conjunction_var; + if ( + (conjunction_var = conjunction_rule(p)) // conjunction + ) + { + _res = conjunction_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, disjunction_type, _res); + return _res; + } +} + +// conjunction: inversion (('and' inversion))+ | inversion +function conjunction_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, conjunction_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // inversion (('and' inversion))+ + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = inversion_rule(p)) // inversion + && + (b = _loop1_87_rule(p)) // (('and' inversion))+ + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BoolOp (new $B.ast.And, $B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.seq_insert_in_front ( p, a, b ) ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // inversion + if (p.error_indicator) { + return NULL; + } + var inversion_var; + if ( + (inversion_var = inversion_rule(p)) // inversion + ) + { + _res = inversion_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, conjunction_type, _res); + return _res; + } +} + +// inversion: 'not' inversion | comparison +function inversion_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, inversion_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // 'not' inversion + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 581)) // token='not' + && + (a = inversion_rule(p)) // inversion + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.UnaryOp (new $B.ast.Not, a, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // comparison + if (p.error_indicator) { + return NULL; + } + var comparison_var; + if ( + (comparison_var = comparison_rule(p)) // comparison + ) + { + _res = comparison_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, inversion_type, _res); + return _res; + } +} + +// comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or +function comparison_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // bitwise_or compare_op_bitwise_or_pair+ + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = bitwise_or_rule(p)) // bitwise_or + && + (b = _loop1_88_rule(p)) // compare_op_bitwise_or_pair+ + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Compare (a, $B.helper_functions.CHECK ( $B.parser_constants.asdl_int_seq, $B._PyPegen.get_cmpops ( p, b ) ), $B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.get_exprs ( p, b ) ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // bitwise_or + if (p.error_indicator) { + return NULL; + } + var bitwise_or_var; + if ( + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + ) + { + _res = bitwise_or_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// compare_op_bitwise_or_pair: +// | eq_bitwise_or +// | noteq_bitwise_or +// | lte_bitwise_or +// | lt_bitwise_or +// | gte_bitwise_or +// | gt_bitwise_or +// | notin_bitwise_or +// | in_bitwise_or +// | isnot_bitwise_or +// | is_bitwise_or +function compare_op_bitwise_or_pair_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // eq_bitwise_or + if (p.error_indicator) { + return NULL; + } + var eq_bitwise_or_var; + if ( + (eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or + ) + { + _res = eq_bitwise_or_var; + return done(); + } + p.mark = _mark; + } + { // noteq_bitwise_or + if (p.error_indicator) { + return NULL; + } + var noteq_bitwise_or_var; + if ( + (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or + ) + { + _res = noteq_bitwise_or_var; + return done(); + } + p.mark = _mark; + } + { // lte_bitwise_or + if (p.error_indicator) { + return NULL; + } + var lte_bitwise_or_var; + if ( + (lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or + ) + { + _res = lte_bitwise_or_var; + return done(); + } + p.mark = _mark; + } + { // lt_bitwise_or + if (p.error_indicator) { + return NULL; + } + var lt_bitwise_or_var; + if ( + (lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or + ) + { + _res = lt_bitwise_or_var; + return done(); + } + p.mark = _mark; + } + { // gte_bitwise_or + if (p.error_indicator) { + return NULL; + } + var gte_bitwise_or_var; + if ( + (gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or + ) + { + _res = gte_bitwise_or_var; + return done(); + } + p.mark = _mark; + } + { // gt_bitwise_or + if (p.error_indicator) { + return NULL; + } + var gt_bitwise_or_var; + if ( + (gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or + ) + { + _res = gt_bitwise_or_var; + return done(); + } + p.mark = _mark; + } + { // notin_bitwise_or + if (p.error_indicator) { + return NULL; + } + var notin_bitwise_or_var; + if ( + (notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or + ) + { + _res = notin_bitwise_or_var; + return done(); + } + p.mark = _mark; + } + { // in_bitwise_or + if (p.error_indicator) { + return NULL; + } + var in_bitwise_or_var; + if ( + (in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or + ) + { + _res = in_bitwise_or_var; + return done(); + } + p.mark = _mark; + } + { // isnot_bitwise_or + if (p.error_indicator) { + return NULL; + } + var isnot_bitwise_or_var; + if ( + (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or + ) + { + _res = isnot_bitwise_or_var; + return done(); + } + p.mark = _mark; + } + { // is_bitwise_or + if (p.error_indicator) { + return NULL; + } + var is_bitwise_or_var; + if ( + (is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or + ) + { + _res = is_bitwise_or_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// eq_bitwise_or: '==' bitwise_or +function eq_bitwise_or_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '==' bitwise_or + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 27)) // token='==' + && + (a = bitwise_or_rule(p)) // bitwise_or + ) + { + _res = $B._PyPegen.cmpop_expr_pair (p, new $B.ast.Eq, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// noteq_bitwise_or: ('!=') bitwise_or +function noteq_bitwise_or_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ('!=') bitwise_or + if (p.error_indicator) { + return NULL; + } + var _tmp_89_var; + var a; + if ( + (_tmp_89_var = _tmp_89_rule(p)) // '!=' + && + (a = bitwise_or_rule(p)) // bitwise_or + ) + { + _res = $B._PyPegen.cmpop_expr_pair (p, new $B.ast.NotEq, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// lte_bitwise_or: '<=' bitwise_or +function lte_bitwise_or_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '<=' bitwise_or + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 29)) // token='<=' + && + (a = bitwise_or_rule(p)) // bitwise_or + ) + { + _res = $B._PyPegen.cmpop_expr_pair (p, new $B.ast.LtE, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// lt_bitwise_or: '<' bitwise_or +function lt_bitwise_or_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '<' bitwise_or + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 20)) // token='<' + && + (a = bitwise_or_rule(p)) // bitwise_or + ) + { + _res = $B._PyPegen.cmpop_expr_pair (p, new $B.ast.Lt, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// gte_bitwise_or: '>=' bitwise_or +function gte_bitwise_or_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '>=' bitwise_or + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 30)) // token='>=' + && + (a = bitwise_or_rule(p)) // bitwise_or + ) + { + _res = $B._PyPegen.cmpop_expr_pair (p, new $B.ast.GtE, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// gt_bitwise_or: '>' bitwise_or +function gt_bitwise_or_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '>' bitwise_or + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 21)) // token='>' + && + (a = bitwise_or_rule(p)) // bitwise_or + ) + { + _res = $B._PyPegen.cmpop_expr_pair (p, new $B.ast.Gt, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// notin_bitwise_or: 'not' 'in' bitwise_or +function notin_bitwise_or_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'not' 'in' bitwise_or + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _keyword_1; + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 581)) // token='not' + && + (_keyword_1 = $B._PyPegen.expect_token(p, 651)) // token='in' + && + (a = bitwise_or_rule(p)) // bitwise_or + ) + { + _res = $B._PyPegen.cmpop_expr_pair (p, new $B.ast.NotIn, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// in_bitwise_or: 'in' bitwise_or +function in_bitwise_or_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'in' bitwise_or + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 651)) // token='in' + && + (a = bitwise_or_rule(p)) // bitwise_or + ) + { + _res = $B._PyPegen.cmpop_expr_pair (p, new $B.ast.In, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// isnot_bitwise_or: 'is' 'not' bitwise_or +function isnot_bitwise_or_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'is' 'not' bitwise_or + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _keyword_1; + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 582)) // token='is' + && + (_keyword_1 = $B._PyPegen.expect_token(p, 581)) // token='not' + && + (a = bitwise_or_rule(p)) // bitwise_or + ) + { + _res = $B._PyPegen.cmpop_expr_pair (p, new $B.ast.IsNot, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// is_bitwise_or: 'is' bitwise_or +function is_bitwise_or_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'is' bitwise_or + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 582)) // token='is' + && + (a = bitwise_or_rule(p)) // bitwise_or + ) + { + _res = $B._PyPegen.cmpop_expr_pair (p, new $B.ast.Is, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// Left-recursive +// bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor +function bitwise_or_raw(){}; +function bitwise_or_rule(p) +{ + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, bitwise_or_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + var _resmark = p.mark; + while (1) { + var tmpvar_2 = $B._PyPegen.update_memo(p, _mark, bitwise_or_type, _res); + if (tmpvar_2) { + return _res; + } + p.mark = _mark; + var _raw = bitwise_or_raw(p); + if (p.error_indicator) { + return NULL; + } + if (_raw == NULL || p.mark <= _resmark) + break; + _resmark = p.mark; + _res = _raw; + } + p.mark = _resmark; + return _res; +} +function bitwise_or_raw(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // bitwise_or '|' bitwise_xor + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = bitwise_or_rule(p)) // bitwise_or + && + (_literal = $B._PyPegen.expect_token(p, 18)) // token='|' + && + (b = bitwise_xor_rule(p)) // bitwise_xor + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BinOp (a, new $B.ast.BitOr, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // bitwise_xor + if (p.error_indicator) { + return NULL; + } + var bitwise_xor_var; + if ( + (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor + ) + { + _res = bitwise_xor_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// Left-recursive +// bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and +function bitwise_xor_raw(){}; +function bitwise_xor_rule(p) +{ + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, bitwise_xor_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + var _resmark = p.mark; + while (1) { + var tmpvar_3 = $B._PyPegen.update_memo(p, _mark, bitwise_xor_type, _res); + if (tmpvar_3) { + return _res; + } + p.mark = _mark; + var _raw = bitwise_xor_raw(p); + if (p.error_indicator) { + return NULL; + } + if (_raw == NULL || p.mark <= _resmark) + break; + _resmark = p.mark; + _res = _raw; + } + p.mark = _resmark; + return _res; +} +function bitwise_xor_raw(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // bitwise_xor '^' bitwise_and + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = bitwise_xor_rule(p)) // bitwise_xor + && + (_literal = $B._PyPegen.expect_token(p, 32)) // token='^' + && + (b = bitwise_and_rule(p)) // bitwise_and + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BinOp (a, new $B.ast.BitXor, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // bitwise_and + if (p.error_indicator) { + return NULL; + } + var bitwise_and_var; + if ( + (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and + ) + { + _res = bitwise_and_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// Left-recursive +// bitwise_and: bitwise_and '&' shift_expr | shift_expr +function bitwise_and_raw(){}; +function bitwise_and_rule(p) +{ + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, bitwise_and_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + var _resmark = p.mark; + while (1) { + var tmpvar_4 = $B._PyPegen.update_memo(p, _mark, bitwise_and_type, _res); + if (tmpvar_4) { + return _res; + } + p.mark = _mark; + var _raw = bitwise_and_raw(p); + if (p.error_indicator) { + return NULL; + } + if (_raw == NULL || p.mark <= _resmark) + break; + _resmark = p.mark; + _res = _raw; + } + p.mark = _resmark; + return _res; +} +function bitwise_and_raw(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // bitwise_and '&' shift_expr + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = bitwise_and_rule(p)) // bitwise_and + && + (_literal = $B._PyPegen.expect_token(p, 19)) // token='&' + && + (b = shift_expr_rule(p)) // shift_expr + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BinOp (a, new $B.ast.BitAnd, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // shift_expr + if (p.error_indicator) { + return NULL; + } + var shift_expr_var; + if ( + (shift_expr_var = shift_expr_rule(p)) // shift_expr + ) + { + _res = shift_expr_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// Left-recursive +// shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum +function shift_expr_raw(){}; +function shift_expr_rule(p) +{ + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, shift_expr_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + var _resmark = p.mark; + while (1) { + var tmpvar_5 = $B._PyPegen.update_memo(p, _mark, shift_expr_type, _res); + if (tmpvar_5) { + return _res; + } + p.mark = _mark; + var _raw = shift_expr_raw(p); + if (p.error_indicator) { + return NULL; + } + if (_raw == NULL || p.mark <= _resmark) + break; + _resmark = p.mark; + _res = _raw; + } + p.mark = _resmark; + return _res; +} +function shift_expr_raw(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // shift_expr '<<' sum + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = shift_expr_rule(p)) // shift_expr + && + (_literal = $B._PyPegen.expect_token(p, 33)) // token='<<' + && + (b = sum_rule(p)) // sum + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BinOp (a, new $B.ast.LShift, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // shift_expr '>>' sum + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = shift_expr_rule(p)) // shift_expr + && + (_literal = $B._PyPegen.expect_token(p, 34)) // token='>>' + && + (b = sum_rule(p)) // sum + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BinOp (a, new $B.ast.RShift, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // sum + if (p.error_indicator) { + return NULL; + } + var sum_var; + if ( + (sum_var = sum_rule(p)) // sum + ) + { + _res = sum_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// Left-recursive +// sum: sum '+' term | sum '-' term | term +function sum_raw(){}; +function sum_rule(p) +{ + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, sum_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + var _resmark = p.mark; + while (1) { + var tmpvar_6 = $B._PyPegen.update_memo(p, _mark, sum_type, _res); + if (tmpvar_6) { + return _res; + } + p.mark = _mark; + var _raw = sum_raw(p); + if (p.error_indicator) { + return NULL; + } + if (_raw == NULL || p.mark <= _resmark) + break; + _resmark = p.mark; + _res = _raw; + } + p.mark = _resmark; + return _res; +} +function sum_raw(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // sum '+' term + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = sum_rule(p)) // sum + && + (_literal = $B._PyPegen.expect_token(p, 14)) // token='+' + && + (b = term_rule(p)) // term + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BinOp (a, new $B.ast.Add, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // sum '-' term + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = sum_rule(p)) // sum + && + (_literal = $B._PyPegen.expect_token(p, 15)) // token='-' + && + (b = term_rule(p)) // term + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BinOp (a, new $B.ast.Sub, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // term + if (p.error_indicator) { + return NULL; + } + var term_var; + if ( + (term_var = term_rule(p)) // term + ) + { + _res = term_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// Left-recursive +// term: +// | term '*' factor +// | term '/' factor +// | term '//' factor +// | term '%' factor +// | term '@' factor +// | factor +function term_raw(){}; +function term_rule(p) +{ + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, term_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + var _resmark = p.mark; + while (1) { + var tmpvar_7 = $B._PyPegen.update_memo(p, _mark, term_type, _res); + if (tmpvar_7) { + return _res; + } + p.mark = _mark; + var _raw = term_raw(p); + if (p.error_indicator) { + return NULL; + } + if (_raw == NULL || p.mark <= _resmark) + break; + _resmark = p.mark; + _res = _raw; + } + p.mark = _resmark; + return _res; +} +function term_raw(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // term '*' factor + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = term_rule(p)) // term + && + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (b = factor_rule(p)) // factor + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BinOp (a, new $B.ast.Mult, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // term '/' factor + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = term_rule(p)) // term + && + (_literal = $B._PyPegen.expect_token(p, 17)) // token='/' + && + (b = factor_rule(p)) // factor + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BinOp (a, new $B.ast.Div, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // term '//' factor + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = term_rule(p)) // term + && + (_literal = $B._PyPegen.expect_token(p, 47)) // token='//' + && + (b = factor_rule(p)) // factor + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BinOp (a, new $B.ast.FloorDiv, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // term '%' factor + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = term_rule(p)) // term + && + (_literal = $B._PyPegen.expect_token(p, 24)) // token='%' + && + (b = factor_rule(p)) // factor + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BinOp (a, new $B.ast.Mod, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // term '@' factor + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = term_rule(p)) // term + && + (_literal = $B._PyPegen.expect_token(p, 49)) // token='@' + && + (b = factor_rule(p)) // factor + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B.helper_functions.CHECK_VERSION ($B.ast.expr, 5, "The '@' operator is", new $B._PyAST.BinOp ( a, new $B.ast.MatMult, b, EXTRA )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // factor + if (p.error_indicator) { + return NULL; + } + var factor_var; + if ( + (factor_var = factor_rule(p)) // factor + ) + { + _res = factor_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// factor: '+' factor | '-' factor | '~' factor | power +function factor_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, factor_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '+' factor + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 14)) // token='+' + && + (a = factor_rule(p)) // factor + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.UnaryOp (new $B.ast.UAdd, a, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '-' factor + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 15)) // token='-' + && + (a = factor_rule(p)) // factor + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.UnaryOp (new $B.ast.USub, a, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '~' factor + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 31)) // token='~' + && + (a = factor_rule(p)) // factor + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.UnaryOp (new $B.ast.Invert, a, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // power + if (p.error_indicator) { + return NULL; + } + var power_var; + if ( + (power_var = power_rule(p)) // power + ) + { + _res = power_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, factor_type, _res); + return _res; + } +} + +// power: await_primary '**' factor | await_primary +function power_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // await_primary '**' factor + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = await_primary_rule(p)) // await_primary + && + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (b = factor_rule(p)) // factor + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.BinOp (a, new $B.ast.Pow, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // await_primary + if (p.error_indicator) { + return NULL; + } + var await_primary_var; + if ( + (await_primary_var = await_primary_rule(p)) // await_primary + ) + { + _res = await_primary_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// await_primary: AWAIT primary | primary +function await_primary_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, await_primary_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // AWAIT primary + if (p.error_indicator) { + return NULL; + } + var a; + var await_var; + if ( + (await_var = $B._PyPegen.expect_token(p, AWAIT)) // token='AWAIT' + && + (a = primary_rule(p)) // primary + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B.helper_functions.CHECK_VERSION ($B.ast.expr, 5, "Await expressions are", new $B._PyAST.Await ( a, EXTRA )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // primary + if (p.error_indicator) { + return NULL; + } + var primary_var; + if ( + (primary_var = primary_rule(p)) // primary + ) + { + _res = primary_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, await_primary_type, _res); + return _res; + } +} + +// Left-recursive +// primary: +// | primary '.' NAME +// | primary genexp +// | primary '(' arguments? ')' +// | primary '[' slices ']' +// | atom +function primary_raw(){}; +function primary_rule(p) +{ + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, primary_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + var _resmark = p.mark; + while (1) { + var tmpvar_8 = $B._PyPegen.update_memo(p, _mark, primary_type, _res); + if (tmpvar_8) { + return _res; + } + p.mark = _mark; + var _raw = primary_raw(p); + if (p.error_indicator) { + return NULL; + } + if (_raw == NULL || p.mark <= _resmark) + break; + _resmark = p.mark; + _res = _raw; + } + p.mark = _resmark; + return _res; +} +function primary_raw(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // primary '.' NAME + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = primary_rule(p)) // primary + && + (_literal = $B._PyPegen.expect_token(p, 23)) // token='.' + && + (b = $B._PyPegen.name_token(p)) // NAME + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Attribute (a, b. id, $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // primary genexp + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = primary_rule(p)) // primary + && + (b = genexp_rule(p)) // genexp + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Call (a, $B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.singleton_seq ( p, b ) ), $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // primary '(' arguments? ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (a = primary_rule(p)) // primary + && + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (b = arguments_rule(p), !p.error_indicator) // arguments? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Call (a, ( b ) ? ( b ). args : $B.parser_constants.NULL, ( b ) ? ( b ). keywords : $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // primary '[' slices ']' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (a = primary_rule(p)) // primary + && + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + && + (b = slices_rule(p)) // slices + && + (_literal_1 = $B._PyPegen.expect_token(p, 10)) // token=']' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Subscript (a, b, $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // atom + if (p.error_indicator) { + return NULL; + } + var atom_var; + if ( + (atom_var = atom_rule(p)) // atom + ) + { + _res = atom_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// slices: slice !',' | ','.(slice | starred_expression)+ ','? +function slices_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // slice !',' + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = slice_rule(p)) // slice + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 12) // token=',' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ','.(slice | starred_expression)+ ','? + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + if ( + (a = _gather_90_rule(p)) // ','.(slice | starred_expression)+ + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Tuple (a, $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// slice: expression? ':' expression? [':' expression?] | named_expression +function slice_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // expression? ':' expression? [':' expression?] + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + var c; + if ( + (a = expression_rule(p), !p.error_indicator) // expression? + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = expression_rule(p), !p.error_indicator) // expression? + && + (c = _tmp_92_rule(p), !p.error_indicator) // [':' expression?] + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Slice (a, b, c, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // named_expression + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = named_expression_rule(p)) // named_expression + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// atom: +// | NAME +// | 'True' +// | 'False' +// | 'None' +// | &(STRING | FSTRING_START) strings +// | NUMBER +// | &'(' (tuple | group | genexp) +// | &'[' (list | listcomp) +// | &'{' (dict | set | dictcomp | setcomp) +// | '...' +function atom_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // NAME + if (p.error_indicator) { + return NULL; + } + var name_var; + if ( + (name_var = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = name_var; + return done(); + } + p.mark = _mark; + } + { // 'True' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 601)) // token='True' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Constant ($B.parser_constants.Py_True, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'False' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 603)) // token='False' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Constant ($B.parser_constants.Py_False, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'None' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 602)) // token='None' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Constant ($B.parser_constants.Py_None, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // &(STRING | FSTRING_START) strings + if (p.error_indicator) { + return NULL; + } + var strings_var; + if ( + $B._PyPegen.lookahead(1, _tmp_93_rule, p) + && + (strings_var = strings_rule(p)) // strings + ) + { + _res = strings_var; + return done(); + } + p.mark = _mark; + } + { // NUMBER + if (p.error_indicator) { + return NULL; + } + var number_var; + if ( + (number_var = $B._PyPegen.number_token(p)) // NUMBER + ) + { + _res = number_var; + return done(); + } + p.mark = _mark; + } + { // &'(' (tuple | group | genexp) + if (p.error_indicator) { + return NULL; + } + var _tmp_94_var; + if ( + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 7) // token='(' + && + (_tmp_94_var = _tmp_94_rule(p)) // tuple | group | genexp + ) + { + _res = _tmp_94_var; + return done(); + } + p.mark = _mark; + } + { // &'[' (list | listcomp) + if (p.error_indicator) { + return NULL; + } + var _tmp_95_var; + if ( + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 9) // token='[' + && + (_tmp_95_var = _tmp_95_rule(p)) // list | listcomp + ) + { + _res = _tmp_95_var; + return done(); + } + p.mark = _mark; + } + { // &'{' (dict | set | dictcomp | setcomp) + if (p.error_indicator) { + return NULL; + } + var _tmp_96_var; + if ( + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 25) // token='{' + && + (_tmp_96_var = _tmp_96_rule(p)) // dict | set | dictcomp | setcomp + ) + { + _res = _tmp_96_var; + return done(); + } + p.mark = _mark; + } + { // '...' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 52)) // token='...' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Constant ($B.parser_constants.Py_Ellipsis, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// group: '(' (yield_expr | named_expression) ')' | invalid_group +function group_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '(' (yield_expr | named_expression) ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = _tmp_97_rule(p)) // yield_expr | named_expression + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_group + if (p.error_indicator) { + return NULL; + } + var invalid_group_var; + if ( + (invalid_group_var = invalid_group_rule(p)) // invalid_group + ) + { + _res = invalid_group_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// lambdef: 'lambda' lambda_params? ':' expression +function lambdef_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // 'lambda' lambda_params? ':' expression + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var a; + var b; + if ( + (_keyword = $B._PyPegen.expect_token(p, 600)) // token='lambda' + && + (a = lambda_params_rule(p), !p.error_indicator) // lambda_params? + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = expression_rule(p)) // expression + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Lambda (( a ) ? a : $B.helper_functions.CHECK ( $B.ast.arguments, $B._PyPegen.empty_arguments ( p ) ), b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// lambda_params: invalid_lambda_parameters | lambda_parameters +function lambda_params_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.call_invalid_rules) { // invalid_lambda_parameters + if (p.error_indicator) { + return NULL; + } + var invalid_lambda_parameters_var; + if ( + (invalid_lambda_parameters_var = invalid_lambda_parameters_rule(p)) // invalid_lambda_parameters + ) + { + _res = invalid_lambda_parameters_var; + return done(); + } + p.mark = _mark; + } + { // lambda_parameters + if (p.error_indicator) { + return NULL; + } + var lambda_parameters_var; + if ( + (lambda_parameters_var = lambda_parameters_rule(p)) // lambda_parameters + ) + { + _res = lambda_parameters_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// lambda_parameters: +// | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? +// | lambda_slash_with_default lambda_param_with_default* lambda_star_etc? +// | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? +// | lambda_param_with_default+ lambda_star_etc? +// | lambda_star_etc +function lambda_parameters_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? + if (p.error_indicator) { + return NULL; + } + var a; + var b; + var c; + var d; + if ( + (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default + && + (b = _loop0_98_rule(p)) // lambda_param_no_default* + && + (c = _loop0_99_rule(p)) // lambda_param_with_default* + && + (d = lambda_star_etc_rule(p), !p.error_indicator) // lambda_star_etc? + ) + { + _res = $B.helper_functions.CHECK_VERSION ($B.ast.arguments, 8, "Positional-only parameters are", $B._PyPegen.make_arguments ( p, a, $B.parser_constants.NULL, b, c, d )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc? + if (p.error_indicator) { + return NULL; + } + var a; + var b; + var c; + if ( + (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default + && + (b = _loop0_100_rule(p)) // lambda_param_with_default* + && + (c = lambda_star_etc_rule(p), !p.error_indicator) // lambda_star_etc? + ) + { + _res = $B.helper_functions.CHECK_VERSION ($B.ast.arguments, 8, "Positional-only parameters are", $B._PyPegen.make_arguments ( p, $B.parser_constants.NULL, a, $B.parser_constants.NULL, b, c )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? + if (p.error_indicator) { + return NULL; + } + var a; + var b; + var c; + if ( + (a = _loop1_101_rule(p)) // lambda_param_no_default+ + && + (b = _loop0_102_rule(p)) // lambda_param_with_default* + && + (c = lambda_star_etc_rule(p), !p.error_indicator) // lambda_star_etc? + ) + { + _res = $B._PyPegen.make_arguments (p, $B.parser_constants.NULL, $B.parser_constants.NULL, a, b, c); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // lambda_param_with_default+ lambda_star_etc? + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = _loop1_103_rule(p)) // lambda_param_with_default+ + && + (b = lambda_star_etc_rule(p), !p.error_indicator) // lambda_star_etc? + ) + { + _res = $B._PyPegen.make_arguments (p, $B.parser_constants.NULL, $B.parser_constants.NULL, $B.parser_constants.NULL, a, b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // lambda_star_etc + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = lambda_star_etc_rule(p)) // lambda_star_etc + ) + { + _res = $B._PyPegen.make_arguments (p, $B.parser_constants.NULL, $B.parser_constants.NULL, $B.parser_constants.NULL, $B.parser_constants.NULL, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// lambda_slash_no_default: +// | lambda_param_no_default+ '/' ',' +// | lambda_param_no_default+ '/' &':' +function lambda_slash_no_default_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // lambda_param_no_default+ '/' ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (a = _loop1_104_rule(p)) // lambda_param_no_default+ + && + (_literal = $B._PyPegen.expect_token(p, 17)) // token='/' + && + (_literal_1 = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // lambda_param_no_default+ '/' &':' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (a = _loop1_105_rule(p)) // lambda_param_no_default+ + && + (_literal = $B._PyPegen.expect_token(p, 17)) // token='/' + && + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 11) // token=':' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// lambda_slash_with_default: +// | lambda_param_no_default* lambda_param_with_default+ '/' ',' +// | lambda_param_no_default* lambda_param_with_default+ '/' &':' +function lambda_slash_with_default_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // lambda_param_no_default* lambda_param_with_default+ '/' ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (a = _loop0_106_rule(p)) // lambda_param_no_default* + && + (b = _loop1_107_rule(p)) // lambda_param_with_default+ + && + (_literal = $B._PyPegen.expect_token(p, 17)) // token='/' + && + (_literal_1 = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = $B._PyPegen.slash_with_default (p, a, b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // lambda_param_no_default* lambda_param_with_default+ '/' &':' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = _loop0_108_rule(p)) // lambda_param_no_default* + && + (b = _loop1_109_rule(p)) // lambda_param_with_default+ + && + (_literal = $B._PyPegen.expect_token(p, 17)) // token='/' + && + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 11) // token=':' + ) + { + _res = $B._PyPegen.slash_with_default (p, a, b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// lambda_star_etc: +// | invalid_lambda_star_etc +// | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? +// | '*' ',' lambda_param_maybe_default+ lambda_kwds? +// | lambda_kwds +function lambda_star_etc_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.call_invalid_rules) { // invalid_lambda_star_etc + if (p.error_indicator) { + return NULL; + } + var invalid_lambda_star_etc_var; + if ( + (invalid_lambda_star_etc_var = invalid_lambda_star_etc_rule(p)) // invalid_lambda_star_etc + ) + { + _res = invalid_lambda_star_etc_var; + return done(); + } + p.mark = _mark; + } + { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + var c; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (a = lambda_param_no_default_rule(p)) // lambda_param_no_default + && + (b = _loop0_110_rule(p)) // lambda_param_maybe_default* + && + (c = lambda_kwds_rule(p), !p.error_indicator) // lambda_kwds? + ) + { + _res = $B._PyPegen.star_etc (p, a, b, c); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '*' ',' lambda_param_maybe_default+ lambda_kwds? + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var b; + var c; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (_literal_1 = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (b = _loop1_111_rule(p)) // lambda_param_maybe_default+ + && + (c = lambda_kwds_rule(p), !p.error_indicator) // lambda_kwds? + ) + { + _res = $B._PyPegen.star_etc (p, $B.parser_constants.NULL, b, c); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // lambda_kwds + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = lambda_kwds_rule(p)) // lambda_kwds + ) + { + _res = $B._PyPegen.star_etc (p, $B.parser_constants.NULL, $B.parser_constants.NULL, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// lambda_kwds: invalid_lambda_kwds | '**' lambda_param_no_default +function lambda_kwds_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.call_invalid_rules) { // invalid_lambda_kwds + if (p.error_indicator) { + return NULL; + } + var invalid_lambda_kwds_var; + if ( + (invalid_lambda_kwds_var = invalid_lambda_kwds_rule(p)) // invalid_lambda_kwds + ) + { + _res = invalid_lambda_kwds_var; + return done(); + } + p.mark = _mark; + } + { // '**' lambda_param_no_default + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (a = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// lambda_param_no_default: lambda_param ',' | lambda_param &':' +function lambda_param_no_default_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // lambda_param ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (a = lambda_param_rule(p)) // lambda_param + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // lambda_param &':' + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = lambda_param_rule(p)) // lambda_param + && + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 11) // token=':' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// lambda_param_with_default: lambda_param default ',' | lambda_param default &':' +function lambda_param_with_default_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // lambda_param default ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var c; + if ( + (a = lambda_param_rule(p)) // lambda_param + && + (c = default_rule(p)) // default + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = $B._PyPegen.name_default_pair (p, a, c, $B.parser_constants.NULL); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // lambda_param default &':' + if (p.error_indicator) { + return NULL; + } + var a; + var c; + if ( + (a = lambda_param_rule(p)) // lambda_param + && + (c = default_rule(p)) // default + && + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 11) // token=':' + ) + { + _res = $B._PyPegen.name_default_pair (p, a, c, $B.parser_constants.NULL); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':' +function lambda_param_maybe_default_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // lambda_param default? ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var c; + if ( + (a = lambda_param_rule(p)) // lambda_param + && + (c = default_rule(p), !p.error_indicator) // default? + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = $B._PyPegen.name_default_pair (p, a, c, $B.parser_constants.NULL); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // lambda_param default? &':' + if (p.error_indicator) { + return NULL; + } + var a; + var c; + if ( + (a = lambda_param_rule(p)) // lambda_param + && + (c = default_rule(p), !p.error_indicator) // default? + && + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 11) // token=':' + ) + { + _res = $B._PyPegen.name_default_pair (p, a, c, $B.parser_constants.NULL); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// lambda_param: NAME +function lambda_param_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // NAME + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.arg (a. id, $B.parser_constants.NULL, $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// fstring_middle: fstring_replacement_field | FSTRING_MIDDLE +function fstring_middle_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // fstring_replacement_field + if (p.error_indicator) { + return NULL; + } + var fstring_replacement_field_var; + if ( + (fstring_replacement_field_var = fstring_replacement_field_rule(p)) // fstring_replacement_field + ) + { + _res = fstring_replacement_field_var; + return done(); + } + p.mark = _mark; + } + { // FSTRING_MIDDLE + if (p.error_indicator) { + return NULL; + } + var t; + if ( + (t = $B._PyPegen.expect_token(p, FSTRING_MIDDLE)) // token='FSTRING_MIDDLE' + ) + { + _res = $B._PyPegen.constant_from_token (p, t); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// fstring_replacement_field: +// | '{' (yield_expr | star_expressions) '='? fstring_conversion? fstring_full_format_spec? '}' +// | invalid_replacement_field +function fstring_replacement_field_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '{' (yield_expr | star_expressions) '='? fstring_conversion? fstring_full_format_spec? '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var conversion; + var debug_expr; + var format; + var rbrace; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (a = _tmp_112_rule(p)) // yield_expr | star_expressions + && + (debug_expr = $B._PyPegen.expect_token(p, 22), !p.error_indicator) // '='? + && + (conversion = fstring_conversion_rule(p), !p.error_indicator) // fstring_conversion? + && + (format = fstring_full_format_spec_rule(p), !p.error_indicator) // fstring_full_format_spec? + && + (rbrace = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B._PyPegen.formatted_value (p, a, debug_expr, conversion, format, rbrace, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_replacement_field + if (p.error_indicator) { + return NULL; + } + var invalid_replacement_field_var; + if ( + (invalid_replacement_field_var = invalid_replacement_field_rule(p)) // invalid_replacement_field + ) + { + _res = invalid_replacement_field_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// fstring_conversion: "!" NAME +function fstring_conversion_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // "!" NAME + if (p.error_indicator) { + return NULL; + } + var conv; + var conv_token; + if ( + (conv_token = $B._PyPegen.expect_token(p, 54)) // token='!' + && + (conv = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = $B._PyPegen.check_fstring_conversion (p, conv_token, conv); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// fstring_full_format_spec: ':' fstring_format_spec* +function fstring_full_format_spec_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // ':' fstring_format_spec* + if (p.error_indicator) { + return NULL; + } + var colon; + var spec; + if ( + (colon = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (spec = _loop0_113_rule(p)) // fstring_format_spec* + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B._PyPegen.setup_full_format_spec (p, colon, spec, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// fstring_format_spec: FSTRING_MIDDLE | fstring_replacement_field +function fstring_format_spec_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // FSTRING_MIDDLE + if (p.error_indicator) { + return NULL; + } + var t; + if ( + (t = $B._PyPegen.expect_token(p, FSTRING_MIDDLE)) // token='FSTRING_MIDDLE' + ) + { + _res = $B._PyPegen.decoded_constant_from_token (p, t); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // fstring_replacement_field + if (p.error_indicator) { + return NULL; + } + var fstring_replacement_field_var; + if ( + (fstring_replacement_field_var = fstring_replacement_field_rule(p)) // fstring_replacement_field + ) + { + _res = fstring_replacement_field_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// fstring: FSTRING_START fstring_middle* FSTRING_END +function fstring_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // FSTRING_START fstring_middle* FSTRING_END + if (p.error_indicator) { + return NULL; + } + var a; + var b; + var c; + if ( + (a = $B._PyPegen.expect_token(p, FSTRING_START)) // token='FSTRING_START' + && + (b = _loop0_114_rule(p)) // fstring_middle* + && + (c = $B._PyPegen.expect_token(p, FSTRING_END)) // token='FSTRING_END' + ) + { + _res = $B._PyPegen.joined_str (p, a, b, c); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// string: STRING +function string_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // STRING + if (p.error_indicator) { + return NULL; + } + var s; + if ( + (s = $B._PyPegen.string_token(p)) // STRING + ) + { + _res = $B._PyPegen.constant_from_string (p, s); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// strings: ((fstring | string))+ +function strings_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, strings_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // ((fstring | string))+ + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = _loop1_115_rule(p)) // ((fstring | string))+ + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B._PyPegen.concatenate_strings (p, a, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, strings_type, _res); + return _res; + } +} + +// list: '[' star_named_expressions? ']' +function list_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '[' star_named_expressions? ']' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + && + (a = star_named_expressions_rule(p), !p.error_indicator) // star_named_expressions? + && + (_literal_1 = $B._PyPegen.expect_token(p, 10)) // token=']' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.List (a, $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// tuple: '(' [star_named_expression ',' star_named_expressions?] ')' +function tuple_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '(' [star_named_expression ',' star_named_expressions?] ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = _tmp_116_rule(p), !p.error_indicator) // [star_named_expression ',' star_named_expressions?] + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Tuple (a, $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// set: '{' star_named_expressions '}' +function set_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '{' star_named_expressions '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (a = star_named_expressions_rule(p)) // star_named_expressions + && + (_literal_1 = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Set (a, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// dict: '{' double_starred_kvpairs? '}' | '{' invalid_double_starred_kvpairs '}' +function dict_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '{' double_starred_kvpairs? '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (a = double_starred_kvpairs_rule(p), !p.error_indicator) // double_starred_kvpairs? + && + (_literal_1 = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Dict ($B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.get_keys ( p, a ) ), $B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.get_values ( p, a ) ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '{' invalid_double_starred_kvpairs '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var invalid_double_starred_kvpairs_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (invalid_double_starred_kvpairs_var = invalid_double_starred_kvpairs_rule(p)) // invalid_double_starred_kvpairs + && + (_literal_1 = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + _res = $B._PyPegen.dummy_name(p, _literal, invalid_double_starred_kvpairs_var, _literal_1); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// double_starred_kvpairs: ','.double_starred_kvpair+ ','? +function double_starred_kvpairs_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.double_starred_kvpair+ ','? + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + if ( + (a = _gather_117_rule(p)) // ','.double_starred_kvpair+ + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// double_starred_kvpair: '**' bitwise_or | kvpair +function double_starred_kvpair_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '**' bitwise_or + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (a = bitwise_or_rule(p)) // bitwise_or + ) + { + _res = $B._PyPegen.key_value_pair (p, $B.parser_constants.NULL, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // kvpair + if (p.error_indicator) { + return NULL; + } + var kvpair_var; + if ( + (kvpair_var = kvpair_rule(p)) // kvpair + ) + { + _res = kvpair_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// kvpair: expression ':' expression +function kvpair_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // expression ':' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = expression_rule(p)) // expression + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (b = expression_rule(p)) // expression + ) + { + _res = $B._PyPegen.key_value_pair (p, a, b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// for_if_clauses: for_if_clause+ +function for_if_clauses_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // for_if_clause+ + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = _loop1_119_rule(p)) // for_if_clause+ + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// for_if_clause: +// | ASYNC 'for' star_targets 'in' ~ disjunction (('if' disjunction))* +// | 'for' star_targets 'in' ~ disjunction (('if' disjunction))* +// | invalid_for_target +function for_if_clause_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ASYNC 'for' star_targets 'in' ~ disjunction (('if' disjunction))* + if (p.error_indicator) { + return NULL; + } + var _cut_var = 0; + var _keyword; + var _keyword_1; + var a; + var async_var; + var b; + var c; + if ( + (async_var = $B._PyPegen.expect_token(p, ASYNC)) // token='ASYNC' + && + (_keyword = $B._PyPegen.expect_token(p, 650)) // token='for' + && + (a = star_targets_rule(p)) // star_targets + && + (_keyword_1 = $B._PyPegen.expect_token(p, 651)) // token='in' + && + (_cut_var = 1) + && + (b = disjunction_rule(p)) // disjunction + && + (c = _loop0_120_rule(p)) // (('if' disjunction))* + ) + { + _res = $B.helper_functions.CHECK_VERSION ($B.ast.comprehension, 6, "Async comprehensions are", new $B._PyAST.comprehension ( a, b, c, 1, p.arena )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + if (_cut_var) { + return NULL; + } + } + { // 'for' star_targets 'in' ~ disjunction (('if' disjunction))* + if (p.error_indicator) { + return NULL; + } + var _cut_var = 0; + var _keyword; + var _keyword_1; + var a; + var b; + var c; + if ( + (_keyword = $B._PyPegen.expect_token(p, 650)) // token='for' + && + (a = star_targets_rule(p)) // star_targets + && + (_keyword_1 = $B._PyPegen.expect_token(p, 651)) // token='in' + && + (_cut_var = 1) + && + (b = disjunction_rule(p)) // disjunction + && + (c = _loop0_121_rule(p)) // (('if' disjunction))* + ) + { + _res = new $B._PyAST.comprehension (a, b, c, 0, p.arena); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + if (_cut_var) { + return NULL; + } + } + if (p.call_invalid_rules) { // invalid_for_target + if (p.error_indicator) { + return NULL; + } + var invalid_for_target_var; + if ( + (invalid_for_target_var = invalid_for_target_rule(p)) // invalid_for_target + ) + { + _res = invalid_for_target_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension +function listcomp_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '[' named_expression for_if_clauses ']' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + && + (a = named_expression_rule(p)) // named_expression + && + (b = for_if_clauses_rule(p)) // for_if_clauses + && + (_literal_1 = $B._PyPegen.expect_token(p, 10)) // token=']' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.ListComp (a, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_comprehension + if (p.error_indicator) { + return NULL; + } + var invalid_comprehension_var; + if ( + (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension + ) + { + _res = invalid_comprehension_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// setcomp: '{' named_expression for_if_clauses '}' | invalid_comprehension +function setcomp_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '{' named_expression for_if_clauses '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (a = named_expression_rule(p)) // named_expression + && + (b = for_if_clauses_rule(p)) // for_if_clauses + && + (_literal_1 = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.SetComp (a, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_comprehension + if (p.error_indicator) { + return NULL; + } + var invalid_comprehension_var; + if ( + (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension + ) + { + _res = invalid_comprehension_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// genexp: +// | '(' (assignment_expression | expression !':=') for_if_clauses ')' +// | invalid_comprehension +function genexp_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '(' (assignment_expression | expression !':=') for_if_clauses ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = _tmp_122_rule(p)) // assignment_expression | expression !':=' + && + (b = for_if_clauses_rule(p)) // for_if_clauses + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.GeneratorExp (a, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_comprehension + if (p.error_indicator) { + return NULL; + } + var invalid_comprehension_var; + if ( + (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension + ) + { + _res = invalid_comprehension_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// dictcomp: '{' kvpair for_if_clauses '}' | invalid_dict_comprehension +function dictcomp_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '{' kvpair for_if_clauses '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (a = kvpair_rule(p)) // kvpair + && + (b = for_if_clauses_rule(p)) // for_if_clauses + && + (_literal_1 = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.DictComp (a.key, a.value, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_dict_comprehension + if (p.error_indicator) { + return NULL; + } + var invalid_dict_comprehension_var; + if ( + (invalid_dict_comprehension_var = invalid_dict_comprehension_rule(p)) // invalid_dict_comprehension + ) + { + _res = invalid_dict_comprehension_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// arguments: args ','? &')' | invalid_arguments +function arguments_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, arguments_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + { // args ','? &')' + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + if ( + (a = args_rule(p)) // args + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + && + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, 8) // token=')' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_arguments + if (p.error_indicator) { + return NULL; + } + var invalid_arguments_var; + if ( + (invalid_arguments_var = invalid_arguments_rule(p)) // invalid_arguments + ) + { + _res = invalid_arguments_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, arguments_type, _res); + return _res; + } +} + +// args: +// | ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ [',' kwargs] +// | kwargs +function args_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ [',' kwargs] + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = _gather_123_rule(p)) // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ + && + (b = _tmp_125_rule(p), !p.error_indicator) // [',' kwargs] + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B._PyPegen.collect_call_seqs (p, a, b, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // kwargs + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = kwargs_rule(p)) // kwargs + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Call ($B._PyPegen.dummy_name ( p ), $B.helper_functions.CHECK_NULL_ALLOWED ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.seq_extract_starred_exprs ( p, a ) ), $B.helper_functions.CHECK_NULL_ALLOWED ( $B.parser_constants.asdl_keyword_seq, $B._PyPegen.seq_delete_starred_exprs ( p, a ) ), EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// kwargs: +// | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ +// | ','.kwarg_or_starred+ +// | ','.kwarg_or_double_starred+ +function kwargs_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = _gather_126_rule(p)) // ','.kwarg_or_starred+ + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (b = _gather_128_rule(p)) // ','.kwarg_or_double_starred+ + ) + { + _res = $B._PyPegen.join_sequences (p, a, b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ','.kwarg_or_starred+ + if (p.error_indicator) { + return NULL; + } + var _gather_130_var; + if ( + (_gather_130_var = _gather_130_rule(p)) // ','.kwarg_or_starred+ + ) + { + _res = _gather_130_var; + return done(); + } + p.mark = _mark; + } + { // ','.kwarg_or_double_starred+ + if (p.error_indicator) { + return NULL; + } + var _gather_132_var; + if ( + (_gather_132_var = _gather_132_rule(p)) // ','.kwarg_or_double_starred+ + ) + { + _res = _gather_132_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// starred_expression: invalid_starred_expression | '*' expression +function starred_expression_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + if (p.call_invalid_rules) { // invalid_starred_expression + if (p.error_indicator) { + return NULL; + } + var invalid_starred_expression_var; + if ( + (invalid_starred_expression_var = invalid_starred_expression_rule(p)) // invalid_starred_expression + ) + { + _res = invalid_starred_expression_var; + return done(); + } + p.mark = _mark; + } + { // '*' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (a = expression_rule(p)) // expression + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Starred (a, $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// kwarg_or_starred: invalid_kwarg | NAME '=' expression | starred_expression +function kwarg_or_starred_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + if (p.call_invalid_rules) { // invalid_kwarg + if (p.error_indicator) { + return NULL; + } + var invalid_kwarg_var; + if ( + (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg + ) + { + _res = invalid_kwarg_var; + return done(); + } + p.mark = _mark; + } + { // NAME '=' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + && + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + && + (b = expression_rule(p)) // expression + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B._PyPegen.keyword_or_starred (p, $B.helper_functions.CHECK ( $B.ast.keyword, new $B._PyAST.keyword ( a. id, b, EXTRA ) ), 1); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // starred_expression + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = starred_expression_rule(p)) // starred_expression + ) + { + _res = $B._PyPegen.keyword_or_starred (p, a, 0); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// kwarg_or_double_starred: invalid_kwarg | NAME '=' expression | '**' expression +function kwarg_or_double_starred_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + if (p.call_invalid_rules) { // invalid_kwarg + if (p.error_indicator) { + return NULL; + } + var invalid_kwarg_var; + if ( + (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg + ) + { + _res = invalid_kwarg_var; + return done(); + } + p.mark = _mark; + } + { // NAME '=' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + && + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + && + (b = expression_rule(p)) // expression + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B._PyPegen.keyword_or_starred (p, $B.helper_functions.CHECK ( $B.ast.keyword, new $B._PyAST.keyword ( a. id, b, EXTRA ) ), 1); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '**' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (a = expression_rule(p)) // expression + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = $B._PyPegen.keyword_or_starred (p, $B.helper_functions.CHECK ( $B.ast.keyword, new $B._PyAST.keyword ( $B.parser_constants.NULL, a, EXTRA ) ), 1); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// star_targets: star_target !',' | star_target ((',' star_target))* ','? +function star_targets_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // star_target !',' + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = star_target_rule(p)) // star_target + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 12) // token=',' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // star_target ((',' star_target))* ','? + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var b; + if ( + (a = star_target_rule(p)) // star_target + && + (b = _loop0_134_rule(p)) // ((',' star_target))* + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Tuple ($B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.seq_insert_in_front ( p, a, b ) ), $B.parser_constants.Store, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// star_targets_list_seq: ','.star_target+ ','? +function star_targets_list_seq_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.star_target+ ','? + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + if ( + (a = _gather_135_rule(p)) // ','.star_target+ + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// star_targets_tuple_seq: star_target ((',' star_target))+ ','? | star_target ',' +function star_targets_tuple_seq_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // star_target ((',' star_target))+ ','? + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var b; + if ( + (a = star_target_rule(p)) // star_target + && + (b = _loop1_137_rule(p)) // ((',' star_target))+ + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + ) + { + _res = $B._PyPegen.seq_insert_in_front (p, a, b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // star_target ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (a = star_target_rule(p)) // star_target + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = $B._PyPegen.singleton_seq (p, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// star_target: '*' (!'*' star_target) | target_with_star_atom +function star_target_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, star_target_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // '*' (!'*' star_target) + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (a = _tmp_138_rule(p)) // !'*' star_target + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Starred ($B.helper_functions.CHECK ( $B.ast.expr, $B._PyPegen.set_expr_context ( p, a, $B.parser_constants.Store ) ), $B.parser_constants.Store, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // target_with_star_atom + if (p.error_indicator) { + return NULL; + } + var target_with_star_atom_var; + if ( + (target_with_star_atom_var = target_with_star_atom_rule(p)) // target_with_star_atom + ) + { + _res = target_with_star_atom_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, star_target_type, _res); + return _res; + } +} + +// target_with_star_atom: +// | t_primary '.' NAME !t_lookahead +// | t_primary '[' slices ']' !t_lookahead +// | star_atom +function target_with_star_atom_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, target_with_star_atom_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // t_primary '.' NAME !t_lookahead + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = $B._PyPegen.expect_token(p, 23)) // token='.' + && + (b = $B._PyPegen.name_token(p)) // NAME + && + $B._PyPegen.lookahead(0, t_lookahead_rule, p) + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Attribute (a, b. id, $B.parser_constants.Store, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // t_primary '[' slices ']' !t_lookahead + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + && + (b = slices_rule(p)) // slices + && + (_literal_1 = $B._PyPegen.expect_token(p, 10)) // token=']' + && + $B._PyPegen.lookahead(0, t_lookahead_rule, p) + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Subscript (a, b, $B.parser_constants.Store, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // star_atom + if (p.error_indicator) { + return NULL; + } + var star_atom_var; + if ( + (star_atom_var = star_atom_rule(p)) // star_atom + ) + { + _res = star_atom_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, target_with_star_atom_type, _res); + return _res; + } +} + +// star_atom: +// | NAME +// | '(' target_with_star_atom ')' +// | '(' star_targets_tuple_seq? ')' +// | '[' star_targets_list_seq? ']' +function star_atom_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // NAME + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = $B._PyPegen.set_expr_context (p, a, $B.parser_constants.Store); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '(' target_with_star_atom ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = target_with_star_atom_rule(p)) // target_with_star_atom + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = $B._PyPegen.set_expr_context (p, a, $B.parser_constants.Store); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '(' star_targets_tuple_seq? ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = star_targets_tuple_seq_rule(p), !p.error_indicator) // star_targets_tuple_seq? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Tuple (a, $B.parser_constants.Store, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '[' star_targets_list_seq? ']' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + && + (a = star_targets_list_seq_rule(p), !p.error_indicator) // star_targets_list_seq? + && + (_literal_1 = $B._PyPegen.expect_token(p, 10)) // token=']' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.List (a, $B.parser_constants.Store, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// single_target: single_subscript_attribute_target | NAME | '(' single_target ')' +function single_target_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // single_subscript_attribute_target + if (p.error_indicator) { + return NULL; + } + var single_subscript_attribute_target_var; + if ( + (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target + ) + { + _res = single_subscript_attribute_target_var; + return done(); + } + p.mark = _mark; + } + { // NAME + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = $B._PyPegen.set_expr_context (p, a, $B.parser_constants.Store); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '(' single_target ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = single_target_rule(p)) // single_target + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// single_subscript_attribute_target: +// | t_primary '.' NAME !t_lookahead +// | t_primary '[' slices ']' !t_lookahead +function single_subscript_attribute_target_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // t_primary '.' NAME !t_lookahead + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = $B._PyPegen.expect_token(p, 23)) // token='.' + && + (b = $B._PyPegen.name_token(p)) // NAME + && + $B._PyPegen.lookahead(0, t_lookahead_rule, p) + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Attribute (a, b. id, $B.parser_constants.Store, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // t_primary '[' slices ']' !t_lookahead + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + && + (b = slices_rule(p)) // slices + && + (_literal_1 = $B._PyPegen.expect_token(p, 10)) // token=']' + && + $B._PyPegen.lookahead(0, t_lookahead_rule, p) + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Subscript (a, b, $B.parser_constants.Store, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// Left-recursive +// t_primary: +// | t_primary '.' NAME &t_lookahead +// | t_primary '[' slices ']' &t_lookahead +// | t_primary genexp &t_lookahead +// | t_primary '(' arguments? ')' &t_lookahead +// | atom &t_lookahead +function t_primary_raw(){}; +function t_primary_rule(p) +{ + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, t_primary_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + var _resmark = p.mark; + while (1) { + var tmpvar_9 = $B._PyPegen.update_memo(p, _mark, t_primary_type, _res); + if (tmpvar_9) { + return _res; + } + p.mark = _mark; + var _raw = t_primary_raw(p); + if (p.error_indicator) { + return NULL; + } + if (_raw == NULL || p.mark <= _resmark) + break; + _resmark = p.mark; + _res = _raw; + } + p.mark = _resmark; + return _res; +} +function t_primary_raw(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // t_primary '.' NAME &t_lookahead + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = $B._PyPegen.expect_token(p, 23)) // token='.' + && + (b = $B._PyPegen.name_token(p)) // NAME + && + $B._PyPegen.lookahead(1, t_lookahead_rule, p) + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Attribute (a, b. id, $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // t_primary '[' slices ']' &t_lookahead + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + && + (b = slices_rule(p)) // slices + && + (_literal_1 = $B._PyPegen.expect_token(p, 10)) // token=']' + && + $B._PyPegen.lookahead(1, t_lookahead_rule, p) + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Subscript (a, b, $B.parser_constants.Load, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // t_primary genexp &t_lookahead + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (b = genexp_rule(p)) // genexp + && + $B._PyPegen.lookahead(1, t_lookahead_rule, p) + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Call (a, $B.helper_functions.CHECK ( $B.parser_constants.asdl_expr_seq, $B._PyPegen.singleton_seq ( p, b ) ), $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // t_primary '(' arguments? ')' &t_lookahead + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (b = arguments_rule(p), !p.error_indicator) // arguments? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + && + $B._PyPegen.lookahead(1, t_lookahead_rule, p) + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Call (a, ( b ) ? ( b ). args : $B.parser_constants.NULL, ( b ) ? ( b ). keywords : $B.parser_constants.NULL, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // atom &t_lookahead + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = atom_rule(p)) // atom + && + $B._PyPegen.lookahead(1, t_lookahead_rule, p) + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// t_lookahead: '(' | '[' | '.' +function t_lookahead_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '(' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '[' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '.' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 23)) // token='.' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// del_targets: ','.del_target+ ','? +function del_targets_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.del_target+ ','? + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + if ( + (a = _gather_139_rule(p)) // ','.del_target+ + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// del_target: +// | t_primary '.' NAME !t_lookahead +// | t_primary '[' slices ']' !t_lookahead +// | del_t_atom +function del_target_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, del_target_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // t_primary '.' NAME !t_lookahead + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = $B._PyPegen.expect_token(p, 23)) // token='.' + && + (b = $B._PyPegen.name_token(p)) // NAME + && + $B._PyPegen.lookahead(0, t_lookahead_rule, p) + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Attribute (a, b. id, $B.parser_constants.Del, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // t_primary '[' slices ']' !t_lookahead + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (a = t_primary_rule(p)) // t_primary + && + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + && + (b = slices_rule(p)) // slices + && + (_literal_1 = $B._PyPegen.expect_token(p, 10)) // token=']' + && + $B._PyPegen.lookahead(0, t_lookahead_rule, p) + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Subscript (a, b, $B.parser_constants.Del, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // del_t_atom + if (p.error_indicator) { + return NULL; + } + var del_t_atom_var; + if ( + (del_t_atom_var = del_t_atom_rule(p)) // del_t_atom + ) + { + _res = del_t_atom_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, del_target_type, _res); + return _res; + } +} + +// del_t_atom: NAME | '(' del_target ')' | '(' del_targets? ')' | '[' del_targets? ']' +function del_t_atom_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // NAME + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = $B._PyPegen.set_expr_context (p, a, $B.parser_constants.Del); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '(' del_target ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = del_target_rule(p)) // del_target + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = $B._PyPegen.set_expr_context (p, a, $B.parser_constants.Del); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '(' del_targets? ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = del_targets_rule(p), !p.error_indicator) // del_targets? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.Tuple (a, $B.parser_constants.Del, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '[' del_targets? ']' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + && + (a = del_targets_rule(p), !p.error_indicator) // del_targets? + && + (_literal_1 = $B._PyPegen.expect_token(p, 10)) // token=']' + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.List (a, $B.parser_constants.Del, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// type_expressions: +// | ','.expression+ ',' '*' expression ',' '**' expression +// | ','.expression+ ',' '*' expression +// | ','.expression+ ',' '**' expression +// | '*' expression ',' '**' expression +// | '*' expression +// | '**' expression +// | ','.expression+ +function type_expressions_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.expression+ ',' '*' expression ',' '**' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _literal_2; + var _literal_3; + var a; + var b; + var c; + if ( + (a = _gather_141_rule(p)) // ','.expression+ + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (_literal_1 = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (b = expression_rule(p)) // expression + && + (_literal_2 = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (_literal_3 = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (c = expression_rule(p)) // expression + ) + { + _res = $B._PyPegen.seq_append_to_end (p, $B.helper_functions.CHECK ( asdl_seq, $B._PyPegen.seq_append_to_end ( p, a, b ) ), c); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ','.expression+ ',' '*' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (a = _gather_143_rule(p)) // ','.expression+ + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (_literal_1 = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (b = expression_rule(p)) // expression + ) + { + _res = $B._PyPegen.seq_append_to_end (p, a, b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ','.expression+ ',' '**' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var b; + if ( + (a = _gather_145_rule(p)) // ','.expression+ + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (_literal_1 = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (b = expression_rule(p)) // expression + ) + { + _res = $B._PyPegen.seq_append_to_end (p, a, b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '*' expression ',' '**' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _literal_2; + var a; + var b; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (a = expression_rule(p)) // expression + && + (_literal_1 = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (_literal_2 = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (b = expression_rule(p)) // expression + ) + { + _res = $B._PyPegen.seq_append_to_end (p, $B.helper_functions.CHECK ( asdl_seq, $B._PyPegen.singleton_seq ( p, a ) ), b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '*' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (a = expression_rule(p)) // expression + ) + { + _res = $B._PyPegen.singleton_seq (p, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '**' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (a = expression_rule(p)) // expression + ) + { + _res = $B._PyPegen.singleton_seq (p, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ','.expression+ + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = _gather_147_rule(p)) // ','.expression+ + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// func_type_comment: +// | NEWLINE TYPE_COMMENT &(NEWLINE INDENT) +// | invalid_double_type_comments +// | TYPE_COMMENT +function func_type_comment_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT) + if (p.error_indicator) { + return NULL; + } + var newline_var; + var t; + if ( + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + (t = $B._PyPegen.expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + && + $B._PyPegen.lookahead(1, _tmp_149_rule, p) + ) + { + _res = t; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + if (p.call_invalid_rules) { // invalid_double_type_comments + if (p.error_indicator) { + return NULL; + } + var invalid_double_type_comments_var; + if ( + (invalid_double_type_comments_var = invalid_double_type_comments_rule(p)) // invalid_double_type_comments + ) + { + _res = invalid_double_type_comments_var; + return done(); + } + p.mark = _mark; + } + { // TYPE_COMMENT + if (p.error_indicator) { + return NULL; + } + var type_comment_var; + if ( + (type_comment_var = $B._PyPegen.expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + ) + { + _res = type_comment_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_arguments: +// | ((','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) ',' '*' +// | expression for_if_clauses ',' [args | expression for_if_clauses] +// | NAME '=' expression for_if_clauses +// | [(args ',')] NAME '=' &(',' | ')') +// | args for_if_clauses +// | args ',' expression for_if_clauses +// | args ',' args +function invalid_arguments_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ((','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) ',' '*' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _tmp_150_var; + var b; + if ( + (_tmp_150_var = _tmp_150_rule(p)) // (','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (b = $B._PyPegen.expect_token(p, 16)) // token='*' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (b, "iterable argument unpacking follows keyword argument unpacking"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // expression for_if_clauses ',' [args | expression for_if_clauses] + if (p.error_indicator) { + return NULL; + } + var _literal; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var b; + if ( + (a = expression_rule(p)) // expression + && + (b = for_if_clauses_rule(p)) // for_if_clauses + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (_opt_var = _tmp_151_rule(p), !p.error_indicator) // [args | expression for_if_clauses] + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, $B._PyPegen.get_last_comprehension_item ( PyPegen_last_item ( b, $B.ast.comprehension ) ), "Generator expression must be parenthesized"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // NAME '=' expression for_if_clauses + if (p.error_indicator) { + return NULL; + } + var a; + var b; + var expression_var; + var for_if_clauses_var; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + && + (b = $B._PyPegen.expect_token(p, 22)) // token='=' + && + (expression_var = expression_rule(p)) // expression + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, b, "invalid syntax. Maybe you meant '==' or ':=' instead of '='?"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // [(args ',')] NAME '=' &(',' | ')') + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var b; + if ( + (_opt_var = _tmp_152_rule(p), !p.error_indicator) // [(args ',')] + && + (a = $B._PyPegen.name_token(p)) // NAME + && + (b = $B._PyPegen.expect_token(p, 22)) // token='=' + && + $B._PyPegen.lookahead(1, _tmp_153_rule, p) + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, b, "expected argument value expression"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // args for_if_clauses + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = args_rule(p)) // args + && + (b = for_if_clauses_rule(p)) // for_if_clauses + ) + { + _res = $B._PyPegen.nonparen_genexp_in_call (p, a, b); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // args ',' expression for_if_clauses + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var args_var; + var b; + if ( + (args_var = args_rule(p)) // args + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (a = expression_rule(p)) // expression + && + (b = for_if_clauses_rule(p)) // for_if_clauses + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, $B._PyPegen.get_last_comprehension_item ( PyPegen_last_item ( b, $B.ast.comprehension ) ), "Generator expression must be parenthesized"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // args ',' args + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var args_var; + if ( + (a = args_rule(p)) // args + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (args_var = args_rule(p)) // args + ) + { + _res = $B._PyPegen.arguments_parsing_error (p, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_kwarg: +// | ('True' | 'False' | 'None') '=' +// | NAME '=' expression for_if_clauses +// | !(NAME '=') expression '=' +// | '**' expression '=' expression +function invalid_kwarg_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ('True' | 'False' | 'None') '=' + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = _tmp_154_rule(p)) // 'True' | 'False' | 'None' + && + (b = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, b, "cannot assign to %s", PyBytes_AS_STRING ( a.bytes )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // NAME '=' expression for_if_clauses + if (p.error_indicator) { + return NULL; + } + var a; + var b; + var expression_var; + var for_if_clauses_var; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + && + (b = $B._PyPegen.expect_token(p, 22)) // token='=' + && + (expression_var = expression_rule(p)) // expression + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, b, "invalid syntax. Maybe you meant '==' or ':=' instead of '='?"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // !(NAME '=') expression '=' + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + $B._PyPegen.lookahead(0, _tmp_155_rule, p) + && + (a = expression_rule(p)) // expression + && + (b = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, b, "expression cannot contain assignment, perhaps you meant \"==\"?"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '**' expression '=' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + var expression_var; + if ( + (a = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (expression_var = expression_rule(p)) // expression + && + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + && + (b = expression_rule(p)) // expression + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, b, "cannot assign to keyword argument unpacking"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// expression_without_invalid: +// | disjunction 'if' disjunction 'else' expression +// | disjunction +// | lambdef +function expression_without_invalid_rule(p) +{ + var _prev_call_invalid = p.call_invalid_rules; + p.call_invalid_rules = 0; + if (p.error_indicator) { + p.call_invalid_rules = _prev_call_invalid; + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + if (p.mark == p.fill && $B._PyPegen.fill_token(p) < 0) { + p.error_indicator = 1; + p.call_invalid_rules = _prev_call_invalid; + return NULL; + } + EXTRA.lineno = p.tokens[_mark].lineno; + EXTRA.col_offset = p.tokens[_mark].col_offset; + { // disjunction 'if' disjunction 'else' expression + if (p.error_indicator) { + p.call_invalid_rules = _prev_call_invalid; + return NULL; + } + var _keyword; + var _keyword_1; + var a; + var b; + var c; + if ( + (a = disjunction_rule(p)) // disjunction + && + (_keyword = $B._PyPegen.expect_token(p, 642)) // token='if' + && + (b = disjunction_rule(p)) // disjunction + && + (_keyword_1 = $B._PyPegen.expect_token(p, 645)) // token='else' + && + (c = expression_rule(p)) // expression + ) + { + var _token = $B._PyPegen.get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p.call_invalid_rules = _prev_call_invalid; + return NULL; + } + EXTRA.end_lineno = _token.end_lineno; + EXTRA.end_col_offset = _token.end_col_offset; + _res = new $B._PyAST.IfExp (b, a, c, EXTRA); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + p.call_invalid_rules = _prev_call_invalid; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // disjunction + if (p.error_indicator) { + p.call_invalid_rules = _prev_call_invalid; + return NULL; + } + var disjunction_var; + if ( + (disjunction_var = disjunction_rule(p)) // disjunction + ) + { + _res = disjunction_var; + return done(); + } + p.mark = _mark; + } + { // lambdef + if (p.error_indicator) { + p.call_invalid_rules = _prev_call_invalid; + return NULL; + } + var lambdef_var; + if ( + (lambdef_var = lambdef_rule(p)) // lambdef + ) + { + _res = lambdef_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + p.call_invalid_rules = _prev_call_invalid; + return _res; + } +} + +// invalid_legacy_expression: NAME !'(' star_expressions +function invalid_legacy_expression_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // NAME !'(' star_expressions + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 7) // token='(' + && + (b = star_expressions_rule(p)) // star_expressions + ) + { + _res = $B._PyPegen.check_legacy_stmt (p, a ) ? $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a, b, "Missing parentheses in call to '%U'. Did you mean %U(...)?", a. id, a. id) : $B.parser_constants.NULL; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_expression: +// | !(NAME STRING | SOFT_KEYWORD) disjunction expression_without_invalid +// | disjunction 'if' disjunction !('else' | ':') +// | 'lambda' lambda_params? ':' &FSTRING_MIDDLE +function invalid_expression_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // !(NAME STRING | SOFT_KEYWORD) disjunction expression_without_invalid + if (p.error_indicator) { + return NULL; + } + var a; + var b; + if ( + $B._PyPegen.lookahead(0, _tmp_156_rule, p) + && + (a = disjunction_rule(p)) // disjunction + && + (b = expression_without_invalid_rule(p)) // expression_without_invalid + ) + { + _res = $B._PyPegen.check_legacy_stmt (p, a ) ? $B.parser_constants.NULL : p.tokens [p.mark - 1].level == 0 ? $B.parser_constants.NULL : $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a, b, "invalid syntax. Perhaps you forgot a comma?"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // disjunction 'if' disjunction !('else' | ':') + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + var b; + if ( + (a = disjunction_rule(p)) // disjunction + && + (_keyword = $B._PyPegen.expect_token(p, 642)) // token='if' + && + (b = disjunction_rule(p)) // disjunction + && + $B._PyPegen.lookahead(0, _tmp_157_rule, p) + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, b, "expected 'else' after 'if' expression"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'lambda' lambda_params? ':' &FSTRING_MIDDLE + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var b; + if ( + (a = $B._PyPegen.expect_token(p, 600)) // token='lambda' + && + (_opt_var = lambda_params_rule(p), !p.error_indicator) // lambda_params? + && + (b = $B._PyPegen.expect_token(p, 11)) // token=':' + && + $B._PyPegen.lookahead_with_int(1, $B._PyPegen.expect_token, p, FSTRING_MIDDLE) // token=FSTRING_MIDDLE + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, b, "f-string: lambda expressions are not allowed without parentheses"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_named_expression: +// | expression ':=' expression +// | NAME '=' bitwise_or !('=' | ':=') +// | !(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=') +function invalid_named_expression_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + if ($B._PyPegen.is_memoized(p, invalid_named_expression_type, _res)) { + return _res.value; + } + _res = NULL; + var _mark = p.mark; + { // expression ':=' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var expression_var; + if ( + (a = expression_rule(p)) // expression + && + (_literal = $B._PyPegen.expect_token(p, 53)) // token=':=' + && + (expression_var = expression_rule(p)) // expression + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "cannot use assignment expressions with %s", $B._PyPegen.get_expr_name ( a )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // NAME '=' bitwise_or !('=' | ':=') + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + if ( + (a = $B._PyPegen.name_token(p)) // NAME + && + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + && + (b = bitwise_or_rule(p)) // bitwise_or + && + $B._PyPegen.lookahead(0, _tmp_158_rule, p) + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, b, "invalid syntax. Maybe you meant '==' or ':=' instead of '='?"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // !(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=') + if (p.error_indicator) { + return NULL; + } + var a; + var b; + var bitwise_or_var; + if ( + $B._PyPegen.lookahead(0, _tmp_159_rule, p) + && + (a = bitwise_or_rule(p)) // bitwise_or + && + (b = $B._PyPegen.expect_token(p, 22)) // token='=' + && + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + && + $B._PyPegen.lookahead(0, _tmp_160_rule, p) + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "cannot assign to %s here. Maybe you meant '==' instead of '='?", $B._PyPegen.get_expr_name ( a )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + $B._PyPegen.insert_memo(p, _mark, invalid_named_expression_type, _res); + return _res; + } +} + +// invalid_assignment: +// | invalid_ann_assign_target ':' expression +// | star_named_expression ',' star_named_expressions* ':' expression +// | expression ':' expression +// | ((star_targets '='))* star_expressions '=' +// | ((star_targets '='))* yield_expr '=' +// | star_expressions augassign (yield_expr | star_expressions) +function invalid_assignment_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // invalid_ann_assign_target ':' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var expression_var; + if ( + (a = invalid_ann_assign_target_rule(p)) // invalid_ann_assign_target + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (expression_var = expression_rule(p)) // expression + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "only single target (not %s) can be annotated", $B._PyPegen.get_expr_name ( a )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // star_named_expression ',' star_named_expressions* ':' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _loop0_161_var; + var a; + var expression_var; + if ( + (a = star_named_expression_rule(p)) // star_named_expression + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (_loop0_161_var = _loop0_161_rule(p)) // star_named_expressions* + && + (_literal_1 = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (expression_var = expression_rule(p)) // expression + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "only single target (not tuple) can be annotated"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // expression ':' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var expression_var; + if ( + (a = expression_rule(p)) // expression + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (expression_var = expression_rule(p)) // expression + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "illegal target for annotation"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ((star_targets '='))* star_expressions '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _loop0_162_var; + var a; + if ( + (_loop0_162_var = _loop0_162_rule(p)) // ((star_targets '='))* + && + (a = star_expressions_rule(p)) // star_expressions + && + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_INVALID_TARGET ($B.parser_constants.STAR_TARGETS, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ((star_targets '='))* yield_expr '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _loop0_163_var; + var a; + if ( + (_loop0_163_var = _loop0_163_rule(p)) // ((star_targets '='))* + && + (a = yield_expr_rule(p)) // yield_expr + && + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "assignment to yield expression not possible"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // star_expressions augassign (yield_expr | star_expressions) + if (p.error_indicator) { + return NULL; + } + var _tmp_164_var; + var a; + var augassign_var; + if ( + (a = star_expressions_rule(p)) // star_expressions + && + (augassign_var = augassign_rule(p)) // augassign + && + (_tmp_164_var = _tmp_164_rule(p)) // yield_expr | star_expressions + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "'%s' is an illegal expression for augmented assignment", $B._PyPegen.get_expr_name ( a )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_ann_assign_target: list | tuple | '(' invalid_ann_assign_target ')' +function invalid_ann_assign_target_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // list + if (p.error_indicator) { + return NULL; + } + var list_var; + if ( + (list_var = list_rule(p)) // list + ) + { + _res = list_var; + return done(); + } + p.mark = _mark; + } + { // tuple + if (p.error_indicator) { + return NULL; + } + var tuple_var; + if ( + (tuple_var = tuple_rule(p)) // tuple + ) + { + _res = tuple_var; + return done(); + } + p.mark = _mark; + } + { // '(' invalid_ann_assign_target ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = invalid_ann_assign_target_rule(p)) // invalid_ann_assign_target + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_del_stmt: 'del' star_expressions +function invalid_del_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'del' star_expressions + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 604)) // token='del' + && + (a = star_expressions_rule(p)) // star_expressions + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_INVALID_TARGET ($B.parser_constants.DEL_TARGETS, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_block: NEWLINE !INDENT +function invalid_block_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var newline_var; + if ( + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_comprehension: +// | ('[' | '(' | '{') starred_expression for_if_clauses +// | ('[' | '{') star_named_expression ',' star_named_expressions for_if_clauses +// | ('[' | '{') star_named_expression ',' for_if_clauses +function invalid_comprehension_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ('[' | '(' | '{') starred_expression for_if_clauses + if (p.error_indicator) { + return NULL; + } + var _tmp_165_var; + var a; + var for_if_clauses_var; + if ( + (_tmp_165_var = _tmp_165_rule(p)) // '[' | '(' | '{' + && + (a = starred_expression_rule(p)) // starred_expression + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "iterable unpacking cannot be used in comprehension"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ('[' | '{') star_named_expression ',' star_named_expressions for_if_clauses + if (p.error_indicator) { + return NULL; + } + var _literal; + var _tmp_166_var; + var a; + var b; + var for_if_clauses_var; + if ( + (_tmp_166_var = _tmp_166_rule(p)) // '[' | '{' + && + (a = star_named_expression_rule(p)) // star_named_expression + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (b = star_named_expressions_rule(p)) // star_named_expressions + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, PyPegen_last_item ( b, $B.ast.expr ), "did you forget parentheses around the comprehension target?"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ('[' | '{') star_named_expression ',' for_if_clauses + if (p.error_indicator) { + return NULL; + } + var _tmp_167_var; + var a; + var b; + var for_if_clauses_var; + if ( + (_tmp_167_var = _tmp_167_rule(p)) // '[' | '{' + && + (a = star_named_expression_rule(p)) // star_named_expression + && + (b = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, b, "did you forget parentheses around the comprehension target?"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_dict_comprehension: '{' '**' bitwise_or for_if_clauses '}' +function invalid_dict_comprehension_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '{' '**' bitwise_or for_if_clauses '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var bitwise_or_var; + var for_if_clauses_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (a = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + && + (_literal_1 = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "dict unpacking cannot be used in dict comprehension"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_parameters: +// | "/" ',' +// | (slash_no_default | slash_with_default) param_maybe_default* '/' +// | slash_no_default? param_no_default* invalid_parameters_helper param_no_default +// | param_no_default* '(' param_no_default+ ','? ')' +// | [(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/' +// | param_maybe_default+ '/' '*' +function invalid_parameters_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // "/" ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (a = $B._PyPegen.expect_token(p, 17)) // token='/' + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "at least one argument must precede /"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // (slash_no_default | slash_with_default) param_maybe_default* '/' + if (p.error_indicator) { + return NULL; + } + var _loop0_169_var; + var _tmp_168_var; + var a; + if ( + (_tmp_168_var = _tmp_168_rule(p)) // slash_no_default | slash_with_default + && + (_loop0_169_var = _loop0_169_rule(p)) // param_maybe_default* + && + (a = $B._PyPegen.expect_token(p, 17)) // token='/' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "/ may appear only once"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // slash_no_default? param_no_default* invalid_parameters_helper param_no_default + if (p.error_indicator) { + return NULL; + } + var _loop0_170_var; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var invalid_parameters_helper_var; + if ( + (_opt_var = slash_no_default_rule(p), !p.error_indicator) // slash_no_default? + && + (_loop0_170_var = _loop0_170_rule(p)) // param_no_default* + && + (invalid_parameters_helper_var = invalid_parameters_helper_rule(p)) // invalid_parameters_helper + && + (a = param_no_default_rule(p)) // param_no_default + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "parameter without a default follows parameter with a default"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // param_no_default* '(' param_no_default+ ','? ')' + if (p.error_indicator) { + return NULL; + } + var _loop0_171_var; + var _loop1_172_var; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var b; + if ( + (_loop0_171_var = _loop0_171_rule(p)) // param_no_default* + && + (a = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (_loop1_172_var = _loop1_172_rule(p)) // param_no_default+ + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + && + (b = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, b, "Function parameters cannot be parenthesized"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // [(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _loop0_174_var; + var _loop0_176_var; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var _tmp_175_var; + var a; + if ( + (_opt_var = _tmp_173_rule(p), !p.error_indicator) // [(slash_no_default | slash_with_default)] + && + (_loop0_174_var = _loop0_174_rule(p)) // param_maybe_default* + && + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (_tmp_175_var = _tmp_175_rule(p)) // ',' | param_no_default + && + (_loop0_176_var = _loop0_176_rule(p)) // param_maybe_default* + && + (a = $B._PyPegen.expect_token(p, 17)) // token='/' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "/ must be ahead of *"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // param_maybe_default+ '/' '*' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _loop1_177_var; + var a; + if ( + (_loop1_177_var = _loop1_177_rule(p)) // param_maybe_default+ + && + (_literal = $B._PyPegen.expect_token(p, 17)) // token='/' + && + (a = $B._PyPegen.expect_token(p, 16)) // token='*' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "expected comma between / and *"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_default: '=' &(')' | ',') +function invalid_default_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '=' &(')' | ',') + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = $B._PyPegen.expect_token(p, 22)) // token='=' + && + $B._PyPegen.lookahead(1, _tmp_178_rule, p) + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "expected default value expression"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_star_etc: +// | '*' (')' | ',' (')' | '**')) +// | '*' ',' TYPE_COMMENT +// | '*' param '=' +// | '*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',') +function invalid_star_etc_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '*' (')' | ',' (')' | '**')) + if (p.error_indicator) { + return NULL; + } + var _tmp_179_var; + var a; + if ( + (a = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (_tmp_179_var = _tmp_179_rule(p)) // ')' | ',' (')' | '**') + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "named arguments must follow bare *"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '*' ',' TYPE_COMMENT + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var type_comment_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (_literal_1 = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (type_comment_var = $B._PyPegen.expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("bare * has associated type comment"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '*' param '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var param_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (param_var = param_rule(p)) // param + && + (a = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "var-positional argument cannot have default value"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',') + if (p.error_indicator) { + return NULL; + } + var _literal; + var _loop0_181_var; + var _tmp_180_var; + var _tmp_182_var; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (_tmp_180_var = _tmp_180_rule(p)) // param_no_default | ',' + && + (_loop0_181_var = _loop0_181_rule(p)) // param_maybe_default* + && + (a = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (_tmp_182_var = _tmp_182_rule(p)) // param_no_default | ',' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "* argument may appear only once"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_kwds: '**' param '=' | '**' param ',' param | '**' param ',' ('*' | '**' | '/') +function invalid_kwds_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '**' param '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var param_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (param_var = param_rule(p)) // param + && + (a = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "var-keyword argument cannot have default value"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '**' param ',' param + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var param_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (param_var = param_rule(p)) // param + && + (_literal_1 = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (a = param_rule(p)) // param + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "arguments cannot follow var-keyword argument"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '**' param ',' ('*' | '**' | '/') + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var param_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (param_var = param_rule(p)) // param + && + (_literal_1 = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (a = _tmp_183_rule(p)) // '*' | '**' | '/' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "arguments cannot follow var-keyword argument"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_parameters_helper: slash_with_default | param_with_default+ +function invalid_parameters_helper_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // slash_with_default + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = slash_with_default_rule(p)) // slash_with_default + ) + { + _res = $B._PyPegen.singleton_seq (p, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // param_with_default+ + if (p.error_indicator) { + return NULL; + } + var _loop1_184_var; + if ( + (_loop1_184_var = _loop1_184_rule(p)) // param_with_default+ + ) + { + _res = _loop1_184_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_lambda_parameters: +// | "/" ',' +// | (lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/' +// | lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default +// | lambda_param_no_default* '(' ','.lambda_param+ ','? ')' +// | [(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/' +// | lambda_param_maybe_default+ '/' '*' +function invalid_lambda_parameters_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // "/" ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (a = $B._PyPegen.expect_token(p, 17)) // token='/' + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "at least one argument must precede /"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // (lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/' + if (p.error_indicator) { + return NULL; + } + var _loop0_186_var; + var _tmp_185_var; + var a; + if ( + (_tmp_185_var = _tmp_185_rule(p)) // lambda_slash_no_default | lambda_slash_with_default + && + (_loop0_186_var = _loop0_186_rule(p)) // lambda_param_maybe_default* + && + (a = $B._PyPegen.expect_token(p, 17)) // token='/' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "/ may appear only once"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default + if (p.error_indicator) { + return NULL; + } + var _loop0_187_var; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var invalid_lambda_parameters_helper_var; + if ( + (_opt_var = lambda_slash_no_default_rule(p), !p.error_indicator) // lambda_slash_no_default? + && + (_loop0_187_var = _loop0_187_rule(p)) // lambda_param_no_default* + && + (invalid_lambda_parameters_helper_var = invalid_lambda_parameters_helper_rule(p)) // invalid_lambda_parameters_helper + && + (a = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "parameter without a default follows parameter with a default"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // lambda_param_no_default* '(' ','.lambda_param+ ','? ')' + if (p.error_indicator) { + return NULL; + } + var _gather_189_var; + var _loop0_188_var; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var b; + if ( + (_loop0_188_var = _loop0_188_rule(p)) // lambda_param_no_default* + && + (a = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (_gather_189_var = _gather_189_rule(p)) // ','.lambda_param+ + && + (_opt_var = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + && + (b = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, b, "Lambda expression parameters cannot be parenthesized"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // [(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _loop0_192_var; + var _loop0_194_var; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var _tmp_193_var; + var a; + if ( + (_opt_var = _tmp_191_rule(p), !p.error_indicator) // [(lambda_slash_no_default | lambda_slash_with_default)] + && + (_loop0_192_var = _loop0_192_rule(p)) // lambda_param_maybe_default* + && + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (_tmp_193_var = _tmp_193_rule(p)) // ',' | lambda_param_no_default + && + (_loop0_194_var = _loop0_194_rule(p)) // lambda_param_maybe_default* + && + (a = $B._PyPegen.expect_token(p, 17)) // token='/' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "/ must be ahead of *"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // lambda_param_maybe_default+ '/' '*' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _loop1_195_var; + var a; + if ( + (_loop1_195_var = _loop1_195_rule(p)) // lambda_param_maybe_default+ + && + (_literal = $B._PyPegen.expect_token(p, 17)) // token='/' + && + (a = $B._PyPegen.expect_token(p, 16)) // token='*' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "expected comma between / and *"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_lambda_parameters_helper: +// | lambda_slash_with_default +// | lambda_param_with_default+ +function invalid_lambda_parameters_helper_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // lambda_slash_with_default + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default + ) + { + _res = $B._PyPegen.singleton_seq (p, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // lambda_param_with_default+ + if (p.error_indicator) { + return NULL; + } + var _loop1_196_var; + if ( + (_loop1_196_var = _loop1_196_rule(p)) // lambda_param_with_default+ + ) + { + _res = _loop1_196_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_lambda_star_etc: +// | '*' (':' | ',' (':' | '**')) +// | '*' lambda_param '=' +// | '*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',') +function invalid_lambda_star_etc_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '*' (':' | ',' (':' | '**')) + if (p.error_indicator) { + return NULL; + } + var _literal; + var _tmp_197_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (_tmp_197_var = _tmp_197_rule(p)) // ':' | ',' (':' | '**') + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("named arguments must follow bare *"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '*' lambda_param '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var lambda_param_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (lambda_param_var = lambda_param_rule(p)) // lambda_param + && + (a = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "var-positional argument cannot have default value"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',') + if (p.error_indicator) { + return NULL; + } + var _literal; + var _loop0_199_var; + var _tmp_198_var; + var _tmp_200_var; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (_tmp_198_var = _tmp_198_rule(p)) // lambda_param_no_default | ',' + && + (_loop0_199_var = _loop0_199_rule(p)) // lambda_param_maybe_default* + && + (a = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (_tmp_200_var = _tmp_200_rule(p)) // lambda_param_no_default | ',' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "* argument may appear only once"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_lambda_kwds: +// | '**' lambda_param '=' +// | '**' lambda_param ',' lambda_param +// | '**' lambda_param ',' ('*' | '**' | '/') +function invalid_lambda_kwds_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '**' lambda_param '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var lambda_param_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (lambda_param_var = lambda_param_rule(p)) // lambda_param + && + (a = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "var-keyword argument cannot have default value"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '**' lambda_param ',' lambda_param + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var lambda_param_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (lambda_param_var = lambda_param_rule(p)) // lambda_param + && + (_literal_1 = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (a = lambda_param_rule(p)) // lambda_param + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "arguments cannot follow var-keyword argument"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '**' lambda_param ',' ('*' | '**' | '/') + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var lambda_param_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (lambda_param_var = lambda_param_rule(p)) // lambda_param + && + (_literal_1 = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (a = _tmp_201_rule(p)) // '*' | '**' | '/' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "arguments cannot follow var-keyword argument"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT +function invalid_double_type_comments_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT + if (p.error_indicator) { + return NULL; + } + var indent_var; + var newline_var; + var newline_var_1; + var type_comment_var; + var type_comment_var_1; + if ( + (type_comment_var = $B._PyPegen.expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + (type_comment_var_1 = $B._PyPegen.expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' + && + (newline_var_1 = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + (indent_var = $B._PyPegen.expect_token(p, INDENT)) // token='INDENT' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("Cannot have two type comments on def"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_with_item: expression 'as' expression &(',' | ')' | ':') +function invalid_with_item_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // expression 'as' expression &(',' | ')' | ':') + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + var expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (a = expression_rule(p)) // expression + && + $B._PyPegen.lookahead(1, _tmp_202_rule, p) + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_INVALID_TARGET ($B.parser_constants.STAR_TARGETS, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_for_target: ASYNC? 'for' star_expressions +function invalid_for_target_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ASYNC? 'for' star_expressions + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + if ( + (_opt_var = $B._PyPegen.expect_token(p, ASYNC), !p.error_indicator) // ASYNC? + && + (_keyword = $B._PyPegen.expect_token(p, 650)) // token='for' + && + (a = star_expressions_rule(p)) // star_expressions + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_INVALID_TARGET ($B.parser_constants.FOR_TARGETS, a); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_group: '(' starred_expression ')' | '(' '**' expression ')' +function invalid_group_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '(' starred_expression ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = starred_expression_rule(p)) // starred_expression + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "cannot use starred expression here"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '(' '**' expression ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var a; + var expression_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = $B._PyPegen.expect_token(p, 35)) // token='**' + && + (expression_var = expression_rule(p)) // expression + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "cannot use double starred expression here"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_import: 'import' ','.dotted_name+ 'from' dotted_name +function invalid_import_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'import' ','.dotted_name+ 'from' dotted_name + if (p.error_indicator) { + return NULL; + } + var _gather_203_var; + var _keyword; + var a; + var dotted_name_var; + if ( + (a = $B._PyPegen.expect_token(p, 607)) // token='import' + && + (_gather_203_var = _gather_203_rule(p)) // ','.dotted_name+ + && + (_keyword = $B._PyPegen.expect_token(p, 608)) // token='from' + && + (dotted_name_var = dotted_name_rule(p)) // dotted_name + ) + { + _res = RAISE_SYNTAX_ERROR_STARTING_FROM (a, "Did you mean to use 'from ... import ...' instead?"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_import_from_targets: import_from_as_names ',' NEWLINE +function invalid_import_from_targets_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // import_from_as_names ',' NEWLINE + if (p.error_indicator) { + return NULL; + } + var _literal; + var import_from_as_names_var; + var newline_var; + if ( + (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("trailing comma not allowed without surrounding parentheses"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_with_stmt: +// | ASYNC? 'with' ','.(expression ['as' star_target])+ NEWLINE +// | ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE +function invalid_with_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ASYNC? 'with' ','.(expression ['as' star_target])+ NEWLINE + if (p.error_indicator) { + return NULL; + } + var _gather_205_var; + var _keyword; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var newline_var; + if ( + (_opt_var = $B._PyPegen.expect_token(p, ASYNC), !p.error_indicator) // ASYNC? + && + (_keyword = $B._PyPegen.expect_token(p, 615)) // token='with' + && + (_gather_205_var = _gather_205_rule(p)) // ','.(expression ['as' star_target])+ + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("expected ':'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE + if (p.error_indicator) { + return NULL; + } + var _gather_207_var; + var _keyword; + var _literal; + var _literal_1; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var _opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + var newline_var; + if ( + (_opt_var = $B._PyPegen.expect_token(p, ASYNC), !p.error_indicator) // ASYNC? + && + (_keyword = $B._PyPegen.expect_token(p, 615)) // token='with' + && + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (_gather_207_var = _gather_207_rule(p)) // ','.(expressions ['as' star_target])+ + && + (_opt_var_1 = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("expected ':'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_with_stmt_indent: +// | ASYNC? 'with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT +// | ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT +function invalid_with_stmt_indent_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ASYNC? 'with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _gather_209_var; + var _literal; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var newline_var; + if ( + (_opt_var = $B._PyPegen.expect_token(p, ASYNC), !p.error_indicator) // ASYNC? + && + (a = $B._PyPegen.expect_token(p, 615)) // token='with' + && + (_gather_209_var = _gather_209_rule(p)) // ','.(expression ['as' star_target])+ + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after 'with' statement on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _gather_211_var; + var _literal; + var _literal_1; + var _literal_2; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var _opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + var a; + var newline_var; + if ( + (_opt_var = $B._PyPegen.expect_token(p, ASYNC), !p.error_indicator) // ASYNC? + && + (a = $B._PyPegen.expect_token(p, 615)) // token='with' + && + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (_gather_211_var = _gather_211_rule(p)) // ','.(expressions ['as' star_target])+ + && + (_opt_var_1 = $B._PyPegen.expect_token(p, 12), !p.error_indicator) // ','? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + && + (_literal_2 = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after 'with' statement on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_try_stmt: +// | 'try' ':' NEWLINE !INDENT +// | 'try' ':' block !('except' | 'finally') +// | 'try' ':' block* except_block+ 'except' '*' expression ['as' NAME] ':' +// | 'try' ':' block* except_star_block+ 'except' [expression ['as' NAME]] ':' +function invalid_try_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'try' ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var newline_var; + if ( + (a = $B._PyPegen.expect_token(p, 624)) // token='try' + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after 'try' statement on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'try' ':' block !('except' | 'finally') + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var block_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 624)) // token='try' + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (block_var = block_rule(p)) // block + && + $B._PyPegen.lookahead(0, _tmp_213_rule, p) + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("expected 'except' or 'finally' block"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'try' ':' block* except_block+ 'except' '*' expression ['as' NAME] ':' + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var _literal_1; + var _loop0_214_var; + var _loop1_215_var; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var b; + var expression_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 624)) // token='try' + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (_loop0_214_var = _loop0_214_rule(p)) // block* + && + (_loop1_215_var = _loop1_215_rule(p)) // except_block+ + && + (a = $B._PyPegen.expect_token(p, 637)) // token='except' + && + (b = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (expression_var = expression_rule(p)) // expression + && + (_opt_var = _tmp_216_rule(p), !p.error_indicator) // ['as' NAME] + && + (_literal_1 = $B._PyPegen.expect_token(p, 11)) // token=':' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, b, "cannot have both 'except' and 'except' on the same 'try'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'try' ':' block* except_star_block+ 'except' [expression ['as' NAME]] ':' + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var _literal_1; + var _loop0_217_var; + var _loop1_218_var; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + if ( + (_keyword = $B._PyPegen.expect_token(p, 624)) // token='try' + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (_loop0_217_var = _loop0_217_rule(p)) // block* + && + (_loop1_218_var = _loop1_218_rule(p)) // except_star_block+ + && + (a = $B._PyPegen.expect_token(p, 637)) // token='except' + && + (_opt_var = _tmp_219_rule(p), !p.error_indicator) // [expression ['as' NAME]] + && + (_literal_1 = $B._PyPegen.expect_token(p, 11)) // token=':' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "cannot have both 'except' and 'except' on the same 'try'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_except_stmt: +// | 'except' '*'? expression ',' expressions ['as' NAME] ':' +// | 'except' '*'? expression ['as' NAME] NEWLINE +// | 'except' NEWLINE +// | 'except' '*' (NEWLINE | ':') +function invalid_except_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'except' '*'? expression ',' expressions ['as' NAME] ':' + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var _literal_1; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var _opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + var a; + var expressions_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 637)) // token='except' + && + (_opt_var = $B._PyPegen.expect_token(p, 16), !p.error_indicator) // '*'? + && + (a = expression_rule(p)) // expression + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (expressions_var = expressions_rule(p)) // expressions + && + (_opt_var_1 = _tmp_220_rule(p), !p.error_indicator) // ['as' NAME] + && + (_literal_1 = $B._PyPegen.expect_token(p, 11)) // token=':' + ) + { + _res = RAISE_SYNTAX_ERROR_STARTING_FROM (a, "multiple exception types must be parenthesized"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'except' '*'? expression ['as' NAME] NEWLINE + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var _opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + var a; + var expression_var; + var newline_var; + if ( + (a = $B._PyPegen.expect_token(p, 637)) // token='except' + && + (_opt_var = $B._PyPegen.expect_token(p, 16), !p.error_indicator) // '*'? + && + (expression_var = expression_rule(p)) // expression + && + (_opt_var_1 = _tmp_221_rule(p), !p.error_indicator) // ['as' NAME] + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("expected ':'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'except' NEWLINE + if (p.error_indicator) { + return NULL; + } + var a; + var newline_var; + if ( + (a = $B._PyPegen.expect_token(p, 637)) // token='except' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("expected ':'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'except' '*' (NEWLINE | ':') + if (p.error_indicator) { + return NULL; + } + var _literal; + var _tmp_222_var; + var a; + if ( + (a = $B._PyPegen.expect_token(p, 637)) // token='except' + && + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (_tmp_222_var = _tmp_222_rule(p)) // NEWLINE | ':' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("expected one or more exception types"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_finally_stmt: 'finally' ':' NEWLINE !INDENT +function invalid_finally_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'finally' ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var newline_var; + if ( + (a = $B._PyPegen.expect_token(p, 633)) // token='finally' + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after 'finally' statement on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_except_stmt_indent: +// | 'except' expression ['as' NAME] ':' NEWLINE !INDENT +// | 'except' ':' NEWLINE !INDENT +function invalid_except_stmt_indent_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'except' expression ['as' NAME] ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _literal; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var expression_var; + var newline_var; + if ( + (a = $B._PyPegen.expect_token(p, 637)) // token='except' + && + (expression_var = expression_rule(p)) // expression + && + (_opt_var = _tmp_223_rule(p), !p.error_indicator) // ['as' NAME] + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after 'except' statement on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'except' ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var newline_var; + if ( + (a = $B._PyPegen.expect_token(p, 637)) // token='except' + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after 'except' statement on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_except_star_stmt_indent: +// | 'except' '*' expression ['as' NAME] ':' NEWLINE !INDENT +function invalid_except_star_stmt_indent_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'except' '*' expression ['as' NAME] ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var expression_var; + var newline_var; + if ( + (a = $B._PyPegen.expect_token(p, 637)) // token='except' + && + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (expression_var = expression_rule(p)) // expression + && + (_opt_var = _tmp_224_rule(p), !p.error_indicator) // ['as' NAME] + && + (_literal_1 = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after 'except' statement on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_match_stmt: +// | "match" subject_expr NEWLINE +// | "match" subject_expr ':' NEWLINE !INDENT +function invalid_match_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // "match" subject_expr NEWLINE + if (p.error_indicator) { + return NULL; + } + var _keyword; + var newline_var; + var subject_expr_var; + if ( + (_keyword = $B._PyPegen.expect_soft_keyword(p, "match")) // soft_keyword='"match"' + && + (subject_expr_var = subject_expr_rule(p)) // subject_expr + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = $B.helper_functions.CHECK_VERSION (_void, 10, "Pattern matching is", $B.helper_functions.RAISE_SYNTAX_ERROR ( "expected ':'" )); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // "match" subject_expr ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var newline_var; + var subject; + if ( + (a = $B._PyPegen.expect_soft_keyword(p, "match")) // soft_keyword='"match"' + && + (subject = subject_expr_rule(p)) // subject_expr + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after 'match' statement on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_case_block: +// | "case" patterns guard? NEWLINE +// | "case" patterns guard? ':' NEWLINE !INDENT +function invalid_case_block_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // "case" patterns guard? NEWLINE + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var newline_var; + var patterns_var; + if ( + (_keyword = $B._PyPegen.expect_soft_keyword(p, "case")) // soft_keyword='"case"' + && + (patterns_var = patterns_rule(p)) // patterns + && + (_opt_var = guard_rule(p), !p.error_indicator) // guard? + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("expected ':'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // "case" patterns guard? ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _literal; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var newline_var; + var patterns_var; + if ( + (a = $B._PyPegen.expect_soft_keyword(p, "case")) // soft_keyword='"case"' + && + (patterns_var = patterns_rule(p)) // patterns + && + (_opt_var = guard_rule(p), !p.error_indicator) // guard? + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after 'case' statement on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_as_pattern: or_pattern 'as' "_" | or_pattern 'as' !NAME expression +function invalid_as_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // or_pattern 'as' "_" + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + var or_pattern_var; + if ( + (or_pattern_var = or_pattern_rule(p)) // or_pattern + && + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (a = $B._PyPegen.expect_soft_keyword(p, "_")) // soft_keyword='"_"' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "cannot use '_' as a target"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // or_pattern 'as' !NAME expression + if (p.error_indicator) { + return NULL; + } + var _keyword; + var a; + var or_pattern_var; + if ( + (or_pattern_var = or_pattern_rule(p)) // or_pattern + && + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + $B._PyPegen.lookahead_with_name(0, $B._PyPegen.name_token, p) + && + (a = expression_rule(p)) // expression + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "invalid pattern target"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_class_pattern: name_or_attr '(' invalid_class_argument_pattern +function invalid_class_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // name_or_attr '(' invalid_class_argument_pattern + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var name_or_attr_var; + if ( + (name_or_attr_var = name_or_attr_rule(p)) // name_or_attr + && + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (a = invalid_class_argument_pattern_rule(p)) // invalid_class_argument_pattern + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (PyPegen_first_item ( a, $B.ast.pattern ), PyPegen_last_item ( a, $B.ast.pattern ), "positional patterns follow keyword patterns"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_class_argument_pattern: +// | [positional_patterns ','] keyword_patterns ',' positional_patterns +function invalid_class_argument_pattern_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // [positional_patterns ','] keyword_patterns ',' positional_patterns + if (p.error_indicator) { + return NULL; + } + var _literal; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var keyword_patterns_var; + if ( + (_opt_var = _tmp_225_rule(p), !p.error_indicator) // [positional_patterns ','] + && + (keyword_patterns_var = keyword_patterns_rule(p)) // keyword_patterns + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (a = positional_patterns_rule(p)) // positional_patterns + ) + { + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_if_stmt: +// | 'if' named_expression NEWLINE +// | 'if' named_expression ':' NEWLINE !INDENT +function invalid_if_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'if' named_expression NEWLINE + if (p.error_indicator) { + return NULL; + } + var _keyword; + var named_expression_var; + var newline_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 642)) // token='if' + && + (named_expression_var = named_expression_rule(p)) // named_expression + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("expected ':'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'if' named_expression ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var a_1; + var newline_var; + if ( + (a = $B._PyPegen.expect_token(p, 642)) // token='if' + && + (a_1 = named_expression_rule(p)) // named_expression + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after 'if' statement on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_elif_stmt: +// | 'elif' named_expression NEWLINE +// | 'elif' named_expression ':' NEWLINE !INDENT +function invalid_elif_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'elif' named_expression NEWLINE + if (p.error_indicator) { + return NULL; + } + var _keyword; + var named_expression_var; + var newline_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 644)) // token='elif' + && + (named_expression_var = named_expression_rule(p)) // named_expression + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("expected ':'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'elif' named_expression ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var named_expression_var; + var newline_var; + if ( + (a = $B._PyPegen.expect_token(p, 644)) // token='elif' + && + (named_expression_var = named_expression_rule(p)) // named_expression + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after 'elif' statement on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_else_stmt: 'else' ':' NEWLINE !INDENT +function invalid_else_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'else' ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var newline_var; + if ( + (a = $B._PyPegen.expect_token(p, 645)) // token='else' + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after 'else' statement on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_while_stmt: +// | 'while' named_expression NEWLINE +// | 'while' named_expression ':' NEWLINE !INDENT +function invalid_while_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'while' named_expression NEWLINE + if (p.error_indicator) { + return NULL; + } + var _keyword; + var named_expression_var; + var newline_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 647)) // token='while' + && + (named_expression_var = named_expression_rule(p)) // named_expression + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("expected ':'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'while' named_expression ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var named_expression_var; + var newline_var; + if ( + (a = $B._PyPegen.expect_token(p, 647)) // token='while' + && + (named_expression_var = named_expression_rule(p)) // named_expression + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after 'while' statement on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_for_stmt: +// | ASYNC? 'for' star_targets 'in' star_expressions NEWLINE +// | ASYNC? 'for' star_targets 'in' star_expressions ':' NEWLINE !INDENT +function invalid_for_stmt_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ASYNC? 'for' star_targets 'in' star_expressions NEWLINE + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _keyword_1; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var newline_var; + var star_expressions_var; + var star_targets_var; + if ( + (_opt_var = $B._PyPegen.expect_token(p, ASYNC), !p.error_indicator) // ASYNC? + && + (_keyword = $B._PyPegen.expect_token(p, 650)) // token='for' + && + (star_targets_var = star_targets_rule(p)) // star_targets + && + (_keyword_1 = $B._PyPegen.expect_token(p, 651)) // token='in' + && + (star_expressions_var = star_expressions_rule(p)) // star_expressions + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("expected ':'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // ASYNC? 'for' star_targets 'in' star_expressions ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _literal; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var a; + var newline_var; + var star_expressions_var; + var star_targets_var; + if ( + (_opt_var = $B._PyPegen.expect_token(p, ASYNC), !p.error_indicator) // ASYNC? + && + (a = $B._PyPegen.expect_token(p, 650)) // token='for' + && + (star_targets_var = star_targets_rule(p)) // star_targets + && + (_keyword = $B._PyPegen.expect_token(p, 651)) // token='in' + && + (star_expressions_var = star_expressions_rule(p)) // star_expressions + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after 'for' statement on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_def_raw: +// | ASYNC? 'def' NAME type_params? '(' params? ')' ['->' expression] ':' NEWLINE !INDENT +function invalid_def_raw_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ASYNC? 'def' NAME type_params? '(' params? ')' ['->' expression] ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _literal_2; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var _opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + var _opt_var_2; + UNUSED(_opt_var_2); // Silence compiler warnings + var _opt_var_3; + UNUSED(_opt_var_3); // Silence compiler warnings + var a; + var name_var; + var newline_var; + if ( + (_opt_var = $B._PyPegen.expect_token(p, ASYNC), !p.error_indicator) // ASYNC? + && + (a = $B._PyPegen.expect_token(p, 652)) // token='def' + && + (name_var = $B._PyPegen.name_token(p)) // NAME + && + (_opt_var_1 = type_params_rule(p), !p.error_indicator) // type_params? + && + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (_opt_var_2 = params_rule(p), !p.error_indicator) // params? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + && + (_opt_var_3 = _tmp_226_rule(p), !p.error_indicator) // ['->' expression] + && + (_literal_2 = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after function definition on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_class_def_raw: +// | 'class' NAME type_params? ['(' arguments? ')'] NEWLINE +// | 'class' NAME type_params? ['(' arguments? ')'] ':' NEWLINE !INDENT +function invalid_class_def_raw_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'class' NAME type_params? ['(' arguments? ')'] NEWLINE + if (p.error_indicator) { + return NULL; + } + var _keyword; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var _opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + var name_var; + var newline_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 654)) // token='class' + && + (name_var = $B._PyPegen.name_token(p)) // NAME + && + (_opt_var = type_params_rule(p), !p.error_indicator) // type_params? + && + (_opt_var_1 = _tmp_227_rule(p), !p.error_indicator) // ['(' arguments? ')'] + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR ("expected ':'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // 'class' NAME type_params? ['(' arguments? ')'] ':' NEWLINE !INDENT + if (p.error_indicator) { + return NULL; + } + var _literal; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var _opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + var a; + var name_var; + var newline_var; + if ( + (a = $B._PyPegen.expect_token(p, 654)) // token='class' + && + (name_var = $B._PyPegen.name_token(p)) // NAME + && + (_opt_var = type_params_rule(p), !p.error_indicator) // type_params? + && + (_opt_var_1 = _tmp_228_rule(p), !p.error_indicator) // ['(' arguments? ')'] + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, INDENT) // token=INDENT + ) + { + _res = $B.helper_functions.RAISE_INDENTATION_ERROR ("expected an indented block after class definition on line %d", a.lineno); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_double_starred_kvpairs: +// | ','.double_starred_kvpair+ ',' invalid_kvpair +// | expression ':' '*' bitwise_or +// | expression ':' &('}' | ',') +function invalid_double_starred_kvpairs_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.double_starred_kvpair+ ',' invalid_kvpair + if (p.error_indicator) { + return NULL; + } + var _gather_229_var; + var _literal; + var invalid_kvpair_var; + if ( + (_gather_229_var = _gather_229_rule(p)) // ','.double_starred_kvpair+ + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (invalid_kvpair_var = invalid_kvpair_rule(p)) // invalid_kvpair + ) + { + _res = $B._PyPegen.dummy_name(p, _gather_229_var, _literal, invalid_kvpair_var); + return done(); + } + p.mark = _mark; + } + { // expression ':' '*' bitwise_or + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var bitwise_or_var; + var expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (a = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + ) + { + _res = RAISE_SYNTAX_ERROR_STARTING_FROM (a, "cannot use a starred expression in a dictionary value"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // expression ':' &('}' | ',') + if (p.error_indicator) { + return NULL; + } + var a; + var expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (a = $B._PyPegen.expect_token(p, 11)) // token=':' + && + $B._PyPegen.lookahead(1, _tmp_231_rule, p) + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "expression expected after dictionary key and ':'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_kvpair: +// | expression !(':') +// | expression ':' '*' bitwise_or +// | expression ':' &('}' | ',') +function invalid_kvpair_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // expression !(':') + if (p.error_indicator) { + return NULL; + } + var a; + if ( + (a = expression_rule(p)) // expression + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 11) // token=(':') + ) + { + _res = $B.helper_functions.RAISE_ERROR_KNOWN_LOCATION (p, $B.parser_constants.PyExc_SyntaxError, a.lineno, a.end_col_offset - 1, a.end_lineno, - 1, "':' expected after dictionary key"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // expression ':' '*' bitwise_or + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var bitwise_or_var; + var expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (a = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or + ) + { + _res = RAISE_SYNTAX_ERROR_STARTING_FROM (a, "cannot use a starred expression in a dictionary value"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // expression ':' &('}' | ',') + if (p.error_indicator) { + return NULL; + } + var a; + var expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (a = $B._PyPegen.expect_token(p, 11)) // token=':' + && + $B._PyPegen.lookahead(1, _tmp_232_rule, p) + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "expression expected after dictionary key and ':'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_starred_expression: '*' expression '=' expression +function invalid_starred_expression_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '*' expression '=' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + var b; + var expression_var; + if ( + (a = $B._PyPegen.expect_token(p, 16)) // token='*' + && + (expression_var = expression_rule(p)) // expression + && + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + && + (b = expression_rule(p)) // expression + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_RANGE (a, b, "cannot assign to iterable argument unpacking"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_replacement_field: +// | '{' '=' +// | '{' '!' +// | '{' ':' +// | '{' '}' +// | '{' !(yield_expr | star_expressions) +// | '{' (yield_expr | star_expressions) !('=' | '!' | ':' | '}') +// | '{' (yield_expr | star_expressions) '=' !('!' | ':' | '}') +// | '{' (yield_expr | star_expressions) '='? invalid_conversion_character +// | '{' (yield_expr | star_expressions) '='? ['!' NAME] !(':' | '}') +// | '{' (yield_expr | star_expressions) '='? ['!' NAME] ':' fstring_format_spec* !'}' +// | '{' (yield_expr | star_expressions) '='? ['!' NAME] !'}' +function invalid_replacement_field_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '{' '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (a = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "f-string: valid expression required before '='"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '{' '!' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (a = $B._PyPegen.expect_token(p, 54)) // token='!' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "f-string: valid expression required before '!'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '{' ':' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (a = $B._PyPegen.expect_token(p, 11)) // token=':' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "f-string: valid expression required before ':'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '{' '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + var a; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (a = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_KNOWN_LOCATION (a, "f-string: valid expression required before '}'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '{' !(yield_expr | star_expressions) + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + $B._PyPegen.lookahead(0, _tmp_233_rule, p) + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ("f-string: expecting a valid expression after '{'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '{' (yield_expr | star_expressions) !('=' | '!' | ':' | '}') + if (p.error_indicator) { + return NULL; + } + var _literal; + var _tmp_234_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (_tmp_234_var = _tmp_234_rule(p)) // yield_expr | star_expressions + && + $B._PyPegen.lookahead(0, _tmp_235_rule, p) + ) + { + _res = PyErr_Occurred () ? $B.parser_constants.NULL : $B.helper_functions.RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting '=', or '!', or ':', or '}'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '{' (yield_expr | star_expressions) '=' !('!' | ':' | '}') + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _tmp_236_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (_tmp_236_var = _tmp_236_rule(p)) // yield_expr | star_expressions + && + (_literal_1 = $B._PyPegen.expect_token(p, 22)) // token='=' + && + $B._PyPegen.lookahead(0, _tmp_237_rule, p) + ) + { + _res = PyErr_Occurred () ? $B.parser_constants.NULL : $B.helper_functions.RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting '!', or ':', or '}'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '{' (yield_expr | star_expressions) '='? invalid_conversion_character + if (p.error_indicator) { + return NULL; + } + var _literal; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var _tmp_238_var; + var invalid_conversion_character_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (_tmp_238_var = _tmp_238_rule(p)) // yield_expr | star_expressions + && + (_opt_var = $B._PyPegen.expect_token(p, 22), !p.error_indicator) // '='? + && + (invalid_conversion_character_var = invalid_conversion_character_rule(p)) // invalid_conversion_character + ) + { + _res = $B._PyPegen.dummy_name(p, _literal, _tmp_238_var, _opt_var, invalid_conversion_character_var); + return done(); + } + p.mark = _mark; + } + { // '{' (yield_expr | star_expressions) '='? ['!' NAME] !(':' | '}') + if (p.error_indicator) { + return NULL; + } + var _literal; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var _opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + var _tmp_239_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (_tmp_239_var = _tmp_239_rule(p)) // yield_expr | star_expressions + && + (_opt_var = $B._PyPegen.expect_token(p, 22), !p.error_indicator) // '='? + && + (_opt_var_1 = _tmp_240_rule(p), !p.error_indicator) // ['!' NAME] + && + $B._PyPegen.lookahead(0, _tmp_241_rule, p) + ) + { + _res = PyErr_Occurred () ? $B.parser_constants.NULL : $B.helper_functions.RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting ':' or '}'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '{' (yield_expr | star_expressions) '='? ['!' NAME] ':' fstring_format_spec* !'}' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _loop0_244_var; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var _opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + var _tmp_242_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (_tmp_242_var = _tmp_242_rule(p)) // yield_expr | star_expressions + && + (_opt_var = $B._PyPegen.expect_token(p, 22), !p.error_indicator) // '='? + && + (_opt_var_1 = _tmp_243_rule(p), !p.error_indicator) // ['!' NAME] + && + (_literal_1 = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (_loop0_244_var = _loop0_244_rule(p)) // fstring_format_spec* + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 26) // token='}' + ) + { + _res = PyErr_Occurred () ? $B.parser_constants.NULL : $B.helper_functions.RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting '}', or format specs"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '{' (yield_expr | star_expressions) '='? ['!' NAME] !'}' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var _opt_var_1; + UNUSED(_opt_var_1); // Silence compiler warnings + var _tmp_245_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + && + (_tmp_245_var = _tmp_245_rule(p)) // yield_expr | star_expressions + && + (_opt_var = $B._PyPegen.expect_token(p, 22), !p.error_indicator) // '='? + && + (_opt_var_1 = _tmp_246_rule(p), !p.error_indicator) // ['!' NAME] + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 26) // token='}' + ) + { + _res = PyErr_Occurred () ? $B.parser_constants.NULL : $B.helper_functions.RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ( "f-string: expecting '}'"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// invalid_conversion_character: '!' &(':' | '}') | '!' !NAME +function invalid_conversion_character_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '!' &(':' | '}') + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 54)) // token='!' + && + $B._PyPegen.lookahead(1, _tmp_247_rule, p) + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ("f-string: missing conversion character"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // '!' !NAME + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 54)) // token='!' + && + $B._PyPegen.lookahead_with_name(0, $B._PyPegen.name_token, p) + ) + { + _res = $B.helper_functions.RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN ("f-string: invalid conversion character"); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_1: NEWLINE +function _loop0_1_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // NEWLINE + if (p.error_indicator) { + return NULL; + } + var newline_var; + while ( + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = newline_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_2: NEWLINE +function _loop0_2_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // NEWLINE + if (p.error_indicator) { + return NULL; + } + var newline_var; + while ( + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = newline_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_3: statement +function _loop1_3_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // statement + if (p.error_indicator) { + return NULL; + } + var statement_var; + while ( + (statement_var = statement_rule(p)) // statement + ) + { + _res = statement_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_5: ';' simple_stmt +function _loop0_5_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ';' simple_stmt + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 13)) // token=';' + && + (elem = simple_stmt_rule(p)) // simple_stmt + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_4: simple_stmt _loop0_5 +function _gather_4_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // simple_stmt _loop0_5 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = simple_stmt_rule(p)) // simple_stmt + && + (seq = _loop0_5_rule(p)) // _loop0_5 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_6: 'import' | 'from' +function _tmp_6_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'import' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 607)) // token='import' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + { // 'from' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 608)) // token='from' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_7: 'def' | '@' | ASYNC +function _tmp_7_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'def' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 652)) // token='def' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + { // '@' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 49)) // token='@' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ASYNC + if (p.error_indicator) { + return NULL; + } + var async_var; + if ( + (async_var = $B._PyPegen.expect_token(p, ASYNC)) // token='ASYNC' + ) + { + _res = async_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_8: 'class' | '@' +function _tmp_8_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'class' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 654)) // token='class' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + { // '@' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 49)) // token='@' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_9: 'with' | ASYNC +function _tmp_9_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'with' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 615)) // token='with' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + { // ASYNC + if (p.error_indicator) { + return NULL; + } + var async_var; + if ( + (async_var = $B._PyPegen.expect_token(p, ASYNC)) // token='ASYNC' + ) + { + _res = async_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_10: 'for' | ASYNC +function _tmp_10_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'for' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 650)) // token='for' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + { // ASYNC + if (p.error_indicator) { + return NULL; + } + var async_var; + if ( + (async_var = $B._PyPegen.expect_token(p, ASYNC)) // token='ASYNC' + ) + { + _res = async_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_11: '=' annotated_rhs +function _tmp_11_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '=' annotated_rhs + if (p.error_indicator) { + return NULL; + } + var _literal; + var d; + if ( + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + && + (d = annotated_rhs_rule(p)) // annotated_rhs + ) + { + _res = d; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_12: '(' single_target ')' | single_subscript_attribute_target +function _tmp_12_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '(' single_target ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var b; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (b = single_target_rule(p)) // single_target + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = b; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + { // single_subscript_attribute_target + if (p.error_indicator) { + return NULL; + } + var single_subscript_attribute_target_var; + if ( + (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target + ) + { + _res = single_subscript_attribute_target_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_13: '=' annotated_rhs +function _tmp_13_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '=' annotated_rhs + if (p.error_indicator) { + return NULL; + } + var _literal; + var d; + if ( + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + && + (d = annotated_rhs_rule(p)) // annotated_rhs + ) + { + _res = d; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop1_14: (star_targets '=') +function _loop1_14_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // (star_targets '=') + if (p.error_indicator) { + return NULL; + } + var _tmp_248_var; + while ( + (_tmp_248_var = _tmp_248_rule(p)) // star_targets '=' + ) + { + _res = _tmp_248_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_15: yield_expr | star_expressions +function _tmp_15_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // yield_expr + if (p.error_indicator) { + return NULL; + } + var yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + _res = yield_expr_var; + return done(); + } + p.mark = _mark; + } + { // star_expressions + if (p.error_indicator) { + return NULL; + } + var star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions + ) + { + _res = star_expressions_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_16: yield_expr | star_expressions +function _tmp_16_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // yield_expr + if (p.error_indicator) { + return NULL; + } + var yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + _res = yield_expr_var; + return done(); + } + p.mark = _mark; + } + { // star_expressions + if (p.error_indicator) { + return NULL; + } + var star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions + ) + { + _res = star_expressions_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_17: 'from' expression +function _tmp_17_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'from' expression + if (p.error_indicator) { + return NULL; + } + var _keyword; + var z; + if ( + (_keyword = $B._PyPegen.expect_token(p, 608)) // token='from' + && + (z = expression_rule(p)) // expression + ) + { + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_19: ',' NAME +function _loop0_19_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' NAME + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_18: NAME _loop0_19 +function _gather_18_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // NAME _loop0_19 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = $B._PyPegen.name_token(p)) // NAME + && + (seq = _loop0_19_rule(p)) // _loop0_19 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_21: ',' NAME +function _loop0_21_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' NAME + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_20: NAME _loop0_21 +function _gather_20_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // NAME _loop0_21 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = $B._PyPegen.name_token(p)) // NAME + && + (seq = _loop0_21_rule(p)) // _loop0_21 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_22: ';' | NEWLINE +function _tmp_22_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ';' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 13)) // token=';' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // NEWLINE + if (p.error_indicator) { + return NULL; + } + var newline_var; + if ( + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = newline_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_23: ',' expression +function _tmp_23_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ',' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var z; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (z = expression_rule(p)) // expression + ) + { + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_24: ('.' | '...') +function _loop0_24_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ('.' | '...') + if (p.error_indicator) { + return NULL; + } + var _tmp_249_var; + while ( + (_tmp_249_var = _tmp_249_rule(p)) // '.' | '...' + ) + { + _res = _tmp_249_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_25: ('.' | '...') +function _loop1_25_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ('.' | '...') + if (p.error_indicator) { + return NULL; + } + var _tmp_250_var; + while ( + (_tmp_250_var = _tmp_250_rule(p)) // '.' | '...' + ) + { + _res = _tmp_250_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_27: ',' import_from_as_name +function _loop0_27_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' import_from_as_name + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = import_from_as_name_rule(p)) // import_from_as_name + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_26: import_from_as_name _loop0_27 +function _gather_26_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // import_from_as_name _loop0_27 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = import_from_as_name_rule(p)) // import_from_as_name + && + (seq = _loop0_27_rule(p)) // _loop0_27 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_28: 'as' NAME +function _tmp_28_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'as' NAME + if (p.error_indicator) { + return NULL; + } + var _keyword; + var z; + if ( + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (z = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_30: ',' dotted_as_name +function _loop0_30_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' dotted_as_name + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = dotted_as_name_rule(p)) // dotted_as_name + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_29: dotted_as_name _loop0_30 +function _gather_29_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // dotted_as_name _loop0_30 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = dotted_as_name_rule(p)) // dotted_as_name + && + (seq = _loop0_30_rule(p)) // _loop0_30 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_31: 'as' NAME +function _tmp_31_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'as' NAME + if (p.error_indicator) { + return NULL; + } + var _keyword; + var z; + if ( + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (z = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop1_32: ('@' named_expression NEWLINE) +function _loop1_32_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ('@' named_expression NEWLINE) + if (p.error_indicator) { + return NULL; + } + var _tmp_251_var; + while ( + (_tmp_251_var = _tmp_251_rule(p)) // '@' named_expression NEWLINE + ) + { + _res = _tmp_251_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_33: '(' arguments? ')' +function _tmp_33_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '(' arguments? ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var z; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (z = arguments_rule(p), !p.error_indicator) // arguments? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_34: '->' expression +function _tmp_34_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '->' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var z; + if ( + (_literal = $B._PyPegen.expect_token(p, 51)) // token='->' + && + (z = expression_rule(p)) // expression + ) + { + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_35: '->' expression +function _tmp_35_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '->' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var z; + if ( + (_literal = $B._PyPegen.expect_token(p, 51)) // token='->' + && + (z = expression_rule(p)) // expression + ) + { + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_36: param_no_default +function _loop0_36_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_no_default + if (p.error_indicator) { + return NULL; + } + var param_no_default_var; + while ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + _res = param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_37: param_with_default +function _loop0_37_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_with_default + if (p.error_indicator) { + return NULL; + } + var param_with_default_var; + while ( + (param_with_default_var = param_with_default_rule(p)) // param_with_default + ) + { + _res = param_with_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_38: param_with_default +function _loop0_38_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_with_default + if (p.error_indicator) { + return NULL; + } + var param_with_default_var; + while ( + (param_with_default_var = param_with_default_rule(p)) // param_with_default + ) + { + _res = param_with_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_39: param_no_default +function _loop1_39_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_no_default + if (p.error_indicator) { + return NULL; + } + var param_no_default_var; + while ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + _res = param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_40: param_with_default +function _loop0_40_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_with_default + if (p.error_indicator) { + return NULL; + } + var param_with_default_var; + while ( + (param_with_default_var = param_with_default_rule(p)) // param_with_default + ) + { + _res = param_with_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_41: param_with_default +function _loop1_41_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_with_default + if (p.error_indicator) { + return NULL; + } + var param_with_default_var; + while ( + (param_with_default_var = param_with_default_rule(p)) // param_with_default + ) + { + _res = param_with_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_42: param_no_default +function _loop1_42_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_no_default + if (p.error_indicator) { + return NULL; + } + var param_no_default_var; + while ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + _res = param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_43: param_no_default +function _loop1_43_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_no_default + if (p.error_indicator) { + return NULL; + } + var param_no_default_var; + while ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + _res = param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_44: param_no_default +function _loop0_44_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_no_default + if (p.error_indicator) { + return NULL; + } + var param_no_default_var; + while ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + _res = param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_45: param_with_default +function _loop1_45_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_with_default + if (p.error_indicator) { + return NULL; + } + var param_with_default_var; + while ( + (param_with_default_var = param_with_default_rule(p)) // param_with_default + ) + { + _res = param_with_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_46: param_no_default +function _loop0_46_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_no_default + if (p.error_indicator) { + return NULL; + } + var param_no_default_var; + while ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + _res = param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_47: param_with_default +function _loop1_47_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_with_default + if (p.error_indicator) { + return NULL; + } + var param_with_default_var; + while ( + (param_with_default_var = param_with_default_rule(p)) // param_with_default + ) + { + _res = param_with_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_48: param_maybe_default +function _loop0_48_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_maybe_default + if (p.error_indicator) { + return NULL; + } + var param_maybe_default_var; + while ( + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default + ) + { + _res = param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_49: param_maybe_default +function _loop0_49_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_maybe_default + if (p.error_indicator) { + return NULL; + } + var param_maybe_default_var; + while ( + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default + ) + { + _res = param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_50: param_maybe_default +function _loop1_50_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_maybe_default + if (p.error_indicator) { + return NULL; + } + var param_maybe_default_var; + while ( + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default + ) + { + _res = param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_52: ',' with_item +function _loop0_52_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' with_item + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = with_item_rule(p)) // with_item + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_51: with_item _loop0_52 +function _gather_51_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // with_item _loop0_52 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = with_item_rule(p)) // with_item + && + (seq = _loop0_52_rule(p)) // _loop0_52 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_54: ',' with_item +function _loop0_54_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' with_item + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = with_item_rule(p)) // with_item + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_53: with_item _loop0_54 +function _gather_53_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // with_item _loop0_54 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = with_item_rule(p)) // with_item + && + (seq = _loop0_54_rule(p)) // _loop0_54 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_56: ',' with_item +function _loop0_56_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' with_item + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = with_item_rule(p)) // with_item + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_55: with_item _loop0_56 +function _gather_55_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // with_item _loop0_56 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = with_item_rule(p)) // with_item + && + (seq = _loop0_56_rule(p)) // _loop0_56 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_58: ',' with_item +function _loop0_58_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' with_item + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = with_item_rule(p)) // with_item + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_57: with_item _loop0_58 +function _gather_57_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // with_item _loop0_58 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = with_item_rule(p)) // with_item + && + (seq = _loop0_58_rule(p)) // _loop0_58 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_59: ',' | ')' | ':' +function _tmp_59_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ':' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop1_60: except_block +function _loop1_60_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // except_block + if (p.error_indicator) { + return NULL; + } + var except_block_var; + while ( + (except_block_var = except_block_rule(p)) // except_block + ) + { + _res = except_block_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_61: except_star_block +function _loop1_61_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // except_star_block + if (p.error_indicator) { + return NULL; + } + var except_star_block_var; + while ( + (except_star_block_var = except_star_block_rule(p)) // except_star_block + ) + { + _res = except_star_block_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_62: 'as' NAME +function _tmp_62_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'as' NAME + if (p.error_indicator) { + return NULL; + } + var _keyword; + var z; + if ( + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (z = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_63: 'as' NAME +function _tmp_63_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'as' NAME + if (p.error_indicator) { + return NULL; + } + var _keyword; + var z; + if ( + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (z = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop1_64: case_block +function _loop1_64_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // case_block + if (p.error_indicator) { + return NULL; + } + var case_block_var; + while ( + (case_block_var = case_block_rule(p)) // case_block + ) + { + _res = case_block_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_66: '|' closed_pattern +function _loop0_66_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // '|' closed_pattern + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._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); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_65: closed_pattern _loop0_66 +function _gather_65_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // closed_pattern _loop0_66 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = closed_pattern_rule(p)) // closed_pattern + && + (seq = _loop0_66_rule(p)) // _loop0_66 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_67: '+' | '-' +function _tmp_67_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '+' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 14)) // token='+' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '-' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 15)) // token='-' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_68: '+' | '-' +function _tmp_68_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '+' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 14)) // token='+' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '-' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 15)) // token='-' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_69: '.' | '(' | '=' +function _tmp_69_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '.' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 23)) // token='.' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '(' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_70: '.' | '(' | '=' +function _tmp_70_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '.' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 23)) // token='.' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '(' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_72: ',' maybe_star_pattern +function _loop0_72_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' maybe_star_pattern + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._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); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_71: maybe_star_pattern _loop0_72 +function _gather_71_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // maybe_star_pattern _loop0_72 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = maybe_star_pattern_rule(p)) // maybe_star_pattern + && + (seq = _loop0_72_rule(p)) // _loop0_72 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_74: ',' key_value_pattern +function _loop0_74_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' key_value_pattern + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._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); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_73: key_value_pattern _loop0_74 +function _gather_73_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // key_value_pattern _loop0_74 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = key_value_pattern_rule(p)) // key_value_pattern + && + (seq = _loop0_74_rule(p)) // _loop0_74 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_75: literal_expr | attr +function _tmp_75_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // literal_expr + if (p.error_indicator) { + return NULL; + } + var literal_expr_var; + if ( + (literal_expr_var = literal_expr_rule(p)) // literal_expr + ) + { + _res = literal_expr_var; + return done(); + } + p.mark = _mark; + } + { // attr + if (p.error_indicator) { + return NULL; + } + var attr_var; + if ( + (attr_var = attr_rule(p)) // attr + ) + { + _res = attr_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_77: ',' pattern +function _loop0_77_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' pattern + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._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); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_76: pattern _loop0_77 +function _gather_76_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // pattern _loop0_77 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = pattern_rule(p)) // pattern + && + (seq = _loop0_77_rule(p)) // _loop0_77 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_79: ',' keyword_pattern +function _loop0_79_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' keyword_pattern + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._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); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_78: keyword_pattern _loop0_79 +function _gather_78_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // keyword_pattern _loop0_79 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = keyword_pattern_rule(p)) // keyword_pattern + && + (seq = _loop0_79_rule(p)) // _loop0_79 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_81: ',' type_param +function _loop0_81_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' type_param + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = type_param_rule(p)) // type_param + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_80: type_param _loop0_81 +function _gather_80_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // type_param _loop0_81 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = type_param_rule(p)) // type_param + && + (seq = _loop0_81_rule(p)) // _loop0_81 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop1_82: (',' expression) +function _loop1_82_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // (',' expression) + if (p.error_indicator) { + return NULL; + } + var _tmp_252_var; + while ( + (_tmp_252_var = _tmp_252_rule(p)) // ',' expression + ) + { + _res = _tmp_252_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_83: (',' star_expression) +function _loop1_83_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // (',' star_expression) + if (p.error_indicator) { + return NULL; + } + var _tmp_253_var; + while ( + (_tmp_253_var = _tmp_253_rule(p)) // ',' star_expression + ) + { + _res = _tmp_253_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_85: ',' star_named_expression +function _loop0_85_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' star_named_expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = star_named_expression_rule(p)) // star_named_expression + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_84: star_named_expression _loop0_85 +function _gather_84_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // star_named_expression _loop0_85 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = star_named_expression_rule(p)) // star_named_expression + && + (seq = _loop0_85_rule(p)) // _loop0_85 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop1_86: ('or' conjunction) +function _loop1_86_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ('or' conjunction) + if (p.error_indicator) { + return NULL; + } + var _tmp_254_var; + while ( + (_tmp_254_var = _tmp_254_rule(p)) // 'or' conjunction + ) + { + _res = _tmp_254_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_87: ('and' inversion) +function _loop1_87_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ('and' inversion) + if (p.error_indicator) { + return NULL; + } + var _tmp_255_var; + while ( + (_tmp_255_var = _tmp_255_rule(p)) // 'and' inversion + ) + { + _res = _tmp_255_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_88: compare_op_bitwise_or_pair +function _loop1_88_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // compare_op_bitwise_or_pair + if (p.error_indicator) { + return NULL; + } + var compare_op_bitwise_or_pair_var; + while ( + (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair + ) + { + _res = compare_op_bitwise_or_pair_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_89: '!=' +function _tmp_89_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '!=' + if (p.error_indicator) { + return NULL; + } + var tok; + if ( + (tok = $B._PyPegen.expect_token(p, 28)) // token='!=' + ) + { + _res = $B._PyPegen.check_barry_as_flufl (p, tok) ? $B.parser_constants.NULL : tok; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_91: ',' (slice | starred_expression) +function _loop0_91_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' (slice | starred_expression) + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = _tmp_256_rule(p)) // slice | starred_expression + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_90: (slice | starred_expression) _loop0_91 +function _gather_90_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // (slice | starred_expression) _loop0_91 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = _tmp_256_rule(p)) // slice | starred_expression + && + (seq = _loop0_91_rule(p)) // _loop0_91 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_92: ':' expression? +function _tmp_92_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ':' expression? + if (p.error_indicator) { + return NULL; + } + var _literal; + var d; + if ( + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + && + (d = expression_rule(p), !p.error_indicator) // expression? + ) + { + _res = d; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_93: STRING | FSTRING_START +function _tmp_93_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // STRING + if (p.error_indicator) { + return NULL; + } + var string_var; + if ( + (string_var = $B._PyPegen.string_token(p)) // STRING + ) + { + _res = string_var; + return done(); + } + p.mark = _mark; + } + { // FSTRING_START + if (p.error_indicator) { + return NULL; + } + var fstring_start_var; + if ( + (fstring_start_var = $B._PyPegen.expect_token(p, FSTRING_START)) // token='FSTRING_START' + ) + { + _res = fstring_start_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_94: tuple | group | genexp +function _tmp_94_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // tuple + if (p.error_indicator) { + return NULL; + } + var tuple_var; + if ( + (tuple_var = tuple_rule(p)) // tuple + ) + { + _res = tuple_var; + return done(); + } + p.mark = _mark; + } + { // group + if (p.error_indicator) { + return NULL; + } + var group_var; + if ( + (group_var = group_rule(p)) // group + ) + { + _res = group_var; + return done(); + } + p.mark = _mark; + } + { // genexp + if (p.error_indicator) { + return NULL; + } + var genexp_var; + if ( + (genexp_var = genexp_rule(p)) // genexp + ) + { + _res = genexp_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_95: list | listcomp +function _tmp_95_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // list + if (p.error_indicator) { + return NULL; + } + var list_var; + if ( + (list_var = list_rule(p)) // list + ) + { + _res = list_var; + return done(); + } + p.mark = _mark; + } + { // listcomp + if (p.error_indicator) { + return NULL; + } + var listcomp_var; + if ( + (listcomp_var = listcomp_rule(p)) // listcomp + ) + { + _res = listcomp_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_96: dict | set | dictcomp | setcomp +function _tmp_96_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // dict + if (p.error_indicator) { + return NULL; + } + var dict_var; + if ( + (dict_var = dict_rule(p)) // dict + ) + { + _res = dict_var; + return done(); + } + p.mark = _mark; + } + { // set + if (p.error_indicator) { + return NULL; + } + var set_var; + if ( + (set_var = set_rule(p)) // set + ) + { + _res = set_var; + return done(); + } + p.mark = _mark; + } + { // dictcomp + if (p.error_indicator) { + return NULL; + } + var dictcomp_var; + if ( + (dictcomp_var = dictcomp_rule(p)) // dictcomp + ) + { + _res = dictcomp_var; + return done(); + } + p.mark = _mark; + } + { // setcomp + if (p.error_indicator) { + return NULL; + } + var setcomp_var; + if ( + (setcomp_var = setcomp_rule(p)) // setcomp + ) + { + _res = setcomp_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_97: yield_expr | named_expression +function _tmp_97_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // yield_expr + if (p.error_indicator) { + return NULL; + } + var yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + _res = yield_expr_var; + return done(); + } + p.mark = _mark; + } + { // named_expression + if (p.error_indicator) { + return NULL; + } + var named_expression_var; + if ( + (named_expression_var = named_expression_rule(p)) // named_expression + ) + { + _res = named_expression_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_98: lambda_param_no_default +function _loop0_98_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_no_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_no_default_var; + while ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = lambda_param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_99: lambda_param_with_default +function _loop0_99_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_with_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_with_default_var; + while ( + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default + ) + { + _res = lambda_param_with_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_100: lambda_param_with_default +function _loop0_100_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_with_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_with_default_var; + while ( + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default + ) + { + _res = lambda_param_with_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_101: lambda_param_no_default +function _loop1_101_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_no_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_no_default_var; + while ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = lambda_param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_102: lambda_param_with_default +function _loop0_102_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_with_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_with_default_var; + while ( + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default + ) + { + _res = lambda_param_with_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_103: lambda_param_with_default +function _loop1_103_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_with_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_with_default_var; + while ( + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default + ) + { + _res = lambda_param_with_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_104: lambda_param_no_default +function _loop1_104_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_no_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_no_default_var; + while ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = lambda_param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_105: lambda_param_no_default +function _loop1_105_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_no_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_no_default_var; + while ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = lambda_param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_106: lambda_param_no_default +function _loop0_106_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_no_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_no_default_var; + while ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = lambda_param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_107: lambda_param_with_default +function _loop1_107_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_with_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_with_default_var; + while ( + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default + ) + { + _res = lambda_param_with_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_108: lambda_param_no_default +function _loop0_108_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_no_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_no_default_var; + while ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = lambda_param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_109: lambda_param_with_default +function _loop1_109_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_with_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_with_default_var; + while ( + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default + ) + { + _res = lambda_param_with_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_110: lambda_param_maybe_default +function _loop0_110_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_maybe_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_maybe_default_var; + while ( + (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default + ) + { + _res = lambda_param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_111: lambda_param_maybe_default +function _loop1_111_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_maybe_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_maybe_default_var; + while ( + (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default + ) + { + _res = lambda_param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_112: yield_expr | star_expressions +function _tmp_112_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // yield_expr + if (p.error_indicator) { + return NULL; + } + var yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + _res = yield_expr_var; + return done(); + } + p.mark = _mark; + } + { // star_expressions + if (p.error_indicator) { + return NULL; + } + var star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions + ) + { + _res = star_expressions_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_113: fstring_format_spec +function _loop0_113_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // fstring_format_spec + if (p.error_indicator) { + return NULL; + } + var fstring_format_spec_var; + while ( + (fstring_format_spec_var = fstring_format_spec_rule(p)) // fstring_format_spec + ) + { + _res = fstring_format_spec_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_114: fstring_middle +function _loop0_114_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // fstring_middle + if (p.error_indicator) { + return NULL; + } + var fstring_middle_var; + while ( + (fstring_middle_var = fstring_middle_rule(p)) // fstring_middle + ) + { + _res = fstring_middle_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_115: (fstring | string) +function _loop1_115_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // (fstring | string) + if (p.error_indicator) { + return NULL; + } + var _tmp_257_var; + while ( + (_tmp_257_var = _tmp_257_rule(p)) // fstring | string + ) + { + _res = _tmp_257_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_116: star_named_expression ',' star_named_expressions? +function _tmp_116_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // star_named_expression ',' star_named_expressions? + if (p.error_indicator) { + return NULL; + } + var _literal; + var y; + var z; + if ( + (y = star_named_expression_rule(p)) // star_named_expression + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (z = star_named_expressions_rule(p), !p.error_indicator) // star_named_expressions? + ) + { + _res = $B._PyPegen.seq_insert_in_front (p, y, z); + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_118: ',' double_starred_kvpair +function _loop0_118_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' double_starred_kvpair + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_117: double_starred_kvpair _loop0_118 +function _gather_117_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // double_starred_kvpair _loop0_118 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair + && + (seq = _loop0_118_rule(p)) // _loop0_118 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop1_119: for_if_clause +function _loop1_119_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // for_if_clause + if (p.error_indicator) { + return NULL; + } + var for_if_clause_var; + while ( + (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause + ) + { + _res = for_if_clause_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_120: ('if' disjunction) +function _loop0_120_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ('if' disjunction) + if (p.error_indicator) { + return NULL; + } + var _tmp_258_var; + while ( + (_tmp_258_var = _tmp_258_rule(p)) // 'if' disjunction + ) + { + _res = _tmp_258_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_121: ('if' disjunction) +function _loop0_121_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ('if' disjunction) + if (p.error_indicator) { + return NULL; + } + var _tmp_259_var; + while ( + (_tmp_259_var = _tmp_259_rule(p)) // 'if' disjunction + ) + { + _res = _tmp_259_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_122: assignment_expression | expression !':=' +function _tmp_122_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // assignment_expression + if (p.error_indicator) { + return NULL; + } + var assignment_expression_var; + if ( + (assignment_expression_var = assignment_expression_rule(p)) // assignment_expression + ) + { + _res = assignment_expression_var; + return done(); + } + p.mark = _mark; + } + { // expression !':=' + if (p.error_indicator) { + return NULL; + } + var expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 53) // token=':=' + ) + { + _res = expression_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_124: ',' (starred_expression | (assignment_expression | expression !':=') !'=') +function _loop0_124_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' (starred_expression | (assignment_expression | expression !':=') !'=') + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = _tmp_260_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_123: +// | (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_124 +function _gather_123_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_124 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = _tmp_260_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' + && + (seq = _loop0_124_rule(p)) // _loop0_124 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_125: ',' kwargs +function _tmp_125_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ',' kwargs + if (p.error_indicator) { + return NULL; + } + var _literal; + var k; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (k = kwargs_rule(p)) // kwargs + ) + { + _res = k; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_127: ',' kwarg_or_starred +function _loop0_127_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' kwarg_or_starred + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_126: kwarg_or_starred _loop0_127 +function _gather_126_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // kwarg_or_starred _loop0_127 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred + && + (seq = _loop0_127_rule(p)) // _loop0_127 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_129: ',' kwarg_or_double_starred +function _loop0_129_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' kwarg_or_double_starred + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_128: kwarg_or_double_starred _loop0_129 +function _gather_128_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // kwarg_or_double_starred _loop0_129 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred + && + (seq = _loop0_129_rule(p)) // _loop0_129 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_131: ',' kwarg_or_starred +function _loop0_131_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' kwarg_or_starred + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_130: kwarg_or_starred _loop0_131 +function _gather_130_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // kwarg_or_starred _loop0_131 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred + && + (seq = _loop0_131_rule(p)) // _loop0_131 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_133: ',' kwarg_or_double_starred +function _loop0_133_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' kwarg_or_double_starred + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_132: kwarg_or_double_starred _loop0_133 +function _gather_132_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // kwarg_or_double_starred _loop0_133 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred + && + (seq = _loop0_133_rule(p)) // _loop0_133 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_134: (',' star_target) +function _loop0_134_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // (',' star_target) + if (p.error_indicator) { + return NULL; + } + var _tmp_261_var; + while ( + (_tmp_261_var = _tmp_261_rule(p)) // ',' star_target + ) + { + _res = _tmp_261_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_136: ',' star_target +function _loop0_136_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' star_target + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = star_target_rule(p)) // star_target + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_135: star_target _loop0_136 +function _gather_135_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // star_target _loop0_136 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = star_target_rule(p)) // star_target + && + (seq = _loop0_136_rule(p)) // _loop0_136 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop1_137: (',' star_target) +function _loop1_137_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // (',' star_target) + if (p.error_indicator) { + return NULL; + } + var _tmp_262_var; + while ( + (_tmp_262_var = _tmp_262_rule(p)) // ',' star_target + ) + { + _res = _tmp_262_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_138: !'*' star_target +function _tmp_138_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // !'*' star_target + if (p.error_indicator) { + return NULL; + } + var star_target_var; + if ( + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 16) // token='*' + && + (star_target_var = star_target_rule(p)) // star_target + ) + { + _res = star_target_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_140: ',' del_target +function _loop0_140_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' del_target + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = del_target_rule(p)) // del_target + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_139: del_target _loop0_140 +function _gather_139_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // del_target _loop0_140 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = del_target_rule(p)) // del_target + && + (seq = _loop0_140_rule(p)) // _loop0_140 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_142: ',' expression +function _loop0_142_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = expression_rule(p)) // expression + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_141: expression _loop0_142 +function _gather_141_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // expression _loop0_142 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = expression_rule(p)) // expression + && + (seq = _loop0_142_rule(p)) // _loop0_142 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_144: ',' expression +function _loop0_144_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = expression_rule(p)) // expression + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_143: expression _loop0_144 +function _gather_143_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // expression _loop0_144 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = expression_rule(p)) // expression + && + (seq = _loop0_144_rule(p)) // _loop0_144 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_146: ',' expression +function _loop0_146_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = expression_rule(p)) // expression + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_145: expression _loop0_146 +function _gather_145_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // expression _loop0_146 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = expression_rule(p)) // expression + && + (seq = _loop0_146_rule(p)) // _loop0_146 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_148: ',' expression +function _loop0_148_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = expression_rule(p)) // expression + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_147: expression _loop0_148 +function _gather_147_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // expression _loop0_148 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = expression_rule(p)) // expression + && + (seq = _loop0_148_rule(p)) // _loop0_148 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_149: NEWLINE INDENT +function _tmp_149_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // NEWLINE INDENT + if (p.error_indicator) { + return NULL; + } + var indent_var; + var newline_var; + if ( + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + && + (indent_var = $B._PyPegen.expect_token(p, INDENT)) // token='INDENT' + ) + { + _res = $B._PyPegen.dummy_name(p, newline_var, indent_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_150: +// | (','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) +// | kwargs +function _tmp_150_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // (','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs) + if (p.error_indicator) { + return NULL; + } + var _tmp_263_var; + if ( + (_tmp_263_var = _tmp_263_rule(p)) // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs + ) + { + _res = _tmp_263_var; + return done(); + } + p.mark = _mark; + } + { // kwargs + if (p.error_indicator) { + return NULL; + } + var kwargs_var; + if ( + (kwargs_var = kwargs_rule(p)) // kwargs + ) + { + _res = kwargs_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_151: args | expression for_if_clauses +function _tmp_151_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // args + if (p.error_indicator) { + return NULL; + } + var args_var; + if ( + (args_var = args_rule(p)) // args + ) + { + _res = args_var; + return done(); + } + p.mark = _mark; + } + { // expression for_if_clauses + if (p.error_indicator) { + return NULL; + } + var expression_var; + var for_if_clauses_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses + ) + { + _res = $B._PyPegen.dummy_name(p, expression_var, for_if_clauses_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_152: args ',' +function _tmp_152_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // args ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + var args_var; + if ( + (args_var = args_rule(p)) // args + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = $B._PyPegen.dummy_name(p, args_var, _literal); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_153: ',' | ')' +function _tmp_153_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_154: 'True' | 'False' | 'None' +function _tmp_154_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'True' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 601)) // token='True' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + { // 'False' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 603)) // token='False' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + { // 'None' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 602)) // token='None' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_155: NAME '=' +function _tmp_155_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // NAME '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + var name_var; + if ( + (name_var = $B._PyPegen.name_token(p)) // NAME + && + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = $B._PyPegen.dummy_name(p, name_var, _literal); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_156: NAME STRING | SOFT_KEYWORD +function _tmp_156_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // NAME STRING + if (p.error_indicator) { + return NULL; + } + var name_var; + var string_var; + if ( + (name_var = $B._PyPegen.name_token(p)) // NAME + && + (string_var = $B._PyPegen.string_token(p)) // STRING + ) + { + _res = $B._PyPegen.dummy_name(p, name_var, string_var); + return done(); + } + p.mark = _mark; + } + { // SOFT_KEYWORD + if (p.error_indicator) { + return NULL; + } + var soft_keyword_var; + if ( + (soft_keyword_var = $B._PyPegen.soft_keyword_token(p)) // SOFT_KEYWORD + ) + { + _res = soft_keyword_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_157: 'else' | ':' +function _tmp_157_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'else' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 645)) // token='else' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + { // ':' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_158: '=' | ':=' +function _tmp_158_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ':=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 53)) // token=':=' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_159: list | tuple | genexp | 'True' | 'None' | 'False' +function _tmp_159_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // list + if (p.error_indicator) { + return NULL; + } + var list_var; + if ( + (list_var = list_rule(p)) // list + ) + { + _res = list_var; + return done(); + } + p.mark = _mark; + } + { // tuple + if (p.error_indicator) { + return NULL; + } + var tuple_var; + if ( + (tuple_var = tuple_rule(p)) // tuple + ) + { + _res = tuple_var; + return done(); + } + p.mark = _mark; + } + { // genexp + if (p.error_indicator) { + return NULL; + } + var genexp_var; + if ( + (genexp_var = genexp_rule(p)) // genexp + ) + { + _res = genexp_var; + return done(); + } + p.mark = _mark; + } + { // 'True' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 601)) // token='True' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + { // 'None' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 602)) // token='None' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + { // 'False' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 603)) // token='False' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_160: '=' | ':=' +function _tmp_160_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ':=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 53)) // token=':=' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_161: star_named_expressions +function _loop0_161_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // star_named_expressions + if (p.error_indicator) { + return NULL; + } + var star_named_expressions_var; + while ( + (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions + ) + { + _res = star_named_expressions_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_162: (star_targets '=') +function _loop0_162_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // (star_targets '=') + if (p.error_indicator) { + return NULL; + } + var _tmp_264_var; + while ( + (_tmp_264_var = _tmp_264_rule(p)) // star_targets '=' + ) + { + _res = _tmp_264_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_163: (star_targets '=') +function _loop0_163_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // (star_targets '=') + if (p.error_indicator) { + return NULL; + } + var _tmp_265_var; + while ( + (_tmp_265_var = _tmp_265_rule(p)) // star_targets '=' + ) + { + _res = _tmp_265_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_164: yield_expr | star_expressions +function _tmp_164_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // yield_expr + if (p.error_indicator) { + return NULL; + } + var yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + _res = yield_expr_var; + return done(); + } + p.mark = _mark; + } + { // star_expressions + if (p.error_indicator) { + return NULL; + } + var star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions + ) + { + _res = star_expressions_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_165: '[' | '(' | '{' +function _tmp_165_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '[' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '(' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '{' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_166: '[' | '{' +function _tmp_166_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '[' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '{' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_167: '[' | '{' +function _tmp_167_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '[' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 9)) // token='[' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '{' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 25)) // token='{' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_168: slash_no_default | slash_with_default +function _tmp_168_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // slash_no_default + if (p.error_indicator) { + return NULL; + } + var slash_no_default_var; + if ( + (slash_no_default_var = slash_no_default_rule(p)) // slash_no_default + ) + { + _res = slash_no_default_var; + return done(); + } + p.mark = _mark; + } + { // slash_with_default + if (p.error_indicator) { + return NULL; + } + var slash_with_default_var; + if ( + (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default + ) + { + _res = slash_with_default_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_169: param_maybe_default +function _loop0_169_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_maybe_default + if (p.error_indicator) { + return NULL; + } + var param_maybe_default_var; + while ( + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default + ) + { + _res = param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_170: param_no_default +function _loop0_170_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_no_default + if (p.error_indicator) { + return NULL; + } + var param_no_default_var; + while ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + _res = param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_171: param_no_default +function _loop0_171_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_no_default + if (p.error_indicator) { + return NULL; + } + var param_no_default_var; + while ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + _res = param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_172: param_no_default +function _loop1_172_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_no_default + if (p.error_indicator) { + return NULL; + } + var param_no_default_var; + while ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + _res = param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_173: slash_no_default | slash_with_default +function _tmp_173_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // slash_no_default + if (p.error_indicator) { + return NULL; + } + var slash_no_default_var; + if ( + (slash_no_default_var = slash_no_default_rule(p)) // slash_no_default + ) + { + _res = slash_no_default_var; + return done(); + } + p.mark = _mark; + } + { // slash_with_default + if (p.error_indicator) { + return NULL; + } + var slash_with_default_var; + if ( + (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default + ) + { + _res = slash_with_default_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_174: param_maybe_default +function _loop0_174_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_maybe_default + if (p.error_indicator) { + return NULL; + } + var param_maybe_default_var; + while ( + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default + ) + { + _res = param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_175: ',' | param_no_default +function _tmp_175_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // param_no_default + if (p.error_indicator) { + return NULL; + } + var param_no_default_var; + if ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + _res = param_no_default_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_176: param_maybe_default +function _loop0_176_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_maybe_default + if (p.error_indicator) { + return NULL; + } + var param_maybe_default_var; + while ( + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default + ) + { + _res = param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_177: param_maybe_default +function _loop1_177_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_maybe_default + if (p.error_indicator) { + return NULL; + } + var param_maybe_default_var; + while ( + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default + ) + { + _res = param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_178: ')' | ',' +function _tmp_178_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_179: ')' | ',' (')' | '**') +function _tmp_179_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ',' (')' | '**') + if (p.error_indicator) { + return NULL; + } + var _literal; + var _tmp_266_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (_tmp_266_var = _tmp_266_rule(p)) // ')' | '**' + ) + { + _res = $B._PyPegen.dummy_name(p, _literal, _tmp_266_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_180: param_no_default | ',' +function _tmp_180_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // param_no_default + if (p.error_indicator) { + return NULL; + } + var param_no_default_var; + if ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + _res = param_no_default_var; + return done(); + } + p.mark = _mark; + } + { // ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_181: param_maybe_default +function _loop0_181_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_maybe_default + if (p.error_indicator) { + return NULL; + } + var param_maybe_default_var; + while ( + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default + ) + { + _res = param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_182: param_no_default | ',' +function _tmp_182_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // param_no_default + if (p.error_indicator) { + return NULL; + } + var param_no_default_var; + if ( + (param_no_default_var = param_no_default_rule(p)) // param_no_default + ) + { + _res = param_no_default_var; + return done(); + } + p.mark = _mark; + } + { // ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_183: '*' | '**' | '/' +function _tmp_183_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '*' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '**' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '/' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 17)) // token='/' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop1_184: param_with_default +function _loop1_184_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // param_with_default + if (p.error_indicator) { + return NULL; + } + var param_with_default_var; + while ( + (param_with_default_var = param_with_default_rule(p)) // param_with_default + ) + { + _res = param_with_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_185: lambda_slash_no_default | lambda_slash_with_default +function _tmp_185_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // lambda_slash_no_default + if (p.error_indicator) { + return NULL; + } + var lambda_slash_no_default_var; + if ( + (lambda_slash_no_default_var = lambda_slash_no_default_rule(p)) // lambda_slash_no_default + ) + { + _res = lambda_slash_no_default_var; + return done(); + } + p.mark = _mark; + } + { // lambda_slash_with_default + if (p.error_indicator) { + return NULL; + } + var lambda_slash_with_default_var; + if ( + (lambda_slash_with_default_var = lambda_slash_with_default_rule(p)) // lambda_slash_with_default + ) + { + _res = lambda_slash_with_default_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_186: lambda_param_maybe_default +function _loop0_186_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_maybe_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_maybe_default_var; + while ( + (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default + ) + { + _res = lambda_param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_187: lambda_param_no_default +function _loop0_187_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_no_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_no_default_var; + while ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = lambda_param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_188: lambda_param_no_default +function _loop0_188_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_no_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_no_default_var; + while ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = lambda_param_no_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop0_190: ',' lambda_param +function _loop0_190_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' lambda_param + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = lambda_param_rule(p)) // lambda_param + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_189: lambda_param _loop0_190 +function _gather_189_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // lambda_param _loop0_190 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = lambda_param_rule(p)) // lambda_param + && + (seq = _loop0_190_rule(p)) // _loop0_190 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_191: lambda_slash_no_default | lambda_slash_with_default +function _tmp_191_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // lambda_slash_no_default + if (p.error_indicator) { + return NULL; + } + var lambda_slash_no_default_var; + if ( + (lambda_slash_no_default_var = lambda_slash_no_default_rule(p)) // lambda_slash_no_default + ) + { + _res = lambda_slash_no_default_var; + return done(); + } + p.mark = _mark; + } + { // lambda_slash_with_default + if (p.error_indicator) { + return NULL; + } + var lambda_slash_with_default_var; + if ( + (lambda_slash_with_default_var = lambda_slash_with_default_rule(p)) // lambda_slash_with_default + ) + { + _res = lambda_slash_with_default_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_192: lambda_param_maybe_default +function _loop0_192_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_maybe_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_maybe_default_var; + while ( + (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default + ) + { + _res = lambda_param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_193: ',' | lambda_param_no_default +function _tmp_193_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // lambda_param_no_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_no_default_var; + if ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = lambda_param_no_default_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_194: lambda_param_maybe_default +function _loop0_194_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_maybe_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_maybe_default_var; + while ( + (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default + ) + { + _res = lambda_param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_195: lambda_param_maybe_default +function _loop1_195_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_maybe_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_maybe_default_var; + while ( + (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default + ) + { + _res = lambda_param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_196: lambda_param_with_default +function _loop1_196_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_with_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_with_default_var; + while ( + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default + ) + { + _res = lambda_param_with_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_197: ':' | ',' (':' | '**') +function _tmp_197_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ':' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ',' (':' | '**') + if (p.error_indicator) { + return NULL; + } + var _literal; + var _tmp_267_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (_tmp_267_var = _tmp_267_rule(p)) // ':' | '**' + ) + { + _res = $B._PyPegen.dummy_name(p, _literal, _tmp_267_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_198: lambda_param_no_default | ',' +function _tmp_198_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // lambda_param_no_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_no_default_var; + if ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = lambda_param_no_default_var; + return done(); + } + p.mark = _mark; + } + { // ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_199: lambda_param_maybe_default +function _loop0_199_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // lambda_param_maybe_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_maybe_default_var; + while ( + (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default + ) + { + _res = lambda_param_maybe_default_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_200: lambda_param_no_default | ',' +function _tmp_200_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // lambda_param_no_default + if (p.error_indicator) { + return NULL; + } + var lambda_param_no_default_var; + if ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = lambda_param_no_default_var; + return done(); + } + p.mark = _mark; + } + { // ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_201: '*' | '**' | '/' +function _tmp_201_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '*' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 16)) // token='*' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '**' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '/' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 17)) // token='/' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_202: ',' | ')' | ':' +function _tmp_202_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ':' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_204: ',' dotted_name +function _loop0_204_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' dotted_name + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = dotted_name_rule(p)) // dotted_name + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_203: dotted_name _loop0_204 +function _gather_203_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // dotted_name _loop0_204 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = dotted_name_rule(p)) // dotted_name + && + (seq = _loop0_204_rule(p)) // _loop0_204 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_206: ',' (expression ['as' star_target]) +function _loop0_206_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' (expression ['as' star_target]) + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = _tmp_268_rule(p)) // expression ['as' star_target] + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_205: (expression ['as' star_target]) _loop0_206 +function _gather_205_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // (expression ['as' star_target]) _loop0_206 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = _tmp_268_rule(p)) // expression ['as' star_target] + && + (seq = _loop0_206_rule(p)) // _loop0_206 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_208: ',' (expressions ['as' star_target]) +function _loop0_208_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' (expressions ['as' star_target]) + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = _tmp_269_rule(p)) // expressions ['as' star_target] + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_207: (expressions ['as' star_target]) _loop0_208 +function _gather_207_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // (expressions ['as' star_target]) _loop0_208 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = _tmp_269_rule(p)) // expressions ['as' star_target] + && + (seq = _loop0_208_rule(p)) // _loop0_208 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_210: ',' (expression ['as' star_target]) +function _loop0_210_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' (expression ['as' star_target]) + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = _tmp_270_rule(p)) // expression ['as' star_target] + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_209: (expression ['as' star_target]) _loop0_210 +function _gather_209_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // (expression ['as' star_target]) _loop0_210 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = _tmp_270_rule(p)) // expression ['as' star_target] + && + (seq = _loop0_210_rule(p)) // _loop0_210 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_212: ',' (expressions ['as' star_target]) +function _loop0_212_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' (expressions ['as' star_target]) + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = _tmp_271_rule(p)) // expressions ['as' star_target] + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_211: (expressions ['as' star_target]) _loop0_212 +function _gather_211_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // (expressions ['as' star_target]) _loop0_212 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = _tmp_271_rule(p)) // expressions ['as' star_target] + && + (seq = _loop0_212_rule(p)) // _loop0_212 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_213: 'except' | 'finally' +function _tmp_213_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'except' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 637)) // token='except' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + { // 'finally' + if (p.error_indicator) { + return NULL; + } + var _keyword; + if ( + (_keyword = $B._PyPegen.expect_token(p, 633)) // token='finally' + ) + { + _res = _keyword; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_214: block +function _loop0_214_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // block + if (p.error_indicator) { + return NULL; + } + var block_var; + while ( + (block_var = block_rule(p)) // block + ) + { + _res = block_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_215: except_block +function _loop1_215_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // except_block + if (p.error_indicator) { + return NULL; + } + var except_block_var; + while ( + (except_block_var = except_block_rule(p)) // except_block + ) + { + _res = except_block_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_216: 'as' NAME +function _tmp_216_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'as' NAME + if (p.error_indicator) { + return NULL; + } + var _keyword; + var name_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (name_var = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = $B._PyPegen.dummy_name(p, _keyword, name_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_217: block +function _loop0_217_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // block + if (p.error_indicator) { + return NULL; + } + var block_var; + while ( + (block_var = block_rule(p)) // block + ) + { + _res = block_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _loop1_218: except_star_block +function _loop1_218_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // except_star_block + if (p.error_indicator) { + return NULL; + } + var except_star_block_var; + while ( + (except_star_block_var = except_star_block_rule(p)) // except_star_block + ) + { + _res = except_star_block_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + if (_n == 0 || p.error_indicator) { + // PyMem_Free(_children); + return NULL; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_219: expression ['as' NAME] +function _tmp_219_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // expression ['as' NAME] + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (_opt_var = _tmp_272_rule(p), !p.error_indicator) // ['as' NAME] + ) + { + _res = $B._PyPegen.dummy_name(p, expression_var, _opt_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_220: 'as' NAME +function _tmp_220_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'as' NAME + if (p.error_indicator) { + return NULL; + } + var _keyword; + var name_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (name_var = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = $B._PyPegen.dummy_name(p, _keyword, name_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_221: 'as' NAME +function _tmp_221_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'as' NAME + if (p.error_indicator) { + return NULL; + } + var _keyword; + var name_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (name_var = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = $B._PyPegen.dummy_name(p, _keyword, name_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_222: NEWLINE | ':' +function _tmp_222_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // NEWLINE + if (p.error_indicator) { + return NULL; + } + var newline_var; + if ( + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = newline_var; + return done(); + } + p.mark = _mark; + } + { // ':' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_223: 'as' NAME +function _tmp_223_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'as' NAME + if (p.error_indicator) { + return NULL; + } + var _keyword; + var name_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (name_var = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = $B._PyPegen.dummy_name(p, _keyword, name_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_224: 'as' NAME +function _tmp_224_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'as' NAME + if (p.error_indicator) { + return NULL; + } + var _keyword; + var name_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (name_var = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = $B._PyPegen.dummy_name(p, _keyword, name_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_225: positional_patterns ',' +function _tmp_225_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // positional_patterns ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + var positional_patterns_var; + if ( + (positional_patterns_var = positional_patterns_rule(p)) // positional_patterns + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = $B._PyPegen.dummy_name(p, positional_patterns_var, _literal); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_226: '->' expression +function _tmp_226_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '->' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var expression_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 51)) // token='->' + && + (expression_var = expression_rule(p)) // expression + ) + { + _res = $B._PyPegen.dummy_name(p, _literal, expression_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_227: '(' arguments? ')' +function _tmp_227_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '(' arguments? ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (_opt_var = arguments_rule(p), !p.error_indicator) // arguments? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = $B._PyPegen.dummy_name(p, _literal, _opt_var, _literal_1); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_228: '(' arguments? ')' +function _tmp_228_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '(' arguments? ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + var _literal_1; + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + if ( + (_literal = $B._PyPegen.expect_token(p, 7)) // token='(' + && + (_opt_var = arguments_rule(p), !p.error_indicator) // arguments? + && + (_literal_1 = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = $B._PyPegen.dummy_name(p, _literal, _opt_var, _literal_1); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_230: ',' double_starred_kvpair +function _loop0_230_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' double_starred_kvpair + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_229: double_starred_kvpair _loop0_230 +function _gather_229_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // double_starred_kvpair _loop0_230 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair + && + (seq = _loop0_230_rule(p)) // _loop0_230 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_231: '}' | ',' +function _tmp_231_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_232: '}' | ',' +function _tmp_232_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ',' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_233: yield_expr | star_expressions +function _tmp_233_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // yield_expr + if (p.error_indicator) { + return NULL; + } + var yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + _res = yield_expr_var; + return done(); + } + p.mark = _mark; + } + { // star_expressions + if (p.error_indicator) { + return NULL; + } + var star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions + ) + { + _res = star_expressions_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_234: yield_expr | star_expressions +function _tmp_234_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // yield_expr + if (p.error_indicator) { + return NULL; + } + var yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + _res = yield_expr_var; + return done(); + } + p.mark = _mark; + } + { // star_expressions + if (p.error_indicator) { + return NULL; + } + var star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions + ) + { + _res = star_expressions_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_235: '=' | '!' | ':' | '}' +function _tmp_235_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '!' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 54)) // token='!' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ':' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_236: yield_expr | star_expressions +function _tmp_236_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // yield_expr + if (p.error_indicator) { + return NULL; + } + var yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + _res = yield_expr_var; + return done(); + } + p.mark = _mark; + } + { // star_expressions + if (p.error_indicator) { + return NULL; + } + var star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions + ) + { + _res = star_expressions_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_237: '!' | ':' | '}' +function _tmp_237_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '!' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 54)) // token='!' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // ':' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_238: yield_expr | star_expressions +function _tmp_238_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // yield_expr + if (p.error_indicator) { + return NULL; + } + var yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + _res = yield_expr_var; + return done(); + } + p.mark = _mark; + } + { // star_expressions + if (p.error_indicator) { + return NULL; + } + var star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions + ) + { + _res = star_expressions_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_239: yield_expr | star_expressions +function _tmp_239_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // yield_expr + if (p.error_indicator) { + return NULL; + } + var yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + _res = yield_expr_var; + return done(); + } + p.mark = _mark; + } + { // star_expressions + if (p.error_indicator) { + return NULL; + } + var star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions + ) + { + _res = star_expressions_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_240: '!' NAME +function _tmp_240_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '!' NAME + if (p.error_indicator) { + return NULL; + } + var _literal; + var name_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 54)) // token='!' + && + (name_var = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = $B._PyPegen.dummy_name(p, _literal, name_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_241: ':' | '}' +function _tmp_241_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ':' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_242: yield_expr | star_expressions +function _tmp_242_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // yield_expr + if (p.error_indicator) { + return NULL; + } + var yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + _res = yield_expr_var; + return done(); + } + p.mark = _mark; + } + { // star_expressions + if (p.error_indicator) { + return NULL; + } + var star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions + ) + { + _res = star_expressions_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_243: '!' NAME +function _tmp_243_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '!' NAME + if (p.error_indicator) { + return NULL; + } + var _literal; + var name_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 54)) // token='!' + && + (name_var = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = $B._PyPegen.dummy_name(p, _literal, name_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_244: fstring_format_spec +function _loop0_244_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // fstring_format_spec + if (p.error_indicator) { + return NULL; + } + var fstring_format_spec_var; + while ( + (fstring_format_spec_var = fstring_format_spec_rule(p)) // fstring_format_spec + ) + { + _res = fstring_format_spec_var; + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _tmp_245: yield_expr | star_expressions +function _tmp_245_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // yield_expr + if (p.error_indicator) { + return NULL; + } + var yield_expr_var; + if ( + (yield_expr_var = yield_expr_rule(p)) // yield_expr + ) + { + _res = yield_expr_var; + return done(); + } + p.mark = _mark; + } + { // star_expressions + if (p.error_indicator) { + return NULL; + } + var star_expressions_var; + if ( + (star_expressions_var = star_expressions_rule(p)) // star_expressions + ) + { + _res = star_expressions_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_246: '!' NAME +function _tmp_246_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '!' NAME + if (p.error_indicator) { + return NULL; + } + var _literal; + var name_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 54)) // token='!' + && + (name_var = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = $B._PyPegen.dummy_name(p, _literal, name_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_247: ':' | '}' +function _tmp_247_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ':' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '}' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 26)) // token='}' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_248: star_targets '=' +function _tmp_248_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // star_targets '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + var z; + if ( + (z = star_targets_rule(p)) // star_targets + && + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_249: '.' | '...' +function _tmp_249_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '.' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 23)) // token='.' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '...' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 52)) // token='...' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_250: '.' | '...' +function _tmp_250_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '.' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 23)) // token='.' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '...' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 52)) // token='...' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_251: '@' named_expression NEWLINE +function _tmp_251_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // '@' named_expression NEWLINE + if (p.error_indicator) { + return NULL; + } + var _literal; + var f; + var newline_var; + if ( + (_literal = $B._PyPegen.expect_token(p, 49)) // token='@' + && + (f = named_expression_rule(p)) // named_expression + && + (newline_var = $B._PyPegen.expect_token(p, NEWLINE)) // token='NEWLINE' + ) + { + _res = f; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_252: ',' expression +function _tmp_252_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ',' expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var c; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (c = expression_rule(p)) // expression + ) + { + _res = c; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_253: ',' star_expression +function _tmp_253_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ',' star_expression + if (p.error_indicator) { + return NULL; + } + var _literal; + var c; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (c = star_expression_rule(p)) // star_expression + ) + { + _res = c; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_254: 'or' conjunction +function _tmp_254_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'or' conjunction + if (p.error_indicator) { + return NULL; + } + var _keyword; + var c; + if ( + (_keyword = $B._PyPegen.expect_token(p, 574)) // token='or' + && + (c = conjunction_rule(p)) // conjunction + ) + { + _res = c; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_255: 'and' inversion +function _tmp_255_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'and' inversion + if (p.error_indicator) { + return NULL; + } + var _keyword; + var c; + if ( + (_keyword = $B._PyPegen.expect_token(p, 575)) // token='and' + && + (c = inversion_rule(p)) // inversion + ) + { + _res = c; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_256: slice | starred_expression +function _tmp_256_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // slice + if (p.error_indicator) { + return NULL; + } + var slice_var; + if ( + (slice_var = slice_rule(p)) // slice + ) + { + _res = slice_var; + return done(); + } + p.mark = _mark; + } + { // starred_expression + if (p.error_indicator) { + return NULL; + } + var starred_expression_var; + if ( + (starred_expression_var = starred_expression_rule(p)) // starred_expression + ) + { + _res = starred_expression_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_257: fstring | string +function _tmp_257_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // fstring + if (p.error_indicator) { + return NULL; + } + var fstring_var; + if ( + (fstring_var = fstring_rule(p)) // fstring + ) + { + _res = fstring_var; + return done(); + } + p.mark = _mark; + } + { // string + if (p.error_indicator) { + return NULL; + } + var string_var; + if ( + (string_var = string_rule(p)) // string + ) + { + _res = string_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_258: 'if' disjunction +function _tmp_258_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'if' disjunction + if (p.error_indicator) { + return NULL; + } + var _keyword; + var z; + if ( + (_keyword = $B._PyPegen.expect_token(p, 642)) // token='if' + && + (z = disjunction_rule(p)) // disjunction + ) + { + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_259: 'if' disjunction +function _tmp_259_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'if' disjunction + if (p.error_indicator) { + return NULL; + } + var _keyword; + var z; + if ( + (_keyword = $B._PyPegen.expect_token(p, 642)) // token='if' + && + (z = disjunction_rule(p)) // disjunction + ) + { + _res = z; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_260: starred_expression | (assignment_expression | expression !':=') !'=' +function _tmp_260_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // starred_expression + if (p.error_indicator) { + return NULL; + } + var starred_expression_var; + if ( + (starred_expression_var = starred_expression_rule(p)) // starred_expression + ) + { + _res = starred_expression_var; + return done(); + } + p.mark = _mark; + } + { // (assignment_expression | expression !':=') !'=' + if (p.error_indicator) { + return NULL; + } + var _tmp_273_var; + if ( + (_tmp_273_var = _tmp_273_rule(p)) // assignment_expression | expression !':=' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 22) // token='=' + ) + { + _res = _tmp_273_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_261: ',' star_target +function _tmp_261_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ',' star_target + if (p.error_indicator) { + return NULL; + } + var _literal; + var c; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (c = star_target_rule(p)) // star_target + ) + { + _res = c; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_262: ',' star_target +function _tmp_262_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ',' star_target + if (p.error_indicator) { + return NULL; + } + var _literal; + var c; + if ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (c = star_target_rule(p)) // star_target + ) + { + _res = c; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + return NULL; + } + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_263: +// | ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs +function _tmp_263_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ ',' kwargs + if (p.error_indicator) { + return NULL; + } + var _gather_274_var; + var _literal; + var kwargs_var; + if ( + (_gather_274_var = _gather_274_rule(p)) // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ + && + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (kwargs_var = kwargs_rule(p)) // kwargs + ) + { + _res = $B._PyPegen.dummy_name(p, _gather_274_var, _literal, kwargs_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_264: star_targets '=' +function _tmp_264_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // star_targets '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + var star_targets_var; + if ( + (star_targets_var = star_targets_rule(p)) // star_targets + && + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = $B._PyPegen.dummy_name(p, star_targets_var, _literal); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_265: star_targets '=' +function _tmp_265_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // star_targets '=' + if (p.error_indicator) { + return NULL; + } + var _literal; + var star_targets_var; + if ( + (star_targets_var = star_targets_rule(p)) // star_targets + && + (_literal = $B._PyPegen.expect_token(p, 22)) // token='=' + ) + { + _res = $B._PyPegen.dummy_name(p, star_targets_var, _literal); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_266: ')' | '**' +function _tmp_266_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ')' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 8)) // token=')' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '**' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_267: ':' | '**' +function _tmp_267_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // ':' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 11)) // token=':' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + { // '**' + if (p.error_indicator) { + return NULL; + } + var _literal; + if ( + (_literal = $B._PyPegen.expect_token(p, 35)) // token='**' + ) + { + _res = _literal; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_268: expression ['as' star_target] +function _tmp_268_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // expression ['as' star_target] + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (_opt_var = _tmp_276_rule(p), !p.error_indicator) // ['as' star_target] + ) + { + _res = $B._PyPegen.dummy_name(p, expression_var, _opt_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_269: expressions ['as' star_target] +function _tmp_269_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // expressions ['as' star_target] + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var expressions_var; + if ( + (expressions_var = expressions_rule(p)) // expressions + && + (_opt_var = _tmp_277_rule(p), !p.error_indicator) // ['as' star_target] + ) + { + _res = $B._PyPegen.dummy_name(p, expressions_var, _opt_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_270: expression ['as' star_target] +function _tmp_270_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // expression ['as' star_target] + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + (_opt_var = _tmp_278_rule(p), !p.error_indicator) // ['as' star_target] + ) + { + _res = $B._PyPegen.dummy_name(p, expression_var, _opt_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_271: expressions ['as' star_target] +function _tmp_271_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // expressions ['as' star_target] + if (p.error_indicator) { + return NULL; + } + var _opt_var; + UNUSED(_opt_var); // Silence compiler warnings + var expressions_var; + if ( + (expressions_var = expressions_rule(p)) // expressions + && + (_opt_var = _tmp_279_rule(p), !p.error_indicator) // ['as' star_target] + ) + { + _res = $B._PyPegen.dummy_name(p, expressions_var, _opt_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_272: 'as' NAME +function _tmp_272_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'as' NAME + if (p.error_indicator) { + return NULL; + } + var _keyword; + var name_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (name_var = $B._PyPegen.name_token(p)) // NAME + ) + { + _res = $B._PyPegen.dummy_name(p, _keyword, name_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_273: assignment_expression | expression !':=' +function _tmp_273_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // assignment_expression + if (p.error_indicator) { + return NULL; + } + var assignment_expression_var; + if ( + (assignment_expression_var = assignment_expression_rule(p)) // assignment_expression + ) + { + _res = assignment_expression_var; + return done(); + } + p.mark = _mark; + } + { // expression !':=' + if (p.error_indicator) { + return NULL; + } + var expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 53) // token=':=' + ) + { + _res = expression_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _loop0_275: ',' (starred_expression | (assignment_expression | expression !':=') !'=') +function _loop0_275_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + var _children = []; + var _children_capacity = 1; + var _n = 0; + { // ',' (starred_expression | (assignment_expression | expression !':=') !'=') + if (p.error_indicator) { + return NULL; + } + var _literal; + var elem; + while ( + (_literal = $B._PyPegen.expect_token(p, 12)) // token=',' + && + (elem = _tmp_280_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p.error_indicator = 1; + PyMem_Free(_children); + return NULL; + } + _children[_n++] = _res; + _mark = p.mark; + } + p.mark = _mark; + } + var _seq = []; + if (!_seq) { + PyMem_Free(_children); + p.error_indicator = 1; + PyErr_NoMemory(); + return NULL; + } + for (let i = 0; i < _n; i++){_seq[i] = _children[i]}; + // PyMem_Free(_children); + return _seq; +} + +// _gather_274: +// | (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_275 +function _gather_274_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_275 + if (p.error_indicator) { + return NULL; + } + var elem; + var seq; + if ( + (elem = _tmp_280_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' + && + (seq = _loop0_275_rule(p)) // _loop0_275 + ) + { + _res = $B._PyPegen.seq_insert_in_front(p, elem, seq); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_276: 'as' star_target +function _tmp_276_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'as' star_target + if (p.error_indicator) { + return NULL; + } + var _keyword; + var star_target_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (star_target_var = star_target_rule(p)) // star_target + ) + { + _res = $B._PyPegen.dummy_name(p, _keyword, star_target_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_277: 'as' star_target +function _tmp_277_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'as' star_target + if (p.error_indicator) { + return NULL; + } + var _keyword; + var star_target_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (star_target_var = star_target_rule(p)) // star_target + ) + { + _res = $B._PyPegen.dummy_name(p, _keyword, star_target_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_278: 'as' star_target +function _tmp_278_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'as' star_target + if (p.error_indicator) { + return NULL; + } + var _keyword; + var star_target_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (star_target_var = star_target_rule(p)) // star_target + ) + { + _res = $B._PyPegen.dummy_name(p, _keyword, star_target_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_279: 'as' star_target +function _tmp_279_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // 'as' star_target + if (p.error_indicator) { + return NULL; + } + var _keyword; + var star_target_var; + if ( + (_keyword = $B._PyPegen.expect_token(p, 640)) // token='as' + && + (star_target_var = star_target_rule(p)) // star_target + ) + { + _res = $B._PyPegen.dummy_name(p, _keyword, star_target_var); + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_280: starred_expression | (assignment_expression | expression !':=') !'=' +function _tmp_280_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // starred_expression + if (p.error_indicator) { + return NULL; + } + var starred_expression_var; + if ( + (starred_expression_var = starred_expression_rule(p)) // starred_expression + ) + { + _res = starred_expression_var; + return done(); + } + p.mark = _mark; + } + { // (assignment_expression | expression !':=') !'=' + if (p.error_indicator) { + return NULL; + } + var _tmp_281_var; + if ( + (_tmp_281_var = _tmp_281_rule(p)) // assignment_expression | expression !':=' + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 22) // token='=' + ) + { + _res = _tmp_281_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +// _tmp_281: assignment_expression | expression !':=' +function _tmp_281_rule(p) +{ + if (p.error_indicator) { + return NULL; + } + var _res = {value: NULL}; + _res = NULL; + var _mark = p.mark; + { // assignment_expression + if (p.error_indicator) { + return NULL; + } + var assignment_expression_var; + if ( + (assignment_expression_var = assignment_expression_rule(p)) // assignment_expression + ) + { + _res = assignment_expression_var; + return done(); + } + p.mark = _mark; + } + { // expression !':=' + if (p.error_indicator) { + return NULL; + } + var expression_var; + if ( + (expression_var = expression_rule(p)) // expression + && + $B._PyPegen.lookahead_with_int(0, $B._PyPegen.expect_token, p, 53) // token=':=' + ) + { + _res = expression_var; + return done(); + } + p.mark = _mark; + } + _res = NULL; + function done(){ + return _res; + } +} + +$B._PyPegen_parse = function(p){ + p.keywords = reserved_keywords; + p.n_keyword_lists = n_keyword_lists; + p.soft_keywords = soft_keywords; + + // skip first token (ENCODING) + p.tok.next() + + return file_rule(p) + +} diff --git a/www/src/pegen.js b/www/src/pegen.js index 5a30d4618..609f73278 100644 --- a/www/src/pegen.js +++ b/www/src/pegen.js @@ -275,42 +275,19 @@ function initialize_token(p, parser_token, new_token, token_type) { return (token_type == ERRORTOKEN ? _Pypegen_tokenizer_error(p) : 0); } -function _resize_tokens_array(p) { - /* - int newsize = p->size * 2; - Token **new_tokens = PyMem_Realloc(p->tokens, newsize * sizeof(Token *)); - if (new_tokens == NULL) { - PyErr_NoMemory(); - return -1; - } - p->tokens = new_tokens; - - for (int i = p->size; i < newsize; i++) { - p->tokens[i] = PyMem_Calloc(1, sizeof(Token)); - if (p->tokens[i] == NULL) { - p->size = i; // Needed, in order to cleanup correctly after parser fails - PyErr_NoMemory(); - return -1; - } - } - p->size = newsize; - */ - return 0; -} - function _PyToken_Init(token) { token.metadata = NULL; } function _PyTokenizer_Get(tok, new_token){ var token = tok.next().value - console.log('token', token) for(var key in token){ new_token[key] = token[key] } - return token.type + return token.num_type } + function get_next_token(p, new_token){ var token = p.tokens[p.fill] ?? p.read_token() for(var key in token){ @@ -320,14 +297,9 @@ function get_next_token(p, new_token){ } $B._PyPegen.fill_token = function(p){ - function error(){ - _PyToken_Free(new_token); - return -1; - } - var new_token = {} - _PyToken_Init(new_token); + var new_token = {metadata: NULL} + //_PyToken_Init(new_token); var type = get_next_token(p, new_token); - // Record and skip '# type: ignore' comments while (type == TYPE_IGNORE) { var len = new_token.end_col_offset - new_token.col_offset; @@ -361,9 +333,11 @@ $B._PyPegen.fill_token = function(p){ } // Check if we are at the limit of the token array capacity and resize if needed + /* if ((p.fill == p.size) && (_resize_tokens_array(p) != 0)) { return error() } + */ var t = p.tokens[p.fill]; return initialize_token(p, t, new_token, type); @@ -519,10 +493,10 @@ $B._PyPegen.expect_soft_keyword = function(p, keyword){ } } var t = p.tokens[p.mark]; - if (t.type != NAME) { + if (t.num_type != NAME) { return NULL; } - console.log('t', t) + const s = t.string // PyBytes_AsString(t.bytes); if (!s) { p.error_indicator = 1; diff --git a/www/src/python_parser_peg_version.js b/www/src/python_parser_peg_version.js index c4d6304fe..025afceee 100644 --- a/www/src/python_parser_peg_version.js +++ b/www/src/python_parser_peg_version.js @@ -412,12 +412,16 @@ Parser.prototype.get_memo = function(rule, position){ return m } +var ignored = [$B.py_tokens.ENCODING, + $B.py_tokens.NL, + $B.py_tokens.COMMENT] + Parser.prototype.read_token = function(){ while(true){ var next = this.tokenizer.next() if(! next.done){ var value = next.value - if(! ['ENCODING', 'NL', 'COMMENT'].includes(value.type)){ + if(! ignored.includes(value.num_type)){ this.tokens.push(value) return value } diff --git a/www/src/python_tokenizer.js b/www/src/python_tokenizer.js index a1edb8fa7..a9cef0267 100644 --- a/www/src/python_tokenizer.js +++ b/www/src/python_tokenizer.js @@ -147,13 +147,9 @@ var ops = '.,:;+-*/%~^|&=<>[](){}@', // ! is valid in f-strings function Token(type, string, start, end, line){ start = start.slice(0, 2) - var res = {type, string, start, end, line} - res[0] = type - res[1] = string - res[2] = start - res[3] = end - res[4] = line + var res if($B.py_tokens){ + res = {string, line} res.num_type = $B.py_tokens[type] if(type == 'OP'){ res.num_type = $B.py_tokens[$B.EXACT_TOKEN_TYPES[string]] @@ -162,6 +158,13 @@ function Token(type, string, start, end, line){ res.col_offset = start[1] res.end_lineno = end[0] res.end_col_offset = end[1] + }else{ + res = {type, string, start, end, line} + res[0] = type + res[1] = string + res[2] = start + res[3] = end + res[4] = line } return res }