calculator

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CalculationStack

type CalculationStack struct {
	// contains filtered or unexported fields
}

Implements a stack of Variant values.

func NewCalculationStack

func NewCalculationStack() *CalculationStack

func (*CalculationStack) Clear

func (c *CalculationStack) Clear()

func (*CalculationStack) Length

func (c *CalculationStack) Length() int

func (*CalculationStack) Peek

func (c *CalculationStack) Peek() *variants.Variant

func (*CalculationStack) PeekAt

func (c *CalculationStack) PeekAt(index int) *variants.Variant

func (*CalculationStack) Pop

func (c *CalculationStack) Pop() *variants.Variant

func (*CalculationStack) Push

func (c *CalculationStack) Push(value *variants.Variant)

type ExpressionCalculator

type ExpressionCalculator struct {
	// contains filtered or unexported fields
}

Implements an expression calculator class.

func ExpressionCalculatorFromExpression

func ExpressionCalculatorFromExpression(expression string) (*ExpressionCalculator, error)

Constructs this class and assigns expression string.

Parameters:

  • expression: The expression string.

func ExpressionCalculatorFromTokens

func ExpressionCalculatorFromTokens(originalTokens []*tokenizers.Token) *ExpressionCalculator

func NewExpressionCalculator

func NewExpressionCalculator() *ExpressionCalculator

Constructs this class with default parameters.

func (*ExpressionCalculator) AutoVariables

func (c *ExpressionCalculator) AutoVariables() bool

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

func (*ExpressionCalculator) Clear

func (c *ExpressionCalculator) Clear()

Cleans up this calculator from all data.

func (*ExpressionCalculator) CreateVariables

func (c *ExpressionCalculator) CreateVariables(vars variables.IVariableCollection)

Populates the specified variables list with variables from parsed expression.

Parameters:

  • variables: The list of variables to be populated.

func (*ExpressionCalculator) DefaultFunctions

func (c *ExpressionCalculator) DefaultFunctions() functions.IFunctionCollection

The list with default functions.

func (*ExpressionCalculator) DefaultVariables

func (c *ExpressionCalculator) DefaultVariables() variables.IVariableCollection

The list with default variables.

func (*ExpressionCalculator) Evaluate

func (c *ExpressionCalculator) Evaluate() (*variants.Variant, error)

Evaluates this expression using default variables and functions.

Returns: An evaluated expression value.

func (*ExpressionCalculator) EvaluateUsingVariables

func (c *ExpressionCalculator) EvaluateUsingVariables(
	vars variables.IVariableCollection) (*variants.Variant, error)

Evaluates this expression using specified variables.

Parameters:

  • variables: The list of variables

Returns: An evaluated expression value.

func (*ExpressionCalculator) EvaluateUsingVariablesAndFunctions

func (c *ExpressionCalculator) EvaluateUsingVariablesAndFunctions(
	vars variables.IVariableCollection, funcs functions.IFunctionCollection) (*variants.Variant, error)

Evaluates this expression using specified variables and functions.

Parameters:

  • variables: The list of variables
  • functions: The list of functions.

Returns: An evaluated expression value.

func (*ExpressionCalculator) Expression

func (c *ExpressionCalculator) Expression() string

Gets the expression string.

func (*ExpressionCalculator) InitialTokens

func (c *ExpressionCalculator) InitialTokens() []*parsers.ExpressionToken

The list of original expression tokens.

func (*ExpressionCalculator) OriginalTokens

func (c *ExpressionCalculator) OriginalTokens() []*tokenizers.Token

func (*ExpressionCalculator) ResultTokens

func (c *ExpressionCalculator) ResultTokens() []*parsers.ExpressionToken

The list of processed expression tokens.

func (*ExpressionCalculator) SetAutoVariables

func (c *ExpressionCalculator) SetAutoVariables(value bool)

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

func (*ExpressionCalculator) SetExpression

func (c *ExpressionCalculator) SetExpression(value string) error

Sets the expression string.

func (*ExpressionCalculator) SetOriginalTokens

func (c *ExpressionCalculator) SetOriginalTokens(value []*tokenizers.Token)

func (*ExpressionCalculator) SetVariantOperations

func (c *ExpressionCalculator) SetVariantOperations(value variants.IVariantOperations)

Sets the manager for operations on variant values.

func (*ExpressionCalculator) VariantOperations

func (c *ExpressionCalculator) VariantOperations() variants.IVariantOperations

Gets the manager for operations on variant values.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL