home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / irit / drawfn3s / expr2trl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-06  |  2.6 KB  |  92 lines

  1.  
  2. /*****************************************************************************
  3. * The local constants -    should be available only to expr2tree.c    module.         *
  4. *****************************************************************************/
  5.  
  6. #ifndef EXPR_2_TREE_LH
  7. #define EXPR_2_TREE_LH
  8.  
  9. #define MAX_PARSER_STACK    100         /* Depth of expression nesting. */
  10.  
  11. /*****************************************************************************
  12. * General definitions goes here:                         *
  13. *****************************************************************************/
  14.  
  15. #define    TAB        9
  16.  
  17. #ifndef LINE_LEN
  18. #define    LINE_LEN    255
  19. #endif    LINE_LEN
  20.  
  21. #ifndef TRUE
  22. #define TRUE        -1
  23. #define FALSE        0
  24. #endif
  25.  
  26. #ifndef INFINITY
  27. #define INFINITY  1e10
  28. #endif  INFINITY
  29.  
  30. #ifndef MIN
  31. #define MIN(x, y)        ((x) > (y) ? (y) : (x))
  32. #define MAX(x, y)        ((x) > (y) ? (x) : (y))
  33. #endif  MIN
  34.  
  35. /*****************************************************************************
  36. * Tokens used in the expression    to tree    conversion and tree definition.         *
  37. *****************************************************************************/
  38.  
  39. #define    ABS        10                           /* Functions. */
  40. #define    ARCCOS        11
  41. #define    ARCSIN        12
  42. #define    ARCTAN        13
  43. #define    COS        14
  44. #define    EXP        15
  45. #define    LN        16
  46. #define    LOG        17
  47. #define    SIN        18
  48. #define    SQR        19
  49. #define    SQRT        20
  50. #define    TAN        21
  51.  
  52. #define    PLUS        30                           /* Operators. */
  53. #define    MINUS        31
  54. #define    MULT        32
  55. #define    DIV        33
  56. #define MODULU        34
  57. #define    POWER        35
  58. #define    UNARMINUS   36
  59. #define MINIMUM        37
  60. #define MAXIMUM        38
  61.  
  62. #define    OPENPARA    40                         /* Paranthesis. */
  63. #define    CLOSPARA    41
  64.  
  65. #define    NUMBER        50                  /* Numbers (or parameter). */
  66. #define    PARAMETER   51
  67.  
  68. #define    TOKENERROR  -1
  69. #define TOKENSTART  60
  70. #define TOKENEND    61
  71.  
  72. /*****************************************************************************
  73. * The local function (static) prototypes:                     *
  74. *****************************************************************************/
  75.  
  76. static ExprNode *MyExprMalloc(void);
  77. static void MyExprFree(ExprNode *Ptr);
  78. static void MakeUpper(char *s);
  79. static ExprNode *OperatorPrecedence(char *s, int *i);
  80. static int TestPreceeding(int Token1, int Token2);
  81. static int GetToken(char *s, int *i, double *Data);
  82. static void LocalPrintTree(ExprNode *Root, int Level, char *Str);
  83.  
  84. #ifdef DERIVATIVE
  85. static ExprNode *DerivTree1(ExprNode *Root, int Param);
  86. static ExprNode *Gen1u2Tree(int Sign1, int Sign2, double Exponent,
  87.                             ExprNode *Expr);
  88. static ExprNode *Optimize(ExprNode *Root, int *Flag);
  89. #endif DERIVATIVE
  90.  
  91. #endif EXPR_2_TREE_LH
  92.