...

Package filtering

import "go.einride.tech/aip/filtering"
Overview
Index
Subdirectories

Overview ▾

Package filtering provides primitives for implementing AIP filtering.

See: https://google.aip.dev/160 (Filtering)

Index ▾

Constants
Variables
func And(args ...*expr.Expr) *expr.Expr
func Duration(value time.Duration) *expr.Expr
func Equals(lhs, rhs *expr.Expr) *expr.Expr
func Expression(sequences ...*expr.Expr) *expr.Expr
func Factor(terms ...*expr.Expr) *expr.Expr
func Float(value float64) *expr.Expr
func Function(name string, args ...*expr.Expr) *expr.Expr
func GreaterEquals(lhs, rhs *expr.Expr) *expr.Expr
func GreaterThan(lhs, rhs *expr.Expr) *expr.Expr
func Has(lhs, rhs *expr.Expr) *expr.Expr
func Int(value int64) *expr.Expr
func LessEquals(lhs, rhs *expr.Expr) *expr.Expr
func LessThan(lhs, rhs *expr.Expr) *expr.Expr
func Member(operand *expr.Expr, field string) *expr.Expr
func NewConstantDeclaration(name string, constantType *expr.Type, constantValue *expr.Constant) *expr.Decl
func NewFunctionDeclaration(name string, overloads ...*expr.Decl_FunctionDecl_Overload) *expr.Decl
func NewFunctionOverload(id string, result *expr.Type, params ...*expr.Type) *expr.Decl_FunctionDecl_Overload
func NewIdentDeclaration(name string, identType *expr.Type) *expr.Decl
func NewStringConstant(value string) *expr.Constant
func Not(arg *expr.Expr) *expr.Expr
func NotEquals(lhs, rhs *expr.Expr) *expr.Expr
func Or(args ...*expr.Expr) *expr.Expr
func Sequence(factors ...*expr.Expr) *expr.Expr
func StandardFunctionAnd() *expr.Decl
func StandardFunctionDeclarations() []*expr.Decl
func StandardFunctionDuration() *expr.Decl
func StandardFunctionEquals() *expr.Decl
func StandardFunctionGreaterEquals() *expr.Decl
func StandardFunctionGreaterThan() *expr.Decl
func StandardFunctionHas() *expr.Decl
func StandardFunctionLessEquals() *expr.Decl
func StandardFunctionLessThan() *expr.Decl
func StandardFunctionNot() *expr.Decl
func StandardFunctionNotEquals() *expr.Decl
func StandardFunctionOr() *expr.Decl
func StandardFunctionTimestamp() *expr.Decl
func String(s string) *expr.Expr
func Text(text string) *expr.Expr
func Timestamp(value time.Time) *expr.Expr
func TypeEnum(enumType protoreflect.EnumType) *expr.Type
func TypeList(elementType *expr.Type) *expr.Type
func TypeMap(keyType, valueType *expr.Type) *expr.Type
func Walk(fn WalkFunc, currExpr *expr.Expr)
type Checker
    func (c *Checker) Check() (*expr.CheckedExpr, error)
    func (c *Checker) Init(exp *expr.Expr, sourceInfo *expr.SourceInfo, declarations *Declarations)
type Cursor
    func (c *Cursor) Expr() *expr.Expr
    func (c *Cursor) Parent() (*expr.Expr, bool)
    func (c *Cursor) Replace(newExpr *expr.Expr)
type DeclarationOption
    func DeclareEnumIdent(name string, enumType protoreflect.EnumType) DeclarationOption
    func DeclareFunction(name string, overloads ...*expr.Decl_FunctionDecl_Overload) DeclarationOption
    func DeclareIdent(name string, t *expr.Type) DeclarationOption
    func DeclareStandardFunctions() DeclarationOption
type Declarations
    func NewDeclarations(opts ...DeclarationOption) (*Declarations, error)
    func (d *Declarations) LookupEnumIdent(name string) (protoreflect.EnumType, bool)
    func (d *Declarations) LookupFunction(name string) (*expr.Decl, bool)
    func (d *Declarations) LookupIdent(name string) (*expr.Decl, bool)
type Filter
    func ApplyMacros(filter Filter, declarations *Declarations, macros ...Macro) (Filter, error)
    func ParseFilter(request Request, declarations *Declarations) (Filter, error)
type Lexer
    func (l *Lexer) Init(filter string)
    func (l *Lexer) Lex() (Token, error)
    func (l *Lexer) LineOffsets() []int32
    func (l *Lexer) Position() Position
type Macro
type Parser
    func (p *Parser) Init(filter string)
    func (p *Parser) Parse() (*expr.ParsedExpr, error)
    func (p *Parser) ParseArg() (_ *expr.Expr, err error)
    func (p *Parser) ParseComparable() (_ *expr.Expr, err error)
    func (p *Parser) ParseComposite() (_ *expr.Expr, err error)
    func (p *Parser) ParseExpression() (_ *expr.Expr, err error)
    func (p *Parser) ParseFactor() (_ *expr.Expr, err error)
    func (p *Parser) ParseFloat() (_ *expr.Expr, err error)
    func (p *Parser) ParseFunction() (_ *expr.Expr, err error)
    func (p *Parser) ParseInt() (_ *expr.Expr, err error)
    func (p *Parser) ParseMember() (_ *expr.Expr, err error)
    func (p *Parser) ParseNumber() (_ *expr.Expr, err error)
    func (p *Parser) ParseRestriction() (_ *expr.Expr, err error)
    func (p *Parser) ParseSequence() (_ *expr.Expr, err error)
    func (p *Parser) ParseSimple() (_ *expr.Expr, err error)
    func (p *Parser) ParseTerm() (_ *expr.Expr, err error)
    func (p *Parser) SourceInfo() *expr.SourceInfo
    func (p *Parser) TryParseFloat() (*expr.Expr, bool)
    func (p *Parser) TryParseFunction() (*expr.Expr, bool)
    func (p *Parser) TryParseNumber() (*expr.Expr, bool)
type Position
    func (p Position) String() string
type Request
type Token
    func (t Token) Unquote() string
type TokenType
    func (t TokenType) Function() string
    func (t TokenType) IsComparator() bool
    func (t TokenType) IsField() bool
    func (t TokenType) IsKeyword() bool
    func (t TokenType) IsName() bool
    func (t TokenType) IsValue() bool
    func (t TokenType) Test(other TokenType) bool
type WalkFunc

Package files

checker.go declarations.go doc.go errors.go expr.go filter.go functions.go lexer.go macro.go parsedexpr.go parser.go position.go request.go token.go tokentype.go types.go walk.go

Constants

Standard function names.

const (
    FunctionFuzzyAnd      = "FUZZY"
    FunctionAnd           = "AND"
    FunctionOr            = "OR"
    FunctionNot           = "NOT"
    FunctionEquals        = "="
    FunctionNotEquals     = "!="
    FunctionLessThan      = "<"
    FunctionLessEquals    = "<="
    FunctionGreaterEquals = ">="
    FunctionGreaterThan   = ">"
    FunctionHas           = ":"
    FunctionDuration      = "duration"
    FunctionTimestamp     = "timestamp"
)

Has overloads.

const (
    FunctionOverloadHasString          = FunctionHas + "_string"
    FunctionOverloadHasMapStringString = FunctionHas + "_map_string_string"
    FunctionOverloadHasListString      = FunctionHas + "_list_string"
)

LessThan overloads.

const (
    FunctionOverloadLessThanInt             = FunctionLessThan + "_int"
    FunctionOverloadLessThanFloat           = FunctionLessThan + "_float"
    FunctionOverloadLessThanString          = FunctionLessThan + "_string"
    FunctionOverloadLessThanTimestamp       = FunctionLessThan + "_timestamp"
    FunctionOverloadLessThanTimestampString = FunctionLessThan + "_timestamp_string"
    FunctionOverloadLessThanDuration        = FunctionLessThan + "_duration"
)

GreaterThan overloads.

const (
    FunctionOverloadGreaterThanInt             = FunctionGreaterThan + "_int"
    FunctionOverloadGreaterThanFloat           = FunctionGreaterThan + "_float"
    FunctionOverloadGreaterThanString          = FunctionGreaterThan + "_string"
    FunctionOverloadGreaterThanTimestamp       = FunctionGreaterThan + "_timestamp"
    FunctionOverloadGreaterThanTimestampString = FunctionGreaterThan + "_timestamp_string"
    FunctionOverloadGreaterThanDuration        = FunctionGreaterThan + "_duration"
)

LessEquals overloads.

const (
    FunctionOverloadLessEqualsInt             = FunctionLessEquals + "_int"
    FunctionOverloadLessEqualsFloat           = FunctionLessEquals + "_float"
    FunctionOverloadLessEqualsString          = FunctionLessEquals + "_string"
    FunctionOverloadLessEqualsTimestamp       = FunctionLessEquals + "_timestamp"
    FunctionOverloadLessEqualsTimestampString = FunctionLessEquals + "_timestamp_string"
    FunctionOverloadLessEqualsDuration        = FunctionLessEquals + "_duration"
)

GreaterEquals overloads.

const (
    FunctionOverloadGreaterEqualsInt             = FunctionGreaterEquals + "_int"
    FunctionOverloadGreaterEqualsFloat           = FunctionGreaterEquals + "_float"
    FunctionOverloadGreaterEqualsString          = FunctionGreaterEquals + "_string"
    FunctionOverloadGreaterEqualsTimestamp       = FunctionGreaterEquals + "_timestamp"
    FunctionOverloadGreaterEqualsTimestampString = FunctionGreaterEquals + "_timestamp_string"
    FunctionOverloadGreaterEqualsDuration        = FunctionGreaterEquals + "_duration"
)

Equals overloads.

const (
    FunctionOverloadEqualsBool            = FunctionEquals + "_bool"
    FunctionOverloadEqualsInt             = FunctionEquals + "_int"
    FunctionOverloadEqualsFloat           = FunctionEquals + "_float"
    FunctionOverloadEqualsString          = FunctionEquals + "_string"
    FunctionOverloadEqualsTimestamp       = FunctionEquals + "_timestamp"
    FunctionOverloadEqualsTimestampString = FunctionEquals + "_timestamp_string"
    FunctionOverloadEqualsDuration        = FunctionEquals + "_duration"
)

NotEquals overloads.

const (
    FunctionOverloadNotEqualsBool            = FunctionNotEquals + "_bool"
    FunctionOverloadNotEqualsInt             = FunctionNotEquals + "_int"
    FunctionOverloadNotEqualsFloat           = FunctionNotEquals + "_float"
    FunctionOverloadNotEqualsString          = FunctionNotEquals + "_string"
    FunctionOverloadNotEqualsTimestamp       = FunctionNotEquals + "_timestamp"
    FunctionOverloadNotEqualsTimestampString = FunctionNotEquals + "_timestamp_string"
    FunctionOverloadNotEqualsDuration        = FunctionNotEquals + "_duration"
)

And overloads.

const (
    FunctionOverloadAndBool = FunctionAnd + "_bool"
)

Duration overloads.

const (
    FunctionOverloadDurationString = FunctionDuration + "_string"
)

Not overloads.

const (
    FunctionOverloadNotBool = FunctionNot + "_bool"
)

Or overloads.

const (
    FunctionOverloadOrBool = FunctionOr + "_bool"
)

Timestamp overloads.

const (
    FunctionOverloadTimestampString = FunctionTimestamp + "_string"
)

Variables

Primitive types.

var (
    TypeInt    = &expr.Type{TypeKind: &expr.Type_Primitive{Primitive: expr.Type_INT64}}
    TypeFloat  = &expr.Type{TypeKind: &expr.Type_Primitive{Primitive: expr.Type_DOUBLE}}
    TypeString = &expr.Type{TypeKind: &expr.Type_Primitive{Primitive: expr.Type_STRING}}
    TypeBool   = &expr.Type{TypeKind: &expr.Type_Primitive{Primitive: expr.Type_BOOL}}
)

Well-known types.

var (
    TypeDuration  = &expr.Type{TypeKind: &expr.Type_WellKnown{WellKnown: expr.Type_DURATION}}
    TypeTimestamp = &expr.Type{TypeKind: &expr.Type_WellKnown{WellKnown: expr.Type_TIMESTAMP}}
)

func And

func And(args ...*expr.Expr) *expr.Expr

func Duration

func Duration(value time.Duration) *expr.Expr

func Equals

func Equals(lhs, rhs *expr.Expr) *expr.Expr

func Expression

func Expression(sequences ...*expr.Expr) *expr.Expr

func Factor

func Factor(terms ...*expr.Expr) *expr.Expr

func Float

func Float(value float64) *expr.Expr

func Function

func Function(name string, args ...*expr.Expr) *expr.Expr

func GreaterEquals

func GreaterEquals(lhs, rhs *expr.Expr) *expr.Expr

func GreaterThan

func GreaterThan(lhs, rhs *expr.Expr) *expr.Expr

func Has

func Has(lhs, rhs *expr.Expr) *expr.Expr

func Int

func Int(value int64) *expr.Expr

func LessEquals

func LessEquals(lhs, rhs *expr.Expr) *expr.Expr

func LessThan

func LessThan(lhs, rhs *expr.Expr) *expr.Expr

func Member

func Member(operand *expr.Expr, field string) *expr.Expr

func NewConstantDeclaration

func NewConstantDeclaration(name string, constantType *expr.Type, constantValue *expr.Constant) *expr.Decl

NewConstantDeclaration creates a new constant ident declaration.

func NewFunctionDeclaration

func NewFunctionDeclaration(name string, overloads ...*expr.Decl_FunctionDecl_Overload) *expr.Decl

NewFunctionDeclaration creates a new function declaration.

func NewFunctionOverload

func NewFunctionOverload(id string, result *expr.Type, params ...*expr.Type) *expr.Decl_FunctionDecl_Overload

NewFunctionOverload creates a new function overload.

func NewIdentDeclaration

func NewIdentDeclaration(name string, identType *expr.Type) *expr.Decl

NewIdentDeclaration creates a new ident declaration.

func NewStringConstant

func NewStringConstant(value string) *expr.Constant

NewStringConstant creates a new string constant.

func Not

func Not(arg *expr.Expr) *expr.Expr

func NotEquals

func NotEquals(lhs, rhs *expr.Expr) *expr.Expr

func Or

func Or(args ...*expr.Expr) *expr.Expr

func Sequence

func Sequence(factors ...*expr.Expr) *expr.Expr

func StandardFunctionAnd

func StandardFunctionAnd() *expr.Decl

StandardFunctionAnd returns a declaration for the standard `AND` function and all its standard overloads.

func StandardFunctionDeclarations

func StandardFunctionDeclarations() []*expr.Decl

StandardFunctionDeclarations returns declarations for all standard functions and their standard overloads.

func StandardFunctionDuration

func StandardFunctionDuration() *expr.Decl

StandardFunctionDuration returns a declaration for the standard `duration` function and all its standard overloads.

func StandardFunctionEquals

func StandardFunctionEquals() *expr.Decl

StandardFunctionEquals returns a declaration for the standard '=' function and all its standard overloads.

func StandardFunctionGreaterEquals

func StandardFunctionGreaterEquals() *expr.Decl

StandardFunctionGreaterEquals returns a declaration for the standard '>=' function and all its standard overloads.

func StandardFunctionGreaterThan

func StandardFunctionGreaterThan() *expr.Decl

StandardFunctionGreaterThan returns a declaration for the standard '>' function and all its standard overloads.

func StandardFunctionHas

func StandardFunctionHas() *expr.Decl

StandardFunctionHas returns a declaration for the standard `:` function and all its standard overloads.

func StandardFunctionLessEquals

func StandardFunctionLessEquals() *expr.Decl

StandardFunctionLessEquals returns a declaration for the standard '<=' function and all its standard overloads.

func StandardFunctionLessThan

func StandardFunctionLessThan() *expr.Decl

StandardFunctionLessThan returns a declaration for the standard '<' function and all its standard overloads.

func StandardFunctionNot

func StandardFunctionNot() *expr.Decl

StandardFunctionNot returns a declaration for the standard `NOT` function and all its standard overloads.

func StandardFunctionNotEquals

func StandardFunctionNotEquals() *expr.Decl

StandardFunctionNotEquals returns a declaration for the standard '!=' function and all its standard overloads.

func StandardFunctionOr

func StandardFunctionOr() *expr.Decl

StandardFunctionOr returns a declaration for the standard `OR` function and all its standard overloads.

func StandardFunctionTimestamp

func StandardFunctionTimestamp() *expr.Decl

StandardFunctionTimestamp returns a declaration for the standard `timestamp` function and all its standard overloads.

func String

func String(s string) *expr.Expr

func Text

func Text(text string) *expr.Expr

func Timestamp

func Timestamp(value time.Time) *expr.Expr

func TypeEnum

func TypeEnum(enumType protoreflect.EnumType) *expr.Type

TypeEnum returns the type of a protobuf enum.

func TypeList

func TypeList(elementType *expr.Type) *expr.Type

TypeList returns the type for a list with the provided element type.

func TypeMap

func TypeMap(keyType, valueType *expr.Type) *expr.Type

TypeMap returns the type for a map with the provided key and value types.

func Walk

func Walk(fn WalkFunc, currExpr *expr.Expr)

Walk an expression in depth-first order.

type Checker

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

func (*Checker) Check

func (c *Checker) Check() (*expr.CheckedExpr, error)

func (*Checker) Init

func (c *Checker) Init(exp *expr.Expr, sourceInfo *expr.SourceInfo, declarations *Declarations)

type Cursor

A Cursor describes an expression encountered while applying a Macro.

The method Replace can be used to rewrite the filter.

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

func (*Cursor) Expr

func (c *Cursor) Expr() *expr.Expr

Expr returns the current expression.

func (*Cursor) Parent

func (c *Cursor) Parent() (*expr.Expr, bool)

Parent returns the parent of the current expression.

func (*Cursor) Replace

func (c *Cursor) Replace(newExpr *expr.Expr)

Replace the current expression with a new expression.

type DeclarationOption

DeclarationOption configures Declarations.

type DeclarationOption func(*Declarations) error

func DeclareEnumIdent

func DeclareEnumIdent(name string, enumType protoreflect.EnumType) DeclarationOption

func DeclareFunction

func DeclareFunction(name string, overloads ...*expr.Decl_FunctionDecl_Overload) DeclarationOption

DeclareFunction is a DeclarationOption that declares a single function and its overloads.

func DeclareIdent

func DeclareIdent(name string, t *expr.Type) DeclarationOption

DeclareIdent is a DeclarationOption that declares a single ident.

func DeclareStandardFunctions

func DeclareStandardFunctions() DeclarationOption

DeclareStandardFunction is a DeclarationOption that declares all standard functions and their overloads.

type Declarations

Declarations contain declarations for type-checking filter expressions.

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

func NewDeclarations

func NewDeclarations(opts ...DeclarationOption) (*Declarations, error)

NewDeclarations creates a new set of Declarations for filter expression type-checking.

func (*Declarations) LookupEnumIdent

func (d *Declarations) LookupEnumIdent(name string) (protoreflect.EnumType, bool)

func (*Declarations) LookupFunction

func (d *Declarations) LookupFunction(name string) (*expr.Decl, bool)

func (*Declarations) LookupIdent

func (d *Declarations) LookupIdent(name string) (*expr.Decl, bool)

type Filter

Filter represents a parsed and type-checked filter.

type Filter struct {
    CheckedExpr *expr.CheckedExpr
}

func ApplyMacros

func ApplyMacros(filter Filter, declarations *Declarations, macros ...Macro) (Filter, error)

ApplyMacros applies the provided macros to the filter and type-checks the result against the provided declarations.

func ParseFilter

func ParseFilter(request Request, declarations *Declarations) (Filter, error)

ParseFilter parses and type-checks the filter in the provided Request.

type Lexer

Lexer is a filter expression lexer.

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

func (*Lexer) Init

func (l *Lexer) Init(filter string)

Init initializes the lexer with the provided filter.

func (*Lexer) Lex

func (l *Lexer) Lex() (Token, error)

Lex returns the next token in the filter expression, or io.EOF when there are no more tokens to lex.

func (*Lexer) LineOffsets

func (l *Lexer) LineOffsets() []int32

LineOffsets returns a monotonically increasing list of character offsets where newlines appear.

func (*Lexer) Position

func (l *Lexer) Position() Position

Position returns the current position of the lexer.

type Macro

Macro represents a function that can perform macro replacements on a filter expression.

type Macro func(*Cursor)

type Parser

Parser for filter expressions.

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

func (*Parser) Init

func (p *Parser) Init(filter string)

Init (re-)initializes the parser to parse the provided filter.

func (*Parser) Parse

func (p *Parser) Parse() (*expr.ParsedExpr, error)

Parse the filter.

func (*Parser) ParseArg

func (p *Parser) ParseArg() (_ *expr.Expr, err error)

ParseArg parses an Arg.

EBNF

arg
  : comparable
  | composite
  ;

func (*Parser) ParseComparable

func (p *Parser) ParseComparable() (_ *expr.Expr, err error)

ParseComparable parses a Comparable.

EBNF

comparable
  : member
  | function
  | number (custom)
  ;

func (*Parser) ParseComposite

func (p *Parser) ParseComposite() (_ *expr.Expr, err error)

ParseComposite parses a Composite.

EBNF

composite
  : LPAREN expression RPAREN
  ;

func (*Parser) ParseExpression

func (p *Parser) ParseExpression() (_ *expr.Expr, err error)

ParseExpression parses an Expression.

EBNF

expression
  : sequence {WS AND WS sequence}
  ;

func (*Parser) ParseFactor

func (p *Parser) ParseFactor() (_ *expr.Expr, err error)

ParseFactor parses a Factor.

EBNF

factor
  : term {WS OR WS term}
  ;

func (*Parser) ParseFloat

func (p *Parser) ParseFloat() (_ *expr.Expr, err error)

ParseFloat parses a float.

EBNF

float
  : MINUS? (NUMBER DOT NUMBER* | DOT NUMBER) EXP?
  ;

func (*Parser) ParseFunction

func (p *Parser) ParseFunction() (_ *expr.Expr, err error)

ParseFunction parses a Function.

EBNF

function
  : name {DOT name} LPAREN [argList] RPAREN
  ;

name
  : TEXT
  | keyword
  ;

func (*Parser) ParseInt

func (p *Parser) ParseInt() (_ *expr.Expr, err error)

ParseInt parses an int.

EBNF

int
  : MINUS? NUMBER
  | MINUS? HEX
  ;

func (*Parser) ParseMember

func (p *Parser) ParseMember() (_ *expr.Expr, err error)

ParseMember parses a Member.

EBNF

member
  : value {DOT field}
  ;

value
  : TEXT
  | STRING
  ;

field
  : value
  | keyword
  | number
  ;

func (*Parser) ParseNumber

func (p *Parser) ParseNumber() (_ *expr.Expr, err error)

ParseNumber parses a number.

EBNF

number
  : float
  | int
  ;

float
  : MINUS? (NUMBER DOT NUMBER* | DOT NUMBER) EXP?
  ;

int
  : MINUS? NUMBER
  | MINUS? HEX
  ;

func (*Parser) ParseRestriction

func (p *Parser) ParseRestriction() (_ *expr.Expr, err error)

ParseRestriction parses a Restriction.

EBNF

restriction
  : comparable [comparator arg]
  ;

func (*Parser) ParseSequence

func (p *Parser) ParseSequence() (_ *expr.Expr, err error)

ParseSequence parses a Sequence.

EBNF

sequence
  : factor {WS factor}
  ;

func (*Parser) ParseSimple

func (p *Parser) ParseSimple() (_ *expr.Expr, err error)

ParseSimple parses a Simple.

EBNF

simple
  : restriction
  | composite
  ;

func (*Parser) ParseTerm

func (p *Parser) ParseTerm() (_ *expr.Expr, err error)

ParseTerm parses a Term.

EBNF

term
  : [(NOT WS | MINUS)] simple
  ;

func (*Parser) SourceInfo

func (p *Parser) SourceInfo() *expr.SourceInfo

func (*Parser) TryParseFloat

func (p *Parser) TryParseFloat() (*expr.Expr, bool)

func (*Parser) TryParseFunction

func (p *Parser) TryParseFunction() (*expr.Expr, bool)

func (*Parser) TryParseNumber

func (p *Parser) TryParseNumber() (*expr.Expr, bool)

type Position

Position represents a position in a filter expression.

type Position struct {
    // Offset is the byte offset, starting at 0.
    Offset int32
    // Line is the line number, starting at 1.
    Line int32
    // Column is the column number, starting at 1 (character count per line).
    Column int32
}

func (Position) String

func (p Position) String() string

String returns a string representation of the position on the format <line>:<column>.

type Request

Request is an interface for gRPC requests that contain a standard AIP filter.

type Request interface {
    GetFilter() string
}

type Token

Token represents a token in a filter expression.

type Token struct {
    // Position of the token.
    Position Position
    // Type of the token.
    Type TokenType
    // Value of the token, if the token is a text or a string.
    Value string
}

func (Token) Unquote

func (t Token) Unquote() string

type TokenType

TokenType represents the type of a filter expression token.

See: https://google.aip.dev/assets/misc/ebnf-filtering.txt

type TokenType string

Value token types.

const (
    TokenTypeWhitespace TokenType = "WS"
    TokenTypeText       TokenType = "TEXT"
    TokenTypeString     TokenType = "STRING"
)

Keyword token types.

const (
    TokenTypeNot TokenType = "NOT"
    TokenTypeAnd TokenType = "AND"
    TokenTypeOr  TokenType = "OR"
)

Numeric token types.

const (
    TokenTypeNumber    TokenType = "NUM"
    TokenTypeHexNumber TokenType = "HEX"
)

Operator token types.

const (
    TokenTypeLeftParen     TokenType = "("
    TokenTypeRightParen    TokenType = ")"
    TokenTypeMinus         TokenType = "-"
    TokenTypeDot           TokenType = "."
    TokenTypeEquals        TokenType = "="
    TokenTypeHas           TokenType = ":"
    TokenTypeLessThan      TokenType = "<"
    TokenTypeGreaterThan   TokenType = ">"
    TokenTypeExclaim       TokenType = "!"
    TokenTypeComma         TokenType = ","
    TokenTypeLessEquals    TokenType = "<="
    TokenTypeGreaterEquals TokenType = ">="
    TokenTypeNotEquals     TokenType = "!="
)

func (TokenType) Function

func (t TokenType) Function() string

func (TokenType) IsComparator

func (t TokenType) IsComparator() bool

IsComparator returns true if the token is a valid comparator.

func (TokenType) IsField

func (t TokenType) IsField() bool

IsField returns true if the token is a valid field.

func (TokenType) IsKeyword

func (t TokenType) IsKeyword() bool

IsKeyword returns true if the token is a valid keyword.

func (TokenType) IsName

func (t TokenType) IsName() bool

IsName returns true if the token is a valid name.

func (TokenType) IsValue

func (t TokenType) IsValue() bool

IsField returns true if the token is a valid value.

func (TokenType) Test

func (t TokenType) Test(other TokenType) bool

type WalkFunc

WalkFunc is called for every expression while calling Walk. Return false to stop Walk.

type WalkFunc func(currExpr, parentExpr *expr.Expr) bool

Subdirectories

Name Synopsis
..
exprs Package exprs provides primitives for working with v1alpha1/expr values.