fpExprPars unit
Provides expression parsing with support for variables, functions, and mathematical operations
This unit implements an expression parser and evaluator that supports a wide variety of data types, mathematical operations, and built-in functions. It provides the infrastructure for parsing and evaluating mathematical expressions with support for variables, functions, and complex data types.
The parser supports the following features:
- Multiple data types: integers, floats, strings, booleans, dates, and currency
- Standard mathematical operators: +, -, *, /, mod, power
- Comparison operators: =, <>, <, >, <=, >=
- Logical operators: and, or, xor, not
- Built-in mathematical, string, and date/time functions comparable to what exists in the SysUtils unit.
- Variable and function definitions
- Conditional expressions (if-then-else)
- Aggregate functions for data processing
The unit is designed to be extensible, allowing custom functions and variables to be registered with the parser for specialized applications.
Classes and records
EExprParser | class | Expression parser exception class |
EExprScanner | class | Exception class for scanner errors |
TAggregateAvg | class | Internally used class for average aggregate functions |
TAggregateCount | class | Internally used class for count aggregate functions |
TAggregateExpr | class | Internally used Base class for aggregate expressions |
TAggregateMax | class | Internally used class for maximum aggregate functions |
TAggregateMin | class | Internally used class for minimum aggregate functions |
TAggregateSum | class | Internally used class for sum aggregate functions |
TCaseOperation | class | Internally used class for case-when conditional operations |
TCurrencyToDateTimeNode | class | Internally used class for converting currency to datetime |
TCurrencyToFloatNode | class | Internally used class for converting currency to float |
TExprBuiltInManager | class | Class for managing built-in functions and variables in expressions |
TFloatToCurrencyNode | class | Internally used class for converting float to currency |
TFloatToDateTimeNode | class | Internally used class for converting float to datetime |
TFPAddOperation | class | Internally used class for addition operations |
TFPBinaryAndOperation | class | Internally used class for binary AND logical operation |
TFPBinaryOperation | class | Internally used class for binary operations with left and right operands |
TFPBinaryOrOperation | class | Internally used class for binary OR logical operation |
TFPBinaryXOrOperation | class | Internally used class for binary XOR logical operation |
TFPBooleanOperation | class | Internally used class for boolean operations in expressions |
TFPBooleanResultOperation | class | Internally used class for operations that result in boolean values |
TFPBuiltInExprIdentifierDef | class | Class for built-in expression identifier definitions |
TFPConstExpression | class | Internally used class for constant value expressions |
TFPConvertNode | class | Internally used class for type conversion operations |
TFPDivideOperation | class | Internally used class for division operations |
TFPEqualOperation | class | Internally used class for equality comparison operations |
TFPExpressionParser | class | Class for parsing and evaluating mathematical expressions |
TFPExpressionResult | record | Record representing the result of expression evaluation |
TFPExpressionScanner | class | Class for tokenizing expression strings into parser tokens |
TFPExprFunction | class | Internally used class for representing function calls in expression trees |
TFPExprIdentifierDef | class | Class for defining identifiers in expressions |
TFPExprIdentifierDefs | class | Collection class for expression identifier definitions |
TFPExprIdentifierNode | class | Internally used class for identifier nodes in expression trees |
TFPExprNode | class | Class for representing nodes in expression trees |
TFPExprVariable | class | Internally used class for variable expression nodes |
TFPFunctionCallBack | class | Internally used class for callback-based function expressions |
TFPFunctionEventHandler | class | Internally used class for event-based function expressions |
TFPGreaterThanEqualOperation | class | Internally used class for greater-than-or-equal comparison operations |
TFPGreaterThanOperation | class | Internally used class for greater-than comparison operations |
TFPLessThanEqualOperation | class | Internally used class for less-than-or-equal comparison operations |
TFPLessThanOperation | class | Internally used class for less-than comparison operations |
TFPModuloOperation | class | Internally used class for modulo operations |
TFPMultiplyOperation | class | Internally used class for multiplication operations |
TFPNegateOperation | class | Internally used class for numeric negation operations |
TFPNotNode | class | Internally used class for logical NOT operations |
TFPOrderingOperation | class | Internally used class for ordering comparison operations |
TFPPowerOperation | class | Internally used class for power/exponentiation operations |
TFPSubtractOperation | class | Internally used class for subtraction operations |
TFPUnaryOperator | class | Internally used class for unary operations with single operand |
TFPUnequalOperation | class | Internally used class for inequality comparison operations |
TIfOperation | class | Internally used class for conditional if-then-else operations |
TIntConvertNode | class | Internally used class for integer conversion operations |
TIntToCurrencyNode | class | Internally used class for converting integer to currency |
TIntToDateTimeNode | class | Internally used class for converting integer to datetime |
TIntToFloatNode | class | Internally used class for converting integer to float |
TMathOperation | class | Internally used class for mathematical operations in expressions |
Procedures and functions
ArgToFloat | function | Convert argument to float value |
BuiltinIdentifiers | function | Get built-in identifiers manager |
CharToResultType | function | Convert character to result type |
RegisterStdBuiltins | procedure | Register standard built-in functions |
ResultTypeName | function | Get name for result type |
TokenName | function | Get name for token type |
Types
PFPExpressionResult | type | Pointer to TFPExpressionResult record |
TBuiltInCategories | set | Set of built-in function categories |
TBuiltInCategory | enumeration | Type representing categories of built-in functions |
TExprArgumentArray | type | Array type for expression arguments |
TExprFloat | type | Type representing floating-point values in expressions |
TExprParameterArray | type | Array type for function parameters in expressions |
TFPBinaryOperationClass | type | Class reference type for TFPBinaryOperation |
TFPBooleanResultOperationClass | type | Class reference type for TFPBooleanResultOperation |
TFPExpressionParserClass | type | Class reference type for TFPExpressionParser |
TFPExprFunctionCallBack | procedure type | Callback procedure type for function evaluation |
TFPExprFunctionClass | type | Class reference type for TFPExprFunction |
TFPExprFunctionEvent | procedure type | Event procedure type for function evaluation |
TFPExprVariableCallBack | procedure type | Callback procedure type for variable evaluation |
TFPExprVariableEvent | procedure type | Event procedure type for variable evaluation |
TIdentifierEvent | procedure type | |
TIdentifierType | enumeration | Type representing different kinds of identifiers in expressions |
TNumberKind | enumeration | Type representing different number formats that can be parsed |
TResultType | enumeration | Type representing different result data types in expressions |
TResultTypes | set | Set of result types |
TTokenType | enumeration | Type representing different token types in expression parsing |
Constants
AllBuiltIns | constant | Set of all built-in identifier categories |
ttComparisons | constant | Set of token types used for comparison operations |
ttDelimiters | constant | Set of token types used as operators and delimiters |
Uses
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
