Exemplo n.º 1
0
def prob3(input, output):
	f = open(input, 'r');
	alphabet = set(f.readline().split());
	s = f.readline();
	f.close();

	DFA = Project_03.ReToDFA(s, alphabet);

	g = open(output, 'w')
	SDK.writeDFAtable(g, DFA);
	g.close();
Exemplo n.º 2
0
def prob5(input, output):
	#input
	f = open(input, 'r');
	#allState, alphabet, startingState, dfaTable, acceptedState
	myDFA = SDK.readDFAtable(f);
	f.close();
	#--------------------------------------------------------------------
	#init

	#newAcceptedState = [u for u in newAcceptedState]
	DFA = Project_05.reduceDFA(myDFA);
	#print output
	g = open(output, 'w');
	SDK.writeDFAtable(g, DFA);
	#g.write('Description\n');
	#for u in newAllState:
		#g.write(str(u) + ': ' + ' '.join(map(str, [v for v in allState if id[v] == u])) + '\n')
	g.close();
Exemplo n.º 3
0
def prob2(input, output):
	#input
	f = open(input, 'r');

	myNFA = SDK.readEpsNFAtable(f);
	f.close();


	g = open(output, 'w');

	#newDfaTable = dict([((id[frozenset(k[0])], k[1]), dfaTable[k]) for k in dfaTable.keys()]);

	DFA = Project_02.NfaToDfa(myNFA);

	SDK.writeDFAtable(g, DFA);

	#for st in dfaState:
		#g.write(str(id[frozenset(st)]) + ': ' + str(st) + '\n');
	g.close();