Skip to content

Commit

Permalink
add input management file
Browse files Browse the repository at this point in the history
  • Loading branch information
larchadrg committed Apr 9, 2024
1 parent b117194 commit 15d4da8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
37 changes: 37 additions & 0 deletions TP/testing/fileToNdfa.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <bits/stdc++.h>
#include "../automata/dfa/DeterministicFiniteAutomata.h"
#include "../automata/ndfa/NotDeterministicFiniteAutomata.h"
#include "../parser/Parser.h"
using namespace std;

const string filename = "TP/testing/input.txt";

int main() {
ifstream file(filename); // Abrir el archivo
Parser parser = *new Parser();

if (!file.is_open()) { // Verificar si el archivo se abrió correctamente
cerr << "No se pudo abrir el archivo." << endl;
return -1;
}

string line;

if (!getline(file, line)) { // Leer la primera línea
cerr << "No se pudo leer la primera línea." << endl;
return -1;
}
if(!Parser::validateFirstLine(line)){
cerr << "Formato invalido del archivo." << endl;
return -1;
}

while (getline(file, line)) {
parser.fileManagement(line);
}

file.close();

//NotDeterministicFiniteAutomata nda = parser.getNDA();
//nda.show(); //TODO: IMPLEMENTAR
}
10 changes: 10 additions & 0 deletions TP/testing/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
digraph{
inic[shape=point];
inic -> 0;
10 -> 11 [label = "1"];
11 -> 11 [label = "2"];
11 -> 12 [label = "2"];
11 -> 13 [label = "1"];
13 -> 13 [label = "-1"];
12[shape=doublecircle];
}

0 comments on commit 15d4da8

Please sign in to comment.