From 5608f2b400fdabfb194af7b8b708f21e526fad0d Mon Sep 17 00:00:00 2001 From: Jonny007-MKD <1-23-4-5@web.de> Date: Tue, 12 Nov 2013 23:58:15 +0100 Subject: [PATCH] Added back(), front(), at(int) and destructor of PrimImplikantCollection --- Hazard/Hazard/CParser.cpp | 4 ++-- Hazard/Hazard/Hazard.cpp | 6 +++--- Hazard/Hazard/PrimImplikantCollection.cpp | 15 +++++++++++++++ Hazard/Hazard/PrimImplikantCollection.h | 8 ++++++-- Hazard/res/errorParser.txt | 12 ++++++++++++ Hazard/res/list.txt | 0 Hazard/res/{error.txt => listParser.txt} | 0 7 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 Hazard/res/errorParser.txt delete mode 100644 Hazard/res/list.txt rename Hazard/res/{error.txt => listParser.txt} (100%) diff --git a/Hazard/Hazard/CParser.cpp b/Hazard/Hazard/CParser.cpp index 39e96d9..5cb8b78 100644 --- a/Hazard/Hazard/CParser.cpp +++ b/Hazard/Hazard/CParser.cpp @@ -118,8 +118,8 @@ int CParser::yyparse(PrimImplikantCollection* &pic, vector* &variables) else if ((yylval.i == 0) ^ KNF) { fprintf(IP_Error, "*** FATAL ERROR *** You can only define either KNF or DNF!\n"); - fprintf(IP_Error, "In line %3d: %s>%i", pic->back()->name, yylval.i); - fprintf(IP_Error, "In line %3d: Defined was: %s, but now shall be changed to %s", (int)IP_LineNumber, KNF ? "KNF" : "DNF", KNF ? "DNF" : "KNF"); + fprintf(IP_Error, "In line %3d: %s>%i\n", (int)IP_LineNumber, pic->back()->name.c_str(), yylval.i); + fprintf(IP_Error, "In line %3d: Defined was: %s, but now shall be changed to %s\n\n", (int)IP_LineNumber, KNF ? "KNF" : "DNF", KNF ? "DNF" : "KNF"); printf("*** FATAL ERROR *** You can only define either KNF or DNF!\n"); return 1; } diff --git a/Hazard/Hazard/Hazard.cpp b/Hazard/Hazard/Hazard.cpp index 30c7a41..50413d9 100644 --- a/Hazard/Hazard/Hazard.cpp +++ b/Hazard/Hazard/Hazard.cpp @@ -12,8 +12,8 @@ using namespace std; -unsigned int dimension = 0; -unsigned int numElements = 0; +unsigned int dimension = 0; // = variables.size() +unsigned int numElements = 0; // = 2 ^ dimension bool KNF = false; int _tmain(int argc, _TCHAR* argv[]) @@ -28,7 +28,7 @@ int _tmain(int argc, _TCHAR* argv[]) system("pause"); return -1; } - fopen_s(&error, "..\\res\\errorParser.txt", "w"); + fopen_s(&error, "..\\res\\errorParser.txt", "a"); if (error == 0) { cout << "Fehler Fehlerdatei"; diff --git a/Hazard/Hazard/PrimImplikantCollection.cpp b/Hazard/Hazard/PrimImplikantCollection.cpp index ebda576..4174e9b 100644 --- a/Hazard/Hazard/PrimImplikantCollection.cpp +++ b/Hazard/Hazard/PrimImplikantCollection.cpp @@ -40,4 +40,19 @@ PrimImplikantCollection PrimImplikantCollection::primImplikantenAt(int position) unsigned int PrimImplikantCollection::size() { return this->PIVector.size(); +} + +PrimImplikant* PrimImplikantCollection::back() +{ + return this->PIVector.back(); +} + +PrimImplikant* PrimImplikantCollection::front() +{ + return this->PIVector.front(); +} + +PrimImplikant* PrimImplikantCollection::at(int const &index) +{ + return this->PIVector.at(index); } \ No newline at end of file diff --git a/Hazard/Hazard/PrimImplikantCollection.h b/Hazard/Hazard/PrimImplikantCollection.h index 37806f4..df6b404 100644 --- a/Hazard/Hazard/PrimImplikantCollection.h +++ b/Hazard/Hazard/PrimImplikantCollection.h @@ -19,11 +19,15 @@ public: unsigned int size(); PrimImplikant* back(); PrimImplikant* front(); - PrimImplikant* at(); + PrimImplikant* at(int const &index); PrimImplikant* operator[](int const &index); const PrimImplikant* operator[](int const &index) const; - ~PrimImplikantCollection(); // destructor + ~PrimImplikantCollection() // destructor + { + for (unsigned int i = 0; i < this->size(); i++) + delete this->at(i); + } private: vector PIVector; }; diff --git a/Hazard/res/errorParser.txt b/Hazard/res/errorParser.txt new file mode 100644 index 0000000..eb13811 --- /dev/null +++ b/Hazard/res/errorParser.txt @@ -0,0 +1,12 @@ +*** FATAL ERROR *** You can only define either KNF or DNF! +In line 8211212: (null)>-1105314512 +In line 4: Defined was: DNF, but now shall be changed to KNF + +*** FATAL ERROR *** You can only define either KNF or DNF! +In line 4: 7>0 +In line 4: Defined was: DNF, but now shall be changed to KNF + +*** FATAL ERROR *** You can only define either KNF or DNF! +In line 4: 7>1 +In line 4: Defined was: KNF, but now shall be changed to DNF + diff --git a/Hazard/res/list.txt b/Hazard/res/list.txt deleted file mode 100644 index e69de29..0000000 diff --git a/Hazard/res/error.txt b/Hazard/res/listParser.txt similarity index 100% rename from Hazard/res/error.txt rename to Hazard/res/listParser.txt