public void ErrorSelect(List <int> ErrorList) { RichTextBox_ProgramCode.SelectAll(); RichTextBox_ProgramCode.SelectionBackColor = Color.White; foreach (int LineNumber in ErrorList) { int startIndex = RichTextBox_ProgramCode.GetFirstCharIndexFromLine(LineNumber); if (startIndex == -1) { startIndex = RichTextBox_ProgramCode.Text.Length; } int endIndex = RichTextBox_ProgramCode.Text.IndexOf('\n', startIndex); if (endIndex == -1) { endIndex = RichTextBox_ProgramCode.Text.Length; } RichTextBox_ProgramCode.Select(startIndex, endIndex - startIndex); RichTextBox_ProgramCode.SelectionBackColor = Color.FromArgb(239, 123, 123); } }
private void Button_SemanticAnalyzer_Click(object sender, EventArgs e) { SemanticAnalyzer SA = new SemanticAnalyzer(RichTextBox_ProgramCode.Text); SA.Analysis(); List <string> AnalysisResult = SA.GetError(); if (AnalysisResult.Count == 0) { RichTextBox_AssemblyStatus.Text = "ОШИБОК НЕТ"; RichTextBox_ProgramCode.SelectAll(); RichTextBox_ProgramCode.SelectionBackColor = Color.White; } else { ErrorSelect(SA.GetErrorNumberLine()); RichTextBox_AssemblyStatus.Text = "НАЙДЕНЫ ОШИБКИ!\n----------------------------------------------------\n"; foreach (string Line in AnalysisResult) { RichTextBox_AssemblyStatus.AppendText(Line + "\n\n"); } } }