Documentation ¶
Index ¶
- Constants
- func CompileQuery(query string) (stmnt *Statement, err *ParseError)
- func CompileSelect(query string) (sel *Selection, err *ParseError)
- func Match(query string, ctx context.Context) (matched bool, err error)
- func SanitizeQuery(query string) (sanitized string)
- func UnquoteRegexp(s string) (out string, err error)
- func UnquoteString(s string) (out string, err error)
- type Boolean
- type Condition
- type Expression
- type Nil
- type Operation
- type ParseError
- type Selecting
- type Selection
- type Statement
- type Value
Constants ¶
View Source
const ( Ident = `\b([a-zA-Z][.a-zA-Z0-9]*)\b` Int = `\b(\d+)\b` Float = `\b(\d*\.\d+)\b` Number = `[-+]?\d*\.?\d+([eE][-+]?\d+)?` String = `'[^']*'|"[^"]*"` Regexp = `/(.+?)/|\!(.+?)\!|\@(.+?)\@|\~(.+?)\~` Operators = `==|=\~|\!=|\!\~|[.,()]` Whitespace = `\s+` )
Variables ¶
This section is empty.
Functions ¶
func CompileQuery ¶
func CompileQuery(query string) (stmnt *Statement, err *ParseError)
func CompileSelect ¶
func CompileSelect(query string) (sel *Selection, err *ParseError)
func SanitizeQuery ¶
func UnquoteRegexp ¶
func UnquoteString ¶
Types ¶
type Condition ¶
type Condition struct { Left *Expression `parser:"'(' @@" json:"left"` Type string `parser:"@( 'AND' | 'OR' )" json:"type"` Right *Expression `parser:"@@ ')'" json:"right"` }
type Expression ¶
type Expression struct { Condition *Condition `parser:"( @@ )?" json:"condition,omitempty"` Operation *Operation `parser:"( @@ )?" json:"operation,omitempty"` }
func (*Expression) Render ¶
func (e *Expression) Render() (clone *Expression)
type Operation ¶
type ParseError ¶
type ParseError struct { Query string Column int Message string // contains filtered or unexported fields }
func (*ParseError) Error ¶
func (e *ParseError) Error() (msg string)
func (*ParseError) Pretty ¶
func (e *ParseError) Pretty() (refined string)
type Selecting ¶
type Selection ¶
type Statement ¶
type Statement struct { Expression *Expression `parser:"@@" json:"expressions,omitempty"` Limit *int `parser:"( 'LIMIT' @Int )?" json:"limit,omitempty"` Offset *int `parser:"( 'OFFSET' @Int )?" json:"offset,omitempty"` OrderBy *string `parser:"( 'ORDER' 'BY' '.' @Ident )?" json:"order-by,omitempty"` SortDir *string `parser:"( @'ASC' | @'DSC' | @'DESC' )?" json:"sort-dir,omitempty"` ContextKeys []string `parser:"" json:"context-keys,omitempty"` // contains filtered or unexported fields }
type Value ¶
type Value struct { ContextKey *string `parser:" ( '.' @Ident )" json:"context-key,omitempty"` Regexp *string `parser:"| ( 'm' @Regexp )" json:"regexp,omitempty"` String *string `parser:"| ( @String )" json:"string,omitempty"` Number *float64 `parser:"| ( @Number )" json:"number,omitempty"` Bool *Boolean `parser:"| @( 'true' | 'false' )" json:"bool,omitempty"` Nil *Nil `parser:"| @( 'nil' )" json:"nil,omitempty"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.