diff --git a/Hazard/Hazard/CParser.cpp b/Hazard/Hazard/CParser.cpp index 5cb8b78..3b42295 100644 --- a/Hazard/Hazard/CParser.cpp +++ b/Hazard/Hazard/CParser.cpp @@ -54,7 +54,7 @@ int CParser::yyparse(PrimImplikantCollection* &pic, vector* &variables) { bool KNFset = false; int tok; - if(prflag)fprintf(IP_List,"%5d ",(int)IP_LineNumber); + if(prflag)fprintf(IP_List,"%5d ", IP_LineNumber); /* * Go parse things! @@ -96,7 +96,7 @@ int CParser::yyparse(PrimImplikantCollection* &pic, vector* &variables) pic->add(yylval.s.c_str()); break; case INTEGER1: - printf("Term Key %d\n",yylval.i); + printf("Term Key %d\n", (unsigned int)yylval.i); pic->add(yylval.i); break; case (int)'>': diff --git a/Hazard/Hazard/PrimImplikant.cpp b/Hazard/Hazard/PrimImplikant.cpp index 2985a42..252e484 100644 --- a/Hazard/Hazard/PrimImplikant.cpp +++ b/Hazard/Hazard/PrimImplikant.cpp @@ -5,17 +5,16 @@ using namespace std; -bool PrimImplikant::valueAt(int pos) { - for (vector::iterator i = implikanten.begin(); i < implikanten.end(); ++i) - { +bool PrimImplikant::valueAt(unsigned int pos) { + for (vector::iterator i = implikanten.begin(); i < implikanten.end(); ++i) if (*i == pos) return true; - } + return false; } void PrimImplikant::parser(string input) { // Analyser - int implikant = 0; + unsigned int implikant = 0; string text0 = ""; string text1 = ""; for (unsigned int i = 0; i < input.size(); i++) @@ -37,7 +36,7 @@ void PrimImplikant::parser(string input) { // Analyser return; } implikant <<= 1; // *2 - implikant += (int)c - (int)'0'; + implikant += (unsigned int)c - (unsigned int)'0'; } implikanten.push_back(implikant); } \ No newline at end of file diff --git a/Hazard/Hazard/PrimImplikant.h b/Hazard/Hazard/PrimImplikant.h index 61a8ac7..ee26dc4 100644 --- a/Hazard/Hazard/PrimImplikant.h +++ b/Hazard/Hazard/PrimImplikant.h @@ -16,20 +16,32 @@ public: name = input; parser(input); } - PrimImplikant(int input) + PrimImplikant(unsigned int input) { - char nameC[sizeof(int)*8+1]; - _itoa_s(input, nameC, sizeof(int)*8+1, 10); + char nameC[sizeof(unsigned int)*8+1]; + _itoa_s(input, nameC, sizeof(unsigned int)*8+1, 10); name = nameC; implikanten.push_back(input); } + PrimImplikant(unsigned int input1, unsigned int input2) + { + char nameC[sizeof(unsigned int)*8+1]; + _itoa_s(input1, nameC, sizeof(unsigned int)*8+1, 10); + name = nameC; + _itoa_s(input2, nameC, sizeof(unsigned int)*8+1, 10); + name.append(" & "); + name.append(nameC); - bool PrimImplikant::valueAt(int position); + implikanten.push_back(input1); + implikanten.push_back(input2); + } + + bool PrimImplikant::valueAt(unsigned int position); void PrimImplikant::parser(string input); private: - vector implikanten; + vector implikanten; }; #endif \ No newline at end of file diff --git a/Hazard/Hazard/PrimImplikantCollection.cpp b/Hazard/Hazard/PrimImplikantCollection.cpp index 4174e9b..e834196 100644 --- a/Hazard/Hazard/PrimImplikantCollection.cpp +++ b/Hazard/Hazard/PrimImplikantCollection.cpp @@ -14,13 +14,18 @@ void PrimImplikantCollection::add(string input) PrimImplikant* PI = new PrimImplikant(input); PIVector.push_back(PI); } -void PrimImplikantCollection::add(int input) +void PrimImplikantCollection::add(unsigned int input) { PrimImplikant* PI = new PrimImplikant(input); PIVector.push_back(PI); } +void PrimImplikantCollection::add(unsigned int input1, unsigned int input2) +{ + PrimImplikant* PI = new PrimImplikant(input1, input2); + PIVector.push_back(PI); +} -bool PrimImplikantCollection::valueAt(int position) +bool PrimImplikantCollection::valueAt(unsigned int position) { for (vector::iterator i = PIVector.begin(); i < PIVector.end(); i++) if ((*i)->valueAt(position)) @@ -28,7 +33,7 @@ bool PrimImplikantCollection::valueAt(int position) return false; } -PrimImplikantCollection PrimImplikantCollection::primImplikantenAt(int position) +PrimImplikantCollection PrimImplikantCollection::primImplikantenAt(unsigned int position) { PrimImplikantCollection pic; for (vector::iterator i = PIVector.begin(); i < PIVector.end(); i++) @@ -52,7 +57,7 @@ PrimImplikant* PrimImplikantCollection::front() return this->PIVector.front(); } -PrimImplikant* PrimImplikantCollection::at(int const &index) +PrimImplikant* PrimImplikantCollection::at(unsigned 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 df6b404..4bd5151 100644 --- a/Hazard/Hazard/PrimImplikantCollection.h +++ b/Hazard/Hazard/PrimImplikantCollection.h @@ -11,17 +11,18 @@ class PrimImplikantCollection{ public: void add(PrimImplikant* &PI); void add(string input); - void add(int input); + void add(unsigned int input); + void add(unsigned int input1, unsigned int input2); - bool valueAt(int position); - PrimImplikantCollection primImplikantenAt(int position); + bool valueAt(unsigned int position); + PrimImplikantCollection primImplikantenAt(unsigned int position); unsigned int size(); PrimImplikant* back(); PrimImplikant* front(); - PrimImplikant* at(int const &index); - PrimImplikant* operator[](int const &index); - const PrimImplikant* operator[](int const &index) const; + PrimImplikant* at(unsigned int const &index); + PrimImplikant* operator[](unsigned int const &index); + const PrimImplikant* operator[](unsigned int const &index) const; ~PrimImplikantCollection() // destructor {