/*======================================================================*/
/*  Calculator Common Definitions Include File                          */
/*======================================================================*/

/* TPARSE definitions */

#define TPA$K_COUNT0        8 
#define TPA$M_BLANKS        1 
#define TPA$M_ABBREV        2 
#define TPA$M_ABBRFM        4 
#define TPA$M_AMBIG   0x10000 
#define TPA$K_LENGTH0    0x24 
#define TPA$C_LENGTH0    0x24 
#define TPA$S_BLANKS        1 
#define TPA$V_BLANKS        0 
#define TPA$S_ABBREV        1 
#define TPA$V_ABBREV        1 
#define TPA$S_ABBRFM        1 
#define TPA$V_ABBRFM        2 
#define TPA$S_AMBIG         1 
#define TPA$V_AMBIG      0x10 
                 
/* TPARSE argument block structure definition */

struct tpadef
{  int  tpa$l_count0;
   variant_union
   {  int  tpa$l_options;
      variant_struct
      {  char  tpadef$$_fill_2[3];
         char  tpa$b_mcount;
      }  mcount_union;
   }  options_union;
   int  tpa$l_stringcnt;
   int  tpa$l_stringptr;
   int  tpa$l_tokencnt;
   int  tpa$l_tokenptr;
   variant_union
   {  int   tpa$l_char;
      char  tpa$b_char;
   }  char_union;
   int  tpa$l_number;
   int  tpa$l_param;
};
                     
/* TPARSE tables */

globalref int CALCULATOR_STATES;
globalref int CALCULATOR_KEYWORDS;

/* calculator token types */

enum tokentype {UNKNOWN,        /* unknow token            */
                INTEGER,        /* integer value token     */
                FLOAT,          /* float value token       */
                BINARY_OP,      /* binary operator token   */
                FUNCTION,       /* function token          */
                UNARY_OP,       /* unary operator token    */
                PAREN};         /* open paren token        */

struct token_struct
   {
   enum tokentype type;
   variant_union
      {
      variant_struct
         {
         enum functype func;    /* function code           */
         int    prec;           /* precedence level        */
         char   oper;           /* operator character      */
         } operator;
      int    idata;             /* integer data            */
      double fdata;             /* float data              */
      } data;
   };

/* calculator math functions */

enum functype {ABS,             /* absolute value          */
               ACOS,            /* arc cosine              */
               ASIN,            /* arc sine                */
               ATAN,            /* arc tangent             */
               CEILING,         /* ceiling value           */
               COS,             /* cosine                  */
               COSH,            /* hyperbolic cosine       */
               EXP,             /* e rased to to a power   */
               FLT,             /* convert to float        */
               FLOOR,           /* floor value             */
               INT,             /* convert to integer      */
               LN,              /* natural logarithm       */
               LOG,             /* logarithm (base 10)     */
               POW,             /* raise to a power        */
               RAND,            /* pseudorandom number     */
               MAX,             /* minimum value           */
               MIN,             /* minimum value           */
               MOD,             /* remainder               */
               SEED,            /* seed pseudorandom number*/
               SIN,             /* sine                    */
               SINH,            /* hyperbolic sine         */
               SQRT,            /* square root             */
               TAN,             /* tangent                 */
               TANH};           /* hyperbolic tangent      */

/* calculator symbol storage definition */

#define symmax    100                /* maximum number of symbols     */
#define strsize    32                /* maximum size of symbol string */
                                     /* including the terminating \0  */
#define tokmax    200                /* maximum number of tokens      */
