Added back(), front(), at(int) and destructor of PrimImplikantCollection
This commit is contained in:
parent
c8c36676b4
commit
5608f2b400
7 changed files with 38 additions and 7 deletions
|
@ -118,8 +118,8 @@ int CParser::yyparse(PrimImplikantCollection* &pic, vector<string>* &variables)
|
||||||
else if ((yylval.i == 0) ^ KNF)
|
else if ((yylval.i == 0) ^ KNF)
|
||||||
{
|
{
|
||||||
fprintf(IP_Error, "*** FATAL ERROR *** You can only define either KNF or DNF!\n");
|
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: %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", (int)IP_LineNumber, KNF ? "KNF" : "DNF", KNF ? "DNF" : "KNF");
|
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");
|
printf("*** FATAL ERROR *** You can only define either KNF or DNF!\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
unsigned int dimension = 0;
|
unsigned int dimension = 0; // = variables.size()
|
||||||
unsigned int numElements = 0;
|
unsigned int numElements = 0; // = 2 ^ dimension
|
||||||
bool KNF = false;
|
bool KNF = false;
|
||||||
|
|
||||||
int _tmain(int argc, _TCHAR* argv[])
|
int _tmain(int argc, _TCHAR* argv[])
|
||||||
|
@ -28,7 +28,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||||
system("pause");
|
system("pause");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fopen_s(&error, "..\\res\\errorParser.txt", "w");
|
fopen_s(&error, "..\\res\\errorParser.txt", "a");
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
{
|
{
|
||||||
cout << "Fehler Fehlerdatei";
|
cout << "Fehler Fehlerdatei";
|
||||||
|
|
|
@ -40,4 +40,19 @@ PrimImplikantCollection PrimImplikantCollection::primImplikantenAt(int position)
|
||||||
unsigned int PrimImplikantCollection::size()
|
unsigned int PrimImplikantCollection::size()
|
||||||
{
|
{
|
||||||
return this->PIVector.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);
|
||||||
}
|
}
|
|
@ -19,11 +19,15 @@ public:
|
||||||
unsigned int size();
|
unsigned int size();
|
||||||
PrimImplikant* back();
|
PrimImplikant* back();
|
||||||
PrimImplikant* front();
|
PrimImplikant* front();
|
||||||
PrimImplikant* at();
|
PrimImplikant* at(int const &index);
|
||||||
PrimImplikant* operator[](int const &index);
|
PrimImplikant* operator[](int const &index);
|
||||||
const PrimImplikant* operator[](int const &index) const;
|
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:
|
private:
|
||||||
vector<PrimImplikant*> PIVector;
|
vector<PrimImplikant*> PIVector;
|
||||||
};
|
};
|
||||||
|
|
12
Hazard/res/errorParser.txt
Normal file
12
Hazard/res/errorParser.txt
Normal file
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue