contactql

package
v0.43.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2019 License: AGPL-3.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ImplicitKey string = "*"
)

Variables

This section is empty.

Functions

func EvaluateQuery

func EvaluateQuery(env envs.Environment, query *ContactQuery, queryable Queryable) (bool, error)

EvaluateQuery evaluates the given parsed query against a queryable object

func NewErrorListener added in v0.6.2

func NewErrorListener() *errorListener

Types

type BoolCombination

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

BoolCombination is a AND or OR combination of multiple conditions

func NewBoolCombination

func NewBoolCombination(op BoolOperator, children ...QueryNode) *BoolCombination

NewBoolCombination creates a new boolean combination

func (*BoolCombination) Children added in v0.41.15

func (b *BoolCombination) Children() []QueryNode

Children returns the children of this boolean combination

func (*BoolCombination) Evaluate

func (b *BoolCombination) Evaluate(env envs.Environment, queryable Queryable) (bool, error)

Evaluate returns whether this combination evaluates to true or false

func (*BoolCombination) Operator added in v0.41.15

func (b *BoolCombination) Operator() BoolOperator

Operator returns the type of boolean operator this combination is

func (*BoolCombination) String

func (b *BoolCombination) String() string

type BoolOperator added in v0.41.15

type BoolOperator string

BoolOperator is a boolean operator (and or or)

const (
	// BoolOperatorAnd is our constant for an AND operation
	BoolOperatorAnd BoolOperator = "and"

	// BoolOperatorOr is our constant for an OR operation
	BoolOperatorOr BoolOperator = "or"
)

type Condition

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

Condition represents a comparison between a keywed value on the contact and a provided value

func (*Condition) Comparator added in v0.41.15

func (c *Condition) Comparator() string

Comparator returns the type of comparison being made

func (*Condition) Evaluate

func (c *Condition) Evaluate(env envs.Environment, queryable Queryable) (bool, error)

Evaluate evaluates this condition against the queryable contact

func (*Condition) Key added in v0.41.15

func (c *Condition) Key() string

Key returns the key for the field being queried

func (*Condition) String

func (c *Condition) String() string

func (*Condition) Value added in v0.41.15

func (c *Condition) Value() string

Value returns the value being compared against

type ContactQuery

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

func ParseQuery

func ParseQuery(text string) (*ContactQuery, error)

ParseQuery parses a ContactQL query from the given input

func (*ContactQuery) Evaluate

func (q *ContactQuery) Evaluate(env envs.Environment, queryable Queryable) (bool, error)

func (*ContactQuery) Root added in v0.41.15

func (q *ContactQuery) Root() QueryNode

func (*ContactQuery) String

func (q *ContactQuery) String() string

type QueryNode

type QueryNode interface {
	fmt.Stringer
	Evaluate(envs.Environment, Queryable) (bool, error)
}

QueryNode is the base for nodes in our query parse tree

type Queryable

type Queryable interface {
	ResolveQueryKey(envs.Environment, string) []interface{}
}

Queryable is the interface objects must implement queried

type Visitor

type Visitor struct {
	gen.BaseContactQLVisitor
}

func NewVisitor

func NewVisitor() *Visitor

NewVisitor creates a new ContactQL visitor

func (*Visitor) Visit

func (v *Visitor) Visit(tree antlr.ParseTree) interface{}

Visit the top level parse tree

func (*Visitor) VisitCombinationAnd

func (v *Visitor) VisitCombinationAnd(ctx *gen.CombinationAndContext) interface{}

expression : expression AND expression

func (*Visitor) VisitCombinationImpicitAnd

func (v *Visitor) VisitCombinationImpicitAnd(ctx *gen.CombinationImpicitAndContext) interface{}

expression : expression expression

func (*Visitor) VisitCombinationOr

func (v *Visitor) VisitCombinationOr(ctx *gen.CombinationOrContext) interface{}

expression : expression OR expression

func (*Visitor) VisitCondition

func (v *Visitor) VisitCondition(ctx *gen.ConditionContext) interface{}

expression : TEXT COMPARATOR literal

func (*Visitor) VisitExpressionGrouping

func (v *Visitor) VisitExpressionGrouping(ctx *gen.ExpressionGroupingContext) interface{}

expression : LPAREN expression RPAREN

func (*Visitor) VisitImplicitCondition

func (v *Visitor) VisitImplicitCondition(ctx *gen.ImplicitConditionContext) interface{}

expression : TEXT

func (*Visitor) VisitParse

func (v *Visitor) VisitParse(ctx *gen.ParseContext) interface{}

parse: expression

func (*Visitor) VisitStringLiteral

func (v *Visitor) VisitStringLiteral(ctx *gen.StringLiteralContext) interface{}

literal : STRING

func (*Visitor) VisitTextLiteral

func (v *Visitor) VisitTextLiteral(ctx *gen.TextLiteralContext) interface{}

literal : TEXT

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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