int FTC_Position; /* FUNCTION TO CALCULATE CURRENT READ POSITION*/
STACK <int> PriorityBuf; /* PRIORITY STACK */
STACK <long double> NumberBuf; /* NUMBER STACK */
int LastPriority; /* LAST PRIORITY FOUND */
int RisePriority; /* PRIORITY RISER */
bool IsCorrect; /* THIS PARAMETER IS TRUE IF FORMULA IS CORRECT */
private:
/* FILTER FUNCTION DEFINITIONS */
/* THIS FUNCTION DELETES ALL SPACES IN CALCULATION FORMULA */
void DeleteSymbols (void)
{
char *result = (char*) malloc (0);
int pos = 0, i = 0;
while (i < FTC_Length)
{
if (FTC[i] != ' ' && FTC[i] != 10 && FTC[i] != 13)
{
result = (char*)realloc (result, pos + 1);
result[pos] = FTC[i];
pos++;
i++;
}
else
i++;
}
free (FTC);
FTC = result;
FTC_Length = pos;
}
/* END OF 'DeleteSymbols' FUNCTION */
int FunctionCall (char elem)
{
/* switch (elem)
{
case 's':
case 'S':
if (FTC[FTC_Position + 1] == 'i' || FTC[FTC_Position + 1] == 'I' &&
FTC[FTC_Position + 2] == 'n' || FTC[FTC_Position + 2] == 'N')
return 600;
case 'c':
case 'C':
if (FTC[FTC_Position + 1] == 'o' || FTC[FTC_Position + 1] == 'O' &&
FTC[FTC_Position + 2] == 's' || FTC[FTC_Position + 2] == 'S')
return 601;
if (FTC[FTC_Position + 1] == 't' || FTC[FTC_Position + 1] == 'T' &&
FTC[FTC_Position + 2] == 'g' || FTC[FTC_Position + 2] == 'G')
return 604;
case 't':
case 'T':
if (FTC[FTC_Position + 1] == 'a' || FTC[FTC_Position + 1] == 'A' &&
FTC[FTC_Position + 2] == 'n' || FTC[FTC_Position + 2] == 'N')
return 605;
case 'a':
case 'A':
if (FTC[FTC_Position + 1] == 's' || FTC[FTC_Position + 1] == 'S' &&
FTC[FTC_Position + 2] == 'i' || FTC[FTC_Position + 2] == 'I' &&
FTC[FTC_Position + 3] == 'n' || FTC[FTC_Position + 3] == 'N')
return 602;
if (FTC[FTC_Position + 1] == 'c' || FTC[FTC_Position + 1] == 'C' &&
FTC[FTC_Position + 2] == 'o' || FTC[FTC_Position + 2] == 'O' &&
FTC[FTC_Position + 3] == 's' || FTC[FTC_Position + 3] == 'S')
return 603;
if (FTC[FTC_Position + 1] == 't' || FTC[FTC_Position + 1] == 'T' &&
FTC[FTC_Position + 2] == 'a' || FTC[FTC_Position + 2] == 'A' &&
FTC[FTC_Position + 3] == 'n' || FTC[FTC_Position + 3] == 'N')
return 606;
/* if (FTC[FTC_Position + 1] == 'c' || FTC[FTC_Position + 1] == 'C' &&
FTC[FTC_Position + 2] == 't' || FTC[FTC_Position + 2] == 'T' &&
FTC[FTC_Position + 3] == 'g' || FTC[FTC_Position + 3] == 'G')
return 607;
}*/
return 0;
}
/* THIS FUNCTION CHECKS FOR PRIORITY ELEMENTS */
bool isprior (char elem)
{
if (elem == '(' || elem == ')' || elem == '+' ||
elem == '-' || elem == '*' || elem == '/' ||
elem == '^' || elem == '!' ||
FunctionCall (elem))
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.