lexerql

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package lexerql provides utilities for lexing in *QL languages.

Index

Constants

View Source
const (
	// Number is a plain Go number.
	Number = iota
	// Duration is a Prometheus/Go duration.
	Duration
	// Bytes is a [humanize.Bytes] value.
	Bytes
)

Variables

This section is empty.

Functions

func IsBytesRune added in v0.1.0

func IsBytesRune[R char](r R) bool

IsBytesRune returns true, if r is a non-digit rune that could be part of bytes.

func IsDigit

func IsDigit[R char](r R) bool

IsDigit returns true, if r is an ASCII digit.

func IsDurationRune

func IsDurationRune[R char](r R) bool

IsDurationRune returns true, if r is a non-digit rune that could be part of duration.

func IsIdentRune

func IsIdentRune[R char](r R) bool

IsIdentRune returns true, if r is a valid character of Go identifier/Prometheus label.

func IsIdentStartRune

func IsIdentStartRune[R char](r R) bool

IsIdentStartRune returns true, if r is a valid first character of Go identifier/Prometheus label.

func IsLetter

func IsLetter[R char](r R) bool

IsLetter returns true, if r is an ASCII letter.

func ParseDuration

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

ParseDuration parses Prometheus or Go duration

func ScanComment

func ScanComment(s *scanner.Scanner)

ScanComment reads runes until newline.

func ScanDuration

func ScanDuration(s *scanner.Scanner, number string) (string, error)

ScanDuration scans and parses duration from given scanner.

Types

type Unit added in v0.1.0

type Unit struct {
	Type UnitType
	Text string
}

Unit represents suffixed numeric token like duration.

func ScanUnit added in v0.1.0

func ScanUnit(s *scanner.Scanner, prefix string) (Unit, error)

ScanUnit scans unit tokens like durations and bytes.

type UnitType added in v0.1.0

type UnitType int

UnitType defines Unit type.

Jump to

Keyboard shortcuts

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