All good, but the algorithm does not work correctly with unary negation.
It is not designed to work with the unary negation.
How to fix?
The easiest way -- typing for unary negation a special character, different from the other operators.
Otherwise you'll have to enter an additional status-whether the previous character and whether he was the operator, and if so, to interpret immediately follows the operator '-' as unary.