summaryrefslogtreecommitdiffstats
path: root/Grammar
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2021-11-19 23:11:57 (GMT)
committerGitHub <noreply@github.com>2021-11-19 23:11:57 (GMT)
commit546cefcda75d7150b55c8bc1724bea35a1e12890 (patch)
tree18d9c398c5d6cdc610bffcedfc74a82c5250a0c6 /Grammar
parentc8c21bdd199f9feb75fc6cdb398a686dc133b99f (diff)
downloadcpython-546cefcda75d7150b55c8bc1724bea35a1e12890.zip
cpython-546cefcda75d7150b55c8bc1724bea35a1e12890.tar.gz
cpython-546cefcda75d7150b55c8bc1724bea35a1e12890.tar.bz2
bpo-45727: Make the syntax error for missing comma more consistent (GH-29427)
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/python.gram4
1 files changed, 2 insertions, 2 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram
index d1901a5..168bb3c 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -618,6 +618,7 @@ expressions[expr_ty]:
expression[expr_ty] (memo):
| invalid_expression
+ | invalid_legacy_expression
| a=disjunction 'if' b=disjunction 'else' c=expression { _PyAST_IfExp(b, a, c, EXTRA) }
| disjunction
| lambdef
@@ -1080,11 +1081,10 @@ invalid_legacy_expression:
"Missing parentheses in call to '%U'. Did you mean %U(...)?", a->v.Name.id, 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 {
- RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Perhaps you forgot a comma?") }
+ _PyPegen_check_legacy_stmt(p, a) ? NULL : RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Perhaps you forgot a comma?") }
| a=disjunction 'if' b=disjunction !('else'|':') { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "expected 'else' after 'if' expression") }
invalid_named_expression: