eval

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type And

type And struct {
	Args []Expression
}

func (And) Eval

func (and And) Eval(context Context) (Value, error)

type BoolValue

type BoolValue struct {
	Val bool
}

func (BoolValue) AsBool

func (n BoolValue) AsBool() (bool, error)

func (BoolValue) AsNumber

func (n BoolValue) AsNumber() (float64, error)

func (BoolValue) AsString

func (n BoolValue) AsString() (string, error)

func (BoolValue) Eq

func (b BoolValue) Eq(other Value) (bool, error)

func (BoolValue) Eval

func (b BoolValue) Eval(_ Context) (Value, error)

func (BoolValue) MarshalJSON

func (b BoolValue) MarshalJSON() ([]byte, error)

func (BoolValue) String

func (b BoolValue) String() string

type ComparisonOperator

type ComparisonOperator struct {
	First    Expression
	Second   Expression
	Comparer func(float64, float64) bool
}

func (ComparisonOperator) Eval

func (c ComparisonOperator) Eval(context Context) (Value, error)

type Context

type Context map[string]Expression

type ContextExpression

type ContextExpression struct {
	Key Expression
}

func (ContextExpression) Eval

func (contextExpr ContextExpression) Eval(context Context) (Value, error)

type Eq

type Eq struct {
	Args []Expression
}

func (Eq) Eval

func (eq Eq) Eval(context Context) (Value, error)

type Expression

type Expression interface {
	Eval(context Context) (Value, error)
}

type If

type If struct {
	Condition Expression
	Then      Expression
	Else      Expression
}

func (If) Eval

func (_if If) Eval(context Context) (Value, error)

type NumberValue

type NumberValue struct {
	Val float64
}

func (NumberValue) AsBool

func (n NumberValue) AsBool() (bool, error)

func (NumberValue) AsNumber

func (n NumberValue) AsNumber() (float64, error)

func (NumberValue) AsString

func (n NumberValue) AsString() (string, error)

func (NumberValue) Eq

func (n NumberValue) Eq(other Value) (bool, error)

func (NumberValue) Eval

func (n NumberValue) Eval(_ Context) (Value, error)

func (NumberValue) MarshalJSON

func (n NumberValue) MarshalJSON() ([]byte, error)

type Or

type Or struct {
	Args []Expression
}

func (Or) Eval

func (or Or) Eval(context Context) (Value, error)

type StringValue

type StringValue struct {
	Val string
}

func (StringValue) AsBool

func (n StringValue) AsBool() (bool, error)

func (StringValue) AsNumber

func (n StringValue) AsNumber() (float64, error)

func (StringValue) AsString

func (n StringValue) AsString() (string, error)

func (StringValue) Eq

func (s StringValue) Eq(other Value) (bool, error)

func (StringValue) Eval

func (s StringValue) Eval(_ Context) (Value, error)

func (StringValue) MarshalJSON

func (s StringValue) MarshalJSON() ([]byte, error)

type Value

type Value interface {
	Expression
	AsNumber() (float64, error)
	AsBool() (bool, error)
	AsString() (string, error)
	Eq(Value) (bool, error)
	MarshalJSON() ([]byte, error)
}

Jump to

Keyboard shortcuts

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