lexer

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 8 Imported by: 3 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind string
const (
	Identifier Kind = "Identifier"
	Number     Kind = "Number"
	String     Kind = "String"
	Bytes      Kind = "Bytes"
	Operator   Kind = "Operator"
	Bracket    Kind = "Bracket"
	EOF        Kind = "EOF"
)

type Lexer added in v1.17.6

type Lexer struct {

	// When true, keywords `if`/`else` are not treated as operators and
	// will be emitted as identifiers instead (for compatibility with custom if()).
	DisableIfOperator bool
	// contains filtered or unexported fields
}

func New added in v1.17.6

func New() *Lexer

New returns a reusable lexer.

func (*Lexer) Next added in v1.17.6

func (l *Lexer) Next() (Token, error)

func (*Lexer) Reset added in v1.17.6

func (l *Lexer) Reset(source file.Source)

type Token

type Token struct {
	file.Location
	Kind  Kind
	Value string
}

func Lex

func Lex(source file.Source) ([]Token, error)

Lex will buffer and return the tokens of a disposable *Lexer.

func (Token) Is

func (t Token) Is(kind Kind, values ...string) bool

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