Beispiel #1
0
        public Form1()
        {
            InitializeComponent();
            cmp = new Compare();
            richTextBox1.Text = basic_text;
            taskTextBox.Text  = cmp.currentProblem.problemText;
            execution         = new execute_all();


            this.KeyPreview = true;
            if (!isDeveloper)
            {
                tabControl1.TabPages.Remove(tabControl1.TabPages[0]);
                tabControl1.TabPages.Remove(tabControl1.TabPages[1]);
                tabControl1.TabPages.Remove(tabControl1.TabPages[tabControl1.TabPages.IndexOfKey("tabPage2")]);
                taskTextBox.ReadOnly   = true;
                resultTextBox.ReadOnly = true;
            }
            else
            {
                tabControl1.Show();
            }
            if (!isDeveloper)
            {
                Info f = new Info();
                f.ShowDialog();
            }
            tabControl1.Update();
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (richTextBox1.Text == "" || richTextBox1.Text == "\t" || richTextBox1.Text == "\n" || richTextBox1.Text == basic_text)
            {
                MessageBox.Show("Необходимо ввести текст программы.", "Предупреждение");
                return;
            }
            execution = new execute_all();
            button2_Click(sender, e);
            execution.solve(richTextBox1.Lines);
            richTextBox5.AppendText("Количество токенов: " + Convert.ToString(execution.tokens_count) + "\n");
            richTextBox3.Text += execution.toOut;
            if (execution.LexicalAnalyser.ErrorListLA.Count > 0)
            {
                foreach (string s in execution.LexicalAnalyser.ErrorListLA)
                {
                    richTextBox2.Text += '\n' + s;
                }
            }
            richTextBox3.AppendText("\nСписок состояний:\n");
            richTextBox3.AppendText(execution.LexicalAnalyser.stateLogLA + "\n");

            foreach (string s in execution.source.Identifiers.errors)
            {
                richTextBox2.AppendText(s);
            }
            richTextBox4.AppendText(execution.SyntaxAnalyser.Log + "\n");
            foreach (var s in execution.SyntaxAnalyser.errLog)
            {
                richTextBox2.AppendText(s + "\n");
            }
            foreach (var x in execution.source.Identifiers.intTable)
            {
                richTextBox5.AppendText(x.Value.name + "  " + "INT \n");
            }
            foreach (var x in execution.source.Identifiers.boolTable)
            {
                richTextBox5.AppendText(x.Value.name + "  " + "BOOL \n");
            }
            richTextBox5.AppendText("\n-------------------\n\n");
            foreach (var x in execution.regroupedTable.TranslationList)
            {
                if (x.Token == TranslationToken.LeftBrace || x.Token == TranslationToken.Semicolon)
                {
                    richTextBox5.AppendText(x.Value + "  " + "\n  ");
                    continue;
                }
                richTextBox5.AppendText(x.Value + "  ");
            }

            richTextBox5.AppendText("\n-------------------\n\n");
            foreach (var x in execution.output)
            {
                if (x.Token == TranslationToken.LeftBrace || x.Token == TranslationToken.Semicolon || x.Token == TranslationToken.GotoLabel || x.Token == TranslationToken.GotoTransition)
                {
                    if (x.Token != TranslationToken.Semicolon)
                    {
                        richTextBox5.AppendText(x.Token + "  " + "\n  ");
                    }
                    continue;
                }
                richTextBox5.AppendText(x.Token + "  ");
            }
            if (execution.out_log != "")
            {
                richTextBox5.AppendText("\n-------------------\n\n");
                richTextBox2.AppendText("\n" + execution.out_log + "\n");
                richTextBox5.AppendText("\n-------------------\n\n");
            }
            foreach (var x in execution.ThreeAddressCode)
            {
                richTextBox5.AppendText(Convert.ToString(x.TriadNumber) + "   "
                                        + x.FirstOperand.Value + "  " + x.Operation.Value + "  " + x.SecondOperand.Value + "\n");
            }
            richTextBox5.AppendText("\n-------------------\n\n");
            foreach (var x in execution.source.Identifiers.intTable)
            {
                richTextBox5.AppendText(x.Value.name + " = " + Convert.ToString(x.Value.value) + " INT  \n");
            }
            foreach (var x in execution.source.Identifiers.boolTable)
            {
                richTextBox5.AppendText(x.Value.name + "  " + Convert.ToString(x.Value.value) + " BOOL \n");
            }
            if (execution.error != "")
            {
                richTextBox2.AppendText(execution.error + "\n");
            }
            richTextBox5.AppendText("\n-------------------\n\n");
            for (int i = 0; i < execution.triadResult.Count(); ++i)
            {
                if (execution.triadResult[i] != null)
                {
                    richTextBox5.AppendText(i.ToString() + ". " + execution.triadResult[i] + "\n");
                }
            }
            string cmpResult = cmp.getResult(execution);

            if (cmpResult != "")
            {
                resultTextBox.Text = "";
                resultTextBox.Text = cmpResult;
            }
            resultTextBox.AppendText("\nЗначения объявленных переменных: \n");
            foreach (var x in execution.source.Identifiers.intTable)
            {
                resultTextBox.AppendText("INT " + x.Value.name + " = " + x.Value.value.ToString() + "\n");
            }
            foreach (var x in execution.source.Identifiers.boolTable)
            {
                resultTextBox.AppendText("BOOL " + x.Value.name + " = " + x.Value.value.ToString() + "\n");
            }
            richTextBox5.AppendText("\n-------------------\n\n");
            tabControl1.SelectedIndex = 1;
        }
Beispiel #3
0
 public string getResult(execute_all i)
 {
     input = i;
     return(compare());
 }