lexer

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package lexer provides tokenization for AQL queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsWhitespace

func IsWhitespace(r rune) bool

IsWhitespace returns true if r is a whitespace character.

Types

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer tokenizes an AQL query string.

func New

func New(input string) *Lexer

New creates a new lexer for the given input.

func (*Lexer) NextToken

func (l *Lexer) NextToken() Token

NextToken returns the next token from the input.

func (*Lexer) Tokenize

func (l *Lexer) Tokenize() ([]Token, error)

Tokenize returns all tokens from the input.

type Token

type Token struct {
	Type    TokenType
	Literal string
	Pos     ast.Position
}

Token represents a lexical token.

type TokenType

type TokenType int

TokenType represents the type of a token.

const (
	TokenEOF TokenType = iota
	TokenError

	// Literals
	TokenIdent    // identifier (field names, entity names)
	TokenString   // "string" or 'string'
	TokenInt      // integer
	TokenFloat    // float
	TokenDuration // duration literal like 30d, 4h

	// Keywords
	TokenFROM
	TokenWHERE
	TokenSELECT
	TokenORDER
	TokenBY
	TokenLIMIT
	TokenASC
	TokenDESC
	TokenAND
	TokenOR
	TokenNOT
	TokenIN
	TokenIS
	TokenNULL
	TokenTRUE
	TokenFALSE
	TokenCONTAINS
	TokenLIKE

	// Aggregation and Grouping
	TokenGROUP
	TokenHAVING
	TokenAS
	TokenDISTINCT

	// Aggregate functions
	TokenCOUNT
	TokenSUM
	TokenAVG
	TokenMIN
	TokenMAX

	// JOINs
	TokenJOIN
	TokenLEFT
	TokenRIGHT
	TokenON

	// Mutations
	TokenINSERT
	TokenINTO
	TokenVALUES
	TokenUPDATE
	TokenSET
	TokenDELETE

	// Operators
	TokenEQ // =
	TokenNE // != or <>
	TokenLT // <
	TokenLE // <=
	TokenGT // >
	TokenGE // >=

	// Delimiters
	TokenLParen // (
	TokenRParen // )
	TokenComma  // ,
	TokenDot    // .
	TokenStar   // *
	TokenMinus  // -
	TokenPlus   // +
)

Token types.

func LookupIdent

func LookupIdent(ident string) TokenType

LookupIdent returns the token type for an identifier. If the identifier is a keyword, it returns the keyword token type.

func (TokenType) String

func (t TokenType) String() string

String returns the string representation of the token type.

Jump to

Keyboard shortcuts

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