private void toolStripButton1_Click(object sender, EventArgs e) { Parser.lines.Clear(); FileText = openFileDialog1.FileName; if (FileText != "") { Form activeChild = this.ActiveMdiChild; if (activeChild != null) { SplitContainer sp = (SplitContainer)activeChild.ActiveControl; RichTextBox editBox = (RichTextBox)sp.Panel2.Controls[0]; if (editBox != null) { Encoding en = Encoding.GetEncoding(1251); StreamWriter sw = new StreamWriter(FileText, false, en); sw.Write(editBox.Text); sw.Close(); } } } else { saveFileDialog1.ShowDialog(); } if (FileText != "") { Syntactic.errors.Clear(); Generation.lbls.Clear(); Parser.isStart = false; Parser.identy.Clear(); Parser.lexems.Clear(); Parser.effLabels.Clear(); Parser.lables.Clear(); Parser.isStart = false; Parser.const_str.Clear(); Parser.const_int.Clear(); Parser.num = 0; Parser.numlbs = 0; Encoding en = Encoding.GetEncoding(1251); StreamReader sr = new StreamReader(FileText, en); while (!sr.EndOfStream) { Parser.Parse(sr.ReadLine()); } sr.Close(); Generation.const_int.Clear(); Generation.const_str.Clear(); Generation.labels.Clear(); Generation.EndWhilelabels.Clear(); Generation.whilelabels.Clear(); Generation.Code = ""; Generation.numLabels = 0; Generation.numWhileLbls = 0; Generation.numEndWhileLbls = 0; Generation.GenData = false; Generation.GenDeclar = false; Syntactic synt = new Syntactic(); Form activeChild1 = this.ActiveMdiChild; SplitContainer sp1 = (SplitContainer)activeChild1.ActiveControl; RichTextBox editBox = (RichTextBox)sp1.Panel1.Controls[0]; int Start = 0; string text, temp; text = editBox.Text; while (Start != -1) { if (Start != text.Length) { Start++; Start = text.IndexOf("\n", Start); temp = text.Remove(Start); text = text.Remove(0, Start + 1); Parser.lables.Add(temp, Convert.ToInt32(temp).ToString()); Start = 0; } else { Start = -1; } } synt.ParseRoot(Parser.lexems); Lexical_analysis la = new Lexical_analysis(); la.ShowDialog(); } }