Documentation
¶
Overview ¶
Package conditions package offers a parser of a simple conditions specification language (reduced set of arithmetic/logical operations). It was created for Flow-Based Programming components that require configuration to perform some operations on the data received from multiple input ports.
Index ¶
- Constants
- func Evaluate(expr Expr, args map[string]interface{}) (bool, error)
- func EvaluateWithArgResolver(expr Expr, args ArgResolver) (bool, error)
- func FormatDuration(d time.Duration) string
- func Quote(s string) string
- func QuoteIdent(s string) string
- func SetDefaultEpsilon(ep float64)
- func Variables(expression Expr) []string
- func Walk(v Visitor, node Node)
- func WalkFunc(node Node, fn func(Node))
- type ArgResolver
- type BinaryExpr
- type BooleanLiteral
- type Collection
- func NewCollection(items []interface{}) (Collection, error)
- func NewMapNumberCollection(items []interface{}) Collection
- func NewMapNumberCollectionFromMap(items map[float64]bool) Collection
- func NewMapStringCollection(items []interface{}) Collection
- func TryNewCollection(items []interface{}) Collection
- type DataType
- type DurationLiteral
- type Expr
- type MapArgResolver
- type MapNumberCollection
- type MapStringCollection
- type Node
- type NumberCollection
- type NumberCollectionLiteral
- type NumberLiteral
- type ParenExpr
- type Parser
- type SliceNumberLiteral
- type SliceStringLiteral
- type StringCollection
- type StringCollectionLiteral
- type StringLiteral
- type TimeLiteral
- type Token
- type VarRef
- type Visitor
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func EvaluateWithArgResolver ¶
func EvaluateWithArgResolver(expr Expr, args ArgResolver) (bool, error)
EvaluateWithArgResolver takes an expr and evaluates it using given arg resolver
func FormatDuration ¶
FormatDuration formats a duration to a string.
func QuoteIdent ¶
QuoteIdent returns a quoted identifier if the identifier requires quoting. Otherwise returns the original string passed in.
func SetDefaultEpsilon ¶
func SetDefaultEpsilon(ep float64)
SetDefaultEpsilon sets the defaultEpsilon
Types ¶
type ArgResolver ¶
func NewMapArgResolver ¶
func NewMapArgResolver(args map[string]interface{}) ArgResolver
type BinaryExpr ¶
BinaryExpr represents an operation between two expressions.
func (*BinaryExpr) Args ¶
func (e *BinaryExpr) Args() []string
func (*BinaryExpr) String ¶
func (e *BinaryExpr) String() string
String returns a string representation of the binary expression.
type BooleanLiteral ¶
type BooleanLiteral struct {
Val bool
}
BooleanLiteral represents a boolean literal.
func (*BooleanLiteral) Args ¶
func (l *BooleanLiteral) Args() []string
func (*BooleanLiteral) String ¶
func (l *BooleanLiteral) String() string
String returns a string representation of the literal.
type Collection ¶
func NewCollection ¶
func NewCollection(items []interface{}) (Collection, error)
func NewMapNumberCollection ¶
func NewMapNumberCollection(items []interface{}) Collection
func NewMapNumberCollectionFromMap ¶
func NewMapNumberCollectionFromMap(items map[float64]bool) Collection
func NewMapStringCollection ¶
func NewMapStringCollection(items []interface{}) Collection
func TryNewCollection ¶
func TryNewCollection(items []interface{}) Collection
type DataType ¶
type DataType string
DataType represents the primitive data types available in InfluxQL.
func InspectDataType ¶
func InspectDataType(v interface{}) DataType
InspectDataType returns the data type of a given value.
type DurationLiteral ¶
DurationLiteral represents a duration literal.
func (*DurationLiteral) String ¶
func (l *DurationLiteral) String() string
String returns a string representation of the literal.
type MapArgResolver ¶
type MapArgResolver struct {
// contains filtered or unexported fields
}
func (*MapArgResolver) Resolve ¶
func (r *MapArgResolver) Resolve(key string) (interface{}, error)
type MapNumberCollection ¶
type MapNumberCollection struct {
// contains filtered or unexported fields
}
func (*MapNumberCollection) Count ¶
func (c *MapNumberCollection) Count() int
func (*MapNumberCollection) Has ¶
func (c *MapNumberCollection) Has(number float64) bool
func (*MapNumberCollection) String ¶
func (c *MapNumberCollection) String() string
type MapStringCollection ¶
type MapStringCollection struct {
// contains filtered or unexported fields
}
func (*MapStringCollection) Count ¶
func (c *MapStringCollection) Count() int
func (*MapStringCollection) Has ¶
func (c *MapStringCollection) Has(val string) bool
func (*MapStringCollection) String ¶
func (c *MapStringCollection) String() string
type Node ¶
type Node interface { String() string // contains filtered or unexported methods }
Node represents a node in the conditions abstract syntax tree.
type NumberCollection ¶
type NumberCollectionLiteral ¶
type NumberCollectionLiteral struct {
Val NumberCollection
}
func (*NumberCollectionLiteral) Args ¶
func (l *NumberCollectionLiteral) Args() []string
func (*NumberCollectionLiteral) String ¶
func (l *NumberCollectionLiteral) String() string
type NumberLiteral ¶
type NumberLiteral struct {
Val float64
}
NumberLiteral represents a numeric literal.
func (*NumberLiteral) Args ¶
func (n *NumberLiteral) Args() []string
func (*NumberLiteral) String ¶
func (l *NumberLiteral) String() string
String returns a string representation of the literal.
type ParenExpr ¶
type ParenExpr struct {
Expr Expr
}
ParenExpr represents a parenthesized expression.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser encapsulates the scanner and responsible for returning AST composed from statements read from a given reader.
type SliceNumberLiteral ¶
type SliceNumberLiteral struct {
Val []float64
}
func (*SliceNumberLiteral) Args ¶
func (l *SliceNumberLiteral) Args() []string
func (*SliceNumberLiteral) String ¶
func (l *SliceNumberLiteral) String() string
String returns a string representation of the literal.
type SliceStringLiteral ¶
type SliceStringLiteral struct { Val []string // contains filtered or unexported fields }
func NewSliceStringLiteral ¶
func NewSliceStringLiteral(val []string) *SliceStringLiteral
func (*SliceStringLiteral) Args ¶
func (l *SliceStringLiteral) Args() []string
func (*SliceStringLiteral) String ¶
func (l *SliceStringLiteral) String() string
String returns a string representation of the literal.
type StringCollection ¶
type StringCollectionLiteral ¶
type StringCollectionLiteral struct {
Val StringCollection
}
func (*StringCollectionLiteral) Args ¶
func (l *StringCollectionLiteral) Args() []string
func (*StringCollectionLiteral) String ¶
func (l *StringCollectionLiteral) String() string
type StringLiteral ¶
type StringLiteral struct {
Val string
}
StringLiteral represents a string literal.
func (*StringLiteral) Args ¶
func (l *StringLiteral) Args() []string
func (*StringLiteral) String ¶
func (l *StringLiteral) String() string
String returns a string representation of the literal.
type TimeLiteral ¶
TimeLiteral represents a point-in-time literal.
func (*TimeLiteral) String ¶
func (l *TimeLiteral) String() string
String returns a string representation of the literal.
type Token ¶
type Token int
Token represents a lexical token.
const ( // ILLEGAL token represent illegal token found in the statement ILLEGAL Token = iota // EOF token represents end of statement EOF IDENT // Variable references $0, $5, etc NUMBER // 12345.67 STRING // "abc" ARRAY // array of values (string or number) ["a","b","c"] [342,4325,6,4] TRUE // true FALSE // false AND // AND OR // OR EQ // = NEQ // != LT // < LTE // <= GT // > GTE // >= NAND // NAND XOR // XOR EREG // =~ NEREG // !~ IN // IN NOTIN // NOT IN CONTAINS // CONTAINS NOTCONTAINS // NOT CONTAINS LPAREN // ( RPAREN // ) )
func (Token) Precedence ¶
Precedence returns the operator precedence of the binary operator token.