toki

package module
v0.0.0-...-36c157a Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: MIT Imports: 4 Imported by: 14

README

toki

Regexp tokenizer/scanner in Go.

The scanner takes in a list of token definitions and string input. it is general and easy to use.

token definition

a token is a pair of constant and regexp string.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Def

type Def struct {
	Token   Token
	Pattern string
	// contains filtered or unexported fields
}

type Position

type Position struct {
	Line   int
	Column int
}

type Result

type Result struct {
	Token Token
	Value []byte
	Pos   Position
}

func (*Result) String

func (this *Result) String() string

type Scanner

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

func NewScanner

func NewScanner(def []Def) *Scanner

func (*Scanner) Next

func (this *Scanner) Next() *Result

func (*Scanner) Peek

func (this *Scanner) Peek() *Result

func (*Scanner) SetInput

func (this *Scanner) SetInput(input string)

type Token

type Token uint32
const (
	EOF Token = 1<<32 - 1 - iota
	Error
)

Jump to

Keyboard shortcuts

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