ExpressionCalculator

Implements an expression calculator.

Description

The ExpressionCalculator class allows you to create an expression calculator.

Constructors

Constructs this class and assigns a expression string.

ExpressionCalculator(expression: str = None)

  • expression: str - expression string.

Properties

auto_variables

Gets the flag to turn on auto-creation of variables for a specified expression.

auto_variables(): bool

  • returns: bool - returns the flag to turn on auto-creation.

Sets the flag to turn on auto-creation of variables for specified expression.

auto_variables(value: bool)

  • value: bool - flag to turn on auto-creation.

default_functions

List with default functions.

default_functions(): IFunctionCollection

default_variables

List with default variables.

default_variables(): IVariableCollection

expression

Expression string.

expression(): str

  • returns: str - expression string.

expression(value: str)

  • value: str - expression string.

initial_tokens

List of original expression tokens.

initial_tokens(): List[ExpressionToken]

original_tokens

List of expression tokens.

original_tokens(): List[Token]

  • returns: List[Token] - list of expression tokens.

original_tokens(value: List[Token])

  • value: List[Token] - list of expression tokens.

result_tokens

List of processed expression tokens.

result_tokens(): List[ExpressionToken]

variant_operations

Gets the manager for operations on variant values.

variant_operations(): IVariantOperations

Sets the manager for operations on variant values.

variant_operations(value: IVariantOperations)

Instance methods

clear

Cleans up this calculator from all data.

clear()

create_variables

Cleans up this calculator from all data.

create_variables(variables: IVariantOperations)

evaluate

Evaluates this expression using default variables and functions.

evaluate(): Variant

  • returns: Variant - evaluation result.

evaluate_with_variables

Evaluates this expression using specified variables.

evaluate_with_variables(variables: IVariantOperations): Variant

evaluate_with_variables_and_functions

Evaluates this expression using specified variables and functions.

evaluate_with_variables_and_functions(variables: Optional[IVariantOperations], functions: Optional[IFunctionCollection]): Variant