-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathcli.py
33 lines (31 loc) · 885 Bytes
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from AutomataTheory import *
import sys
def main():
inp = "(01*1)*1"
if len(sys.argv)>1:
inp = sys.argv[1]
print "Regular Expression: ", inp
nfaObj = NFAfromRegex(inp)
nfa = nfaObj.getNFA()
dfaObj = DFAfromNFA(nfa)
dfa = dfaObj.getDFA()
minDFA = dfaObj.getMinimisedDFA()
print "\nNFA: "
nfaObj.displayNFA()
print "\nDFA: "
dfaObj.displayDFA()
print "\nMinimised DFA: "
dfaObj.displayMinimisedDFA()
if isInstalled("dot"):
drawGraph(dfa, "dfa")
drawGraph(nfa, "nfa")
drawGraph(minDFA, "mdfa")
print "\nGraphs have been created in the code directory"
print minDFA.getDotFile()
if __name__ == '__main__':
t = time.time()
try:
main()
except BaseException as e:
print "\nFailure:", e
print "\nExecution time: ", time.time() - t, "seconds"