|##########|
|#MAGIC   #|BMOLIJHI
|#PROJECT #|""
|#PATHS   #|"StdProject"
|#FLAGS   #|xx---x--x----xx-----------------
|#USERSW  #|--------------------------------
|#USERMASK#|--------------------------------
|#SWITCHES#|x----xxxxx-xx---
|##########|
DEFINITION MODULE OFunctions;

FROM Resources IMPORT ContextPtr;

EXCEPTION
  WrongParamsNum  : "Wrong number of parameters";
  SyntaxError     : "Syntactic error in expression";

TYPE
  Expression  = HIDDEN;
  Variable    = HIDDEN;
  VarDict     = HIDDEN;

  Function    = POINTER TO FunctionO;
  FunctionO   = OBJECT
                  con         : ContextPtr;
                  ex          : Expression;
                  varDict     : VarDict;
                  variables   : CLASSPTR TO ARRAY OF Variable;

                  CONSTRUCTOR Create(REF str     : STRING;
                                         context : ContextPtr := NIL;
                                     REF vars    : LIST OF STRING);

                  CONSTRUCTOR Differentiate(    of      : Function;
                                            REF after   : STRING;
                                                context : ContextPtr := NIL);

                  DESTRUCTOR Delete;

                  METHOD Eval(vars : LIST OF LONGREAL):LONGREAL;

                  $$OwnHeap:=TRUE
                  METHOD toString():STRING;
                END;

PROCEDURE CheckFunction(REF str  : STRING;
                        REF vars : LIST OF STRING):INTEGER;

END OFunctions.

