lexer

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package lexer contains LogQL lexer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses Prometheus or Go duration

Types

type Token

type Token struct {
	Type TokenType
	Text string
	Pos  scanner.Position
}

Token is a LogQL token.

func Tokenize

func Tokenize(s string, opts TokenizeOptions) ([]Token, error)

Tokenize scans given string to LogQL tokens.

type TokenType

type TokenType int

TokenType defines LogQL token type.

const (
	Invalid TokenType = iota
	EOF
	Ident
	// Literals
	String
	Number
	Duration
	Bytes

	Comma
	Dot
	OpenBrace
	CloseBrace
	Eq
	NotEq
	Re
	NotRe
	PipeExact
	PipeMatch
	Pipe
	Unwrap
	OpenParen
	CloseParen
	By
	Without
	Bool
	OpenBracket
	CloseBracket
	Offset
	On
	Ignoring
	GroupLeft
	GroupRight

	// Binary operations
	Or
	And
	Unless
	Add
	Sub
	Mul
	Div
	Mod
	Pow
	// Comparison operations
	CmpEq
	Gt
	Gte
	Lt
	Lte

	JSON
	Regexp
	Logfmt
	Unpack
	Pattern
	LabelFormat
	LineFormat
	IP
	Decolorize
	Distinct
	Drop
	Keep

	Range
	Rate
	RateCounter
	CountOverTime
	BytesRate
	BytesOverTime
	AvgOverTime
	SumOverTime
	MinOverTime
	MaxOverTime
	StdvarOverTime
	StddevOverTime
	QuantileOverTime
	FirstOverTime
	LastOverTime
	AbsentOverTime
	Vector

	Sum
	Avg
	Max
	Min
	Count
	Stddev
	Stdvar
	Bottomk
	Topk
	Sort
	SortDesc
	LabelReplace

	BytesConv
	DurationConv
	DurationSecondsConv
)

func (TokenType) IsFunction

func (tt TokenType) IsFunction() bool

IsFunction returns true if token is function name.

func (TokenType) String

func (i TokenType) String() string

type TokenizeOptions

type TokenizeOptions struct {
	// Filename sets filename for the scanner.
	Filename string
	// AllowDots allows dots in identifiers.
	AllowDots bool
}

TokenizeOptions is a Tokenize options structure.

Jump to

Keyboard shortcuts

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