lexer

package
v0.0.0-...-4c5ac3e Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(inputName string, input io.Reader, initState StateFunc, tokenFunc TokenFunc) error

Types

type Context

type Context interface {
	// Token returns the currently accumulated token string.
	Token() string
	// Emit will run the TokenFunc provided to Run with the given token.
	Emit(token interface{})
	// Clear clears the currently accumulated token string.
	Clear()
	// Error ends the lexing process, and causes run to return an error with err in its history.
	// The StateFunc returned by Error should be returned immediately.
	Error(err error) StateFunc
}

type LocationInFile

type LocationInFile struct {
	File string
	Line int
	Rune int
}

func (*LocationInFile) AdvanceLine

func (lif *LocationInFile) AdvanceLine()

func (*LocationInFile) AdvanceRune

func (lif *LocationInFile) AdvanceRune()

func (LocationInFile) String

func (lif LocationInFile) String() string

type StateFunc

type StateFunc func(ctx Context, in rune) StateFunc

func MatchString

func MatchString(s string, token interface{}, success StateFunc) StateFunc

type TokenFunc

type TokenFunc func(token interface{}) error

Jump to

Keyboard shortcuts

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