Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if ((status.Text == "Введите выражение: левую часть") && (Enter.Text != null))
            {
                status.Text = "Введите выражение";

            }
            if ((status.Text == "Введите правую часть выражения") && (Enter.Text != null))
            {
                P[ex_num].rightSide = Enter.Text;
                richTextBox1.Text = richTextBox1.Text + Enter.Text + "\n";
                ex_num++;
                if (ex_num < P.Length)
                {
                    status.Text = "Введите выражение: левую часть";
                    Enter.Text = null;
                }
                else
                {
                    status.Text="Ввод закончен";
                    Enter.Text = null;
                    button2.Visible = true;

                }

            }
            if ((status.Text == "Введите выражение") && (Enter.Text != null))
            {
                status.Text = "Введите выражение: левую часть";
                richTextBox1.Text = richTextBox1.Text + Enter.Text + " -> ";
                P[ex_num].leftSide = Enter.Text;
                status.Text = "Введите правую часть выражения";
                Enter.Text = null;

            }
            if ((status.Text == "Введите количество выражений") && (Enter.Text != null))
            {
               P=new P_element[int.Parse(Enter.Text)];
               for (int i = 0; i < int.Parse(Enter.Text); i++)
               {
                   P[i] = new P_element();
               }
               status.Text = "Введите выражение";
               richTextBox1.Visible = true;
               Enter.Text = null;
            }

            if ((status.Text == "Введите аксиому") && (Enter.Text != null))
            {
                Enter.Text = Enter.Text.ToUpper();
                bool crutch = true;
                if (Enter.Text.Length > 1)
                {
                    Enter.Text = null;
                    MessageBox.Show("Введите одну букву");
                    crutch = false;
                }
                if (crutch == true)
                {
                    S = Enter.Text[0];
                    textBox5.Visible = true;
                    S_box.Visible = true;
                    S_box.Text = Enter.Text;
                    Enter.Text = null;
                    status.Text = "Введите количество выражений";
                }
            }

            if ((status.Text == "Введите нетерминалы") && (Enter.Text != null))
            {
                Enter.Text=Enter.Text.ToUpper();
                bool crutch = true;
                N = new char[Enter.Text.Length];
                for (int i = 0; i < Enter.Text.Length; i++)
                {
                    for (int j = 0; j < Enter.Text.Length; j++)
                    {
                        if ((Enter.Text[i] == Enter.Text[j]) && (i != j))
                        {
                            Enter.Text = null;
                            N = null;
                            MessageBox.Show("Нетерминалы повторяются");
                            crutch = false;
                        }
                    }

                }
                if (crutch == true)
                {
                    N_box.Text = Enter.Text;
                    N_box.Visible = true;
                    textBox4.Visible = true;
                    status.Text = "Введите аксиому";
                    Enter.Text = null;
                }
            }

            if ((status.Text == "Введите терминалы") && (Enter.Text != null))
            {
                Enter.Text = Enter.Text.ToLower();
                bool crutch = true;
                T = new char[Enter.Text.Length];
                for (int i = 0; i < Enter.Text.Length; i++)
                {
                    for (int j = 0; j < Enter.Text.Length; j++)
                    {
                        if ((Enter.Text[i] == Enter.Text[j]) && (i != j))
                        {
                            Enter.Text = null;
                            T = null;
                            MessageBox.Show("Терминалы повторяются");
                            crutch = false;
                        }
                    }

                }
                if (crutch==true)
                {
                    T_box.Text = Enter.Text;
                    T_box.Visible = true;
                    textBox1.Visible = true;
                    status.Text = "Введите нетерминалы";
                    Enter.Text = null;
                }
            }
        }
Example #2
0
 public static bool Is_right(P_element[] P)
 {
     bool crutch = false;
     for (int i = 0; i < P.Length; i++)
     {
         if ((P[i].rightSide.ToUpper() != P[i].rightSide) && (P[i].rightSide.ToLower() != P[i].rightSide))
         {
             if (P[i].rightSide[P[i].rightSide.Length - 1].ToString() != P[i].rightSide[P[i].rightSide.Length - 1].ToString().ToUpper())
             {
                 crutch = true;
             }
         }
     }
     if (crutch == true) return false;
     if (crutch == false) return true;
     return false;
 }
Example #3
0
 public static bool Check_2(P_element[] P)
 {
     for (int i = 0; i < P.Length; i++)
     {
         if (P[i].leftSide.Length > 1)
         {
             return false;
         }
     }
     return true;
 }
Example #4
0
            public static bool Check_3(P_element[] P)
            {
                bool crutch = false;
                for (int i = 0; i < P.Length; i++)
                {
                    crutch = false;
                    if ((P[i].rightSide != "e") && (P[i].rightSide[0].ToString() == P[i].rightSide[0].ToString().ToUpper()))
                    {
                        for (int j = 0; j < P[i].rightSide.Length; j++)
                        {
                            if (P[i].rightSide[j].ToString() != P[i].rightSide[j].ToString().ToUpper())
                            {
                                crutch = true;
                            }
                            if ((crutch == true) && (P[i].rightSide[j].ToString() == P[i].rightSide[j].ToString().ToUpper()))
                            {
                                return false;
                            }
                        }
                    }
                    crutch = false;
                    if ((P[i].rightSide != "e") && (P[i].rightSide[0].ToString() != P[i].rightSide[0].ToString().ToUpper()))
                    {
                        for (int j = 0; j < P[i].rightSide.Length; j++)
                        {
                            if (P[i].rightSide[j].ToString() == P[i].rightSide[j].ToString().ToUpper())
                            {
                                crutch = true;
                            }
                            if ((crutch == true) && (P[i].rightSide[j].ToString() != P[i].rightSide[j].ToString().ToUpper()))
                            {
                                return false;
                            }
                        }
                    }

                }
                return true;
            }
Example #5
0
 public static bool Check_1(P_element[] P)
 {
     bool crutch = false;
     for (int i = 0; i < P.Length; i++)
     {
         crutch = false;
         for (int j = 0; j < P[i].leftSide.Length; j++)
         {
             if (P[i].leftSide[j].ToString() == P[i].leftSide[j].ToString().ToUpper())
             {
                 crutch = true;
             }
         }
         if (crutch == false)
         {
             return false;
         }
     }
     return true;
 }