Написание калькулятора с разбором выражений, страница 3

          /*(elem == 's' && FTC[FTC_Position + 1] == 'i' && FTC[FTC_Position + 2] == 'n') ||

          (elem == 'c' && FTC[FTC_Position + 1] == 'o' && FTC[FTC_Position + 2] == 's'))/**/

        return true;

      return false;

    }

    /* END OF 'isprior' FUNCTION */

    /* THIS FUNCTION RETURNS PRIORITY */

    int SetPriority (char prt)

    {

       switch (prt)

       {

       case '(':

         return 800;

       case ')':

         return 900;

       case '+':

         return 100;

       case '-':

         return 105;

       case '*':

         return 205;

       case '/':

         return 200;

       case '^':

         return 300;

       case '!':

         return 400;

       /*case 's':

       case 'S':

         if (FunctionCall ('s')

           return 600;

         break;

       case 'c':

       case 'C':

         if (FunctionCall ('c')

           return 601;*/

       default:

         return FunctionCall (prt);

       }

       return -2;

    }

    /* END OF 'SetPriority' FUNCTION */

    /* THIS FUNCTION CHECKS FOR SIGN BEFORE NUMBER */

    bool IsSign (void)

    {

      switch (FTC [FTC_Position])

      {

      case '-':

      case '+':

        return true;

      }

      return false;

    }

    /* END OF 'IsSign' FUNCTION */

    /* THIS FUNCTION RETURNS FLOAT NUMBER FROM CALCULATION FORMULA */

    long double GetNumber (void)

    {

      bool LastDot = false;

      char *num = (char*)malloc (0);

      int i = 0;

      long double res;

      while (isdigit (FTC[FTC_Position]) || FTC [FTC_Position] == '.' && LastDot == false)

      {

        if (FTC [FTC_Position] == '.')

          LastDot = true;

        num = (char*)realloc (num, i + 1);

        num [i++] = FTC [FTC_Position++];

        if (FTC_Position >= FTC_Length)

          break;

      }

      res = atof (num);

      free (num);

      return res;

    }

    /* END OF 'GetNumber' FUNCTION */

  /* END OF FILTER FUNCTION DEFINITIONS */

  /* CHECK LAST ELEMENTS FUNCTIONS DEFINITION */

    /* THIS FUNCTION RETURNS LAST PUSHED PRIORITY MEMBER */

    int GetLastPriority (void)

    {

      if (PriorityBuf.TOP () == 0)

        return -0xAF;

      return PriorityBuf.LastElem ();

    }

    /* END OF 'GetLastPriority' FUNCTION */

    /* THIS FUNCTION LOOKS FOR NON-LAST ELEMAENT IN BUFFER */

    int LookForPriority (void)

    {

      int lp;

      if ( (lp = PriorityBuf.PrevElem ()) == NULL)

        return -0xAF;

      return lp;

    }

    /* END OF 'LookForPriority' FUNCTION */

    /* THIS FUNCTION RETURNS LAST PUSHED NUMBER */

    long double GetLastNumber (void)

    {

      long double ln = NumberBuf.LastElem ();

      if (ln == NULL)

        return -0xAF;

      return ln;

    }

    /* END OF 'GetLastMember' FUNCTION */

  /* END OF CHECK LAST ELEMENTS FUNCTION DEFINITIONS */

  /* DOUBLE STACK FUNCTIONS PUSH AND POP DEFINITIONS */

    /* THIS FUNCTION PUSH PRIORITY TO PRIORITY BUFFER */

    bool PUSH_Priority (void)

    {

      int p;

      switch (FTC [FTC_Position])

      {

      case '(':

        RisePriority += 1000;

        FTC_Position++;