summaryrefslogtreecommitdiff
path: root/Parser/pegen.c
diff options
context:
space:
mode:
Diffstat (limited to 'Parser/pegen.c')
-rw-r--r--Parser/pegen.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c
index 4d6e69edc2..e32b2710db 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -2352,7 +2352,17 @@ expr_ty
_PyPegen_ensure_imaginary(Parser *p, expr_ty exp)
{
if (exp->kind != Constant_kind || !PyComplex_CheckExact(exp->v.Constant.value)) {
- RAISE_SYNTAX_ERROR_KNOWN_LOCATION(exp, "Imaginary number required in complex literal");
+ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(exp, "imaginary number required in complex literal");
+ return NULL;
+ }
+ return exp;
+}
+
+expr_ty
+_PyPegen_ensure_real(Parser *p, expr_ty exp)
+{
+ if (exp->kind != Constant_kind || PyComplex_CheckExact(exp->v.Constant.value)) {
+ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(exp, "real number required in complex literal");
return NULL;
}
return exp;