home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / calculat / doit.zip / DO_TYPE.PAS < prev    next >
Pascal/Delphi Source File  |  1989-09-23  |  5KB  |  117 lines

  1. Unit Do_type;
  2.  
  3. (*
  4. ┌───────────────────────────────────────────────────────────────────────────┐
  5. │                         Unidad DO_TYPE.PAS                                │
  6. ├───────────────────────────────────────────────────────────────────────────┤
  7. │   Versión             : 1.0                                               │
  8. │   Computadora         : IBM-PC o compatible                               │
  9. │   Lenguaje            : Turbo Pascal 5.5                                  │
  10. │   Autor               : Bernardo Zamora Etcharren                         │
  11. ├───────────────────────────────────────────────────────────────────────────┤
  12. │   Unit that defines variables for all units.                              │
  13. └───────────────────────────────────────────────────────────────────────────┘
  14. *)
  15.  
  16. INTERFACE
  17.  
  18. Const
  19.   MaxOpSize      = 6;  { maximum size of operation's names ie [sin,cos,...] }
  20.  
  21.   MaxConstantes  = 4;  { How many constants defined         }
  22.   MaxOperaciones = 30; { number of UNARY operations defined
  23.                          sin, con, tanh, log, abs,...       }
  24.   MaxStack       = 50;  { maximum stack size                }
  25.  
  26.  
  27. Type
  28.   do_element = record     { for each node in the stack }
  29.     tipo       : char;    { Operacion,Unitaria,Numero,Variable,'X',Parentesis }
  30.     operacion  : string[MaxOpSize]; { +,-,*,log... or name_of_variable }
  31.     numero     : real;
  32.   end;
  33.   Do_Stack    = array[0..50] of do_element;
  34.   Rpn_type = record
  35.     error      : integer;  { any error?            }
  36.     message,               { error message         }
  37.     fun_string,            { original expression   }
  38.     rpn_string : string;   { new RPN expression    }
  39.     s1         : do_stack; { stack with the RPN function to be evaluated }
  40.     p1         : integer;  { # of [numbers & ops] in the RPN stack       }
  41.   end;
  42.   Constant_type = record
  43.     letra : char;          { constant letter       }
  44.     valor : real;          { value of the letter   }
  45.     expln : string;        { explanation of letter }
  46.   end;
  47.  
  48.  
  49.  
  50. Const
  51.   Constantes  : array [1..MaxConstantes] of constant_type = (
  52.   (letra:'E';valor:2.718281828;expln:'Eulers constant'),
  53.   (letra:'G';valor:9.80665;expln:'Gravity constant'),
  54.   (letra:'P';valor:3.1415926535897932385;expln:'Pi'),
  55.   (letra:'C';valor:2.99792458E8;expln:'Speed of light') );
  56.  
  57.   Arreglo : array [1..MaxOperaciones] of string[MaxOpSize] = (
  58.  
  59.   'SIN'  ,   'COS'  ,  'TAN'  ,   'COT'  , 'SEC'  ,   'CSC'  ,
  60.   'LN'   ,   'LOG'  ,  'INT'  ,   'ROUND',
  61.   'FRAC' ,   'ABS'  ,  'SGN'  ,   'SQRT' ,
  62.   'SINH' ,   'COSH' ,  'TANH' ,   'COTH' , 'SECH' ,   'CSCH' ,
  63.   'ASIN' ,   'ACOS' ,  'ATAN' ,   'ACOT' , 'ASEC' ,   'ACSC' ,
  64.   'RAD'  ,   'GRADOS', '-'    ,   'EXP'  ) ;
  65.  
  66. { ------------ Error codes returned during conversion --------------- }
  67.  
  68.   ERROR_PUSH_S           = 'Error in Push';
  69.   ERROR_PUSH             = 1;
  70.   ERROR_PARENTESIS_S     = 'Check the parenthesis';
  71.   ERROR_PARENTESIS       = 2;
  72.   ERROR_POP_S            = 'Error in Pop';
  73.   ERROR_POP              = 3;
  74.   ERROR_UNRECOGNIZE_S    = 'Cant recognize : ';
  75.   ERROR_UNRECOGNIZE      = 4;
  76.   ERROR_PARENTESIS_VACIOS_S = 'Empty group of parenthesis';
  77.   ERROR_PARENTESIS_VACIOS   = 5;
  78.   ERROR_EXTRA_PARENTESIS_S  = 'Extra parentesis : ';
  79.   ERROR_EXTRA_PARENTESIS    = 6;
  80.   ERROR_WEIRD_PARENTESIS_S  = 'Error in parenthesis : different class or incorrect order';
  81.   ERROR_WEIRD_PARENTESIS    = 7;
  82.   ERROR_EXTRA_SYMBOL_S      = 'Extra symbol : ';
  83.   ERROR_EXTRA_SYMBOL        = 8;
  84.   ERROR_NO_OPERATION_S      = 'No operation to evaluate!';
  85.   ERROR_NO_OPERATION        = 9;
  86.  
  87.  
  88. { ------------ Error codes returned during evaluation --------------- }
  89.  
  90.   ERROR_TANGENTE_S       = 'Tan(pi/2)';   ERROR_TANGENTE         = 1;
  91.   ERROR_COTANGENTE_S     = 'Cot(0)';      ERROR_COTANGENTE       = 2;
  92.   ERROR_SECANTE_S        = 'Sec(pi/2)';   ERROR_SECANTE          = 3;
  93.   ERROR_COSECANTE_S      = 'Csc(0)';      ERROR_COSECANTE        = 4;
  94.   ERROR_LN_S             = 'Ln(x<=0)';    ERROR_LN               = 5;
  95.   ERROR_LOG_S            = 'Log(x<=0)';   ERROR_LOG              = 6;
  96.   ERROR_SQRT_S           = 'Sqrt(x<=)';   ERROR_SQRT             = 7;
  97.  
  98.   ERROR_SIN_INV_S        = 'SinI(?)';     ERROR_SIN_INV          = 8;
  99.   ERROR_COS_INV_S        = 'CosI(?)';     ERROR_COS_INV          = 9;
  100.   ERROR_SEC_INV_S        = 'SecI(?)';     ERROR_SEC_INV          = 10;
  101.   ERROR_CSC_INV_S        = 'CscI(?)';     ERROR_CSC_INV          = 11;
  102.  
  103.   ERROR_TAN_HIP_S        = 'TanH(?)';     ERROR_TAN_HIP          = 12;
  104.   ERROR_COT_HIP_S        = 'CotH(?)';     ERROR_COT_HIP          = 13;
  105.   ERROR_SEC_HIP_S        = 'SecH(?)';     ERROR_SEC_HIP          = 14;
  106.   ERROR_CSC_HIP_S        = 'CscH(?)';     ERROR_CSC_HIP          = 15;
  107.  
  108.   ERROR_X_ENTRE_0_S      = 'x/0';         ERROR_X_ENTRE_0        = 16;
  109.  
  110.   ERROR_EXP_Y_BASE_NEG_S = 'r^(-b)';      ERROR_EXP_Y_BASE_NEG   = 17;
  111.  
  112.  
  113. IMPLEMENTATION
  114.  
  115.  
  116. begin
  117. end.