self.assertEqual(y, 1)
self.assertIs(z, x)
+ def test_patma_256(self):
+ x = 0
+ match x:
+ case +0:
+ y = 0
+ self.assertEqual(x, 0)
+ self.assertEqual(y, 0)
+
+ def test_patma_257(self):
+ x = 0
+ match x:
+ case +0.0:
+ y = 0
+ self.assertEqual(x, 0)
+ self.assertEqual(y, 0)
+
+ def test_patma_258(self):
+ x = 0
+ match x:
+ case +0j:
+ y = 0
+ self.assertEqual(x, 0)
+ self.assertEqual(y, 0)
+
+ def test_patma_259(self):
+ x = 0
+ match x:
+ case +0.0j:
+ y = 0
+ self.assertEqual(x, 0)
+ self.assertEqual(y, 0)
+
+ def test_patma_260(self):
+ x = 1
+ match x:
+ case +1:
+ y = 0
+ self.assertEqual(x, 1)
+ self.assertEqual(y, 0)
+
+ def test_patma_261(self):
+ x = 1.5
+ match x:
+ case +1.5:
+ y = 0
+ self.assertEqual(x, 1.5)
+ self.assertEqual(y, 0)
+
+ def test_patma_262(self):
+ x = 1j
+ match x:
+ case +1j:
+ y = 0
+ self.assertEqual(x, 1j)
+ self.assertEqual(y, 0)
+
+ def test_patma_263(self):
+ x = 1.5j
+ match x:
+ case +1.5j:
+ y = 0
+ self.assertEqual(x, 1.5j)
+ self.assertEqual(y, 0)
+
+ def test_patma_264(self):
+ x = 0.25 + 1.75j
+ match x:
+ case +0.25 + 1.75j:
+ y = 0
+ self.assertEqual(x, 0.25 + 1.75j)
+ self.assertEqual(y, 0)
+
+ def test_patma_265(self):
+ x = 0.25 - 1.75j
+ match x:
+ case 0.25 - +1.75j:
+ y = 0
+ self.assertEqual(x, 0.25 - 1.75j)
+ self.assertEqual(y, 0)
+
+ def test_patma_266(self):
+ x = 0
+ match x:
+ case +1e1000:
+ y = 0
+ case 0:
+ y = 1
+ self.assertEqual(x, 0)
+ self.assertEqual(y, 1)
+
def test_patma_runtime_checkable_protocol(self):
# Runtime-checkable protocol
from typing import Protocol, runtime_checkable
return _res;
}
-// signed_number: NUMBER | '-' NUMBER
+// signed_number: NUMBER | '+' NUMBER | '-' NUMBER
static expr_ty
signed_number_rule(Parser *p)
{
D(fprintf(stderr, "%*c%s signed_number[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER"));
}
+ { // '+' NUMBER
+ if (p->error_indicator) {
+ p->level--;
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> signed_number[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+' NUMBER"));
+ Token * _literal;
+ expr_ty number;
+ if (
+ (_literal = _PyPegen_expect_token(p, 14)) // token='+'
+ &&
+ (number = _PyPegen_number_token(p)) // NUMBER
+ )
+ {
+ D(fprintf(stderr, "%*c+ signed_number[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+' NUMBER"));
+ _res = number;
+ if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ p->level--;
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s signed_number[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+' NUMBER"));
+ }
{ // '-' NUMBER
if (p->error_indicator) {
p->level--;
return _res;
}
-// signed_real_number: real_number | '-' real_number
+// signed_real_number: real_number | '+' real_number | '-' real_number
static expr_ty
signed_real_number_rule(Parser *p)
{
D(fprintf(stderr, "%*c%s signed_real_number[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "real_number"));
}
+ { // '+' real_number
+ if (p->error_indicator) {
+ p->level--;
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> signed_real_number[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+' real_number"));
+ Token * _literal;
+ expr_ty real;
+ if (
+ (_literal = _PyPegen_expect_token(p, 14)) // token='+'
+ &&
+ (real = real_number_rule(p)) // real_number
+ )
+ {
+ D(fprintf(stderr, "%*c+ signed_real_number[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+' real_number"));
+ _res = real;
+ if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ p->level--;
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s signed_real_number[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+' real_number"));
+ }
{ // '-' real_number
if (p->error_indicator) {
p->level--;
return _res;
}
-// imaginary_number: NUMBER
+// imaginary_number: NUMBER | '+' NUMBER
static expr_ty
imaginary_number_rule(Parser *p)
{
D(fprintf(stderr, "%*c%s imaginary_number[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER"));
}
+ { // '+' NUMBER
+ if (p->error_indicator) {
+ p->level--;
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> imaginary_number[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+' NUMBER"));
+ Token * _literal;
+ expr_ty imag;
+ if (
+ (_literal = _PyPegen_expect_token(p, 14)) // token='+'
+ &&
+ (imag = _PyPegen_number_token(p)) // NUMBER
+ )
+ {
+ D(fprintf(stderr, "%*c+ imaginary_number[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+' NUMBER"));
+ _res = _PyPegen_ensure_imaginary ( p , imag );
+ if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ p->level--;
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s imaginary_number[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+' NUMBER"));
+ }
_res = NULL;
done:
p->level--;