Unit RbwParser

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

The RbwParser unit declares TRbwParser along with associated classes and types.

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
record TFunctionRecord A TFunctionRecord is used to define a function that can be used in a TRbwParser. To use the function, you must first assign the fields of the TFunctionRecord and then call TRbwParser.Functions.Add.
record TVariables TVariables are used in the protected section of TExpression.
Class ERbwParserError ERbwParserError is raised if by TRbwParser to report user errors and some programmer errors.
Class TFunctionClass TFunctionClass defines a function that can be called by TRbwParser.
Class TFunctionStringList TFunctionStringList maintains a sorted list of TFunctionClasses.
Class TConstant TConstant defines storage for a constant value such as "Abc", 1, 2.5, or True.
Class TCustomValue TCustomValue is the abstract ancestor of TCustomVariable and TExpression. It adds Name and Classification properties to TConstant.
Class TCustomVariable TCustomVariable is the abstract ancestor of TRealVariable, TIntegerVariable, TBooleanVariable and TStringVariable.
Class TRealVariable TRealVariable stores a double that may change from one execution of a TExpression to the next.
Class TIntegerVariable TIntegerVariable stores a integer that may change from one execution of a TExpression to the next.
Class TBooleanVariable TBooleanVariable stores a boolean that may change from one execution of a TExpression to the next.
Class TStringVariable TStringVariable stores a string that may change from one execution of a TExpression to the next.
Class TNotifierComponent  
Class TExpression TExpression is the compiled version of an Expression generated by the TRbwParser.Compile method.
Class TSpecialImplementor TSpecialImplementor is used in conjunction with TRbwParser.SpecialImplementorList to create a descendant of TExpression in TExpression.New.
Class TSpecialImplementorList TSpecialImplementorList is the type of TRbwParser.SpecialImplementorList. It is used together with TSpecialImplementor to create a descendant of TExpression in TExpression.New.
Class TOperator TOperator is used to define operators that are between two arguments or are before a single argument.
Class TOperatorArgumentDefinition TOperatorArgumentDefinition is used to define valid argument types for an operator.
Class TArgumentList Name is used to restrict ensure that in TOperatorDefinition only TOperatorArgumentDefinitions are added to ArgumentDefinitions.
Class TOperatorDefinition TOperatorDefinition defines an operator.
Class TRbwParser TRbwParser compiles expression in strings via the Compile method into TExpression objects that it owns.
Class TSelectExpression TSelectExpression is used for "if" and "case" statements. It allows Evaluate to be faster and safer by only evaluating the arguments that will be used.

Functions and Procedures

procedure Register;
function DataTypeToString(const DataType: TRbwDataType): string;
function GenerateVariableName(const root: string): string;
function IdenticalFormulas(const Formula1, Formula2: string): boolean;

Types

TRbwRealFunction = function(Values: array of pointer): double;
TRbwIntegerFunction = function(Values: array of pointer): Integer;
TRbwBooleanFunction = function(Values: array of pointer): Boolean;
TRbwStringFunction = function(Values: array of pointer): string;
TRbwDataType = (...);
TRbwDataTypes = set of TRbwDataType;
PFunctionRecord = ˆTFunctionRecord;
PBoolean = ˆBoolean;
TRealVariableClass = class of TRealVariable;
TIntegerVariableClass = class of TIntegerVariable;
TBooleanVariableClass = class of TBooleanVariable;
TStringVariableClass = class of TStringVariable;
TDecompileType = (...);
TExpressionClass = class of TExpression;
TArgumentCount = (...);
TCreationMethod = (...);
TOperatorClass = class of TOperator;
TPrecedence = (...);

Variables

OverloadedFunctionList: TObjectList;

Description

Functions and Procedures

procedure Register;

Register installs the component on the component palette.

function DataTypeToString(const DataType: TRbwDataType): string;

DataTypeToString converts a TRbwDataType to a string. This function is primarily used in error messages.

function GenerateVariableName(const root: string): string;

GenerateVariableName uses root to generate the name of a variable that could be accepted by TRbwParser but does check whether a variable with that name already exists.

function IdenticalFormulas(const Formula1, Formula2: string): boolean;
 

Types

TRbwRealFunction = function(Values: array of pointer): double;

TRbwRealFunction is the prototype for functions in TRbwParser that return a real number. To use a TRbwRealFunction, assign it to a RFunctionAddr, assign the remainder of the fields in the TFunctionRecord and then call Add of Functions. Be sure that the ResultType is rdtDouble when assigning a TRbwRealFunction. Failure to do so will lead to access violations or invalid results.

TRbwIntegerFunction = function(Values: array of pointer): Integer;

TRbwIntegerFunction is the prototype for functions in TRbwParser that return an integer. To use a TRbwIntegerFunction, assign it to the IFunctionAddr of a TFunctionRecord, assign the remainder of the fields in the TFunctionRecord and then call the Add function of TRbwParser.Functions. Be sure that the ResultType of the TFunctionRecord is rdtInteger when assigning a TRbwIntegerFunction. Failure to do so will lead to access violations or invalid results.

TRbwBooleanFunction = function(Values: array of pointer): Boolean;

TRbwBooleanFunction is the prototype for functions in TRbwParser that return a Boolean. To use a TRbwBooleanFunction, assign it to the BFunctionAddr of a TFunctionRecord, assign the remainder of the fields in the TFunctionRecord and then call the Add function of TRbwParser.Functions. Be sure that the ResultType of the TFunctionRecord is rdtBoolean when assigning a TRbwBooleanFunction. Failure to do so will lead to access violations or invalid results.

TRbwStringFunction = function(Values: array of pointer): string;

TRbwStringFunction is the prototype for functions in TRbwParser that return a string. To use a TRbwStringFunction, assign it to the SFunctionAddr of a TFunctionRecord, assign the remainder of the fields in the TFunctionRecord and then call the Add function of TRbwParser.Functions. Be sure that the ResultType of the TFunctionRecord is rdtString when assigning a TRbwStringFunction. Failure to do so will lead to access violations or invalid results.

TRbwDataType = (...);

TRbwDataType is used to define the data type passed into or returned by a function. In the case of rdtString used to define the data passed into a function, the data are passed into the function as a PString. Data are passed into a function as pointers to variables of the correct type. Results of the functions are values of the correct type rather than pointers.

Values
  • rdtDouble:  
  • rdtInteger:  
  • rdtBoolean:  
  • rdtString:  
TRbwDataTypes = set of TRbwDataType;

TRbwDataTypes is defined for convenience here but is not used by TRbwParser.

PFunctionRecord = ˆTFunctionRecord;

PFunctionRecord is a pointer to a TFunctionRecord.

PBoolean = ˆBoolean;

PBoolean is a pointer to a boolean.

TRealVariableClass = class of TRealVariable;
 
TIntegerVariableClass = class of TIntegerVariable;
 
TBooleanVariableClass = class of TBooleanVariable;
 
TStringVariableClass = class of TStringVariable;
 
TDecompileType = (...);
 
Values
  • dtInternal:  
  • dtDisplay:  
TExpressionClass = class of TExpression;

TExpressionClass is used in TSpecialImplementor to create a descendant of TExpression.

TArgumentCount = (...);

TArgumentCount is used in TOperatorDefinition to indicate how many arguments an operator has.

Values
  • acOne:  
  • acTwo:  
TCreationMethod = (...);

TCreationMethod is used in TOperatorDefinition to whether the new expression should be created with TOperator.Create or TOperator.New.

Values
  • cmCreate:  
  • cmNew:  
TOperatorClass = class of TOperator;

TOperatorClass is used in TOperatorArgumentDefinition to indicate what type of operator should be created.

TPrecedence = (...);

TPrecedence is used to determine in which order operators will be evaluated. p1 will be evaluated first; p5 will be evaluated last.

Values
  • p1:  
  • p2:  
  • p3:  
  • p4:  
  • p5:  

Variables

OverloadedFunctionList: TObjectList;

OverloadedFunctionList contains a series of TFunctionClasses that define overloaded functions.

The following functions are included by default.

  • Abs(Value) returns the absolute value of Value. Value can be either an integer or a real number. The value returned by Abs will have the same type as Value.

  • Case(Index, Result1, Result2, ...). Case uses Index to determine which of the Result1, Result2, ... arguments will be returned as a result. If Index equals 1, Result1 is returned; if Index equals 2, Result2 is returned; if Index equals 3, Result3 is returned; and so forth. Only "Index", constant expressions and the result that is returned will be evaluated. The types of Result1, Result2, ... must all be the same but they can be of any type. The type that is returned will be the same as the type of Result1, Result2, ...

  • If(Boolean_Value, If_True_Result, If_False_Result). If uses Boolean_Value to determine whether If_True_Result or If_False_Result is returned as a result. If Boolean_Value is true, If_True_Result is returned; if Boolean_Value is false, If_False_Result is returned. Only "Boolean_Value", constant expressions and the result that is returned will be evaluated. The types of If_True_Result and If_False_Result must be the same but they can be of any type. The type that is returned will be the same as the type of If_True_Result and If_False_Result.

  • Max(Value1, Value2, ...) returns whichever of its arguments is the largest. Its arguments must be either integers or real numbers. The result will be a real number if any of the arguments is a real number. If all the arguments are integers, the result will be an integer.

  • Min(Value1, Value2, ...) returns whichever of its arguments is the smallest. Its arguments must be either integers or real numbers. The result will be a real number if any of the arguments is a real number. If all the arguments are integers, the result will be an integer.

  • MultiInterpolate(Position, Value1, Distance1, [Value2, Distance2,] ...). If Position is less than or equal to Distance1, MultiInterpolate returns Value1. If Position is greater than or equal to DistanceN, MultiInterpolate returns ValueN. If Position is between any two adjacent distances, linear interpolation between the associated values will be used to determine the value that will be returned. See also Interpolate.

  • Sqr(Value) returns Value Squared. Value can be either an integer or a real number. The result of Sqr will be an integer if Value is an integer. Otherwise it will be a real number.


Generated by PasDoc 0.12.1 on 2013-05-13 15:41:59