summaryrefslogtreecommitdiffstats
path: root/Grammar
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2021-07-27 16:19:22 (GMT)
committerGitHub <noreply@github.com>2021-07-27 16:19:22 (GMT)
commit6948964ecf94e858448dd28eea634317226d2913 (patch)
tree31cf0a4e617bbf2a8d1edbac809b9b494da9b980 /Grammar
parent2f54fbafa6481fb10528cb1d3d6b517ca2a4647f (diff)
downloadcpython-6948964ecf94e858448dd28eea634317226d2913.zip
cpython-6948964ecf94e858448dd28eea634317226d2913.tar.gz
cpython-6948964ecf94e858448dd28eea634317226d2913.tar.bz2
bpo-34013: Generalize the invalid legacy statement error message (GH-27389)
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/python.gram7
1 files changed, 6 insertions, 1 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram
index 70d0912..7b8af04 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -847,10 +847,15 @@ expression_without_invalid[expr_ty]:
| a=disjunction 'if' b=disjunction 'else' c=expression { _PyAST_IfExp(b, a, c, EXTRA) }
| disjunction
| lambdef
+invalid_legacy_expression:
+ | a=NAME b=expression_without_invalid {
+ _PyPegen_check_legacy_stmt(p, a) ? RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "Missing parentheses in call to '%U'.", a->v.Name.id) : NULL}
+
invalid_expression:
+ | invalid_legacy_expression
# !(NAME STRING) is not matched so we don't show this error with some invalid string prefixes like: kf"dsfsdf"
# Soft keywords need to also be ignored because they can be parsed as NAME NAME
- | !(NAME STRING | SOFT_KEYWORD) a=disjunction b=expression_without_invalid {
+ | !(NAME STRING | SOFT_KEYWORD) a=disjunction b=expression_without_invalid {
RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Perhaps you forgot a comma?") }
invalid_named_expression: