//
//  NAME
//    eval.h
//
//  DESCRIPTION
//    This file contains the type definitions and function prototypes
//    exported by the Evaluation module.
//

#ifndef _eval_h_
#define _eval_h_


//
//  NAME
//    operation
//
//  DESCRIPTION
//    This data type models an operation.
//

enum operation { Constant,
                 Addition,
                 Subtraction,
                 Multiplication,
                 Division
               };


//
//  NAME
//    expr
//
//  DESCRIPTION
//    This data type models an expression.
//
//  MEMBERS
//    oper   - operation of the expression.
//    number - value if the expression is a constant.
//    op1    - pointer to the first operand.  If the expression
//               is a constant, then op1 is set to NULL.
//    op2    - pointer to the second operand.  If the expression
//               is a constant, then op2 is set to NULL.
//

struct expr {
   operation   oper;
   double      number;
   expr      * op1;
   expr      * op2;
   };


//
//  NAME
//    evaluate
//
//  DESCRIPTION
//    This function evaluates an expression.
//
//  PARAMETERS
//    e  (in) - expression to evaluate.
//
//  RETURNS
//    value of the expression.
//

double evaluate(const expr * e);


//
//  NAME
//    freeExpr
//
//  DESCRIPTION
//    This function frees the memory allocated to an expression.
//
//  PARAMETERS
//    e  (in) - expression to free.
//
//  RETURNS
//    (none)
//

void freeExpr(expr * e);


//
//  NAME
//    display
//
//  DESCRIPTION
//    This function displays an expression.
//
//  PARAMETERS
//    e  (in) - expression to display.
//
//  RETURNS
//    (none)
//

void display(const expr * e);


#endif