lexer

package
v3.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token struct {
	Kind  TokenKind
	Value string
	Pos   int
	Len   int
}

func NewToken

func NewToken(kind TokenKind, value string, pos int, len int) Token

func (Token) IsKind

func (t Token) IsKind(kind ...TokenKind) bool

type TokenKind

type TokenKind int
const (
	EOF TokenKind = iota
	Symbol
	Comma
	Colon
	OpenBracket  // [
	CloseBracket // ]
	OpenCurly
	CloseCurly
	OpenParen
	CloseParen
	Equal    // ==
	Equals   // =
	NotEqual // !=
	And
	Or
	Like    // =~
	NotLike // !~
	String
	Number
	Bool
	Plus
	Increment
	IncrementBy
	Dash
	Decrement
	DecrementBy
	Star
	Slash
	Percent
	Dot
	Spread           // ...
	RecursiveDescent // ..
	Dollar
	Variable
	GreaterThan
	GreaterThanOrEqual
	LessThan
	LessThanOrEqual
	Exclamation
	Null
	If
	Else
	ElseIf
	Branch
	Map
	Each
	Filter
	Search
	RegexPattern
	SortBy
	Asc
	Desc
	QuestionMark
	DoubleQuestionMark
	Semicolon
)

func TokenKinds

func TokenKinds(tk ...TokenKind) []TokenKind

type Tokenizer

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

func NewTokenizer

func NewTokenizer(src string) *Tokenizer

func (*Tokenizer) Next

func (p *Tokenizer) Next() (Token, error)

func (*Tokenizer) Tokenize

func (p *Tokenizer) Tokenize() (Tokens, error)

type Tokens

type Tokens []Token

func (Tokens) Split

func (tt Tokens) Split(kind TokenKind) []Tokens

type UnexpectedEOFError

type UnexpectedEOFError struct {
	Pos int
}

func (*UnexpectedEOFError) Error

func (e *UnexpectedEOFError) Error() string

type UnexpectedTokenError

type UnexpectedTokenError struct {
	Pos   int
	Token rune
}

func (*UnexpectedTokenError) Error

func (e *UnexpectedTokenError) Error() string

Jump to

Keyboard shortcuts

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