parser

package
v0.0.0-...-d841f61 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

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) Query

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

type Condition

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

func (*Condition) Query

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

type ConditionOperand

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

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) Query

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

type Contains

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

func (*Contains) Query

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

type Expression

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

func (*Expression) Query

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

type Like

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

func (*Like) Query

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

type MongoQuery

type MongoQuery interface {
	Query() bson.M
}

type NotContains

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

func (*NotContains) Query

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

type NotLike

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

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) 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