lexer

package
v0.0.0-...-98563a5 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const IDENT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_?!"
View Source
const LEGAL_IDENT_CHARS = "?!"
View Source
const OPERATOR_CHARS = "+-*/%&<>=,;#.:(){}[]|@$?!"

NOTE: Overlap of `?` and `!`

Variables

View Source
var LexStartFn = startLexer

LexStartFn represents the entrypoint the Lexer uses to start processing the input.

Functions

This section is empty.

Types

type Lexer

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

Lexer is the engine to process input and emit Tokens

func New

func New(input string) *Lexer

New returns a Lexer instance ready to process the given input.

func (*Lexer) HasNext

func (l *Lexer) HasNext() bool

HasNext returns true if there are tokens left, false if EOF has reached

func (*Lexer) NextToken

func (l *Lexer) NextToken() token.Token

NextToken will return the next token processed from the lexer.

Callers should make sure to call Lexer.HasNext before calling this method as it will panic if it is called after token.EOF is returned.

type StateFn

type StateFn func(*Lexer) StateFn

StateFn represents a function which is capable of lexing parts of the input. It returns another StateFn to proceed with.

Typically a state function would get called from LexStartFn and should return LexStartFn to go back to the decision loop. It also could return another non start state function if the partial input to parse is abiguous.

Jump to

Keyboard shortcuts

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