Exemplo n.º 1
0
def getTransitions(k, alpha, file, w):
    alphabet = set(str(alpha))
    dfa = DFA(k, alphabet)
    M = dfa.constructDFA()
    Ti = dfa.getTransitions(M, w)
    f = open(file, 'w')
    f.write("Ti=%s\n" % strDict(Ti))
    f.close()
    return
Exemplo n.º 2
0
def getTransitions(k, alpha, file, w):
    alphabet = set(str(alpha))
    dfa = DFA(k, alphabet)
    M = dfa.constructDFA()
    Ti = dfa.getTransitions(M, w)
    f = open(file, "w")
    f.write("Ti=%s\n" % strDict(Ti))
    f.close()
    return
Exemplo n.º 3
0
def getAcceptState(k, alpha, file, TiStr):
    alphabet = set(str(alpha))
    dfa = DFA(k, alphabet)
    M = dfa.constructDFA()
    Ti = eval(TiStr)
    x = dfa.getAcceptState(Ti)
    f = open(file, 'w')
    f.write("x=%s\n" % x)
    f.close()
    return
Exemplo n.º 4
0
def getAcceptState(k, alpha, file, TiStr):
    alphabet = set(str(alpha))
    dfa = DFA(k, alphabet)
    M = dfa.constructDFA()
    Ti = eval(TiStr)
    x = dfa.getAcceptState(Ti)
    f = open(file, "w")
    f.write("x=%s\n" % x)
    f.close()
    return
Exemplo n.º 5
0
def isStrAccept(k, alpha, file, w):
    alphabet = set(str(alpha))
    dfa = DFA(k, alphabet)
    M = dfa.constructDFA()
    res = dfa.accept(M, w)
    if res: i = 1
    else: i = 0
    f = open(file, 'w')
    f.write("accept=%s\n" % i)
    f.close()
    return
Exemplo n.º 6
0
def constructDFA(k, alpha, file):
    alphabet = set(str(alpha))
    dfa = DFA(k, alphabet)
    M = dfa.constructDFA()
    Q, S, T, q0, F = M
    f = open(file, 'w')
    f.write("Q=%s\n" % strList(Q))
    f.write("T=%s\n" % strList(T))
    f.write("q0=%s\n" % q0)
    f.write("F=%s\n" % strList(F))
    f.close()
    return
Exemplo n.º 7
0
def constructDFA(k, alpha, file):
    alphabet = set(str(alpha))
    dfa = DFA(k, alphabet)
    M = dfa.constructDFA()
    Q, S, T, q0, F = M
    f = open(file, "w")
    f.write("Q=%s\n" % strList(Q))
    f.write("T=%s\n" % strList(T))
    f.write("q0=%s\n" % q0)
    f.write("F=%s\n" % strList(F))
    f.close()
    return
Exemplo n.º 8
0
def isStrAccept(k, alpha, file, w):
    alphabet = set(str(alpha))
    dfa = DFA(k, alphabet)
    M = dfa.constructDFA()
    res = dfa.accept(M, w)
    if res:
        i = 1
    else:
        i = 0
    f = open(file, "w")
    f.write("accept=%s\n" % i)
    f.close()
    return