Class TCustomParser (unit Parser10)

Inherits from

TComponent

Constructors


constructor Create(AOwner: TComponent);

while OperationLoop<>nil


Functions

procedure AddFunctionOneParam(const AFunctionName: string; const Func: TMathProcedure);


procedure AddFunctionTwoParam(const AFunctionName: string; const Func: TMathProcedure);


procedure ClearFunction(const AFunctionName: string);

invalidate expression

procedure ClearFunctions;


procedure ClearVariable(const AVarName: string);

invalidate expression

procedure ClearVariables;


destructor Destroy;


procedure FreeExpression;

invalidate expression

function GetVariable(const VarName: string): extended;

is the variable name a valid identifier?

function ParseExpression(const AnExpression: string): boolean;

**************************************************************} { } { TCustomParser } { } { A base class which does not publish the variable properties } { and adds no functions by default } { } {

function SetVariable(VarName: string; const Value: extended): PParserFloat;

The PParserFloat returned points to the place in memory where the variable actually sits; to speed up assignment you can DIRECTLY assign data to the memory area.

function VariableExists(const AVarName: string): boolean;

invalidate expression

function CalcValue: extended;

this implies FExpression := AnExpression

procedure SetExpression(const AnExpression: string);


procedure SetVar(const VarName: string; const Value: extended);


Properties

property Expression : string

setting Expression automatically parses it Warning: exceptions MAY be raised, if OnParserError is NOT assigned, otherwise the event will be triggered in case of an error

property PascalNumberformat : boolean


property Value : extended


property LinkedOperationList : POperation


property ParserError : boolean


property Variable : extended


property A : ParserFloat

functions with TWO arguments, e.

property B : ParserFloat


property C : ParserFloat


property D : ParserFloat


property E : ParserFloat


property T : ParserFloat


property X : ParserFloat


property Y : ParserFloat


Events

event OnParserError : TParserExceptionEvent


Variables

FunctionOne : TStringList;

lists of available functions, see .

FunctionTwo : TStringList;

functions with ONE argument, e.

FA : ParserFloat;

some pre-allocated space for variables

FB : ParserFloat;


FC : ParserFloat;


FD : ParserFloat;


FE : ParserFloat;


FExpression : string;


FOnParserError : TParserExceptionEvent;


FParserError : boolean;


FPascalNumberformat : boolean;


FStartOperationList : POperation;


FT : ParserFloat;


FVariables : TStringList;


FX : ParserFloat;


FY : ParserFloat;



Constructors


constructor Create(AOwner: TComponent);

while OperationLoop<>nil


Functions


procedure AddFunctionOneParam(const AFunctionName: string; const Func: TMathProcedure);


procedure AddFunctionTwoParam(const AFunctionName: string; const Func: TMathProcedure);


procedure ClearFunction(const AFunctionName: string);

invalidate expression


procedure ClearFunctions;


procedure ClearVariable(const AVarName: string);

invalidate expression


procedure ClearVariables;


destructor Destroy;


procedure FreeExpression;

invalidate expression


function GetVariable(const VarName: string): extended;

is the variable name a valid identifier?


function ParseExpression(const AnExpression: string): boolean;

**************************************************************} { } { TCustomParser } { } { A base class which does not publish the variable properties } { and adds no functions by default } { } {


function SetVariable(VarName: string; const Value: extended): PParserFloat;

The PParserFloat returned points to the place in memory where the variable actually sits; to speed up assignment you can DIRECTLY assign data to the memory area.


function VariableExists(const AVarName: string): boolean;

invalidate expression


function CalcValue: extended;

this implies FExpression := AnExpression


procedure SetExpression(const AnExpression: string);


procedure SetVar(const VarName: string; const Value: extended);


Properties


property Expression : string

setting Expression automatically parses it Warning: exceptions MAY be raised, if OnParserError is NOT assigned, otherwise the event will be triggered in case of an error


property PascalNumberformat : boolean


property Value : extended


property LinkedOperationList : POperation


property ParserError : boolean


property Variable : extended


property A : ParserFloat

functions with TWO arguments, e.g. max(,) } { predefined variables - could be left out


property B : ParserFloat


property C : ParserFloat


property D : ParserFloat


property E : ParserFloat


property T : ParserFloat


property X : ParserFloat


property Y : ParserFloat


Events


event OnParserError : TParserExceptionEvent


Variables


FunctionOne : TStringList;

lists of available functions, see .Create for example use


FunctionTwo : TStringList;

functions with ONE argument, e.g. exp()


FA : ParserFloat;

some pre-allocated space for variables


FB : ParserFloat;


FC : ParserFloat;


FD : ParserFloat;


FE : ParserFloat;


FExpression : string;


FOnParserError : TParserExceptionEvent;


FParserError : boolean;


FPascalNumberformat : boolean;


FStartOperationList : POperation;


FT : ParserFloat;


FVariables : TStringList;


FX : ParserFloat;


FY : ParserFloat;