コード例 #1
0
 static void Remove_Epsilon(string state, CAutomat automat, string fake_state, CAutomat NonEpsilon)
 {
     foreach (CTranzitie Aux_tranz in automat.get_Tranzitii())
     {
         if (state == Aux_tranz.get_dinspre())
         {
             if (Aux_tranz.get_cost() == "e")
             {
                 Remove_Epsilon(Aux_tranz.get_catre(), automat, fake_state, NonEpsilon);
             }
             else
             {
                 var tranz_noua = new CTranzitie(Aux_tranz.get_catre(), fake_state, Aux_tranz.get_cost());
                 NonEpsilon.Accept_Tranzitii(tranz_noua);
             }
         }
     }
 }
コード例 #2
0
 public void Remove_useless_states()
 {
     foreach (string stare in MStari)
     {
         bool ok = false;
         foreach (CTranzitie Aux_tranz in MTranzitii)
         {
             if (stare == Aux_tranz.get_catre())
             {
                 if (Aux_tranz.get_cost() != "e")
                 {
                     ok = true;
                 }
             }
         }
         if (stare == MStare_initiala)
         {
             ok = true;
         }
         if (ok == false)
         {
             foreach (string q in MStari)
             {
                 if (q == stare)
                 {
                     List <string> aux = MStari.ToList();
                     aux.Remove(q);
                     MStari = aux.ToArray();
                 }
             }
             for (int i = 0; i < MTranzitii.Count; i++)
             {
                 if (MTranzitii[i].get_dinspre() == stare)
                 {
                     MTranzitii.Remove(MTranzitii[i]);
                     i--;
                 }
             }
         }
     }
 }
コード例 #3
0
        static void Main(string[] args)
        {
            CAutomat automat = new CAutomat();

            Citeste_automatul(args[0], automat);
            Afiseaza_automatul(automat);
            CAutomat NonEpsilon = new CAutomat(automat);

            foreach (CTranzitie Aux_tranz in automat.get_Tranzitii())
            {
                Remove_Epsilon(Aux_tranz.get_dinspre(), automat, Aux_tranz.get_dinspre(), NonEpsilon);
            }

            File.AppendAllText("out.txt", Environment.NewLine);
            File.AppendAllText("out.txt", Environment.NewLine);
            NonEpsilon.Clean_automat();
            NonEpsilon.Remove_useless_states();

            //        NonEpsilon.Clean_automat();
            Afiseaza_automatul(NonEpsilon);
        }