cql

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package cql provides a syntax parser for a "Context Query Language"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(query string) (stmnt *Statement, err *ParseError)

func EBNF

func EBNF() (ebnf string)

func UnquoteRegexp

func UnquoteRegexp(s string) (out string, err error)

func UnquoteString

func UnquoteString(s string) (out string, err error)

Types

type Boolean

type Boolean bool

func (*Boolean) Capture

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

type Condition

type Condition struct {
	Left  *Expression `parser:"'(' @@" json:"left"`
	Type  string      `parser:"@( 'AND' | 'OR' )" json:"type"`
	Right *Expression `parser:"@@ ')'" json:"right"`
}

func (*Condition) Render

func (c *Condition) Render() (clone *Condition)

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 Nil

type Nil bool

func (*Nil) Capture

func (n *Nil) Capture(values []string) error

type Operation

type Operation struct {
	Left  *string `parser:" '(' '.' @Ident" json:"left"`
	Type  string  `parser:"  ( @'!=' | @'==' | @'=~' | @'!~' )" json:"type"`
	Right *Value  `parser:"  @@ ')'" json:"right"`
}

func (*Operation) Render

func (o *Operation) Render() (clone *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 Statement

type Statement struct {
	Expression  *Expression `parser:"@@" json:"expressions,omitempty"`
	ContextKeys []string    `parser:"" json:"context-keys,omitempty"`
	// contains filtered or unexported fields
}

func (*Statement) Render

func (s *Statement) Render() (out *Statement)

func (*Statement) String

func (s *Statement) String() (query string)

func (*Statement) Stringify

func (s *Statement) Stringify() (out string)

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"`
	Int        *int     `parser:"| ( @Int )" json:"int,omitempty"`
	Float      *float64 `parser:"| ( @Float )" json:"float,omitempty"`
	Bool       *Boolean `parser:"| @( 'true' | 'false' )" json:"bool,omitempty"`
	Nil        *Nil     `parser:"| @( 'nil' )" json:"nil,omitempty"`
}

func (*Value) Render

func (v *Value) Render() (clone *Value)

Jump to

Keyboard shortcuts

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