operators

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(inputL, inputR core.Value) core.Value

Adds numbers Concatenates strings

func Decrement

func Decrement(inputL, _ core.Value) core.Value

func Divide

func Divide(inputL, inputR core.Value) core.Value

func Equal

func Equal(left, right core.Value) core.Value

Equality

func Greater

func Greater(left, right core.Value) core.Value

func GreaterOrEqual

func GreaterOrEqual(left, right core.Value) core.Value

func Increment

func Increment(inputL, _ core.Value) core.Value

func Less

func Less(left, right core.Value) core.Value

func LessOrEqual

func LessOrEqual(left, right core.Value) core.Value

func Modulus

func Modulus(inputL, inputR core.Value) core.Value

func Multiply

func Multiply(inputL, inputR core.Value) core.Value

func Negative added in v0.3.0

func Negative(value, _ core.Value) core.Value

func Not

func Not(left, _ core.Value) core.Value

func NotEqual

func NotEqual(left, right core.Value) core.Value

func Positive added in v0.3.0

func Positive(value, _ core.Value) core.Value

func Subtract

func Subtract(inputL, inputR core.Value) core.Value

func ToBoolean added in v0.3.0

func ToBoolean(value, _ core.Value) core.Value

func ToNumberOnly added in v0.8.0

func ToNumberOnly(input core.Value) core.Value

func ToNumberOrString added in v0.8.0

func ToNumberOrString(input core.Value) core.Value

Types

type ArrayOperator

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

func NewArrayOperator

func NewArrayOperator(
	src core.SourceMap,
	left core.Expression,
	right core.Expression,
	variantStr string,
	comparator core.Predicate,
) (*ArrayOperator, error)

func (*ArrayOperator) Eval

func (operator *ArrayOperator) Eval(ctx context.Context, left, right core.Value) (core.Value, error)

func (*ArrayOperator) Exec

func (operator *ArrayOperator) Exec(ctx context.Context, scope *core.Scope) (core.Value, error)

type ArrayOperatorVariant added in v0.16.0

type ArrayOperatorVariant int
const (
	ArrayOperatorVariantAll ArrayOperatorVariant = iota
	ArrayOperatorVariantAny
	ArrayOperatorVariantNone
)

func ToArrayOperatorVariant added in v0.16.0

func ToArrayOperatorVariant(name string) (ArrayOperatorVariant, error)

type EqualityOperator

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

func NewEqualityOperator

func NewEqualityOperator(
	src core.SourceMap,
	left core.Expression,
	right core.Expression,
	operator string,
) (*EqualityOperator, error)

func (*EqualityOperator) Eval

func (operator *EqualityOperator) Eval(_ context.Context, left, right core.Value) (core.Value, error)

func (*EqualityOperator) Exec

func (operator *EqualityOperator) Exec(ctx context.Context, scope *core.Scope) (core.Value, error)

type InOperator

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

func NewInOperator

func NewInOperator(
	src core.SourceMap,
	left core.Expression,
	right core.Expression,
	negate bool,
) (*InOperator, error)

func (*InOperator) Eval

func (operator *InOperator) Eval(_ context.Context, left, right core.Value) (core.Value, error)

func (*InOperator) Exec

func (operator *InOperator) Exec(ctx context.Context, scope *core.Scope) (core.Value, error)

type LikeOperator added in v0.14.0

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

func NewLikeOperator added in v0.14.0

func NewLikeOperator(
	src core.SourceMap,
	left core.Expression,
	right core.Expression,
	negate bool,
) (*LikeOperator, error)

func (*LikeOperator) Eval added in v0.14.0

func (operator *LikeOperator) Eval(_ context.Context, left, right core.Value) (core.Value, error)

func (*LikeOperator) Exec added in v0.14.0

func (operator *LikeOperator) Exec(ctx context.Context, scope *core.Scope) (core.Value, error)

type LogicalOperator

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

func NewLogicalOperator

func NewLogicalOperator(
	src core.SourceMap,
	left core.Expression,
	right core.Expression,
	operator string,
) (*LogicalOperator, error)

func (*LogicalOperator) Eval

func (operator *LogicalOperator) Eval(_ context.Context, left, right core.Value) (core.Value, error)

func (*LogicalOperator) Exec

func (operator *LogicalOperator) Exec(ctx context.Context, scope *core.Scope) (core.Value, error)

type LogicalOperatorVariant added in v0.16.0

type LogicalOperatorVariant int
const (
	LogicalOperatorVariantAnd LogicalOperatorVariant = 0
	LogicalOperatorVariantOr  LogicalOperatorVariant = 1
	LogicalOperatorVariantNot LogicalOperatorVariant = 2
)

type MathOperator

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

func NewMathOperator

func NewMathOperator(
	src core.SourceMap,
	left core.Expression,
	right core.Expression,
	variantStr string,
) (*MathOperator, error)

func (*MathOperator) Eval

func (operator *MathOperator) Eval(_ context.Context, left, right core.Value) (core.Value, error)

func (*MathOperator) Exec

func (operator *MathOperator) Exec(ctx context.Context, scope *core.Scope) (core.Value, error)

func (*MathOperator) Type added in v0.6.0

func (operator *MathOperator) Type() MathOperatorVariant

type MathOperatorVariant added in v0.16.0

type MathOperatorVariant string
const (
	MathOperatorVariantAdd       MathOperatorVariant = "+"
	MathOperatorVariantSubtract  MathOperatorVariant = "-"
	MathOperatorVariantMultiply  MathOperatorVariant = "*"
	MathOperatorVariantDivide    MathOperatorVariant = "/"
	MathOperatorVariantModulus   MathOperatorVariant = "%"
	MathOperatorVariantIncrement MathOperatorVariant = "++"
	MathOperatorVariantDecrement MathOperatorVariant = "--"
)

type OperatorFunc

type OperatorFunc func(left, right core.Value) core.Value

type RangeOperator

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

func NewRangeOperator

func NewRangeOperator(
	src core.SourceMap,
	left core.Expression,
	right core.Expression,
) (*RangeOperator, error)

func (*RangeOperator) Eval

func (operator *RangeOperator) Eval(_ context.Context, left, right core.Value) (core.Value, error)

func (*RangeOperator) Exec

func (operator *RangeOperator) Exec(ctx context.Context, scope *core.Scope) (core.Value, error)

type RegexpOperator added in v0.8.0

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

func NewRegexpOperator added in v0.8.0

func NewRegexpOperator(
	src core.SourceMap,
	left core.Expression,
	right core.Expression,
	operatorStr string,
) (*RegexpOperator, error)

func (*RegexpOperator) Eval added in v0.8.0

func (operator *RegexpOperator) Eval(_ context.Context, left, right core.Value) (core.Value, error)

func (*RegexpOperator) Exec added in v0.8.0

func (operator *RegexpOperator) Exec(ctx context.Context, scope *core.Scope) (core.Value, error)

func (*RegexpOperator) Type added in v0.8.0

func (operator *RegexpOperator) Type() RegexpOperatorVariant

type RegexpOperatorVariant added in v0.16.0

type RegexpOperatorVariant int
const (
	RegexpOperatorVariantNegative RegexpOperatorVariant = 0
	RegexpOperatorVariantPositive RegexpOperatorVariant = 1
)

type UnaryOperator added in v0.3.0

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

func NewUnaryOperator added in v0.3.0

func NewUnaryOperator(
	src core.SourceMap,
	exp core.Expression,
	variantStr string,
) (*UnaryOperator, error)

func (*UnaryOperator) Eval added in v0.3.0

func (operator *UnaryOperator) Eval(_ context.Context, left, _ core.Value) (core.Value, error)

func (*UnaryOperator) Exec added in v0.3.0

func (operator *UnaryOperator) Exec(ctx context.Context, scope *core.Scope) (core.Value, error)

type UnaryOperatorVariant added in v0.16.0

type UnaryOperatorVariant string
const (
	UnaryOperatorVariantNoop     UnaryOperatorVariant = ""
	UnaryOperatorVariantNot      UnaryOperatorVariant = "!"
	UnaryOperatorVariantNot2     UnaryOperatorVariant = "NOT"
	UnaryOperatorVariantNegative UnaryOperatorVariant = "-"
	UnaryOperatorVariantPositive UnaryOperatorVariant = "+"
)

Jump to

Keyboard shortcuts

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