Added output in to error file in CParser

This commit is contained in:
Jonny007-MKD 2013-11-12 23:48:24 +01:00
parent 070e2cba9e
commit c8c36676b4
3 changed files with 23 additions and 5 deletions

View File

@ -111,9 +111,15 @@ int CParser::yyparse(PrimImplikantCollection* &pic, vector<string>* &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");
}
}
}

View File

@ -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<Cell*> 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);

View File

@ -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<PrimImplikant*> PIVector;
};