private void SplitLines()
 {
     linesInWords = new Word[Lines.Length][];
     for (int i = 0; i < Lines.Length; i++)
     {
         string line = Line.TrimmedLine(Lines[i]);
         int    singleLineCommentStart = line.IndexOf(Data.SINGLELINE_COMMENT.Text);
         if (singleLineCommentStart >= 0)
         {
             line = line.Substring(0, singleLineCommentStart);
         }
         int multiLineCommentStart = line.IndexOf(Data.MULTILINE_COMMENT_Start.Text);
         if (multiLineCommentStart >= 0)
         {
             SkipMultiLineComment(ref i, multiLineCommentStart, line);
             continue;
         }
         linesInWords[i] = Split.SeparateLine(line);
         Word.TrimWords(ref linesInWords[i]);
     }
     isCodeNormalized = true;
 }
 private void CASE_ToSingleLine()
 {
     for (int i = 0; i < lines.Length; i++)
     {
         Word[] words = Split.SeparateLine(lines[i]);
         Word.TrimWords(ref words);
         if (words.Length == 0)
         {
             continue;
         }
         int  nested_SWITCH   = 0;
         bool wasNestedSwitch = false;
         if (Line.TrimmedLine(Word.FirstNotEmptyWord(words).Text) == Data.SWITCH.Text)
         {
             i++;
             int SWITCH_End = Brackets.GetCloseCurveBracketIndex(lines, i);
             for (int j = i + 1; j < SWITCH_End; j++)
             {
                 words = Split.SeparateLine(lines[j]);
                 string firstWord;
                 try
                 {
                     firstWord = Line.TrimmedLine(Word.FirstNotEmptyWord(words).Text);
                 }
                 catch (Exception)
                 {
                     continue;
                 }
                 if (firstWord == Data.CASE.Text)
                 {
                     if (Word.IndexOfFirst(words, Data.CASE) == words.Length - 1)
                     {
                         CombineLines(ref j);
                         break;
                     }
                     else
                     {
                         Split_CASE_Or_DEFAULT(words, j);
                     }
                 }
                 else if (firstWord == Data.DEFAULT.Text)
                 {
                     if (Word.IndexOfFirst(words, Data.DEFAULT) == words.Length - 1)
                     {
                         CombineLines(ref j);
                         break;
                     }
                     else
                     {
                         Split_CASE_Or_DEFAULT(words, j);
                     }
                 }
                 else if (firstWord == Data.DEFAULT_WithColon.Text)
                 {
                     if (Word.IndexOfFirst(words, Data.DEFAULT_WithColon) == words.Length - 1)
                     {
                         CombineLines(ref j);
                         break;
                     }
                     else
                     {
                         Split_CASE_Or_DEFAULT(words, j);
                     }
                 }
                 else if ((firstWord == Data.SWITCH.Text || firstWord.Contains(Data.SWITCH_WithBracket.Text)) && !wasNestedSwitch)
                 {
                     nested_SWITCH   = j;
                     wasNestedSwitch = true;
                 }
             }
             i = SWITCH_End;
             if (wasNestedSwitch)
             {
                 i = nested_SWITCH;
             }
         }
     }
 }
        private void CarryFromConditionToNewLine()
        {
            for (int i = 0; i < lines.Length; i++)
            {
                string offset = "";
                if (i != 0)
                {
                    offset = Line.GetOffset(lines[i - 1]);
                }

                Word[] words = Split.SeparateLine(Line.TrimmedLine(lines[i]));
                Word.TrimWords(ref words);
                if (words.Length == 0)
                {
                    continue;
                }
                if (Word.Contains(words, Data.DO))
                {
                    string[] parts       = new string[2];
                    int      DO_Position = Word.IndexOfFirst(words, Data.DO);
                    parts[0] = offset + Word.ToLine(words, 0, DO_Position);
                    parts[1] = Word.ToLine(words, DO_Position + 1);
                    if (Line.TrimmedLine(parts[1]) == "")
                    {
                        Array.Resize(ref parts, 1);
                    }
                    Split.InsertInsteadOf(i, ref lines, parts);
                }
                else if (Word.ContainsBlockOperator(words))
                {
                    if (words[0].Text == Data.WHILE.Text)
                    {
                        int closeRoundBracket = Brackets.GetCloseBracketPosition(words, '(');
                        if (closeRoundBracket != words.Length - 1 && words[closeRoundBracket + 1].Text == ";")
                        {
                            continue;
                        }
                    }
                    int      closeBracketPosition = Brackets.GetCloseBracketPosition(words, '(');
                    string[] parts = new string[2];
                    parts[0] = offset + Word.ToLine(words, 0, closeBracketPosition);
                    parts[1] = offset + "\t" + Word.ToLine(words, closeBracketPosition + 1);
                    if (Line.TrimmedLine(parts[1]) == "")
                    {
                        continue;
                    }
                    Split.InsertInsteadOf(i, ref lines, parts);
                }
                else if (words[0].Text == Data.ELSE.Text)
                {
                    string[] parts = new string[2];
                    parts[0] = offset + Data.ELSE.Text;
                    parts[1] = offset + "\t" + Word.ToLine(words, 1);
                    if (Line.TrimmedLine(parts[1]) == "")
                    {
                        continue;
                    }
                    Split.InsertInsteadOf(i, ref lines, parts);
                }
            }
        }