Documentation ¶
Index ¶
- Constants
- type ErrSide
- type ErrTypeGuardFailed
- type EvalBinaryNode
- func (e *EvalBinaryNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
- func (e *EvalBinaryNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
- func (e *EvalBinaryNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
- func (n *EvalBinaryNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalBinaryNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
- func (n *EvalBinaryNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
- type EvalBoolNode
- func (n *EvalBoolNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
- func (n *EvalBoolNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
- func (n *EvalBoolNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
- func (n *EvalBoolNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalBoolNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
- func (n *EvalBoolNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
- type EvalFloatNode
- func (n *EvalFloatNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
- func (n *EvalFloatNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
- func (n *EvalFloatNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
- func (n *EvalFloatNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalFloatNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
- func (n *EvalFloatNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
- type EvalFunctionNode
- func (n *EvalFunctionNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
- func (n *EvalFunctionNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
- func (n *EvalFunctionNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
- func (n *EvalFunctionNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalFunctionNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
- func (n *EvalFunctionNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
- type EvalIntNode
- func (n *EvalIntNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
- func (n *EvalIntNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
- func (n *EvalIntNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
- func (n *EvalIntNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalIntNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
- func (n *EvalIntNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
- type EvalReferenceNode
- func (n *EvalReferenceNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
- func (n *EvalReferenceNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
- func (n *EvalReferenceNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
- func (n *EvalReferenceNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalReferenceNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
- func (n *EvalReferenceNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
- type EvalRegexNode
- func (n *EvalRegexNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
- func (n *EvalRegexNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
- func (n *EvalRegexNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
- func (n *EvalRegexNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalRegexNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
- func (n *EvalRegexNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
- type EvalStringNode
- func (n *EvalStringNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
- func (n *EvalStringNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
- func (n *EvalStringNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
- func (n *EvalStringNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalStringNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
- func (n *EvalStringNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
- type EvalUnaryNode
- func (n *EvalUnaryNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
- func (n *EvalUnaryNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
- func (n *EvalUnaryNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
- func (n *EvalUnaryNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
- func (n *EvalUnaryNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
- func (n *EvalUnaryNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
- type ExecutionState
- type Expression
- type NodeEvaluator
- type ReadOnlyScope
- type ValueType
Constants ¶
const TNumeric = TFloat64 & TInt64
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 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 *tick.BinaryNode) (*EvalBinaryNode, error)
func (*EvalBinaryNode) EvalBool ¶
func (e *EvalBinaryNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
EvalBool executes the expression based on eval bool
func (*EvalBinaryNode) EvalFloat ¶
func (e *EvalBinaryNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
EvalNum executes the expression based on eval numeric
func (*EvalBinaryNode) EvalInt ¶
func (e *EvalBinaryNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
func (*EvalBinaryNode) EvalRegex ¶
func (n *EvalBinaryNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalBinaryNode) EvalString ¶
func (n *EvalBinaryNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
func (*EvalBinaryNode) Type ¶
func (n *EvalBinaryNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
type EvalBoolNode ¶
func (*EvalBoolNode) EvalBool ¶
func (n *EvalBoolNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
func (*EvalBoolNode) EvalFloat ¶
func (n *EvalBoolNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
func (*EvalBoolNode) EvalInt ¶
func (n *EvalBoolNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
func (*EvalBoolNode) EvalRegex ¶
func (n *EvalBoolNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalBoolNode) EvalString ¶
func (n *EvalBoolNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
func (*EvalBoolNode) Type ¶
func (n *EvalBoolNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
type EvalFloatNode ¶
type EvalFloatNode struct {
Float64 float64
}
func (*EvalFloatNode) EvalBool ¶
func (n *EvalFloatNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
func (*EvalFloatNode) EvalFloat ¶
func (n *EvalFloatNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
func (*EvalFloatNode) EvalInt ¶
func (n *EvalFloatNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
func (*EvalFloatNode) EvalRegex ¶
func (n *EvalFloatNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalFloatNode) EvalString ¶
func (n *EvalFloatNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
func (*EvalFloatNode) Type ¶
func (n *EvalFloatNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
type EvalFunctionNode ¶
type EvalFunctionNode struct {
// contains filtered or unexported fields
}
func NewEvalFunctionNode ¶
func NewEvalFunctionNode(funcNode *tick.FunctionNode) (*EvalFunctionNode, error)
func (*EvalFunctionNode) EvalBool ¶
func (n *EvalFunctionNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
func (*EvalFunctionNode) EvalFloat ¶
func (n *EvalFunctionNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
func (*EvalFunctionNode) EvalInt ¶
func (n *EvalFunctionNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
func (*EvalFunctionNode) EvalRegex ¶
func (n *EvalFunctionNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalFunctionNode) EvalString ¶
func (n *EvalFunctionNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
func (*EvalFunctionNode) Type ¶
func (n *EvalFunctionNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
type EvalIntNode ¶
type EvalIntNode struct {
Int64 int64
}
func (*EvalIntNode) EvalBool ¶
func (n *EvalIntNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
func (*EvalIntNode) EvalFloat ¶
func (n *EvalIntNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
func (*EvalIntNode) EvalInt ¶
func (n *EvalIntNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
func (*EvalIntNode) EvalRegex ¶
func (n *EvalIntNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalIntNode) EvalString ¶
func (n *EvalIntNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
func (*EvalIntNode) Type ¶
func (n *EvalIntNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
type EvalReferenceNode ¶
type EvalReferenceNode struct {
Node *tick.ReferenceNode
}
func (*EvalReferenceNode) EvalBool ¶
func (n *EvalReferenceNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
func (*EvalReferenceNode) EvalFloat ¶
func (n *EvalReferenceNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
func (*EvalReferenceNode) EvalInt ¶
func (n *EvalReferenceNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
func (*EvalReferenceNode) EvalRegex ¶
func (n *EvalReferenceNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalReferenceNode) EvalString ¶
func (n *EvalReferenceNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
func (*EvalReferenceNode) Type ¶
func (n *EvalReferenceNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
type EvalRegexNode ¶
func (*EvalRegexNode) EvalBool ¶
func (n *EvalRegexNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
func (*EvalRegexNode) EvalFloat ¶
func (n *EvalRegexNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
func (*EvalRegexNode) EvalInt ¶
func (n *EvalRegexNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
func (*EvalRegexNode) EvalRegex ¶
func (n *EvalRegexNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalRegexNode) EvalString ¶
func (n *EvalRegexNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
func (*EvalRegexNode) Type ¶
func (n *EvalRegexNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
type EvalStringNode ¶
type EvalStringNode struct {
Node *tick.StringNode
}
func (*EvalStringNode) EvalBool ¶
func (n *EvalStringNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
func (*EvalStringNode) EvalFloat ¶
func (n *EvalStringNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
func (*EvalStringNode) EvalInt ¶
func (n *EvalStringNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
func (*EvalStringNode) EvalRegex ¶
func (n *EvalStringNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalStringNode) EvalString ¶
func (n *EvalStringNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
func (*EvalStringNode) Type ¶
func (n *EvalStringNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
type EvalUnaryNode ¶
type EvalUnaryNode struct {
// contains filtered or unexported fields
}
func NewEvalUnaryNode ¶
func NewEvalUnaryNode(unaryNode *tick.UnaryNode) (*EvalUnaryNode, error)
func (*EvalUnaryNode) EvalBool ¶
func (n *EvalUnaryNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error)
func (*EvalUnaryNode) EvalFloat ¶
func (n *EvalUnaryNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error)
func (*EvalUnaryNode) EvalInt ¶
func (n *EvalUnaryNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error)
func (*EvalUnaryNode) EvalRegex ¶
func (n *EvalUnaryNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error)
func (*EvalUnaryNode) EvalString ¶
func (n *EvalUnaryNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error)
func (*EvalUnaryNode) Type ¶
func (n *EvalUnaryNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error)
type ExecutionState ¶
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() EvalFloat(scope *tick.Scope) (float64, error) EvalInt(scope *tick.Scope) (int64, error) EvalString(scope *tick.Scope) (string, error) EvalBool(scope *tick.Scope) (bool, error) EvalNum(scope *tick.Scope) (interface{}, error) }
Expression is interface that describe expression with state and it's evaluation.
func NewExpression ¶
func NewExpression(node tick.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 NodeEvaluator ¶
type NodeEvaluator interface { EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error) // Type returns the type of ValueType Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error) }
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