parser

package
v0.0.0-...-9b5cd94 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package parser contains expression parser for search parameter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Boolean

type Boolean bool

func (*Boolean) Capture

func (b *Boolean) Capture(values []string) error

type Compare

type Compare struct {
	Operator string   `@( "<=" | ">=" | "=" | "<" | ">" | "!=" )`
	Operand  *Operand `(  @@`
	Select   *Operand ` | @@ )`
}

func (*Compare) ExprQuery

func (c *Compare) ExprQuery(op string) bson.M

func (*Compare) Query

func (c *Compare) Query() bson.M

type Condition

type Condition struct {
	Operand *ConditionOperand `  @@`
	Not     *Condition        `| "NOT" @@`
}

func (*Condition) ExprQuery

func (c *Condition) ExprQuery() bson.M

func (*Condition) GetFields

func (c *Condition) GetFields() []string

func (*Condition) Query

func (c *Condition) Query() bson.M

type ConditionOperand

type ConditionOperand struct {
	Operand      *Operand      `@@`
	ConditionRHS *ConditionRHS `[ @@ ]`
}

func (*ConditionOperand) ExprQuery

func (o *ConditionOperand) ExprQuery() bson.M

func (*ConditionOperand) GetFields

func (o *ConditionOperand) GetFields() []string

func (*ConditionOperand) NotExprQuery

func (o *ConditionOperand) NotExprQuery() bson.M

func (*ConditionOperand) NotQuery

func (o *ConditionOperand) NotQuery() bson.M

func (*ConditionOperand) Query

func (o *ConditionOperand) Query() bson.M

type ConditionRHS

type ConditionRHS struct {
	Compare     *Compare     `  @@`
	Like        *Like        `| "LIKE" @@`
	NotLike     *NotLike     `| "NOT" "LIKE" @@`
	Contains    *Contains    `| "CONTAINS" @@`
	NotContains *NotContains `| "NOT" "CONTAINS" @@`
}

func (*ConditionRHS) ExprQuery

func (r *ConditionRHS) ExprQuery(op string) bson.M

func (*ConditionRHS) NotExprQuery

func (r *ConditionRHS) NotExprQuery(op string) bson.M

func (*ConditionRHS) NotQuery

func (r *ConditionRHS) NotQuery() bson.M

func (*ConditionRHS) Query

func (r *ConditionRHS) Query() bson.M

type Contains

type Contains struct {
	Operand *Operand `@@`
}

func (*Contains) ExprQuery

func (l *Contains) ExprQuery(op string) bson.M

func (*Contains) Query

func (l *Contains) Query() bson.M

type Expression

type Expression struct {
	Or []*OrCondition `@@ { "OR" @@ }`
}

func (*Expression) ExprQuery

func (e *Expression) ExprQuery() bson.M

func (*Expression) GetFields

func (e *Expression) GetFields() []string

func (*Expression) Query

func (e *Expression) Query() bson.M

type Like

type Like struct {
	Operand *Operand `@@`
}

func (*Like) ExprQuery

func (l *Like) ExprQuery(op string) bson.M

func (*Like) Query

func (l *Like) Query() bson.M

type MongoQuery

type MongoQuery interface {
	Query() bson.M
	ExprQuery() bson.M
	GetFields() []string
}

type NotContains

type NotContains struct {
	Operand *Operand `@@`
}

func (*NotContains) ExprQuery

func (l *NotContains) ExprQuery(op string) bson.M

func (*NotContains) Query

func (l *NotContains) Query() bson.M

type NotLike

type NotLike struct {
	Operand *Operand `@@`
}

func (*NotLike) ExprQuery

func (l *NotLike) ExprQuery(op string) bson.M

func (*NotLike) Query

func (l *NotLike) Query() bson.M

type Operand

type Operand struct {
	Terms []*Term `@@ { @@ }`
}

func (*Operand) Val

func (o *Operand) Val() interface{}

type OrCondition

type OrCondition struct {
	And []*Condition `@@ { "AND" @@ }`
}

func (*OrCondition) ExprQuery

func (c *OrCondition) ExprQuery() bson.M

func (*OrCondition) GetFields

func (c *OrCondition) GetFields() []string

func (*OrCondition) Query

func (c *OrCondition) Query() bson.M

type Parser

type Parser interface {
	Parse(string) (MongoQuery, error)
}

Parser parses expression.

func NewParser

func NewParser() Parser

NewParser creates new parser.

type Term

type Term struct {
	Name        *string  `(@Ident`
	NumberFloat *float64 ` | @Float`
	NumberInt   *int     ` | @Int`
	Str         *string  ` | @String`
	Boolean     *Boolean ` | @("TRUE" | "FALSE")`
	Null        bool     ` | @"NULL" )`
}

func (*Term) Val

func (t *Term) Val() interface{}

Jump to

Keyboard shortcuts

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