public void scrollTo(string labelId)
 {
     foreach (model.Label lab in Labels)
     {
         if (lab.Id == labelId)
         {
             SelectedLabel = lab;
             LabelsTable.ScrollIntoView(lab);
             break;
         }
     }
 }
        private void GenerateConditionPolish(ref Token token, ref int i)
        {
            bool isShortCondition = false;

            stack.Push(token);
            i++;

            while (i < outputTokenTable.Count)
            {
                token = outputTokenTable[i];

                DefineTokenToGeneratePolish(ref token, ref i);

                if ((token.Name == ")" && Checker.IsRelation(Polish.Last())))
                {
                    if (outputTokenTable[i + 1].Name != "{")
                    {
                        isShortCondition = true;
                    }
                    string newLabelName = GetNewLabel();

                    Polish.Add($"{newLabelName} JNE");
                    stack.Push(new Token {
                        Name = newLabelName, TokenType = "label"
                    });
                    AddToViewTable(token);
                }

                if (token.Name == "}" || (token.Name == ";" && isShortCondition))
                {
                    string labelName = labelsStack.Pop();

                    LabelsTable.Add(labelName, Polish.Count);
                    Polish.Add($"{labelName}:");

                    while (stack.Pop().Name != "if")
                    {
                    }

                    AddToViewTable(token);

                    i++;
                    token = outputTokenTable[i];

                    return;
                }

                i++;
            }
        }
        private void GenerateCyclePolish(ref Token token, ref int i)
        {
            Polish.Add($"r{cycleDesignationCounter}");
            Polish.Add("1");
            Polish.Add("=");

            stack.Push(token);
            AddToViewTable(token);

            i++;

            bool   baseFlg      = false;
            string iteratorName = string.Empty;


            while (i < outputTokenTable.Count)
            {
                token = outputTokenTable[i];

                if (baseFlg)
                {
                    DefineTokenToGeneratePolish(ref token, ref i);

                    if (token.Name == "}")
                    {
                        cycleDesignationCounter--;
                        Polish.Add($"r{cycleDesignationCounter}");
                        Polish.Add("0");
                        Polish.Add("=");

                        string labelName = labelsStack.Pop();

                        Polish.Add($"{labelsStack.Pop()} JMP");

                        LabelsTable.Add(labelName, Polish.Count);
                        Polish.Add($"{labelName}:");

                        while (stack.Pop().Name != "for")
                        {
                        }

                        AddToViewTable(token);
                        return;
                    }
                }
                else
                {
                    if (token.TokenType == "IDN" || token.TokenType == "CON")
                    {
                        Polish.Add(token.Name);
                        AddToViewTable(token);

                        i++;
                        continue;
                    }

                    if ("()".Contains(token.Name))
                    {
                        i++;
                        if (token.Name == "(")
                        {
                            iteratorName = outputTokenTable[i].Name;
                        }
                        AddToViewTable(token);
                        continue;
                    }

                    if (stack.Count == 0)
                    {
                        stack.Push(token);
                    }
                    else
                    {
                        while (stack.Count > 0)
                        {
                            if (stack.Peek().TokenType != "label" && stack.Peek().GetPriority() >= token.GetPriority())
                            {
                                if (stack.Peek().Name != "for")
                                {
                                    Token stackHead = stack.Pop();

                                    Polish.Add(stackHead.TokenType.Equals("@") ? stackHead.TokenType : stackHead.Name);

                                    AddToViewTable(token);
                                }
                            }
                            else if (token.Name == ";")
                            {
                                if (Polish.Last() == "=")
                                {
                                    string newLabelName = GetNewLabel();


                                    LabelsTable.Add(newLabelName, Polish.Count);

                                    Polish.Add($"{newLabelName}:");
                                    stack.Push(new Token {
                                        Name = newLabelName, TokenType = "label"
                                    });

                                    AddToViewTable(token);

                                    break;
                                }
                                else if (Checker.IsRelation(Polish.Last()))
                                {
                                    string newLabelName = GetNewLabel();

                                    Polish.Add($"{newLabelName} JNE");
                                    stack.Push(new Token {
                                        Name = newLabelName, TokenType = "label"
                                    });

                                    Polish.Add($"r{cycleDesignationCounter}");
                                    Polish.Add($"0");
                                    Polish.Add($"==");

                                    cycleDesignationCounter++;

                                    newLabelName = GetNewLabel();
                                    Polish.Add($"{newLabelName} JNE");
                                    stack.Push(new Token {
                                        Name = newLabelName, TokenType = "label"
                                    });

                                    Polish.Add(iteratorName);

                                    AddToViewTable(token);
                                    break;
                                }
                            }
                            else if (token.Name == "{" && stack.Peek().Name == "for")
                            {
                                break;
                            }
                            else
                            {
                                if (token.Name == "{" && !baseFlg)
                                {
                                    Polish.Add("=");
                                    string labelName = labelsStack.Pop();

                                    LabelsTable.Add(labelName, Polish.Count);
                                    Polish.Add($"{labelName}:");

                                    AddToViewTable(token);

                                    baseFlg = true;
                                    break;
                                }

                                stack.Push(token);
                                break;
                            }
                        }
                    }
                }
                i++;
            }
        }