public AutomataD createAutomata(string s) { InfixToPostfix ix = new InfixToPostfix(s); ArbolSin ar = new ArbolSin(s); Converter con = new Converter(); return(con.DirectAFD(ar)); }
public ArbolSin(string s) { InfixToPostfix ix = new InfixToPostfix(s); Stack <Symbol> postfix = ix.getStackPost(); Stack <Nodo> sNodo = new Stack <Nodo>(); alfa = new List <string>(); Nodo temp; int cont = 0; foreach (Symbol sim in postfix) { if (sim.isOper()) { switch (sim.getSym()) { case "|": sNodo.Push(new Nodo(sim.getSym(), sNodo.Pop(), sNodo.Pop())); break; case ".": sNodo.Push(new Nodo(sim.getSym(), sNodo.Pop(), sNodo.Pop())); break; case "*": sNodo.Push(new Nodo(sim.getSym(), sNodo.Pop())); break; /*case '+': * temp = DeepCopy(sNodo.Peek()); * sNodo.Push(new Nodo("*", sNodo.Pop())); * sNodo.Push(new Nodo(".", temp, sNodo.Pop())); * break;*/ } } else { temp = new Nodo(sim.getSym()); temp.getFPos().Add(temp); temp.getLPos().Add(temp); if (sim.getSym() == "#") { this.fin = temp; } else { if (!alfa.Contains(sim.getSym())) { alfa.Add(sim.getSym()); } } cont++; temp.setNum(cont.ToString()); sNodo.Push(temp); break; } } this.raiz = sNodo.Pop(); }