vellum: github.com/couchbase/vellum/regexp Index | Files

package regexp

import "github.com/couchbase/vellum/regexp"

Index

Package Files

compile.go dfa.go inst.go regexp.go sparse.go

Constants

const (
    OpMatch instOp = iota
    OpJmp
    OpSplit
    OpRange
)

the enumeration of operations

const StateLimit = 10000

StateLimit is the maximum number of states allowed

Variables

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

ErrCompiledTooBig returned when regular expression parses into too many instructions

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

ErrNoBytes returned when byte literals are used

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

ErrNoEmpty returned when "zero width assertions" are used

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

ErrNoLazy returned when lazy quantifiers are used

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

ErrNoWordBoundary returned when word boundaries are used

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.

type Regexp Uses

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

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

func New Uses

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 Uses

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

func NewWithLimit Uses

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 Uses

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 Uses

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

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

func (*Regexp) IsMatch Uses

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

IsMatch returns if the specified state is a matching state.

func (*Regexp) Start Uses

func (r *Regexp) Start() int

Start returns the start state of this automaton.

func (*Regexp) WillAlwaysMatch Uses

func (r *Regexp) WillAlwaysMatch(int) bool

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

Package regexp imports 6 packages (graph) and is imported by 10 packages. Updated 2019-07-16. Refresh now. Tools for package owners.