Types used by the NFA
Types
Bounds = Slice[int]
CaptIdx = int32
Capts3 = object s: seq[Slice[int]] groupsLen: Natural blockSize: Natural blockSizeL2: Natural states: seq[CaptState] free: seq[CaptIdx] freezeId: CaptState
- Seq of captures divided into blocks of power of 2 len. One block per parallel state. A seq/set to keep track of used blocks. A seq of free blocks for reusing
CaptState = uint8
Captures = seq[seq[Slice[int]]]
MatchFlag = enum mfShortestMatch, mfNoCaptures, mfFindMatch, mfFindMatchOpt, mfAnchored, mfBwMatch, mfReverseCapts, mfBytesInput
MatchFlags = set[MatchFlag]
NodeIdx = int16
Regex = object nfa*: Nfa groupsCount*: int16 namedGroups*: OrderedTable[string, int16] flags*: RegexFlags litOpt*: LitOpt
- deprecated
RegexLit = distinct string
- raw regex literal string
RegexMatch = object captures*: Captures namedGroups*: OrderedTable[string, int16] boundaries*: Slice[int]
- deprecated
RegexMatch2 = object captures*: seq[Slice[int]] namedGroups*: OrderedTable[string, int16] boundaries*: Slice[int]
- result from matching operations
Consts
nonCapture = (a: -1, b: -2)
Procs
func clear(m: var RegexMatch) {.inline, ...raises: [], tags: [].}
func clear(m: var RegexMatch2) {.inline, ...raises: [], tags: [].}
func constructSubmatches(captures: var Captures; capts: Capts; capt, size: int) {. inline, ...raises: [], tags: [].}
func freeze(capts: var Capts3): CaptState {....raises: [], tags: [].}
- Freeze all in use capts. Return freezeId
func initCapts3(groupsLen: int): Capts3 {....raises: [], tags: [].}
func initPstate(ni: NodeIdx; ci: CaptIdx; bounds: Bounds): Pstate {.inline, ...raises: [], tags: [].}
func initPstates(size: int): Pstates {.inline, ...raises: [], tags: [].}
func notRecyclable(capts: var Capts3; captIdx: CaptIdx) {.inline, ...raises: [], tags: [].}
func recyclable(capts: var Capts3; captIdx: CaptIdx) {.inline, ...raises: [], tags: [].}
func recycle(capts: var Capts3) {....raises: [], tags: [].}
- Free recyclable entries Set initial/keepAlive entries to recyclable
func reverse(capts: var Capts; a, b: CaptIdx): CaptIdx {....raises: [], tags: [].}
- reverse capture indices from a to b; return head
func toMatchFlags(f: RegexFlags): MatchFlags {....raises: [], tags: [].}