regexp

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 6 Imported by: 42

Documentation

Index

Constants

View Source
const (
	OpMatch instOp = iota
	OpJmp
	OpSplit
	OpRange
)

the enumeration of operations

View Source
const StateLimit = 10000

StateLimit is the maximum number of states allowed

Variables

View Source
var DefaultLimit = uint(10 * (1 << 20))
View Source
var ErrCompiledTooBig = fmt.Errorf("too many instructions")

ErrCompiledTooBig returned when regular expression parses into too many instructions

View Source
var ErrNoBytes = fmt.Errorf("byte literals are not allowed")

ErrNoBytes returned when byte literals are used

View Source
var ErrNoEmpty = fmt.Errorf("zero width assertions not allowed")

ErrNoEmpty returned when "zero width assertions" are used

View Source
var ErrNoLazy = fmt.Errorf("lazy quantifiers are not allowed")

ErrNoLazy returned when lazy quantifiers are used

View Source
var ErrNoWordBoundary = fmt.Errorf("word boundaries are not allowed")

ErrNoWordBoundary returned when word boundaries are used

View Source
var ErrTooManyStates = fmt.Errorf("dfa contains more than %d states",
	StateLimit)

ErrTooManyStates is returned if you attempt to build a Levenshtein automaton which requires too many states.

Functions

This section is empty.

Types

type Regexp

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

Regexp implements the vellum.Automaton interface for matcing a user specified regular expression.

func New

func New(expr string) (*Regexp, error)

NewRegexp creates a new Regular Expression automaton with the specified expression. By default it is limited to approximately 10MB for the compiled finite state automaton. If this size is exceeded, ErrCompiledTooBig will be returned.

func NewParsedWithLimit

func NewParsedWithLimit(expr string, parsed *syntax.Regexp, size uint) (*Regexp, error)

func NewWithLimit

func NewWithLimit(expr string, size uint) (*Regexp, error)

NewRegexpWithLimit creates a new Regular Expression automaton with the specified expression. The size of the compiled finite state automaton exceeds the user specified size, ErrCompiledTooBig will be returned.

func (*Regexp) Accept

func (r *Regexp) Accept(s int, b byte) int

Accept returns the new state, resulting from the transition byte b when currently in the state s.

func (*Regexp) CanMatch

func (r *Regexp) CanMatch(s int) bool

CanMatch returns if the specified state can ever transition to a matching state.

func (*Regexp) IsMatch

func (r *Regexp) IsMatch(s int) bool

IsMatch returns if the specified state is a matching state.

func (*Regexp) Start

func (r *Regexp) Start() int

Start returns the start state of this automaton.

func (*Regexp) WillAlwaysMatch

func (r *Regexp) WillAlwaysMatch(int) bool

WillAlwaysMatch returns if the specified state will always end in a matching state.

Jump to

Keyboard shortcuts

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