Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CriteriaAST ¶
type CriteriaAST interface { // RootOperation returns the operation performed by the root node, // or the grouping, if the root is a leaf. RootOperation() OperationType // RootOperation returns the function performed by the root node, // if any. RootFunction() FunctionType // IsLeaf returns true if the root node is a leaf. IsLeaf() bool // AcceptVisitor implements the visitor pattern. AcceptVisitor(v Visitor) // Clone returns a deep copy of the tree. Clone() CriteriaAST }
CriteriaAST is the abstract syntax tree of a filter criteria.
func SimplifyCriteria ¶
func SimplifyCriteria(tree CriteriaAST) (CriteriaAST, error)
SimplifyCriteria applies multiple simplifications to a criteria.
type FunctionType ¶
type FunctionType int
FunctionType is the type of a function.
const ( FunctionNone FunctionType = iota FunctionFrom FunctionTo FunctionCc FunctionBcc FunctionReplyTo FunctionSubject FunctionList FunctionHas FunctionQuery )
Functions.
func (FunctionType) String ¶
func (f FunctionType) String() string
type Leaf ¶
type Leaf struct { Function FunctionType Grouping OperationType Args []string IsRaw bool }
Leaf is an AST node with no children.
If the function has multiple arguments, they are grouped together with a logical operator. For example: from:{a b} has two arguments grouped with an OR and from:(a b) is grouped with an AND.
func (*Leaf) AcceptVisitor ¶
AcceptVisitor implements the visitor pattern.
func (*Leaf) RootFunction ¶
func (n *Leaf) RootFunction() FunctionType
RootFunction returns the function of the leaf.
func (*Leaf) RootOperation ¶
func (n *Leaf) RootOperation() OperationType
RootOperation returns the grouping of the leaf.
type Node ¶
type Node struct { Operation OperationType Children []CriteriaAST }
Node is an AST node with children nodes. It can only be a logical operator.
func (*Node) AcceptVisitor ¶
AcceptVisitor implements the visitor pattern.
func (*Node) RootFunction ¶
func (n *Node) RootFunction() FunctionType
RootFunction will always return 'none'.
func (*Node) RootOperation ¶
func (n *Node) RootOperation() OperationType
RootOperation returns the operation performed by the root node.
type OperationType ¶
type OperationType int
OperationType is the type of logical operator.
const ( OperationNone OperationType = iota OperationAnd OperationOr OperationNot )
Logical operations.
func (OperationType) String ¶
func (t OperationType) String() string
type Rule ¶
type Rule struct { Criteria CriteriaAST Actions Actions }
Rule is an intermediate representation of a Gmail filter.