1p/srclib/transforma.c
/**
    AFNDTransforma
    Input:
        AFND *afnd: pointer to a ndfa object
    Returns:
        ndfa object, or NULL in error case
    Advanced description:
        It computes the equivalent DFA of the introduced NDFA.
*/
AFNDTransforma
Input:
AFND *afnd: pointer to a ndfa object
Returns:
ndfa object, or NULL in error case
Advanced description:
It computes the equivalent DFA of the introduced NDFA.
AFNDTransforma Input : AFND * afnd : pointer to a ndfa object Returns : ndfa object or NULL in error case Advanced description : It computes the equivalent DFA of the introduced NDFA .
AFND *AFNDTransforma(AFND *afnd){
    if (!afnd){
        return NULL;
    }
    size_t nstates, alph_sz, dfa_states;
    uint8_t ***nfa_trans_tb = get_nfa_transition_table(afnd);
    uint8_t **l_clausure = get_lambda_clausure(afnd, &nstates);
    uint8_t *i_states = get_initial_states(afnd, &nstates);
    uint8_t *f_states = get_final_states(afnd, &nstates);
    char **alphabet = get_alphabet(afnd, &alph_sz);
    row *dfa_table = __get_dfa_table(nfa_trans_tb, l_clausure, i_states, f_states, alph_sz, nstates, &dfa_states);
    AFND *dfa = get_dfa_object(dfa_table, alphabet, alph_sz, dfa_states, nstates);
    for (size_t i = 0; i < dfa_states; i++) {
        for (size_t j = 0; j < alph_sz; j++) {
            cstate_remove(dfa_table[i].state_to[j]);
        }
        free(dfa_table[i].state_to);
        cstate_remove(dfa_table[i].state_from);
    }
    free(dfa_table);
    free(i_states);
    free(f_states);
    free(alphabet);
    sq_mtx_delete(l_clausure, nstates);
    delete_nfa_transition_table(nfa_trans_tb, nstates, alph_sz);
    return dfa;
}
AFND * AFNDTransforma ( AFND * afnd ) { if ( ! afnd ) { return NULL ; } size_t nstates , alph_sz , dfa_states ; uint8_t * * * nfa_trans_tb = get_nfa_transition_table ( afnd ) ; uint8_t * * l_clausure = get_lambda_clausure ( afnd , & nstates ) ; uint8_t * i_states = get_initial_states ( afnd , & nstates ) ; uint8_t * f_states = get_final_states ( afnd , & nstates ) ; char * * alphabet = get_alphabet ( afnd , & alph_sz ) ; row * dfa_table = __get_dfa_table ( nfa_trans_tb , l_clausure , i_states , f_states , alph_sz , nstates , & dfa_states ) ; AFND * dfa = get_dfa_object ( dfa_table , alphabet , alph_sz , dfa_states , nstates ) ; for ( size_t i = 0 ; i < dfa_states ; i ++ ) { for ( size_t j = 0 ; j < alph_sz ; j ++ ) { cstate_remove ( dfa_table [ i ] . state_to [ j ] ) ; } free ( dfa_table [ i ] . state_to ) ; cstate_remove ( dfa_table [ i ] . state_from ) ; } free ( dfa_table ) ; free ( i_states ) ; free ( f_states ) ; free ( alphabet ) ; sq_mtx_delete ( l_clausure , nstates ) ; delete_nfa_transition_table ( nfa_trans_tb , nstates , alph_sz ) ; return dfa ; }
AFNDTransforma
Input:
AFND *afnd: pointer to a ndfa object
Returns:
ndfa object, or NULL in error case
Advanced description:
It computes the equivalent DFA of the introduced NDFA.
AFNDTransforma Input : AFND * afnd : pointer to a ndfa object Returns : ndfa object or NULL in error case Advanced description : It computes the equivalent DFA of the introduced NDFA .
// Fill our structures from the AFND object information
 //// Get the NDFA transition table
 //// Get the lambda clausure matrix
 //// Get the set of initial states
 //// Get the set of final states
 //// Get alphabet of the NDFA
 // Execute the algorithm to find the equivalent DFA to the given NDFA
 // Translate our table to the AFND object this function have to return
 // Free's resources
