// CodeGear C++Builder
// Copyright (c) 1995, 2009 by Embarcadero Technologies, Inc.
// All rights reserved

// (DO NOT EDIT: machine generated header) 'Fatexp.pas' rev: 21.00

#ifndef FatexpHPP
#define FatexpHPP

#pragma delphiheader begin
#pragma option push
#pragma option -w-      // All warnings off
#pragma option -Vx      // Zero-length empty class member functions
#pragma pack(push,8)
#include <System.hpp>	// Pascal unit
#include <Sysinit.hpp>	// Pascal unit
#include <Classes.hpp>	// Pascal unit
#include <Dialogs.hpp>	// Pascal unit
#include <Sysutils.hpp>	// Pascal unit
#include <Math.hpp>	// Pascal unit
#include <Variants.hpp>	// Pascal unit

//-- user supplied -----------------------------------------------------------

namespace Fatexp
{
//-- type declarations -------------------------------------------------------
#pragma option push -b-
enum TTokenType { ttNone, ttNumeric, ttParenthesis, ttOperation, ttString, ttParamDelimitor, ttVariable };
#pragma option pop

#pragma option push -b-
enum TEvaluateOrder { eoInternalFirst, eoEventFirst };
#pragma option pop

typedef void __fastcall (__closure *TOnEvaluate)(System::TObject* Sender, System::WideString Eval, System::Variant *Args, const int Args_Size, int ArgCount, System::Variant &Value, bool &Done);

typedef void __fastcall (__closure *TOnVariable)(System::TObject* Sender, System::AnsiString Variable, System::Variant &Value, bool &Done);

class DELPHICLASS TExpToken;
class PASCALIMPLEMENTATION TExpToken : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	System::AnsiString FText;
	TTokenType FTokenType;
	
public:
	__property System::AnsiString Text = {read=FText};
	__property TTokenType TokenType = {read=FTokenType, nodefault};
public:
	/* TObject.Create */ inline __fastcall TExpToken(void) : System::TObject() { }
	/* TObject.Destroy */ inline __fastcall virtual ~TExpToken(void) { }
	
};


class DELPHICLASS TExpParser;
class PASCALIMPLEMENTATION TExpParser : public System::TObject
{
	typedef System::TObject inherited;
	
protected:
	System::AnsiString FExpression;
	Classes::TList* FTokens;
	int FPos;
	
private:
	void __fastcall Clear(void);
	TExpToken* __fastcall GetToken(int Index);
	void __fastcall SetExpression(const System::AnsiString Value);
	
public:
	__fastcall TExpParser(void);
	__fastcall virtual ~TExpParser(void);
	TExpToken* __fastcall ReadFirstToken(void);
	TExpToken* __fastcall ReadNextToken(void);
	int __fastcall TokenCount(void);
	__property TExpToken* Tokens[int Index] = {read=GetToken};
	__property Classes::TList* TokenList = {read=FTokens};
	__property System::AnsiString Expression = {read=FExpression, write=SetExpression};
};


class DELPHICLASS TExpNode;
class PASCALIMPLEMENTATION TExpNode : public System::TObject
{
	typedef System::TObject inherited;
	
protected:
	System::TObject* FOwner;
	TExpNode* FParent;
	Classes::TList* FChildren;
	Classes::TList* FTokens;
	int FLevel;
	TExpToken* FToken;
	TOnEvaluate FOnEvaluate;
	TOnVariable FOnVariable;
	
private:
	TExpToken* __fastcall GetToken(int Index);
	TExpNode* __fastcall GetChildren(int Index);
	int __fastcall FindLSOTI(void);
	bool __fastcall ParseFunction(void);
	void __fastcall RemoveSorroundingParenthesis(void);
	void __fastcall SplitToChildren(int TokenIndex);
	System::Variant __fastcall Evaluate(void);
	System::Variant __fastcall Variable(void);
	__property TExpNode* Children[int Index] = {read=GetChildren};
	bool __fastcall ParseVariable(void);
	
public:
	__fastcall TExpNode(System::TObject* AOwner, TExpNode* AParent, Classes::TList* Tokens);
	__fastcall virtual ~TExpNode(void);
	void __fastcall Build(void);
	int __fastcall TokenCount(void);
	System::Variant __fastcall Calculate(void);
	__property TExpToken* Tokens[int Index] = {read=GetToken};
	__property TExpNode* Parent = {read=FParent};
	__property int Level = {read=FLevel, nodefault};
	__property TOnEvaluate OnEvaluate = {read=FOnEvaluate, write=FOnEvaluate};
	__property TOnVariable OnVarible = {read=FOnVariable, write=FOnVariable};
};


class DELPHICLASS TFunction;
class PASCALIMPLEMENTATION TFunction : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	typedef DynamicArray<System::Extended> _TFunction__1;
	
	
protected:
	System::AnsiString FAsString;
	System::AnsiString FName;
	System::AnsiString FHead;
	System::AnsiString FFunction;
	System::TObject* FOwner;
	int FArgCount;
	Classes::TStringList* FArgs;
	_TFunction__1 FValues;
	
private:
	void __fastcall SetAsString(const System::AnsiString Value);
	void __fastcall EvalArgs(System::TObject* Sender, System::AnsiString Eval, System::Variant *Args, const int Args_Size, int ArgCount, System::Variant &Value);
	
public:
	__fastcall TFunction(System::TObject* AOwner);
	__fastcall virtual ~TFunction(void);
	System::Extended __fastcall Call(System::Variant *Values, const int Values_Size);
	__property System::AnsiString AsString = {read=FAsString, write=SetAsString};
	__property System::AnsiString Name = {read=FName};
	__property int ArgCount = {read=FArgCount, nodefault};
	__property Classes::TStringList* Args = {read=FArgs};
};


class DELPHICLASS TFatExpression;
class PASCALIMPLEMENTATION TFatExpression : public Classes::TComponent
{
	typedef Classes::TComponent inherited;
	
protected:
	System::AnsiString FInfo;
	System::AnsiString FText;
	TEvaluateOrder FEvaluateOrder;
	TOnEvaluate FOnEvaluate;
	TOnVariable FOnVariable;
	System::Variant FValue;
	Classes::TStringList* FFunctions;
	
private:
	void __fastcall Compile(void);
	System::Variant __fastcall GetValue(void);
	void __fastcall SetInfo(System::AnsiString Value);
	void __fastcall Evaluate(System::AnsiString Eval, System::Variant *Args, const int Args_Size, System::Variant &Value);
	TFunction* __fastcall FindFunction(System::AnsiString FuncName);
	void __fastcall SetFunctions(Classes::TStringList* Value);
	void __fastcall SetText(const System::AnsiString Value);
	
public:
	__fastcall virtual TFatExpression(Classes::TComponent* AOwner);
	__fastcall virtual ~TFatExpression(void);
	__property System::Variant Value = {read=GetValue};
	
__published:
	__property System::AnsiString Text = {read=FText, write=SetText};
	__property System::AnsiString Info = {read=FInfo, write=SetInfo};
	__property Classes::TStringList* Functions = {read=FFunctions, write=SetFunctions};
	__property TEvaluateOrder EvaluateOrder = {read=FEvaluateOrder, write=FEvaluateOrder, nodefault};
	__property TOnEvaluate OnEvaluate = {read=FOnEvaluate, write=FOnEvaluate};
	__property TOnVariable OnVariable = {read=FOnVariable, write=FOnVariable};
};


//-- var, const, procedure ---------------------------------------------------

}	/* namespace Fatexp */
using namespace Fatexp;
#pragma pack(pop)
#pragma option pop

#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif	// FatexpHPP
