regexp2

package
v0.0.0-...-86e9f11 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package regexp2 implements regular expression engine.

Index

Constants

View Source
const MaxCharInRegex = 1000

MaxCharInRegex is the maximum number of characters in a regex string

View Source
const MaxNodesAutomaton = 3000

MaxNodesAutomaton is the maximum number of states when constructing and transforming NFAs and DFAs.

Variables

This section is empty.

Functions

func Compile

func Compile(expr string, regexType RegexType) (regex *regexp.Regexp, err error)

Compile return a regex for the provided string and regexType.

func DumpDebug

func DumpDebug(writer io.Writer, data []byte, nBits, nNodes, nGroups int, regex string)

func IsSupported

func IsSupported(expr string) error

IsSupported determines whether expr is a supported regex; return nil if supported, error otherwise

func PrettyStrForDot

func PrettyStrForDot(str string) string

PrettyStrForDot makes the string pretty and usable for printing in dot files

Types

type DFA

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

type DFAStore

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

func CompileDFA

func CompileDFA(regex *regexp.Regexp, maxNodes int) (*DFAStore, error)

func CompileDFADebug

func CompileDFADebug(regex *regexp.Regexp, writeDot bool, maxNodes int) (*DFAStore, error)

func (*DFAStore) Dot

func (store *DFAStore) Dot() *Graphviz

func (*DFAStore) HasRLZA

func (store *DFAStore) HasRLZA() bool

HasRLZA returns whether this automaton contains at least one node with a Remaining Length Zero Assertion (RLZA) '$'

func (*DFAStore) HasUnicodeEdge

func (store *DFAStore) HasUnicodeEdge() bool

HasUnicodeEdge returns true if the store has an edge with a non-ASCII unicode symbol excluding a unicode wildcard edge.

func (*DFAStore) HasUnicodeWildcard

func (store *DFAStore) HasUnicodeWildcard() (present bool, wildcardRange symbolRangeT)

HasUnicodeWildcard returns true if the DFA has at least one wildcard edge for ALL non-ASCII values, and all other edges are ASCII observations (thus no regular non-ASCII edges)

func (*DFAStore) IsTrivial

func (store *DFAStore) IsTrivial() (trivial, accept bool)

IsTrivial return whether the DFA is a trivial automation; if the DFA is trivial, accept indicate whether the DFA always accepts or always rejects

func (*DFAStore) MergeEdgeRanges

func (store *DFAStore) MergeEdgeRanges(discardRLZ bool)

func (*DFAStore) NumberOfNodes

func (store *DFAStore) NumberOfNodes() int

NumberOfNodes return the number of nodes in this automaton

type DataStructures

type DataStructures struct {
	Expr                string
	RegexGolang         *regexp.Regexp
	RegexSneller        *regexp.Regexp
	RegexSupported      bool
	DsT6, DsT7, DsT8    []byte
	DsT6Z, DsT7Z, DsT8Z []byte
	DsLZ                []byte
}

func CreateDs

func CreateDs(expr string, regexType RegexType, writeDot bool, maxNodes int) (DataStructures, error)

CreateDs creates data-structures for the provided regex string

type DsLarge

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

DsLarge is a data structure for the large DFA implementation

func NewDsLarge

func NewDsLarge(store *DFAStore) (*DsLarge, error)

NewDsLarge creates a data structure that is accepted by the large DFA

func (*DsLarge) Data

func (d *DsLarge) Data() []byte

func (*DsLarge) DumpDebug

func (d *DsLarge) DumpDebug(dst io.Writer) (err error)

DumpDebug dumps this data structure with annotations to dst

type DsTiny

type DsTiny struct {
	Store *DFAStore
	// contains filtered or unexported fields
}

func NewDsTiny

func NewDsTiny(store *DFAStore) (*DsTiny, error)

func (*DsTiny) Data

func (d *DsTiny) Data(nBits int, hasUnicodeWildcard bool, wildcardRange symbolRangeT) ([]byte, bool)

Data creates the data-structure with the provided parameters

func (*DsTiny) DataWithGraphviz

func (d *DsTiny) DataWithGraphviz(writeDot bool, nBits int, hasWildcard bool, wildcardRange symbolRangeT) ([]byte, bool, *Graphviz)

func (*DsTiny) NumberOfGroups

func (d *DsTiny) NumberOfGroups() int

type Graphviz

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

func (*Graphviz) DotContent

func (dot *Graphviz) DotContent(dst io.Writer, graphName, graphTitle string) error

func (*Graphviz) WriteToFile

func (dot *Graphviz) WriteToFile(filename, graphName, graphTitle string)

type NFAStore

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

type RegexType

type RegexType int
const (
	SimilarTo RegexType = iota
	Regexp
	RegexpCi
	GolangSimilarTo
	GolangRegexp
)

Jump to

Keyboard shortcuts

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