Documentation
¶
Index ¶
- Variables
- type BacktrackEngine
- type CaptureSlot
- type Engine
- type EngineKind
- type Input
- type LazyDFA
- func (d *LazyDFA) Abandoned() bool
- func (d *LazyDFA) Match(prog *compiler.Program, input *Input, pos int) *MatchResult
- func (d *LazyDFA) Search(prog *compiler.Program, input *Input, pos int) *MatchResult
- func (d *LazyDFA) SearchBool(prog *compiler.Program, input Input, pos int) (matched bool, abandoned bool)
- func (d *LazyDFA) SearchInto(prog *compiler.Program, input *Input, pos int, dst *MatchResult, ...) (bool, bool)
- type LiteralEngine
- func (e *LiteralEngine) Match(prog *compiler.Program, input *Input, pos int) *MatchResult
- func (e *LiteralEngine) MatchString(s string, pos int) (end int, ok bool)
- func (e *LiteralEngine) Search(prog *compiler.Program, input *Input, pos int) *MatchResult
- func (e *LiteralEngine) SearchString(s string, pos int) (start, end int, ok bool)
- type MatchResult
- type MetaEngine
- func (me *MetaEngine) Literal() *LiteralEngine
- func (me *MetaEngine) Match(prog *compiler.Program, input *Input, pos int) *MatchResult
- func (me *MetaEngine) PikeVM() *PikeVM
- func (me *MetaEngine) Search(prog *compiler.Program, input *Input, pos int) *MatchResult
- func (me *MetaEngine) SearchBool(prog *compiler.Program, input Input, pos int) bool
- func (me *MetaEngine) SearchRange(prog *compiler.Program, input Input, pos int) (start, end int, ok bool)
- type PikeVM
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBacktrackLimit = errors.New("rexa: backtrack limit exceeded")
Functions ¶
This section is empty.
Types ¶
type BacktrackEngine ¶
type BacktrackEngine struct {
// contains filtered or unexported fields
}
func NewBacktrackEngine ¶
func NewBacktrackEngine(limit int64) *BacktrackEngine
func (*BacktrackEngine) Match ¶
func (e *BacktrackEngine) Match(prog *compiler.Program, input *Input, pos int) *MatchResult
func (*BacktrackEngine) Search ¶
func (e *BacktrackEngine) Search(prog *compiler.Program, input *Input, startPos int) *MatchResult
type CaptureSlot ¶
func CopySlots ¶
func CopySlots(src []CaptureSlot) []CaptureSlot
func EmptySlots ¶
func EmptySlots(n int) []CaptureSlot
type Engine ¶
type Engine interface {
Match(prog *compiler.Program, input *Input, pos int) *MatchResult
Search(prog *compiler.Program, input *Input, pos int) *MatchResult
}
type EngineKind ¶
type EngineKind int
const ( EngineLiteral EngineKind = iota EngineLazyDFA EnginePikeVM EngineBacktrack )
func (EngineKind) String ¶
func (k EngineKind) String() string
type Input ¶
type Input struct {
// contains filtered or unexported fields
}
func NewInputBytes ¶
func NewInputString ¶
func (*Input) SliceString ¶
type LazyDFA ¶
type LazyDFA struct {
// contains filtered or unexported fields
}
LazyDFA builds DFA states on the fly from the NFA program. Each DFA state is a set of NFA instruction PCs (the epsilon closure). States are cached; if the cache overflows it's flushed and rebuilt.
func (*LazyDFA) SearchBool ¶
func (*LazyDFA) SearchInto ¶
func (d *LazyDFA) SearchInto(prog *compiler.Program, input *Input, pos int, dst *MatchResult, caps []CaptureSlot) (bool, bool)
SearchInto finds first match, writing result into dst. Returns (matched, abandoned).
type LiteralEngine ¶
type LiteralEngine struct {
// contains filtered or unexported fields
}
func NewLiteralEngine ¶
func NewLiteralEngine(literal string) *LiteralEngine
func (*LiteralEngine) Match ¶
func (e *LiteralEngine) Match(prog *compiler.Program, input *Input, pos int) *MatchResult
func (*LiteralEngine) MatchString ¶
func (e *LiteralEngine) MatchString(s string, pos int) (end int, ok bool)
MatchString checks if the pattern matches at exactly position pos. Zero allocs for ASCII.
func (*LiteralEngine) Search ¶
func (e *LiteralEngine) Search(prog *compiler.Program, input *Input, pos int) *MatchResult
func (*LiteralEngine) SearchString ¶
func (e *LiteralEngine) SearchString(s string, pos int) (start, end int, ok bool)
SearchString searches directly on a string without creating Input. Zero allocs.
type MatchResult ¶
type MatchResult struct {
Matched bool
Captures []CaptureSlot
Err error
}
type MetaEngine ¶
type MetaEngine struct {
Used EngineKind
// contains filtered or unexported fields
}
func NewMetaEngine ¶
func NewMetaEngine(prog *compiler.Program) *MetaEngine
func NewMetaEngineWithOptions ¶
func NewMetaEngineWithOptions(prog *compiler.Program, backtrackLimit int64, cacheCapacity int) *MetaEngine
func (*MetaEngine) Literal ¶
func (me *MetaEngine) Literal() *LiteralEngine
func (*MetaEngine) Match ¶
func (me *MetaEngine) Match(prog *compiler.Program, input *Input, pos int) *MatchResult
func (*MetaEngine) PikeVM ¶
func (me *MetaEngine) PikeVM() *PikeVM
func (*MetaEngine) Search ¶
func (me *MetaEngine) Search(prog *compiler.Program, input *Input, pos int) *MatchResult
func (*MetaEngine) SearchBool ¶
func (*MetaEngine) SearchRange ¶
func (me *MetaEngine) SearchRange(prog *compiler.Program, input Input, pos int) (start, end int, ok bool)
SearchRange returns match boundaries without allocating MatchResult.
Click to show internal directories.
Click to hide internal directories.