//Genera todo del la ER public void generarT() { thompson.Clear(); conteo = 0; iterador = 1; llenar(); Thompson y = (Thompson)thompson[thompson.Count - 1]; fin = y.getFinal(); terminal(); tablaT(); graficarThompson(); generarDFA(); //imprimirTerminales(); graficarAFD(); graficarTabla(); }
//Convierte los thompson en una tabla private void tablaT() { Thompson final = (Thompson)thompson[thompson.Count - 1]; Thompson temp; for (int i = 0; i < final.getFinal(); i++) { Thomp nuevo = new Thomp(i); //Recorro la lista de thompson buscando uno por uno for (int j = 0; j < thompson.Count; j++) { temp = (Thompson)thompson[j]; if (i == temp.getInicio()) { nuevo.setTrans(temp.getTransicion()); nuevo.add(temp.getFinal()); } } thomp.Add(nuevo); } }
public void graficarThompson() { StreamWriter FilaRThtml = new StreamWriter(Nombre + "_AFN.dot"); string afn = ""; afn += "digraph G { \n"; afn += "nodesep=0.8; \n"; afn += "ranksep=0.5; \n"; afn += "rankdir = LR; \n"; afn += "node[shape = circle ]; \n"; for (int i = 0; i < thompson.Count; i++) { Thompson temp = (Thompson)thompson[i]; afn += temp.getInicio() + "->" + temp.getFinal() + " [ label = \" " + temp.getTransicion() + "\"]; \n"; if (i == thompson.Count - 1) { if (temp.getInicio() > temp.getFinal()) { afn += temp.getInicio() + "[ shape = doublecircle];"; } else { afn += temp.getFinal() + "[ shape = doublecircle];"; } } } afn += "}"; FilaRThtml.Write(afn); FilaRThtml.Close(); System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c dot -Tpng -o " + Nombre + "_AFN.png " + Nombre + "_AFN.dot"); // Indicamos que la salida del proceso se redireccione en un Stream procStartInfo.RedirectStandardOutput = true; procStartInfo.UseShellExecute = false; //Indica que el proceso no despliegue una pantalla negra (El proceso se ejecuta en background) procStartInfo.CreateNoWindow = false; //Inicializa el proceso System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo = procStartInfo; proc.Start(); }