token

package
v0.0.0-...-df3f4e6 Latest Latest
Warning

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

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

Documentation

Overview

Package token models the various tokens of the Varda query language.

Index

Constants

View Source
const (
	LowestPrec  = 0 // non-operators
	UnaryPrec   = 6
	HighestPrec = 7
)

A set of constants for precedence-based expression parsing. Non-operators have lowest precedence, followed by operators starting with precedence 1 up to unary operators. The highest precedence serves as "catch-all" precedence for selector, indexing, and other operator and delimiter tokens.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind uint8
const (
	ILLEGAL Kind = iota
	EOF

	// Identifiers and basic type literals
	IDENT  // image, audio, video, ...
	INT    // 12345
	FLOAT  // 123.45
	STRING // "abc"
	TIME   // 2006-01-02, 2006-01, 2006
	SHA    // 3100d57...

	// Operators and delimiters
	SUB // -
	AND // &&, and
	OR  // ||, or

	EQ  // ==
	LT  // <
	GT  // >
	NOT // !

	NEQ // !=
	LEQ // <=
	GEQ // >=

	LPAREN // (
	RPAREN // )
	COMMA  // ,
	COLON  // :

	// Keywords
	AFTER    // after:<some-time>
	BEFORE   // before:<some-time>
	IS       // is:image, is:video, is:audio, is:<some-mime>
	LOCATION // loc:<location>
	REF      // ref:<some-varda-ref>
	TAG      // tag:<some-tag-name>

)

func (Kind) String

func (k Kind) String() string

type Pos

type Pos int

Pos represents a position within a vql expression.

type Token

type Token struct {
	Kind    Kind
	Literal string
}

func (Token) Precedence

func (op Token) Precedence() int

Precedence returns the operator precedence of the binary operator op. If op is not a binary operator, the result is LowestPrecedence.

func (Token) String

func (t Token) String() string

Jump to

Keyboard shortcuts

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