#include struct state { int state_number; struct state *transition1; char v1; struct state *transition2; char v2; }; struct automata { struct state *start; struct state *final; }; int createNewState (struct state **ptr) { if(tmp = malloc(sizeof(struct state))) { tmp = {0,(struct state*)NULL,'$',(struct state*)NULL,'$'}; *ptr = &tmp; return TRUE; } else { return FALSE; } } struct automata findNfa ( struct automata ) { struct automata nfa = {NULL,NULL}; while(ch != '$') { scanf("%c",&ch); if (ch >= 'a' && ch <= 'z') { struct state *temp1,*temp2; if(createNewState(&temp1) && createNewState(&temp2)) { temp1->state_number = ct++; temp2->state_number = ct++; temp1->transition1 = temp2; temp1->v1=ch; nfa.start = temp1; nfa.final = temp2; } if ( ch == '(') { nfa = findNFA (nfa); } else if ( ch == ')' ) { return nfa; } else if (ch == '*') { nfa = applyStar(nfa); } else if (ch == '|') { struct automata temp2 = {NULL,NULL}; findNfa(temp2); nfa = applyOr(nfa,temp2); } else if (ch == '.') { struct automata temp3 = {NULL,NULL}; findNfa(temp3); nfa = applyAnd(nfa,temp3); } else { printf("\nInvalid Input Characters\n"); exit(1); } } return nfa; }