Unit P9Build

version 9.1 - revision by Alin Flaider, june 1997 - removed >4k memory leak per expression parsing under regular operation

Classes

Functions

ParseFunction - error actually is superfluous as we are now using exceptions

Types

Float
PFloat
POperation
TMathProcedure
TOperation
TToken

Constants

MathOperators
TokenOperators

Variables


Functions


procedure ParseFunction( FunctionString: string; { the unparsed string } Variables: TStringlist; { list of variables } { lists of available functions } FunctionOne, { functions with ONE argument, e.g. exp() } FunctionTwo: TStringList; { functions with TWO arguments, e.g. max(,) } { return pointer to tree, number of performed operations and error state } var FirstOP : POperation; var NumberOperations : integer; var Error : boolean);

error actually is superfluous as we are now using exceptions

Types


Float = double
hopefully we will never see this one
PFloat = ^Float
we want it Presto!; please do NOT use "real", only single, double, extended
POperation = ^TOperation

TMathProcedure = procedure(AnOperation: POperation)

TOperation = record
Arg1 : PFloat;
Arg2 : PFloat;
Dest : PFloat;
NextOperation : POperation;
Operation : TMathProcedure;
Token : TToken;
end;

TToken=( variab, constant, brack,
           minus, sum, diff, prod, divis, modulo, IntDiv,
           intpower, realpower,
           square, third, fourth,
           FuncOneVar, FuncTwoVar);

Constants

MathOperators = ( '+', '*', '-', '/', '^', 'MOD', 'DIV' )

perhaps one could use "%" for MOD and remove DIV ( o1 div o2 <=> trunc(trunc(o1)/trunc(o2)) )

TokenOperators = [minus, sum, diff, prod, divis, modulo, IntDiv, intpower, realpower]


Variables