Skip to content

Commit

Permalink
rename automata usa punteros
Browse files Browse the repository at this point in the history
  • Loading branch information
ignacioDias committed May 22, 2024
1 parent da931e6 commit e8fe82c
Show file tree
Hide file tree
Showing 46 changed files with 2,383 additions and 89 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ add_executable(tpOb1
TP/parser/automata-to-string/dfa/DFAToString.cpp
TP/auxiliarmethods/AutomataOperations.cpp
TP/auxiliarmethods/AutomataOperations.h
TP/testing/TestRename.h
TP/testing/TestRename.cpp
)
1 change: 0 additions & 1 deletion TP/automata/convertion/ConvertionOfAutomatas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ set<int> ConvertionOfAutomatas::getLambdaReachableStates(int state) {
}
}
}

return result;
}

Expand Down
20 changes: 10 additions & 10 deletions TP/auxiliarmethods/AutomataOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ NotDeterministicFiniteAutomata AutomataOperations::nfaUnion(NotDeterministicFini
{
NotDeterministicFiniteAutomata newAutomata = NotDeterministicFiniteAutomata();

int counter = renameAutomata(a1, 1);
renameAutomata(a2, counter);
int counter = renameAutomata(&a1, 1);
renameAutomata(&a2, counter);

int newInitialState = 0;
newAutomata.addState(newInitialState);
Expand All @@ -32,20 +32,20 @@ NotDeterministicFiniteAutomata AutomataOperations::nfaUnion(NotDeterministicFini
}
return newAutomata;
}
int AutomataOperations::renameAutomata(NotDeterministicFiniteAutomata a1, int counter) {
for(auto node : a1.getSates()) {
if(CollectionsOperators::belongs(counter, a1.getSates())) {
a1.changeValueState(counter, node);
int AutomataOperations::renameAutomata(NotDeterministicFiniteAutomata *a1, int counter) {
for(auto node : a1->getSates()) {
if(CollectionsOperators::belongs(counter, a1->getSates())) {
a1->changeValueState(counter, node);
} else {
a1.changeValueState(node, counter);
a1->changeValueState(node, counter);
}
counter++;
}
return counter;
}
NotDeterministicFiniteAutomata AutomataOperations::nfaConcatenation(NotDeterministicFiniteAutomata a1, NotDeterministicFiniteAutomata a2) {

int counter = renameAutomata(a1, 0);
int counter = renameAutomata(&a1, 0);
NotDeterministicFiniteAutomata newAutomata = NotDeterministicFiniteAutomata();
newAutomata.setInitialState(a1.getInitialState());
for(int s: a1.getAlphabet()){
Expand All @@ -57,7 +57,7 @@ NotDeterministicFiniteAutomata AutomataOperations::nfaConcatenation(NotDetermini
for(int state: a1.getSates()){
newAutomata.addState(state);
}
renameAutomata(a2, counter);
renameAutomata(&a2, counter);
for(int state: a2.getSates()){
newAutomata.addState(state);
}
Expand All @@ -70,7 +70,7 @@ NotDeterministicFiniteAutomata AutomataOperations::nfaConcatenation(NotDetermini

void AutomataOperations::kleeneClosure(NotDeterministicFiniteAutomata a1) {
NotDeterministicFiniteAutomata kleeneNDA = *new NotDeterministicFiniteAutomata();
int cant = renameAutomata(a1, 1);
int cant = renameAutomata(&a1, 1);
int newQ0 = 0;
a1.addState(newQ0);
a1.addPath(newQ0, LAMBDA, a1.getInitialState());
Expand Down
2 changes: 1 addition & 1 deletion TP/auxiliarmethods/AutomataOperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AutomataOperations {
static NotDeterministicFiniteAutomata nfaConcatenation(NotDeterministicFiniteAutomata a1, NotDeterministicFiniteAutomata a2);
static void kleeneClosure(NotDeterministicFiniteAutomata a1);
static DeterministicFiniteAutomata minimization(DeterministicFiniteAutomata dfa);
static int renameAutomata(NotDeterministicFiniteAutomata *a1, int counter);
private:
static int renameAutomata(NotDeterministicFiniteAutomata a1, int counter);
static bool checkSameEquivalenceClass(const set<int>& delta1, set<int> delta2, const vector<set<set<int>>>& states);
};
7 changes: 0 additions & 7 deletions TP/ejemplos_documentados/ex2_file_creation.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
/**
* En este programa se probará la función de cargar un automata
* por medio de la clase DeterministicFiniteAutomata y guardarlo en un archivo.
* El automata de ejemplo y las instrucciones de compilación está descrito en ex2_readme.txt
* El archivo de salida será automata2.dot
*/

#include <bits/stdc++.h>
#include "../automata/ndfa/NotDeterministicFiniteAutomata.h"
#include "../parser/Parser.h"
Expand Down
18 changes: 18 additions & 0 deletions TP/testing/TestRename.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "TestRename.h"
int main() {
NotDeterministicFiniteAutomata ndfa = *new NotDeterministicFiniteAutomata();
ndfa.setInitialState(9);
ndfa.addState(2);
ndfa.addState(18);
ndfa.addState(9);
ndfa.addState(12);
ndfa.addPath(9, 0, 12);
ndfa.addPath(12, 0, 18);
ndfa.addPath(18, 0, 2);
ndfa.setFinalState({2});
ndfa.setAlphabet({0});
cout << NDFAToString::ndfaToString(ndfa);
AutomataOperations::renameAutomata(&ndfa, 0);
cout << NDFAToString::ndfaToString(ndfa);

}
11 changes: 11 additions & 0 deletions TP/testing/TestRename.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef TPOB1_TESTRENAME_H
#define TPOB1_TESTRENAME_H
#include "../automata/ndfa/NotDeterministicFiniteAutomata.h"
#include "../parser/automata-to-string/ndfa/NDFAToString.h"
#include "../auxiliarmethods/AutomataOperations.h"
class TestRename {

};


#endif //TPOB1_TESTRENAME_H
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{
"directoryIndex" : 0,
"id" : "tpOb1::@6890427a1f51a3e7e1df",
"jsonFile" : "target-tpOb1-Debug-1ee2742130baf9c3ee0a.json",
"jsonFile" : "target-tpOb1-Debug-b57a11822714e49c8c60.json",
"name" : "tpOb1",
"projectIndex" : 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"objects" :
[
{
"jsonFile" : "codemodel-v2-c4cdf99b3a4516340122.json",
"jsonFile" : "codemodel-v2-e512d408a39551568842.json",
"kind" : "codemodel",
"version" :
{
Expand Down Expand Up @@ -86,7 +86,7 @@
},
"codemodel-v2" :
{
"jsonFile" : "codemodel-v2-c4cdf99b3a4516340122.json",
"jsonFile" : "codemodel-v2-e512d408a39551568842.json",
"kind" : "codemodel",
"version" :
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
19,
20,
22,
23
23,
26
]
}
],
Expand Down Expand Up @@ -114,7 +115,8 @@
19,
20,
22,
23
23,
26
]
},
{
Expand All @@ -128,7 +130,8 @@
8,
15,
21,
24
24,
25
]
}
],
Expand Down Expand Up @@ -275,6 +278,17 @@
"backtrace" : 1,
"path" : "TP/auxiliarmethods/AutomataOperations.h",
"sourceGroupIndex" : 1
},
{
"backtrace" : 1,
"path" : "TP/testing/TestRename.h",
"sourceGroupIndex" : 1
},
{
"backtrace" : 1,
"compileGroupIndex" : 0,
"path" : "TP/testing/TestRename.cpp",
"sourceGroupIndex" : 0
}
],
"type" : "EXECUTABLE"
Expand Down
4 changes: 2 additions & 2 deletions cmake-build-debug/CMakeFiles/Makefile2
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ clean: CMakeFiles/tpOb1.dir/clean
CMakeFiles/tpOb1.dir/all:
$(MAKE) $(MAKESILENT) -f CMakeFiles/tpOb1.dir/build.make CMakeFiles/tpOb1.dir/depend
$(MAKE) $(MAKESILENT) -f CMakeFiles/tpOb1.dir/build.make CMakeFiles/tpOb1.dir/build
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --progress-dir=/home/ignaciodias/Desktop/uni/automatas/automataTPO1/cmake-build-debug/CMakeFiles --progress-num=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 "Built target tpOb1"
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --progress-dir=/home/ignaciodias/Desktop/uni/automatas/automataTPO1/cmake-build-debug/CMakeFiles --progress-num=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 "Built target tpOb1"
.PHONY : CMakeFiles/tpOb1.dir/all

# Build rule for subdir invocation for target.
CMakeFiles/tpOb1.dir/rule: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /home/ignaciodias/Desktop/uni/automatas/automataTPO1/cmake-build-debug/CMakeFiles 18
$(CMAKE_COMMAND) -E cmake_progress_start /home/ignaciodias/Desktop/uni/automatas/automataTPO1/cmake-build-debug/CMakeFiles 19
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 CMakeFiles/tpOb1.dir/all
$(CMAKE_COMMAND) -E cmake_progress_start /home/ignaciodias/Desktop/uni/automatas/automataTPO1/cmake-build-debug/CMakeFiles 0
.PHONY : CMakeFiles/tpOb1.dir/rule
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion cmake-build-debug/CMakeFiles/Progress/5

This file was deleted.

1 change: 0 additions & 1 deletion cmake-build-debug/CMakeFiles/Progress/6

This file was deleted.

2 changes: 1 addition & 1 deletion cmake-build-debug/CMakeFiles/Progress/count.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
19
2 changes: 1 addition & 1 deletion cmake-build-debug/CMakeFiles/progress.marks
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
19
1 change: 1 addition & 0 deletions cmake-build-debug/CMakeFiles/tpOb1.dir/DependInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(CMAKE_DEPENDS_DEPENDENCY_FILES
"/home/ignaciodias/Desktop/uni/automatas/automataTPO1/TP/parser/Parser.cpp" "CMakeFiles/tpOb1.dir/TP/parser/Parser.cpp.o" "gcc" "CMakeFiles/tpOb1.dir/TP/parser/Parser.cpp.o.d"
"/home/ignaciodias/Desktop/uni/automatas/automataTPO1/TP/parser/automata-to-string/dfa/DFAToString.cpp" "CMakeFiles/tpOb1.dir/TP/parser/automata-to-string/dfa/DFAToString.cpp.o" "gcc" "CMakeFiles/tpOb1.dir/TP/parser/automata-to-string/dfa/DFAToString.cpp.o.d"
"/home/ignaciodias/Desktop/uni/automatas/automataTPO1/TP/parser/automata-to-string/ndfa/NDFAToString.cpp" "CMakeFiles/tpOb1.dir/TP/parser/automata-to-string/ndfa/NDFAToString.cpp.o" "gcc" "CMakeFiles/tpOb1.dir/TP/parser/automata-to-string/ndfa/NDFAToString.cpp.o.d"
"/home/ignaciodias/Desktop/uni/automatas/automataTPO1/TP/testing/TestRename.cpp" "CMakeFiles/tpOb1.dir/TP/testing/TestRename.cpp.o" "gcc" "CMakeFiles/tpOb1.dir/TP/testing/TestRename.cpp.o.d"
"/home/ignaciodias/Desktop/uni/automatas/automataTPO1/TP/testing/fileToNdfa.cpp" "CMakeFiles/tpOb1.dir/TP/testing/fileToNdfa.cpp.o" "gcc" "CMakeFiles/tpOb1.dir/TP/testing/fileToNdfa.cpp.o.d"
"/home/ignaciodias/Desktop/uni/automatas/automataTPO1/TP/testing/ndfaToFile.cpp" "CMakeFiles/tpOb1.dir/TP/testing/ndfaToFile.cpp.o" "gcc" "CMakeFiles/tpOb1.dir/TP/testing/ndfaToFile.cpp.o.d"
"/home/ignaciodias/Desktop/uni/automatas/automataTPO1/TP/testing/testClausuraLambda.cpp" "CMakeFiles/tpOb1.dir/TP/testing/testClausuraLambda.cpp.o" "gcc" "CMakeFiles/tpOb1.dir/TP/testing/testClausuraLambda.cpp.o.d"
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit e8fe82c

Please sign in to comment.