lexer

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package lexer contains LogQL lexer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error added in v0.0.8

type Error struct {
	Msg string
	Pos scanner.Position
}

Error is a lexing error.

func (*Error) Error added in v0.0.8

func (e *Error) Error() string

Error implements error.

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

	ParserFlag
)

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