Documentation ¶
Index ¶
- Variables
- type Domain
- type Domains
- type DynamicFunc
- type DynamicMethod
- type ErrSide
- type ErrTypeGuardFailed
- type ErrWrongFuncSignature
- type EvalBinaryNode
- func (e *EvalBinaryNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
- func (e *EvalBinaryNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
- func (e *EvalBinaryNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
- func (e *EvalBinaryNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
- func (n *EvalBinaryNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
- func (n *EvalBinaryNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (e *EvalBinaryNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
- func (n *EvalBinaryNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
- func (n *EvalBinaryNode) IsDynamic() bool
- func (n *EvalBinaryNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
- type EvalBoolNode
- func (n *EvalBoolNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
- func (n *EvalBoolNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
- func (n *EvalBoolNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
- func (n *EvalBoolNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
- func (n *EvalBoolNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
- func (n *EvalBoolNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalBoolNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
- func (n *EvalBoolNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
- func (n *EvalBoolNode) IsDynamic() bool
- func (n *EvalBoolNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
- type EvalDurationNode
- func (n *EvalDurationNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
- func (n *EvalDurationNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
- func (n *EvalDurationNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
- func (n *EvalDurationNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
- func (n *EvalDurationNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
- func (n *EvalDurationNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalDurationNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
- func (n *EvalDurationNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
- func (n *EvalDurationNode) IsDynamic() bool
- func (n *EvalDurationNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
- type EvalFloatNode
- func (n *EvalFloatNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
- func (n *EvalFloatNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
- func (n *EvalFloatNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
- func (n *EvalFloatNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
- func (n *EvalFloatNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
- func (n *EvalFloatNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalFloatNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
- func (n *EvalFloatNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
- func (n *EvalFloatNode) IsDynamic() bool
- func (n *EvalFloatNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
- type EvalFunctionNode
- func (n *EvalFunctionNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
- func (n *EvalFunctionNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
- func (n *EvalFunctionNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
- func (n *EvalFunctionNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
- func (n *EvalFunctionNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
- func (n *EvalFunctionNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalFunctionNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
- func (n *EvalFunctionNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
- func (n *EvalFunctionNode) IsDynamic() bool
- func (n *EvalFunctionNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
- type EvalIntNode
- func (n *EvalIntNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
- func (n *EvalIntNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
- func (n *EvalIntNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
- func (n *EvalIntNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
- func (n *EvalIntNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
- func (n *EvalIntNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalIntNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
- func (n *EvalIntNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
- func (n *EvalIntNode) IsDynamic() bool
- func (n *EvalIntNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
- type EvalLambdaNode
- func (n *EvalLambdaNode) EvalBool(scope *Scope, _ ExecutionState) (bool, error)
- func (n *EvalLambdaNode) EvalDuration(scope *Scope, _ ExecutionState) (time.Duration, error)
- func (n *EvalLambdaNode) EvalFloat(scope *Scope, _ ExecutionState) (float64, error)
- func (n *EvalLambdaNode) EvalInt(scope *Scope, _ ExecutionState) (int64, error)
- func (n *EvalLambdaNode) EvalMissing(scope *Scope, _ ExecutionState) (*ast.Missing, error)
- func (n *EvalLambdaNode) EvalRegex(scope *Scope, _ ExecutionState) (*regexp.Regexp, error)
- func (n *EvalLambdaNode) EvalString(scope *Scope, _ ExecutionState) (string, error)
- func (n *EvalLambdaNode) EvalTime(scope *Scope, _ ExecutionState) (time.Time, error)
- func (n *EvalLambdaNode) IsDynamic() bool
- func (n *EvalLambdaNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
- type EvalReferenceNode
- func (n *EvalReferenceNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
- func (n *EvalReferenceNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
- func (n *EvalReferenceNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
- func (n *EvalReferenceNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
- func (n *EvalReferenceNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
- func (n *EvalReferenceNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalReferenceNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
- func (n *EvalReferenceNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
- func (n *EvalReferenceNode) IsDynamic() bool
- func (n *EvalReferenceNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
- type EvalRegexNode
- func (n *EvalRegexNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
- func (n *EvalRegexNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
- func (n *EvalRegexNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
- func (n *EvalRegexNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
- func (n *EvalRegexNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
- func (n *EvalRegexNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalRegexNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
- func (n *EvalRegexNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
- func (n *EvalRegexNode) IsDynamic() bool
- func (n *EvalRegexNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
- type EvalStringNode
- func (n *EvalStringNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
- func (n *EvalStringNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
- func (n *EvalStringNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
- func (n *EvalStringNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
- func (n *EvalStringNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
- func (n *EvalStringNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalStringNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
- func (n *EvalStringNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
- func (n *EvalStringNode) IsDynamic() bool
- func (n *EvalStringNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
- type EvalUnaryNode
- func (n *EvalUnaryNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
- func (n *EvalUnaryNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
- func (n *EvalUnaryNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
- func (n *EvalUnaryNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
- func (n *EvalUnaryNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
- func (n *EvalUnaryNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalUnaryNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
- func (n *EvalUnaryNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
- func (n *EvalUnaryNode) IsDynamic() bool
- func (n *EvalUnaryNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
- type ExecutionState
- type Expression
- type Func
- type Funcs
- type NodeEvaluator
- type ReadOnlyScope
- type Scope
- func (s *Scope) DynamicFunc(name string) *DynamicFunc
- func (s *Scope) DynamicMethod(name string) DynamicMethod
- func (s *Scope) Get(name string) (interface{}, error)
- func (s *Scope) Has(name string) bool
- func (s *Scope) Reset()
- func (s *Scope) Set(name string, value interface{})
- func (s *Scope) SetDynamicFunc(name string, f *DynamicFunc)
- func (s *Scope) SetDynamicMethod(name string, m DynamicMethod)
- type ScopePool
Constants ¶
This section is empty.
Variables ¶
var ErrNotFloat = errors.New("value is not a float")
Functions ¶
This section is empty.
Types ¶
type DynamicFunc ¶ added in v1.3.0
type DynamicFunc struct { F func(args ...interface{}) (interface{}, error) Sig map[Domain]ast.ValueType }
func (DynamicFunc) Call ¶ added in v1.3.0
func (df DynamicFunc) Call(args ...interface{}) (interface{}, error)
func (DynamicFunc) Reset ¶ added in v1.3.0
func (df DynamicFunc) Reset()
type DynamicMethod ¶ added in v1.0.0
type DynamicMethod func(self interface{}, args ...interface{}) (interface{}, error)
type ErrSide ¶
ErrSide wraps the error in the evaluation, we use this error to indicate the origin of the error left side or right side
type ErrTypeGuardFailed ¶
ErrTypeGuardFailed is returned when a speicifc value type is requested thorugh NodeEvaluator (for example: "Float64Value") when the node doesn't support the given type, for example "Float64Value" is called on BoolNode
func (ErrTypeGuardFailed) Error ¶
func (e ErrTypeGuardFailed) Error() string
type ErrWrongFuncSignature ¶ added in v1.3.0
func (ErrWrongFuncSignature) Error ¶ added in v1.3.0
func (e ErrWrongFuncSignature) Error() string
type EvalBinaryNode ¶
type EvalBinaryNode struct {
// contains filtered or unexported fields
}
EvalBinaryNode is stateful expression which
is evaluated using "expression trees" instead of stack based interpreter
func NewEvalBinaryNode ¶
func NewEvalBinaryNode(node *ast.BinaryNode) (*EvalBinaryNode, error)
func (*EvalBinaryNode) EvalBool ¶
func (e *EvalBinaryNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
EvalBool executes the expression based on eval bool
func (*EvalBinaryNode) EvalDuration ¶ added in v1.0.0
func (e *EvalBinaryNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
func (*EvalBinaryNode) EvalFloat ¶
func (e *EvalBinaryNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
EvalNum executes the expression based on eval numeric
func (*EvalBinaryNode) EvalInt ¶
func (e *EvalBinaryNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
func (*EvalBinaryNode) EvalMissing ¶ added in v1.3.0
func (n *EvalBinaryNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
func (*EvalBinaryNode) EvalRegex ¶
func (n *EvalBinaryNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalBinaryNode) EvalString ¶
func (e *EvalBinaryNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
func (*EvalBinaryNode) EvalTime ¶ added in v1.0.0
func (n *EvalBinaryNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
func (*EvalBinaryNode) IsDynamic ¶ added in v1.0.0
func (n *EvalBinaryNode) IsDynamic() bool
func (*EvalBinaryNode) Type ¶
func (n *EvalBinaryNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
type EvalBoolNode ¶
func (*EvalBoolNode) EvalBool ¶
func (n *EvalBoolNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
func (*EvalBoolNode) EvalDuration ¶ added in v1.0.0
func (n *EvalBoolNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
func (*EvalBoolNode) EvalFloat ¶
func (n *EvalBoolNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
func (*EvalBoolNode) EvalInt ¶
func (n *EvalBoolNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
func (*EvalBoolNode) EvalMissing ¶ added in v1.3.0
func (n *EvalBoolNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
func (*EvalBoolNode) EvalRegex ¶
func (n *EvalBoolNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalBoolNode) EvalString ¶
func (n *EvalBoolNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
func (*EvalBoolNode) EvalTime ¶ added in v1.0.0
func (n *EvalBoolNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
func (*EvalBoolNode) IsDynamic ¶ added in v1.0.0
func (n *EvalBoolNode) IsDynamic() bool
func (*EvalBoolNode) Type ¶
func (n *EvalBoolNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
type EvalDurationNode ¶ added in v1.0.0
func (*EvalDurationNode) EvalBool ¶ added in v1.0.0
func (n *EvalDurationNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
func (*EvalDurationNode) EvalDuration ¶ added in v1.0.0
func (n *EvalDurationNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
func (*EvalDurationNode) EvalFloat ¶ added in v1.0.0
func (n *EvalDurationNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
func (*EvalDurationNode) EvalInt ¶ added in v1.0.0
func (n *EvalDurationNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
func (*EvalDurationNode) EvalMissing ¶ added in v1.3.0
func (n *EvalDurationNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
func (*EvalDurationNode) EvalRegex ¶ added in v1.0.0
func (n *EvalDurationNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalDurationNode) EvalString ¶ added in v1.0.0
func (n *EvalDurationNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
func (*EvalDurationNode) EvalTime ¶ added in v1.0.0
func (n *EvalDurationNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
func (*EvalDurationNode) IsDynamic ¶ added in v1.0.0
func (n *EvalDurationNode) IsDynamic() bool
func (*EvalDurationNode) Type ¶ added in v1.0.0
func (n *EvalDurationNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
type EvalFloatNode ¶
type EvalFloatNode struct {
Float64 float64
}
func (*EvalFloatNode) EvalBool ¶
func (n *EvalFloatNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
func (*EvalFloatNode) EvalDuration ¶ added in v1.0.0
func (n *EvalFloatNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
func (*EvalFloatNode) EvalFloat ¶
func (n *EvalFloatNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
func (*EvalFloatNode) EvalInt ¶
func (n *EvalFloatNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
func (*EvalFloatNode) EvalMissing ¶ added in v1.3.0
func (n *EvalFloatNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
func (*EvalFloatNode) EvalRegex ¶
func (n *EvalFloatNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalFloatNode) EvalString ¶
func (n *EvalFloatNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
func (*EvalFloatNode) EvalTime ¶ added in v1.0.0
func (n *EvalFloatNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
func (*EvalFloatNode) IsDynamic ¶ added in v1.0.0
func (n *EvalFloatNode) IsDynamic() bool
func (*EvalFloatNode) Type ¶
func (n *EvalFloatNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
type EvalFunctionNode ¶
type EvalFunctionNode struct {
// contains filtered or unexported fields
}
func NewEvalFunctionNode ¶
func NewEvalFunctionNode(funcNode *ast.FunctionNode) (*EvalFunctionNode, error)
func (*EvalFunctionNode) EvalBool ¶
func (n *EvalFunctionNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
func (*EvalFunctionNode) EvalDuration ¶ added in v1.0.0
func (n *EvalFunctionNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
func (*EvalFunctionNode) EvalFloat ¶
func (n *EvalFunctionNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
func (*EvalFunctionNode) EvalInt ¶
func (n *EvalFunctionNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
func (*EvalFunctionNode) EvalMissing ¶ added in v1.3.0
func (n *EvalFunctionNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
func (*EvalFunctionNode) EvalRegex ¶
func (n *EvalFunctionNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalFunctionNode) EvalString ¶
func (n *EvalFunctionNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
func (*EvalFunctionNode) EvalTime ¶ added in v1.0.0
func (n *EvalFunctionNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
func (*EvalFunctionNode) IsDynamic ¶ added in v1.0.0
func (n *EvalFunctionNode) IsDynamic() bool
func (*EvalFunctionNode) Type ¶
func (n *EvalFunctionNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
type EvalIntNode ¶
type EvalIntNode struct {
Int64 int64
}
func (*EvalIntNode) EvalBool ¶
func (n *EvalIntNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
func (*EvalIntNode) EvalDuration ¶ added in v1.0.0
func (n *EvalIntNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
func (*EvalIntNode) EvalFloat ¶
func (n *EvalIntNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
func (*EvalIntNode) EvalInt ¶
func (n *EvalIntNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
func (*EvalIntNode) EvalMissing ¶ added in v1.3.0
func (n *EvalIntNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
func (*EvalIntNode) EvalRegex ¶
func (n *EvalIntNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalIntNode) EvalString ¶
func (n *EvalIntNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
func (*EvalIntNode) EvalTime ¶ added in v1.0.0
func (n *EvalIntNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
func (*EvalIntNode) IsDynamic ¶ added in v1.0.0
func (n *EvalIntNode) IsDynamic() bool
func (*EvalIntNode) Type ¶
func (n *EvalIntNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
type EvalLambdaNode ¶ added in v1.0.0
type EvalLambdaNode struct {
// contains filtered or unexported fields
}
func NewEvalLambdaNode ¶ added in v1.0.0
func NewEvalLambdaNode(lambda *ast.LambdaNode) (*EvalLambdaNode, error)
func (*EvalLambdaNode) EvalBool ¶ added in v1.0.0
func (n *EvalLambdaNode) EvalBool(scope *Scope, _ ExecutionState) (bool, error)
func (*EvalLambdaNode) EvalDuration ¶ added in v1.0.0
func (n *EvalLambdaNode) EvalDuration(scope *Scope, _ ExecutionState) (time.Duration, error)
func (*EvalLambdaNode) EvalFloat ¶ added in v1.0.0
func (n *EvalLambdaNode) EvalFloat(scope *Scope, _ ExecutionState) (float64, error)
func (*EvalLambdaNode) EvalInt ¶ added in v1.0.0
func (n *EvalLambdaNode) EvalInt(scope *Scope, _ ExecutionState) (int64, error)
func (*EvalLambdaNode) EvalMissing ¶ added in v1.3.0
func (n *EvalLambdaNode) EvalMissing(scope *Scope, _ ExecutionState) (*ast.Missing, error)
func (*EvalLambdaNode) EvalRegex ¶ added in v1.0.0
func (n *EvalLambdaNode) EvalRegex(scope *Scope, _ ExecutionState) (*regexp.Regexp, error)
func (*EvalLambdaNode) EvalString ¶ added in v1.0.0
func (n *EvalLambdaNode) EvalString(scope *Scope, _ ExecutionState) (string, error)
func (*EvalLambdaNode) EvalTime ¶ added in v1.0.0
func (n *EvalLambdaNode) EvalTime(scope *Scope, _ ExecutionState) (time.Time, error)
func (*EvalLambdaNode) IsDynamic ¶ added in v1.0.0
func (n *EvalLambdaNode) IsDynamic() bool
func (*EvalLambdaNode) Type ¶ added in v1.0.0
func (n *EvalLambdaNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
type EvalReferenceNode ¶
type EvalReferenceNode struct {
Node *ast.ReferenceNode
}
func (*EvalReferenceNode) EvalBool ¶
func (n *EvalReferenceNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
func (*EvalReferenceNode) EvalDuration ¶ added in v1.0.0
func (n *EvalReferenceNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
func (*EvalReferenceNode) EvalFloat ¶
func (n *EvalReferenceNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
func (*EvalReferenceNode) EvalInt ¶
func (n *EvalReferenceNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
func (*EvalReferenceNode) EvalMissing ¶ added in v1.3.0
func (n *EvalReferenceNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
func (*EvalReferenceNode) EvalRegex ¶
func (n *EvalReferenceNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalReferenceNode) EvalString ¶
func (n *EvalReferenceNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
func (*EvalReferenceNode) EvalTime ¶ added in v1.0.0
func (n *EvalReferenceNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
func (*EvalReferenceNode) IsDynamic ¶ added in v1.0.0
func (n *EvalReferenceNode) IsDynamic() bool
func (*EvalReferenceNode) Type ¶
func (n *EvalReferenceNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
type EvalRegexNode ¶
func (*EvalRegexNode) EvalBool ¶
func (n *EvalRegexNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
func (*EvalRegexNode) EvalDuration ¶ added in v1.0.0
func (n *EvalRegexNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
func (*EvalRegexNode) EvalFloat ¶
func (n *EvalRegexNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
func (*EvalRegexNode) EvalInt ¶
func (n *EvalRegexNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
func (*EvalRegexNode) EvalMissing ¶ added in v1.3.0
func (n *EvalRegexNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
func (*EvalRegexNode) EvalRegex ¶
func (n *EvalRegexNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalRegexNode) EvalString ¶
func (n *EvalRegexNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
func (*EvalRegexNode) EvalTime ¶ added in v1.0.0
func (n *EvalRegexNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
func (*EvalRegexNode) IsDynamic ¶ added in v1.0.0
func (n *EvalRegexNode) IsDynamic() bool
func (*EvalRegexNode) Type ¶
func (n *EvalRegexNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
type EvalStringNode ¶
type EvalStringNode struct {
Node *ast.StringNode
}
func (*EvalStringNode) EvalBool ¶
func (n *EvalStringNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
func (*EvalStringNode) EvalDuration ¶ added in v1.0.0
func (n *EvalStringNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
func (*EvalStringNode) EvalFloat ¶
func (n *EvalStringNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
func (*EvalStringNode) EvalInt ¶
func (n *EvalStringNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
func (*EvalStringNode) EvalMissing ¶ added in v1.3.0
func (n *EvalStringNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
func (*EvalStringNode) EvalRegex ¶
func (n *EvalStringNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalStringNode) EvalString ¶
func (n *EvalStringNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
func (*EvalStringNode) EvalTime ¶ added in v1.0.0
func (n *EvalStringNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
func (*EvalStringNode) IsDynamic ¶ added in v1.0.0
func (n *EvalStringNode) IsDynamic() bool
func (*EvalStringNode) Type ¶
func (n *EvalStringNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
type EvalUnaryNode ¶
type EvalUnaryNode struct {
// contains filtered or unexported fields
}
func NewEvalUnaryNode ¶
func NewEvalUnaryNode(unaryNode *ast.UnaryNode) (*EvalUnaryNode, error)
func (*EvalUnaryNode) EvalBool ¶
func (n *EvalUnaryNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error)
func (*EvalUnaryNode) EvalDuration ¶ added in v1.0.0
func (n *EvalUnaryNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error)
func (*EvalUnaryNode) EvalFloat ¶
func (n *EvalUnaryNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error)
func (*EvalUnaryNode) EvalInt ¶
func (n *EvalUnaryNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error)
func (*EvalUnaryNode) EvalMissing ¶ added in v1.3.0
func (n *EvalUnaryNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error)
func (*EvalUnaryNode) EvalRegex ¶
func (n *EvalUnaryNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalUnaryNode) EvalString ¶
func (n *EvalUnaryNode) EvalString(scope *Scope, executionState ExecutionState) (string, error)
func (*EvalUnaryNode) EvalTime ¶ added in v1.0.0
func (n *EvalUnaryNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error)
func (*EvalUnaryNode) IsDynamic ¶ added in v1.0.0
func (n *EvalUnaryNode) IsDynamic() bool
func (*EvalUnaryNode) Type ¶
func (n *EvalUnaryNode) Type(scope ReadOnlyScope) (ast.ValueType, error)
type ExecutionState ¶
type ExecutionState struct {
Funcs Funcs
}
ExecutionState is auxiliary struct for data/context that needs to be passed to evaluation functions
func CreateExecutionState ¶
func CreateExecutionState() ExecutionState
func (ExecutionState) ResetAll ¶
func (ea ExecutionState) ResetAll()
type Expression ¶
type Expression interface { Reset() Type(scope ReadOnlyScope) (ast.ValueType, error) EvalFloat(scope *Scope) (float64, error) EvalInt(scope *Scope) (int64, error) EvalString(scope *Scope) (string, error) EvalBool(scope *Scope) (bool, error) EvalDuration(scope *Scope) (time.Duration, error) Eval(scope *Scope) (interface{}, error) // Return a copy of the expression but with a Reset state. CopyReset() Expression }
Expression is interface that describe expression with state and it's evaluation.
func NewExpression ¶
func NewExpression(node ast.Node) (Expression, error)
NewExpression accept a node and try to "compile"/ "specialise" it in order to achieve better runtime performance.
For example:
Given a BinaryNode{ReferNode("value"), NumberNode{Float64:10}} during runtime we can find the type of "value" and find the most matching comparison function - (float64,float64) or (int64,float64)
type Func ¶ added in v1.0.0
type Func interface { Reset() Call(...interface{}) (interface{}, error) Signature() map[Domain]ast.ValueType }
A callable function from within the expression
type NodeEvaluator ¶
type NodeEvaluator interface { EvalFloat(scope *Scope, executionState ExecutionState) (float64, error) EvalInt(scope *Scope, executionState ExecutionState) (int64, error) EvalString(scope *Scope, executionState ExecutionState) (string, error) EvalBool(scope *Scope, executionState ExecutionState) (bool, error) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error) // Type returns the type of ast.ValueType Type(scope ReadOnlyScope) (ast.ValueType, error) // Whether the type returned by the node can change. IsDynamic() bool }
NodeEvaluator provides a generic way for trying to fetch node value, if a speicifc type is requested (so Value isn't called, the *Value is called) ErrTypeGuardFailed must be returned
type ReadOnlyScope ¶
type ReadOnlyScope interface { Get(name string) (interface{}, error) DynamicFunc(name string) *DynamicFunc }
type Scope ¶ added in v1.0.0
type Scope struct {
// contains filtered or unexported fields
}
Contains a set of variables references and their values.
func (*Scope) DynamicFunc ¶ added in v1.3.0
func (s *Scope) DynamicFunc(name string) *DynamicFunc
func (*Scope) DynamicMethod ¶ added in v1.0.0
func (s *Scope) DynamicMethod(name string) DynamicMethod
func (*Scope) Reset ¶ added in v1.0.0
func (s *Scope) Reset()
Reset all scope values to an empty state.
func (*Scope) SetDynamicFunc ¶ added in v1.3.0
func (s *Scope) SetDynamicFunc(name string, f *DynamicFunc)
func (*Scope) SetDynamicMethod ¶ added in v1.0.0
func (s *Scope) SetDynamicMethod(name string, m DynamicMethod)
type ScopePool ¶
ScopePool - pooling mechanism for Scope The idea behind scope pool is to pool scopes and to put them only the needed variables for execution.
func NewScopePool ¶
NewScopePool - creates new ScopePool for the given Node
Source Files ¶
- eval_binary_node.go
- eval_bool_node.go
- eval_duration_node.go
- eval_float_node.go
- eval_function_node.go
- eval_int_node.go
- eval_lambda_node.go
- eval_reference_node.go
- eval_regex_node.go
- eval_string_node.go
- eval_unary_node.go
- evaluation_funcs.go
- execution_state.go
- expr.go
- functions.go
- node_evaluator.go
- scope.go
- scope_pool.go