summaryrefslogtreecommitdiffstats
path: root/Grammar
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2023-09-22 18:03:23 (GMT)
committerGitHub <noreply@github.com>2023-09-22 18:03:23 (GMT)
commitb28ffaa193efc66f46ab90d383279174a11a11d7 (patch)
treeacea940a825714a0c55c4669d31e23fa08ed8bf0 /Grammar
parent7c553991724d8d537f8444db73f016008753d77a (diff)
downloadcpython-b28ffaa193efc66f46ab90d383279174a11a11d7.zip
cpython-b28ffaa193efc66f46ab90d383279174a11a11d7.tar.gz
cpython-b28ffaa193efc66f46ab90d383279174a11a11d7.tar.bz2
gh-109596: Ensure repeated rules in the grammar are not allowed and fix incorrect soft keywords (#109606)
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/python.gram11
1 files changed, 4 insertions, 7 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram
index ae998f9..73aaa79 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -19,8 +19,6 @@ _PyPegen_parse(Parser *p)
result = eval_rule(p);
} else if (p->start_rule == Py_func_type_input) {
result = func_type_rule(p);
- } else if (p->start_rule == Py_fstring_input) {
- result = fstring_rule(p);
}
return result;
@@ -89,7 +87,6 @@ file[mod_ty]: a=[statements] ENDMARKER { _PyPegen_make_module(p, a) }
interactive[mod_ty]: a=statement_newline { _PyAST_Interactive(a, p->arena) }
eval[mod_ty]: a=expressions NEWLINE* ENDMARKER { _PyAST_Expression(a, p->arena) }
func_type[mod_ty]: '(' a=[type_expressions] ')' '->' b=expression NEWLINE* ENDMARKER { _PyAST_FunctionType(a, b, p->arena) }
-fstring[expr_ty]: star_expressions
# GENERAL STATEMENTS
# ==================
@@ -647,20 +644,20 @@ type_param_seq[asdl_type_param_seq*]: a[asdl_type_param_seq*]=','.type_param+ ['
type_param[type_param_ty] (memo):
| a=NAME b=[type_param_bound] { _PyAST_TypeVar(a->v.Name.id, b, EXTRA) }
- | '*' a=NAME colon=":" e=expression {
+ | '*' a=NAME colon=':' e=expression {
RAISE_SYNTAX_ERROR_STARTING_FROM(colon, e->kind == Tuple_kind
? "cannot use constraints with TypeVarTuple"
: "cannot use bound with TypeVarTuple")
}
| '*' a=NAME { _PyAST_TypeVarTuple(a->v.Name.id, EXTRA) }
- | '**' a=NAME colon=":" e=expression {
+ | '**' a=NAME colon=':' e=expression {
RAISE_SYNTAX_ERROR_STARTING_FROM(colon, e->kind == Tuple_kind
? "cannot use constraints with ParamSpec"
: "cannot use bound with ParamSpec")
}
| '**' a=NAME { _PyAST_ParamSpec(a->v.Name.id, EXTRA) }
-type_param_bound[expr_ty]: ":" e=expression { e }
+type_param_bound[expr_ty]: ':' e=expression { e }
# EXPRESSIONS
# -----------
@@ -915,7 +912,7 @@ fstring_middle[expr_ty]:
| fstring_replacement_field
| t=FSTRING_MIDDLE { _PyPegen_constant_from_token(p, t) }
fstring_replacement_field[expr_ty]:
- | '{' a=(yield_expr | star_expressions) debug_expr="="? conversion=[fstring_conversion] format=[fstring_full_format_spec] rbrace='}' {
+ | '{' a=(yield_expr | star_expressions) debug_expr='='? conversion=[fstring_conversion] format=[fstring_full_format_spec] rbrace='}' {
_PyPegen_formatted_value(p, a, debug_expr, conversion, format, rbrace, EXTRA) }
| invalid_replacement_field
fstring_conversion[ResultTokenWithMetadata*]: