Skip to content

Commit

Permalink
modif main
Browse files Browse the repository at this point in the history
  • Loading branch information
larchadrg committed Apr 8, 2024
1 parent 9f274eb commit 7f13303
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
19 changes: 18 additions & 1 deletion TP/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
using namespace std;

int main() {
string filename = "archivo.txt"; // Nombre del archivo
/**
string filename = "archivo.txt"; // Nombre del archivo
ifstream file(filename); // Abrir el archivo
Parser parser = *new Parser();
Expand All @@ -30,6 +31,22 @@ int main() {
}
file.close();
*/

NotDeterministicFiniteAutomata ndfa;
ndfa.setInitialState(0);
ndfa.setE({1,2});
ndfa.setK({0,1,2,3});
ndfa.addPath(0,1,1);
ndfa.addPath(1,2,1);
ndfa.addPath(1,2,2);
ndfa.addPath(1,1,3);
ndfa.addPath(3,1,3);
ndfa.addPath(3,2,3);
ndfa.addFinalState(2);

Parser parser;
std::cout << parser.ndfaToFile(ndfa);

return 0;
}
2 changes: 1 addition & 1 deletion TP/automata/ndfa/NotDeterministicFiniteAutomata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ DeterministicFiniteAutomata NotDeterministicFiniteAutomata :: nfaToDfa() { //TOD
set<int> q0AsSet;
q0AsSet.insert(getInitialState());
set<int> Q0 = getSymbolClosure(q0AsSet, LAMBDA);
convertedAutomata.setQ0(Q0);
convertedAutomata.setInitialState(Q0);
set<set<int>> newK;
newK.insert(Q0);

Expand Down
4 changes: 2 additions & 2 deletions TP/parser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void Parser::fileManagement(const string& line) {
} else if(!isRankdirLine(line) || line == "}" && readLastLine)
throw runtime_error("Formato invalido del archivo.");
}
string Parser::ndnaToFile(NotDeterministicFiniteAutomata ndfa) {
string Parser::ndfaToFile(NotDeterministicFiniteAutomata ndfa) {
string ret = "digraph{"
"inic[shape=point];"
"inic->";
Expand All @@ -112,7 +112,7 @@ string Parser::ndnaToFile(NotDeterministicFiniteAutomata ndfa) {
void Parser::toStringSates(NotDeterministicFiniteAutomata ndfa, string ret) {
for(int number : ndfa.getK()) {
for(int number2 : ndfa.getK()) {
set<int> label = ndfa.calculateWaysToGo(number,number2);q3->q3 [label="a,b"];
set<int> label = ndfa.calculateWaysToGo(number,number2);
if(!label.empty()) {
ret += to_string(number) + "->" + to_string(number2) + "label[=\"";
for(auto elem : label) {
Expand Down
2 changes: 1 addition & 1 deletion TP/parser/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Parser {
static bool validateTransitionLine(const string& line);
static bool validateFinalStateLine(const string& line);
bool isRankdirLine(const string& line);
string ndnaToFile(NotDeterministicFiniteAutomata ndfa);
string ndfaToFile(NotDeterministicFiniteAutomata ndfa);

private:
static bool checkDelta(const string& line);
Expand Down

0 comments on commit 7f13303

Please sign in to comment.