predicate

package
v0.0.0-rc9 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindVal

func FindVal(expr Expr) any

func Quote

func Quote(s string) string

Quote returns a quoted string.

Types

type BinaryExpr

type BinaryExpr struct {
	Op  Token
	LHS Expr
	RHS Expr
}

BinaryExpr represents an operation between two expressions.

func (*BinaryExpr) Args

func (e *BinaryExpr) Args() []string

func (*BinaryExpr) String

func (e *BinaryExpr) String() string

String returns a string representation of the binary expression.

type BooleanLiteral

type BooleanLiteral struct {
	Val bool
}

BooleanLiteral represents a boolean literal.

func (*BooleanLiteral) Args

func (l *BooleanLiteral) Args() []string

func (*BooleanLiteral) String

func (l *BooleanLiteral) String() string

String returns a string representation of the literal.

type Expr

type Expr interface {
	Node

	Args() []string
	// contains filtered or unexported methods
}

Expr represents an expression that can be evaluated to a value.

type Node

type Node interface {
	String() string
	// contains filtered or unexported methods
}

Node represents a node in the conditions abstract syntax tree.

type NumberLiteral

type NumberLiteral struct {
	Val float64
}

NumberLiteral represents a numeric literal.

func (*NumberLiteral) Args

func (n *NumberLiteral) Args() []string

func (*NumberLiteral) String

func (n *NumberLiteral) String() string

String returns a string representation of the literal.

type Operand

type Operand struct {
	Op  Token
	Val any
}

func InclusionOperands

func InclusionOperands(predicate abstract.WhereStatement, col string) ([]Operand, error)

func (Operand) Match

func (o Operand) Match(v any) bool

type ParenExpr

type ParenExpr struct {
	Expr     Expr
	Inverted bool
}

ParenExpr represents a parenthesized expression.

func (*ParenExpr) Args

func (e *ParenExpr) Args() []string

func (*ParenExpr) String

func (e *ParenExpr) String() string

String returns a string representation of the parenthesized expression.

type Parser

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

Parser encapsulates the scanner and responsible for returning AST composed of statements read from a given reader.

func NewParser

func NewParser(r io.Reader) *Parser

NewParser returns a new instance of Parser.

func (*Parser) Parse

func (p *Parser) Parse() (Expr, error)

Parse starts scanning & parsing process (main entry point). It returns an expression (AST) which you can use for the final evaluation of the conditions/statements

type StringLiteral

type StringLiteral struct {
	Val string
}

StringLiteral represents a string literal.

func (*StringLiteral) Args

func (l *StringLiteral) Args() []string

func (*StringLiteral) String

func (l *StringLiteral) String() string

String returns a string representation of the literal.

type Token

type Token int

Token represents a lexical token.

const (
	// ILLEGAL token represent illegal token found in the statement
	ILLEGAL Token = iota
	// EOF token represents end of statement
	EOF

	// Literals
	NUMBER // 12345.67
	STRING // "abc"
	TRUE   // true
	FALSE  // false

	AND // AND
	OR  // OR
	EQ  // =
	NEQ // !=
	LT  // <
	LTE // <=
	GT  // >
	GTE // >=

	LPAREN // (
	RPAREN // )

	NOT // NOT
)

func (Token) Precedence

func (tok Token) Precedence() int

Precedence returns the operator precedence of the binary operator token.

func (Token) String

func (tok Token) String() string

String returns the string representation of the token.

Jump to

Keyboard shortcuts

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