From 1b107f6c7727d08f2a3fef4d2fe8b37f9ef9460d Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 28 Oct 2024 16:45:47 -0500 Subject: [PATCH] Fix parsing precedence between unary and power, add test --- pymbolic/parser.py | 4 ++-- test/test_pymbolic.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pymbolic/parser.py b/pymbolic/parser.py index bb79859..4384db0 100644 --- a/pymbolic/parser.py +++ b/pymbolic/parser.py @@ -92,8 +92,8 @@ _PREC_COMPARISON = 200 _PREC_SHIFT = 205 _PREC_PLUS = 210 _PREC_TIMES = 220 -_PREC_POWER = 230 -_PREC_UNARY = 240 +_PREC_UNARY = 230 +_PREC_POWER = 240 _PREC_CALL = 250 diff --git a/test/test_pymbolic.py b/test/test_pymbolic.py index 07566ad..8dc3a28 100644 --- a/test/test_pymbolic.py +++ b/test/test_pymbolic.py @@ -332,6 +332,8 @@ def test_parser(): assert_parsed_same_as_python("0 if 1 if 2 else 3 else 4") assert_parsed_same_as_python("0 if (1 if 2 else 3) else 4") assert_parsed_same_as_python("(2, 3,)") + assert_parsed_same_as_python("-3**0.5") + assert_parsed_same_as_python("1/2/7") with pytest.deprecated_call(): parse("1+if(0, 1, 2)") -- GitLab