Skip to content

Commit ede5646

Browse files
committed
All current tests pass
1 parent 47abd15 commit ede5646

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,9 +2578,9 @@ protected virtual bool EvaluateOperators(string expression, Stack<object> stack,
25782578
{
25792579
string op = match.Value;
25802580

2581-
if (op.Equals("+") && (stack.Count == 0 || stack.Peek() is ExpressionOperator))
2581+
if (op.Equals("+") && (stack.Count == 0 || (stack.Peek() is ExpressionOperator previousOp && !LeftOperandOnlyOperatorsEvaluationDictionary.Contains(previousOp))))
25822582
stack.Push(ExpressionOperator.UnaryPlus);
2583-
else if (op.Equals("-") && (stack.Count == 0 || stack.Peek() is ExpressionOperator))
2583+
else if (op.Equals("-") && (stack.Count == 0 || (stack.Peek() is ExpressionOperator previousOp2 && !LeftOperandOnlyOperatorsEvaluationDictionary.Contains(previousOp2))))
25842584
stack.Push(ExpressionOperator.UnaryMinus);
25852585
else
25862586
stack.Push(operatorsDictionary[op]);

0 commit comments

Comments
 (0)