Documentation
¶
Index ¶
- func Evaluate(expr Expr, post *models.Post, ctx *EvalContext) (bool, error)
- func MatchPost(expression string, post *models.Post) (bool, error)
- func Posts(expression string, posts []*models.Post) ([]*models.Post, error)
- type BinaryExpr
- type CallExpr
- type EvalContext
- type Expr
- type FieldAccess
- type Filter
- func (f *Filter) Expression() string
- func (f *Filter) Match(post *models.Post) (bool, error)
- func (f *Filter) MatchAll(posts []*models.Post) []*models.Post
- func (f *Filter) MatchAllWithErrors(posts []*models.Post) ([]*models.Post, []error)
- func (f *Filter) MustMatch(post *models.Post) bool
- func (f *Filter) RefreshContext()
- func (f *Filter) SetContext(ctx *EvalContext)
- type Identifier
- type InExpr
- type Lexer
- type Literal
- type Parser
- type SpecialValue
- type Token
- type TokenType
- type UnaryExpr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BinaryExpr ¶
BinaryExpr represents a binary expression (left op right)
func (*BinaryExpr) String ¶
func (e *BinaryExpr) String() string
type EvalContext ¶
EvalContext contains the context for evaluating filter expressions
func NewEvalContext ¶
func NewEvalContext() *EvalContext
NewEvalContext creates a new evaluation context with current time values
type Expr ¶
type Expr interface {
String() string
// contains filtered or unexported methods
}
Expr is the interface for all AST nodes
func ParseExpression ¶
ParseExpression parses a filter expression string into an AST
type FieldAccess ¶
FieldAccess represents field access (object.field)
func (*FieldAccess) String ¶
func (e *FieldAccess) String() string
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter represents a compiled filter expression
func Parse ¶
Parse parses a filter expression and returns a Filter. Parsed ASTs are cached to avoid re-parsing identical expressions.
func (*Filter) Expression ¶
Expression returns the original filter expression string
func (*Filter) MatchAllWithErrors ¶
MatchAllWithErrors filters a slice of posts and returns matches along with any errors
func (*Filter) RefreshContext ¶
func (f *Filter) RefreshContext()
RefreshContext refreshes the context with current time values
func (*Filter) SetContext ¶
func (f *Filter) SetContext(ctx *EvalContext)
SetContext sets a custom evaluation context
type Identifier ¶
type Identifier struct {
Name string
}
Identifier represents an identifier
func (*Identifier) String ¶
func (e *Identifier) String() string
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer tokenizes a filter expression
type Literal ¶
type Literal struct {
Value interface{}
}
Literal represents a literal value (string, number, bool, nil)
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser parses filter expressions into an AST
type SpecialValue ¶
type SpecialValue struct {
Name string
}
SpecialValue represents special values like 'today' and 'now'
func (*SpecialValue) String ¶
func (e *SpecialValue) String() string
type Token ¶
type Token struct {
Type TokenType
Value string
Literal interface{} // For STRING, NUMBER, BOOL: the actual value
Pos int // Position in the input string
}
Token represents a lexical token