diff --git a/Hazard/Hazard/CParser.cpp b/Hazard/Hazard/CParser.cpp index 227a181..39e96d9 100644 --- a/Hazard/Hazard/CParser.cpp +++ b/Hazard/Hazard/CParser.cpp @@ -111,9 +111,15 @@ int CParser::yyparse(PrimImplikantCollection* &pic, vector* &variables) if (tok == INTEGER1) { if (!KNFset) + { KNF = (yylval.i == 0); + KNFset = true; + } 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"); printf("*** FATAL ERROR *** You can only define either KNF or DNF!\n"); return 1; } @@ -332,7 +338,10 @@ int CParser::yylex() }else PushString((char)c); break; - default: printf("***Fatal Error*** Wrong case label in yylex\n"); + default: + fprintf(IP_Error, "*** FATAL ERROR *** Wrong case label in yylex\n"); + fprintf(IP_Error, "In line %3d: state %i", IP_LineNumber, s); + printf("***Fatal Error*** Wrong case label in yylex\n"); } } } \ No newline at end of file diff --git a/Hazard/Hazard/Hazard.cpp b/Hazard/Hazard/Hazard.cpp index d0e3101..30c7a41 100644 --- a/Hazard/Hazard/Hazard.cpp +++ b/Hazard/Hazard/Hazard.cpp @@ -28,14 +28,14 @@ int _tmain(int argc, _TCHAR* argv[]) system("pause"); return -1; } - fopen_s(&error, "..\\res\\error.txt", "w"); + fopen_s(&error, "..\\res\\errorParser.txt", "w"); if (error == 0) { cout << "Fehler Fehlerdatei"; system("pause"); return -1; } - fopen_s(&list, "..\\res\\list.txt", "w"); + fopen_s(&list, "..\\res\\listParser.txt", "w"); if (list == 0) { cout << "Fehler Listdatei"; @@ -51,7 +51,10 @@ int _tmain(int argc, _TCHAR* argv[]) parser.pr_tokentable(); parser.InitParse(input, error, list); if (parser.yyparse(globalPIC, variables) != 0) + { + system("pause"); return 1; + } system("pause"); /*pic.add(7); @@ -79,7 +82,7 @@ int _tmain(int argc, _TCHAR* argv[]) vector cells; cells.resize(numElements); - for (int i = 0; i < numElements; i++) + for (unsigned int i = 0; i < numElements; i++) { cells[i] = new Cell(i, globalPIC); printf("Pos %2d: %d\n", i, cells[i]->value); diff --git a/Hazard/Hazard/PrimImplikantCollection.h b/Hazard/Hazard/PrimImplikantCollection.h index 8f6eb1d..37806f4 100644 --- a/Hazard/Hazard/PrimImplikantCollection.h +++ b/Hazard/Hazard/PrimImplikantCollection.h @@ -15,9 +15,15 @@ public: bool valueAt(int position); PrimImplikantCollection primImplikantenAt(int position); + unsigned int size(); - void deleteAll(); + PrimImplikant* back(); + PrimImplikant* front(); + PrimImplikant* at(); + PrimImplikant* operator[](int const &index); + const PrimImplikant* operator[](int const &index) const; + ~PrimImplikantCollection(); // destructor private: vector PIVector; };