diff options
Diffstat (limited to 'Grammar')
-rw-r--r-- | Grammar/python.gram | 4 |
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: |