predicate

package
v0.0.0-...-2bc12df Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryOp

type BinaryOp interface {
	Predicate
	Combine(Predicate, Predicate) Predicate
}

BinaryOp represents a binary operation that combines predicates to return a new predicate.

type CompositeParser

type CompositeParser struct {
	MatchErrMsg string
	Parsers     []Parser
}

CompositeParser represents a parser composed of multiple predicate parsers.

func (CompositeParser) Parse

func (cp CompositeParser) Parse(tokens []string) (Predicate, []string, error)

Parse is a wrapper to ParseAndReturnParserID. It implements the predicate.Parser interface for a CompositeParser.

func (CompositeParser) ParseAndReturnParserID

func (cp CompositeParser) ParseAndReturnParserID(tokens []string) (Predicate, []string, int, error)

ParseAndReturnParserID attempts to parse a predicate from the given tokens. It loops through each of cp's parsers, returning the result of the first parser that matches the input, and the matching parser's ID. If no parser matches the input, then Parse returns a MatchError containing cp.MatchErrMsg

type Parser

type Parser interface {
	Parse(tokens []string) (Predicate, []string, error)
}

Parser represents a parser that parses predicates.

func ToParser

func ToParser(parseFunc func(tokens []string) (Predicate, []string, error)) Parser

ToParser converts the given parse function to a predicate.Parser object

type Predicate

type Predicate interface {
	Negate() Predicate
	IsSatisfiedBy(v interface{}) bool
}

Predicate is an interface representing a predicate. It is used to generalize the expression parsing logic used by the top-level parser and the meta primary.

TODO: This interface is here because Go 1 doesn't support generics. Go 2 is planning to introduce some basic generic support, so we should re-evaluate this approach once it is released.

Jump to

Keyboard shortcuts

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