lexer

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: MIT Imports: 3 Imported by: 0

README

go-lexer

Implementation of a basic lexer from Rob Pike talk https://www.youtube.com/watch?v=HxaD_trXwRE
Used https://github.com/bbuck/go-lexer as reference

Documentation

Index

Constants

View Source
const (
	EOFRune    rune      = -1
	ErrorToken TokenType = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

type Lexer interface {
	Start() chan Token
	Emit(t TokenType)
	Next() (r rune)
	Peek() (r rune)
	Ignore()
	Backup()
	Accept(valid string) bool
	AcceptRun(valid string)
	Errorf(format string, args ...interface{}) StateFn
}

func New

func New(name, s string, startState StateFn) Lexer

type StateFn

type StateFn func(Lexer) StateFn

type Token

type Token struct {
	Type  TokenType
	At    int
	Value string
}

type TokenType

type TokenType int

Jump to

Keyboard shortcuts

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