home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / irit / drawfuns.arc / EXPR2TRL.H < prev    next >
C/C++ Source or Header  |  1989-07-29  |  5KB  |  180 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. /*****************************************************************************
  77. * The local constants -    should be available only to expr2tree.c    module.         *
  78. *****************************************************************************/
  79.  
  80. #ifndef EXPR_2_TREE_LH
  81. #define EXPR_2_TREE_LH
  82.  
  83. #define MAX_PARSER_STACK    100          /* Depth of expression nesting */
  84.  
  85. /*****************************************************************************
  86. * General definitions goes here:                         *
  87. *****************************************************************************/
  88.  
  89. #define    TAB        9
  90.  
  91. #ifndef LINE_LEN
  92. #define    LINE_LEN    255
  93. #endif    LINE_LEN
  94.  
  95. #ifndef TRUE
  96. #define TRUE        -1
  97. #define FALSE        0
  98. #endif
  99.  
  100. #ifndef INFINITY
  101. #define INFINITY  1e10
  102. #endif  INFINITY
  103.  
  104. #ifndef MIN
  105. #define MIN(x, y)        ((x) > (y) ? (y) : (x))
  106. #define MAX(x, y)        ((x) > (y) ? (x) : (y))
  107. #endif  MIN
  108.  
  109. /*****************************************************************************
  110. * Tokens used in the expression    to tree    conversion and tree definition.         *
  111. *****************************************************************************/
  112.  
  113. #define    ABS        10 /* Functions */
  114. #define    ARCCOS        11
  115. #define    ARCSIN        12
  116. #define    ARCTAN        13
  117. #define    COS        14
  118. #define    EXP        15
  119. #define    LN        16
  120. #define    LOG        17
  121. #define    SIN        18
  122. #define    SQR        19
  123. #define    SQRT        20
  124. #define    TAN        21
  125.  
  126. #define    PLUS        30 /* Operators */
  127. #define    MINUS        31
  128. #define    MULT        32
  129. #define    DIV        33
  130. #define MODULU        34
  131. #define    POWER        35
  132. #define    UNARMINUS   36
  133. #define MINIMUM        37
  134. #define MAXIMUM        38
  135.  
  136. #define    OPENPARA    40 /* Paranthesis */
  137. #define    CLOSPARA    41
  138.  
  139. #define    NUMBER        50 /* Numbers (or parameter) */
  140. #define    PARAMETER   51
  141.  
  142. #define    TOKENERROR  -1
  143. #define TOKENSTART  60
  144. #define TOKENEND    61
  145.  
  146. /*****************************************************************************
  147. * The local function (static) prototypes:                     *
  148. *****************************************************************************/
  149. static ExprNode *MyExprMalloc(void);
  150. static void MyExprFree(ExprNode *Ptr);
  151. static void MakeUpper(char *s);
  152. static ExprNode *OperatorPrecedence(char *s, int *i);
  153. static int TestPreceeding(int Token1, int Token2);
  154. static int GetToken(char *s, int *i, double *Data);
  155. static void LocalPrintTree(ExprNode *Root, int Level, char *Str);
  156.  
  157. #ifdef DERIVATIVE
  158. static ExprNode *DerivTree1(ExprNode *Root, int Param);
  159. static ExprNode *Gen1u2Tree(int Sign1, int Sign2, double Exponent,
  160.                             ExprNode *Expr);
  161. static ExprNode *Optimize(ExprNode *Root, int *Flag);
  162. #endif DERIVATIVE
  163.  
  164. #endif EXPR_2_TREE_LH
  165. static ExprNode *MyExprMalloc(void);
  166. static void MakeUpper(char *s);
  167. static ExprNode *OperatorPrecedence(char *s, int *i);
  168. static int TestPreceeding(int Token1, int Token2);
  169. static int GetToken(char *s, int *i, double *Data);
  170. static void LocalPrintTree(ExprNode *Root, int Level, char *Str);
  171.  
  172. #ifdef DERIVATIVE
  173. static ExprNode *DerivTree1(ExprNode *Root, int Param);
  174. static ExprNode *Gen1u2Tree(int Sign1, int Sign2, double Exponent,
  175.                             ExprNode *Expr);
  176. static ExprNode *Optimize(ExprNode *Root, int *Flag);
  177. #endif DERIVATIVE
  178.  
  179. #endif EXPR_2_TREE_LH
  180.