/// <summary>
            /// Checks need of adding nil element to transform -x to 0-x.
            /// </summary>
            /// <param name="currentChar"></param>
            internal void CheckAndAddNilElement(char currentChar)
            {
                if (VariableBuilder.Length != 0 || currentChar == '=')
                {
                    return;
                }

                // apply imitation only on formula start or after equal operator
                if (ExpressionsStack.Count == 0 || OperatorsStack.Count > 0 && OperatorsStack.Peek() == '=')
                {
                    // 0 imitation in start or after '=': -x => 0-x +x => 0+x
                    ExpressionsStack.Push(new VariableExpressionsGroup(new VariablesExpression()));
                }
            }
            /// <summary>
            /// Push variable from <see cref="VariableBuilder"/> to <see cref="ExpressionsStack"/>.
            /// </summary>
            internal void PushVariable()
            {
                if (VariableBuilder.Length <= 0)
                {
                    return;
                }

                var variablevalue = VariableBuilder.ToString();
                var variable      = _expressionFactory.GetVariable(variablevalue);

                if (variable == null)
                {
                    throw new InvalidFormulaException(_formula, $"cannot parse variable '{variablevalue}'");
                }
                ExpressionsStack.Push(new VariableExpressionsGroup(variable));
                VariableBuilder.Clear();
            }
            /// <summary>
            /// Apply operator from <see cref="OperatorsStack"/>.
            /// </summary>
            internal void ApplyTopOperator()
            {
                if (OperatorsStack.Count == 0)
                {
                    return;
                }
                var operatorChar = OperatorsStack.Pop();

                if (operatorChar == '(')
                {
                    throw new InvalidFormulaException(_formula, "all parentheses must be closed");
                }
                PushVariable();
                if (ExpressionsStack.Count < 2)
                {
                    throw new InvalidFormulaException(_formula, $"not enough operands to apply {operatorChar} operator");
                }
                var rightOperand = ExpressionsStack.Pop();

                ExpressionsStack.Peek().Combine(rightOperand, changeSign: operatorChar != '+');
            }