/**********
Copyright © 1996 Norlinvest Ltd. All rights reserved.
Visual Code Model Generator, EDSpice, EDWin, EE Designer, CompCAD,
CAD 1000, CAD ABC and Visionics are trade marks of Norlinvest Ltd.
Copyright © 1983 - 1996.
*
*
Copyright 1990 Regents of the University of California.  All rights reserved.
Author: 1987 Wayne A. Christopher, U. C. Berkeley CAD Group 
**********/

#include "ifsim.h"

#ifndef INP_PARSE
#define INP_PARSE

typedef struct INPparseTree {
    IFparseTree p;
    struct INPparseNode *tree;  
    struct INPparseNode **derivs; 
} INPparseTree;

typedef struct INPparseNode {
    int type;    
    struct INPparseNode *left;  
    struct INPparseNode *right; 
    double constant;  
    int valueIndex;  
    char *funcname; 
    int funcnum;    
    double (*function)();  
} INPparseNode;

#define PT_PLACEHOLDER  0    
#define PT_PLUS     1
#define PT_MINUS    2
#define PT_TIMES    3
#define PT_DIVIDE   4
#define PT_POWER    5
#define PT_FUNCTION 6
#define PT_CONSTANT 7
#define PT_VAR      8
#define PT_COMMA    10


#define PTF_ACOS    0
#define PTF_ACOSH   1
#define PTF_ASIN    2
#define PTF_ASINH   3
#define PTF_ATAN    4
#define PTF_ATANH   5
#define PTF_COS     6
#define PTF_COSH    7
#define PTF_EXP     8
#define PTF_LN      9
#define PTF_LOG     10
#define PTF_SIN     11
#define PTF_SINH    12
#define PTF_SQRT    13
#define PTF_TAN     14
#define PTF_TANH    15
#define PTF_UMINUS  16
#define PTF_ABS		17
#define PTF_SGN		18
#define PTF_USTEP	19
#define PTF_URAMP	20


#define TOK_END         0
#define TOK_PLUS        1
#define TOK_MINUS       2
#define TOK_TIMES       3
#define TOK_DIVIDE      4
#define TOK_POWER       5
#define TOK_UMINUS      6
#define TOK_LPAREN      7
#define TOK_RPAREN      8
#define TOK_VALUE       9
#define TOK_COMMA       10


#define TYP_NUM         0
#define TYP_STRING      1
#define TYP_PNODE       2


typedef struct PTelement {
    int token;
    int type;
    union {
        char *string;
        double real;
        INPparseNode *pnode;
    } value;
} PTelement ;

#define PT_STACKSIZE 200


extern double PTplus();
extern double PTminus();
extern double PTtimes();
extern double PTdivide();
extern double PTpower();
extern double PTacos();
extern double PTabs();
extern double PTacosh();
extern double PTasin();
extern double PTasinh();
extern double PTatan();
extern double PTatanh();
extern double PTcos();
extern double PTcosh();
extern double PTexp();
extern double PTln();
extern double PTlog();
extern double PTsgn();
extern double PTsin();
extern double PTsinh();
extern double PTsqrt();
extern double PTtan();
extern double PTtanh();
extern double PTustep();
extern double PTuramp();
extern double PTuminus();


#ifdef __STDC__
extern int IFeval(IFparseTree *, double, double*, double*, double*);
#else /* stdc */
extern int IFeval();
#endif /* stdc */

#endif

