query

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TOK_INVALID = iota
	TOK_EOF
	TOK_NL

	TOK_IDENTIFIER
	TOK_KEYWORD
	TOK_NUMBER
	TOK_STRING
	TOK_TOPIC
	TOK_COMMA

	// Arithmetic
	TOK_PLUS
	TOK_MINUS
	TOK_STAR

	// Time
	TOK_WHENCE
	TOK_TIMESPAN

	TOK_PAREN_L
	TOK_PAREN_R

	TOK_ARROW
)

Variables

This section is empty.

Functions

func ParseVagueDateTime

func ParseVagueDateTime(some string) (time.Time, error)

func Prepare

func Prepare(d *database.Database, statement string) (database.Filters, error)

Types

type ASTNode

type ASTNode interface {
	Children() []ASTNode
	GenerateFilter(*database.Database) database.Filter
	Walk(*database.Database) []database.Filter
}

type BaseNode

type BaseNode struct {
	Value string
	// contains filtered or unexported fields
}

func (*BaseNode) AddChild

func (b *BaseNode) AddChild(child ASTNode)

func (*BaseNode) Children

func (b *BaseNode) Children() []ASTNode

func (*BaseNode) GenerateFilter

func (b *BaseNode) GenerateFilter(_ *database.Database) database.Filter

func (*BaseNode) Walk

func (b *BaseNode) Walk(d *database.Database) []database.Filter

type BinaryOpNode

type BinaryOpNode struct {
	BaseNode
}

func (BinaryOpNode) DerivedValue

func (b BinaryOpNode) DerivedValue() int64

type NumberNode

type NumberNode struct {
	BaseNode
}

func (NumberNode) DerivedValue

func (n NumberNode) DerivedValue() int64

type Numeric

type Numeric interface {
	DerivedValue() int64
}

type Parser

type Parser struct {
	Scanner Scanner
}

func (*Parser) Parse

func (p *Parser) Parse() (query ASTNode, err error)

type QuantifierNode

type QuantifierNode struct {
	BaseNode
}

func (QuantifierNode) GenerateFilter

func (q QuantifierNode) GenerateFilter(db *database.Database) database.Filter

type QueryNode

type QueryNode struct {
	BaseNode
}

func (QueryNode) GenerateFilter

func (q QueryNode) GenerateFilter(_ *database.Database) database.Filter

type Scanner

type Scanner struct {
	Input     string
	Start     int
	Pos       int
	RuneWidth int
	LastWidth int
}

func (*Scanner) Emit

func (s *Scanner) Emit() Token

Emit the next Token found on Scanner.Input

func (*Scanner) MatchIdentifier

func (s *Scanner) MatchIdentifier() int

MatchIdentifier returns the length of the next token, assuming it is an identifier.

Grammar:

identifier      = 1*(ALPHA / DIGIT)

func (*Scanner) MatchNumber

func (s *Scanner) MatchNumber() int

MatchNumber returns the length of the next token, assuming it is a number

Grammar:

number          = 1*DIGIT

func (*Scanner) MatchTimeWhence

func (s *Scanner) MatchTimeWhence() int

MatchTimeWhence returns the length of the next token, assuming it is a time-whence

Grammar:

time-whence     = "~now" / "~" RFC3339

func (*Scanner) MatchTimespan

func (s *Scanner) MatchTimespan() int

MatchTimespan returns the length of the next token, assuming it is a timespan

Grammar:

timespan        = "@second" / "@minute" / "@hour" / "@day" / "@week" / "@month" / "@year"

func (*Scanner) MatchTopic

func (s *Scanner) MatchTopic() int

MatchTopic returns the length of the next token, assuming it is a topic string.

Grammar:

topic           = "/" 1*(ALPHA / DIGIT / "/")

func (*Scanner) Rewind

func (s *Scanner) Rewind()

Rewind the last read token

func (*Scanner) SkipToBoundary

func (s *Scanner) SkipToBoundary(boundary boundaryFunc) int

SkipToBoundary returns the number of bytes until the next delimiter. This is useful for skipping over invalid tokens.

type SyntaxError

type SyntaxError struct {
	Location [2]int
	Message  string
}

func NewSyntaxError

func NewSyntaxError(t Token, m string) SyntaxError

func (*SyntaxError) FormatError

func (s *SyntaxError) FormatError(input string) string

type TimeExpressionNode

type TimeExpressionNode struct {
	BaseNode
}

func (TimeExpressionNode) Time

func (t TimeExpressionNode) Time() time.Time

type TimePredicateNode

type TimePredicateNode struct {
	BaseNode
}

func (TimePredicateNode) GenerateFilter

func (t TimePredicateNode) GenerateFilter(db *database.Database) database.Filter

type TimeWhenceNode

type TimeWhenceNode struct {
	BaseNode
	When time.Time
}

func (TimeWhenceNode) Time

func (t TimeWhenceNode) Time() time.Time

type TimespanNode

type TimespanNode struct {
	BaseNode
}

func (TimespanNode) DerivedValue

func (t TimespanNode) DerivedValue() int64

type Token

type Token struct {
	Type     TokenType
	Lexeme   string
	Location [2]int
}

type TokenType

type TokenType int

func (TokenType) ToString

func (t TokenType) ToString() string

type TopicNode

type TopicNode struct {
	BaseNode
}

type TopicSelectorNode

type TopicSelectorNode struct {
	BaseNode
}

func (TopicSelectorNode) GenerateFilter

func (q TopicSelectorNode) GenerateFilter(db *database.Database) database.Filter

Jump to

Keyboard shortcuts

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