private void Split_CASE_Or_DEFAULT(Word[] words, int j) { int endIndex = Word.GetWordWithColonIndex(words); if (endIndex != words.Length - 1) { string[] parts = new string[2]; parts[0] = Word.ToLine(words, 0, endIndex); parts[1] = Line.GetOffset(parts[0]) + "\t" + Word.ToLine(words, endIndex + 1); Split.InsertInsteadOf(j, ref lines, parts); } }
public static int CloseQuoteIndex(Word[] words, int openQuoteIndex) { for (int i = openQuoteIndex + 1; i < words.Length; i++) { if (words[i].Text == "\"") { if (words[i - 1].Text != "\\") { return(i); } } } Data.ThrowError("Кавычки расставлены неверно в строке \'" + Word.ToLine(words, 0) + "\'"); return(0); }
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); } } }