scannertest

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: BSD-3-Clause, MIT Imports: 11 Imported by: 0

README

Package scannertest provides helpers for automated testing of scanners/lexers/tokenizers.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestStates

func TestStates(name string, src io.Reader, scanner Interface) error

TestStates reads golex definitions from src, assuming they come from name. The test uses the computed DFA to synthesize test inputs for the scanner.

Types

type Interface

type Interface interface {
	// Init initializes the scanner with src, which is assumed to come from name.
	Init(name string, src []byte) error
	// Rune returns any rune for class c and indicated if the class is valid.
	Rune(c byte) (r rune, ok bool)
	// Scan scans the source set by Init and returns and error if the source does
	// not start with a valid token.
	Scan() error
}

Interface wraps methods of the tested scanner/lexer/tokenizer.

Jump to

Keyboard shortcuts

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