From 153f77621eb37c429997ee1976041a28b239a6d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Mon, 30 Mar 2020 06:42:54 +0200 Subject: [PATCH] Fix precedence of absolute value operation As the absolute value operation has its own type of parentheses, it never needs to take precedence over other terms in order to be displayed correctly. To avoid extraneous parentheses around absolute value operations, set its precedence level to 0. --- src/format.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/format.rs b/src/format.rs index 305c6fc..8c20b42 100644 --- a/src/format.rs +++ b/src/format.rs @@ -15,6 +15,8 @@ impl Precedence for crate::Term | Self::Integer(_) | Self::String(_) | Self::Variable(_) + | Self::UnaryOperation( + crate::UnaryOperation{operator: crate::UnaryOperator::AbsoluteValue, ..}) => 0, Self::UnaryOperation( crate::UnaryOperation{operator: crate::UnaryOperator::Negative, ..}) @@ -33,9 +35,6 @@ impl Precedence for crate::Term | Self::BinaryOperation( crate::BinaryOperation{operator: crate::BinaryOperator::Subtract, ..}) => 4, - Self::UnaryOperation( - crate::UnaryOperation{operator: crate::UnaryOperator::AbsoluteValue, ..}) - => 5, } } }