Sign in Join
FPDoc Onlineexperiment

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

EExprParserclassExpression parser exception class
EExprScannerclassException class for scanner errors
TAggregateAvgclassInternally used class for average aggregate functions
TAggregateCountclassInternally used class for count aggregate functions
TAggregateExprclassInternally used Base class for aggregate expressions
TAggregateMaxclassInternally used class for maximum aggregate functions
TAggregateMinclassInternally used class for minimum aggregate functions
TAggregateSumclassInternally used class for sum aggregate functions
TCaseOperationclassInternally used class for case-when conditional operations
TCurrencyToDateTimeNodeclassInternally used class for converting currency to datetime
TCurrencyToFloatNodeclassInternally used class for converting currency to float
TExprBuiltInManagerclassClass for managing built-in functions and variables in expressions
TFloatToCurrencyNodeclassInternally used class for converting float to currency
TFloatToDateTimeNodeclassInternally used class for converting float to datetime
TFPAddOperationclassInternally used class for addition operations
TFPBinaryAndOperationclassInternally used class for binary AND logical operation
TFPBinaryOperationclassInternally used class for binary operations with left and right operands
TFPBinaryOrOperationclassInternally used class for binary OR logical operation
TFPBinaryXOrOperationclassInternally used class for binary XOR logical operation
TFPBooleanOperationclassInternally used class for boolean operations in expressions
TFPBooleanResultOperationclassInternally used class for operations that result in boolean values
TFPBuiltInExprIdentifierDefclassClass for built-in expression identifier definitions
TFPConstExpressionclassInternally used class for constant value expressions
TFPConvertNodeclassInternally used class for type conversion operations
TFPDivideOperationclassInternally used class for division operations
TFPEqualOperationclassInternally used class for equality comparison operations
TFPExpressionParserclassClass for parsing and evaluating mathematical expressions
TFPExpressionResultrecordRecord representing the result of expression evaluation
TFPExpressionScannerclassClass for tokenizing expression strings into parser tokens
TFPExprFunctionclassInternally used class for representing function calls in expression trees
TFPExprIdentifierDefclassClass for defining identifiers in expressions
TFPExprIdentifierDefsclassCollection class for expression identifier definitions
TFPExprIdentifierNodeclassInternally used class for identifier nodes in expression trees
TFPExprNodeclassClass for representing nodes in expression trees
TFPExprVariableclassInternally used class for variable expression nodes
TFPFunctionCallBackclassInternally used class for callback-based function expressions
TFPFunctionEventHandlerclassInternally used class for event-based function expressions
TFPGreaterThanEqualOperationclassInternally used class for greater-than-or-equal comparison operations
TFPGreaterThanOperationclassInternally used class for greater-than comparison operations
TFPLessThanEqualOperationclassInternally used class for less-than-or-equal comparison operations
TFPLessThanOperationclassInternally used class for less-than comparison operations
TFPModuloOperationclassInternally used class for modulo operations
TFPMultiplyOperationclassInternally used class for multiplication operations
TFPNegateOperationclassInternally used class for numeric negation operations
TFPNotNodeclassInternally used class for logical NOT operations
TFPOrderingOperationclassInternally used class for ordering comparison operations
TFPPowerOperationclassInternally used class for power/exponentiation operations
TFPSubtractOperationclassInternally used class for subtraction operations
TFPUnaryOperatorclassInternally used class for unary operations with single operand
TFPUnequalOperationclassInternally used class for inequality comparison operations
TIfOperationclassInternally used class for conditional if-then-else operations
TIntConvertNodeclassInternally used class for integer conversion operations
TIntToCurrencyNodeclassInternally used class for converting integer to currency
TIntToDateTimeNodeclassInternally used class for converting integer to datetime
TIntToFloatNodeclassInternally used class for converting integer to float
TMathOperationclassInternally used class for mathematical operations in expressions

Procedures and functions

ArgToFloatfunctionConvert argument to float value
BuiltinIdentifiersfunctionGet built-in identifiers manager
CharToResultTypefunctionConvert character to result type
RegisterStdBuiltinsprocedureRegister standard built-in functions
ResultTypeNamefunctionGet name for result type
TokenNamefunctionGet name for token type

Types

PFPExpressionResulttypePointer to TFPExpressionResult record
TBuiltInCategoriessetSet of built-in function categories
TBuiltInCategoryenumerationType representing categories of built-in functions
TExprArgumentArraytypeArray type for expression arguments
TExprFloattypeType representing floating-point values in expressions
TExprParameterArraytypeArray type for function parameters in expressions
TFPBinaryOperationClasstypeClass reference type for TFPBinaryOperation
TFPBooleanResultOperationClasstypeClass reference type for TFPBooleanResultOperation
TFPExpressionParserClasstypeClass reference type for TFPExpressionParser
TFPExprFunctionCallBackprocedure typeCallback procedure type for function evaluation
TFPExprFunctionClasstypeClass reference type for TFPExprFunction
TFPExprFunctionEventprocedure typeEvent procedure type for function evaluation
TFPExprVariableCallBackprocedure typeCallback procedure type for variable evaluation
TFPExprVariableEventprocedure typeEvent procedure type for variable evaluation
TIdentifierEventprocedure type
TIdentifierTypeenumerationType representing different kinds of identifiers in expressions
TNumberKindenumerationType representing different number formats that can be parsed
TResultTypeenumerationType representing different result data types in expressions
TResultTypessetSet of result types
TTokenTypeenumerationType representing different token types in expression parsing

Constants

AllBuiltInsconstantSet of all built-in identifier categories
ttComparisonsconstantSet of token types used for comparison operations
ttDelimitersconstantSet of token types used as operators and delimiters

Uses

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.