示例#1
0
        public void Expresion()
        {
            if (tokenactual.idtoken.Equals("TK_id"))
            {
                match("TK_id");
                difer();
                match("TK_pcoma");
                // ver las ERS

                //-----aca se obtiene la ER del archivo de entrada
                if (ERS.Count == 0)
                {
                }
                else
                {
                    Thompson            meodoThompson = new Thompson(ERS);
                    ARBOL.GrafoThompson grafooo       = new ARBOL.GrafoThompson(ERS);

                    /*
                     * for(int i=0; i<ERS.Count; i++){
                     *  System.Windows.Forms.MessageBox.Show("parser: "+ERS[i].lexema);
                     * }
                     */
                    ERS.Clear();
                }


                //fin del procedimiento por ER
                Expresion();
            }
            else
            {
                //epsilon
            }
        }
示例#2
0
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         Thompson.ReporteXML();
     }
     catch
     {
         MessageBox.Show("De momento no se puede generar el reporte XML. ", "Error");
     }
 }
示例#3
0
 private void button4_Click(object sender, EventArgs e)
 {
     LexemasEvaluar.Clear();
     try
     {
         int ps = 0;
         for (int i = 0; i < listaLexema.Count; i++)
         {
             if (listaLexema[i].Equals(selector.SelectedItem.ToString()))
             {
                 if (ps != 0)
                 {
                     LexemasEvaluar.Add(listaLexema[i + 2]);
                 }
                 ps++;
             }
         }
         Thompson v = new Thompson();
         v.Inicio(selector.SelectedItem.ToString());
         String AuxMostrar = "";
         int    j          = 0;
         for (int i = 0; i < Thompson.SalidaEvaluar.Count; i++)
         {
             string[] words = Thompson.SalidaEvaluar[i].ToString().Split(',');
             if (words[0].Equals("FIN"))
             {
                 MostrarConsola.Add("La expresion \"" + LexemasEvaluar[j] + "\" es " + words[1] + " para la expresion regular " + selector.SelectedItem.ToString());
                 AuxMostrar += "La expresion \"" + LexemasEvaluar[j] + "\" es " + words[1] + " para la expresion regular " + selector.SelectedItem.ToString() + "\n";
                 j++;
             }
         }
         Consola.Text = AuxMostrar;
     }
     catch
     {
         MessageBox.Show("No se ha seleccionado ninguna expresion regular. ", "Error");
     }
 }
 public Listado_Thompson(String name_expresion, Thompson ex_thomson)
 {
     this.name_expresion = name_expresion;
     this.ex_thomson     = ex_thomson;
 }
示例#5
0
        private void button2_Click(object sender, EventArgs e)
        {
            NodeAFN N1 = new NodeAFN("N", 1, "E", Tipo.TipoN.EPSILON);
            NodeAFN N2 = new NodeAFN("N", 2, "E", Tipo.TipoN.EPSILON);

            NodeAFN f1 = new NodeAFN("N", 2, "E", Tipo.TipoN.EPSILON);
            NodeAFN f2 = new NodeAFN("N", 2, "E", Tipo.TipoN.EPSILON);

            f1.Tran_left = "f1";
            f2.Tran_left = "f2";


            NodeAFN N3 = new NodeAFN("N", 2, "E", Tipo.TipoN.EPSILON);
            NodeAFN N4 = new NodeAFN("N", 2, "E", Tipo.TipoN.EPSILON);

            N1.Tran_left  = "1";
            N1.ultimo_ref = N1;

            N2.Tran_left  = "2";
            N2.ultimo_ref = N2;
            ///////
            N3.Tran_left  = "a";
            N3.ultimo_ref = N3;

            N4.Tran_left  = "b";
            N4.ultimo_ref = N4;

            //N1.left = N2;
            N1.ultimo_ref.left = N2;
            //N2.left = f1;
            N2.ultimo_ref.left = f1;

            N1.ultimo_ref = f1;

            ///////f1.left = N3;

            //N3.left = N4;
            N3.ultimo_ref.left = N4;
            //N4.left = f2;
            N4.ultimo_ref.left = f2;
            N3.ultimo_ref      = f2;

            ///concatenando
            //N2.left = N3;

            MessageBox.Show(f1.Tran_left, "1 f1.Tran_left");
            MessageBox.Show(N2.left.Tran_left, "1 N2.left.Tran_left");
            MessageBox.Show(N1.ultimo_ref.Tran_left, "1 N1.ultimo_ref.Tran_left");
            //f1 = N3;
            N1.ultimo_ref.lexema     = N3.lexema;
            N1.ultimo_ref.left       = N3.left;
            N1.ultimo_ref.Tran_left  = N3.Tran_left;
            N1.ultimo_ref.ultimo_ref = N3.ultimo_ref;

            MessageBox.Show(f1.Tran_left, "2 f1.Tran_left");
            MessageBox.Show(N2.left.Tran_left, "2 N2.left.Tran_left");
            MessageBox.Show(N1.ultimo_ref.Tran_left, "1 N1.ultimo_ref.Tran_left");

            //MessageBox.Show(f1.Tran_left, "1 f1.Tran_left");
            //MessageBox.Show(N2.left.Tran_left, "1 N2.left.Tran_left");
            ////f1 = N3;
            //f1.lexema = N3.lexema;
            //f1.left = N3.left;
            //f1.Tran_left = N3.Tran_left;

            //MessageBox.Show(f1.Tran_left, "2 f1.Tran_left");
            //MessageBox.Show(N2.left.Tran_left, "2 N2.left.Tran_left");


            Thompson tree = new Thompson(N1, "prub", null);

            tree.SetIndex();
            tree.IniciarVisitado();
            tree.graficando_Thomson();
        }
示例#6
0
        public void Crea_AFN_AFD_ER()
        {
            /*probando armando el arbol*/
            List <Listado_Thompson> lis_arnew = new List <Listado_Thompson>();

            lis_thompson_expre = lis_arnew;

            for (int i = 0; i < lis_ex_reg.Count; ++i)
            {
                ////////////////MessageBox.Show(lis_ex_reg.ElementAt(i).name_exreg );//**
                //MessageBox.Show( lis_ex_reg.ElementAt(i).name_exreg /*+ " - "  **
                //        +lis_ex_reg.get(i).prefijo*/);
                ///
                List <ER_unitario> pref_er = new List <ER_unitario>();
                pref_er = lis_ex_reg.ElementAt(i).prefijo;


                /////creando arbol
                Armando_RPN arbol = new Armando_RPN(pref_er);
                NodeAFN     root_exp;
                root_exp = arbol.leyendo_expresiones();

                /////JOptionPane.showMessageDialog(null,"res arbol: " + root);


                ///////////////////inicioa graficas
                //Arbol tree = new Arbol(root_exp);
                Thompson tree = new Thompson(root_exp, lis_ex_reg.ElementAt(i).name_exreg, arbol.Listado_Tran);
                tree.SetIndex();
                //dtable.DataSource = tree.view_Listado_Tran();
                tree.IniciarVisitado();

                ////////////////////////tree.graficando_Thomson();  ////**
                tree.Set_Start_End_nodos();

                tree.IniciarVisitado();
                tree.MetedoCerradura();

                dtable.RowHeadersWidth = 12;
                //dtable.ColumnHeadersHeight = 10;
                dtable.DataSource = tree.view_Listado_Tran();
                dtable.AutoResizeColumns();

                ////////////////////////tree.graficando_Automata();  ////**



                ////////////////////tree.listar();

                //    tree.preOrder();

                //    tree.posOrder();
                //    tree.Graficando_arbol();
                //    //JOptionPane.showMessageDialog(null,"recor _pos ");

                //    tree.posOrder_sig();
                //    tree.graficando_siguientes();

                //    ////transiciones
                //    //tree.TabTransiciones();
                //    tree.Create_TabTransiciones();
                //    tree.graficando_Automata();

                Listado_Thompson thom = new Listado_Thompson(lis_ex_reg.ElementAt(i).name_exreg, tree);
                lis_thompson_expre.Add(thom);
                //
                //////////           tree.EvaluandoLexema_final(lis_evaluar_expre.get(0).cadena_eva, lis_var);
                //
                //            ////////////////fin graficas
            }
            //lis_ar();
            llenando_Combobox();
            //JOptionPane.showMessageDialog(null, "Termino de graficar");

            MessageBox.Show("Termino el proceso", "Creacion AFD");
        }