private static void FindTokenPlace(Queue<string> queue, Stack<string> stack, Token token) { if (token.Tupe == TupeToken.Number) { queue.Enqueue(token.Value); } else if (token.Tupe == TupeToken.Operators || token.Tupe == TupeToken.Function) { OperatorsPrecedence(queue, stack, token); stack.Push(token.Value); } else if (token.Tupe == TupeToken.Serarator && token.Value == ",") { string str = ""; while (str != "(") { str = stack.Pop(); if (str != "(") { queue.Enqueue(str); } } stack.Push("("); } else if (token.Tupe == TupeToken.Serarator && token.Value == "(") { stack.Push(token.Value); } else if (token.Tupe == TupeToken.Serarator && token.Value == ")") { RightBracket(queue, stack); } }
private static void OperatorsPrecedence(Queue<string> queue, Stack<string> stack, Token token) { if (token.Value == "-" || token.Value == "+") { string operator1 = ""; if (stack.Count != 0) { operator1 = stack.Peek(); } if (operator1 == "*" || operator1 == "/" || operator1 == "-") { while (true) { if (stack.Count != 0) { operator1 = stack.Peek(); } else { break; } if (operator1 == "*" || operator1 == "/" || operator1 == "-") { queue.Enqueue(stack.Pop()); } else { break; } } } } }