query

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package query implements a parser for the Ekanite query language. It borrows heavily from the InfluxDB 0.9 release series query parser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryExpr

type BinaryExpr struct {
	Op  Token
	LHS Expr
	RHS Expr
}

BinaryExpr represents a binary expression.

func (*BinaryExpr) String

func (b *BinaryExpr) String() string

type Expr

type Expr interface {
	// contains filtered or unexported methods
}

Expr represents an expression.

type FieldExpr

type FieldExpr struct {
	Field string
	Term  string
}

FieldExpr represents a field expression.

func (*FieldExpr) String

func (f *FieldExpr) String() string

type Lexer

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

Lexer represents a lexer.

func NewLexer

func NewLexer(r io.Reader) *Lexer

NewLexer returns a new instance of a Lexer.

func (*Lexer) Lex

func (s *Lexer) Lex() (tok Token, lit string)

Lex returns the next token and associated literal value.

type ParenExpr

type ParenExpr struct {
	Expr Expr
}

ParenExpr represents a parenthesized expression.

type Parser

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

Parser represents a command parser

func NewParser

func NewParser(r io.Reader, defaultField string) *Parser

NewParser returns a new instance of Parser.

func (*Parser) Parse

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

Parse parses an expression.

type Statement

type Statement struct {
	Expressions []*FieldExpr
}

Statement is an encapsulation of a set of term queries. AND is implicit.

func (*Statement) String

func (s *Statement) String() string

String returns the string representation of a statement

type Token

type Token int

Token represents a lexical token.

const (
	ILLEGAL Token = iota // Illegal tokens
	EOF                  // End-of-file
	WS                   // Whitespace
	COLON                // ;

	// Search terms
	STRING // search fields terms

	AND // AND boolean
	OR  // OR boolean
	NOT // NOT boolean

	LPAREN // (
	RPAREN // )

)

func Lookup

func Lookup(ident string) (Token, bool)

Lookup returns the token associated with a given string.

func (Token) Precedence

func (t Token) Precedence() int

Precedence returns the operator precedence of the binary operator token.

func (Token) String

func (t 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