src/regex/types

Types

Enfa = object
  s*: seq[Node]
Flag = enum
  flagCaseInsensitive, flagNotCaseInsensitive, flagMultiLine, flagNotMultiLine,
  flagAnyMatchNewLine, flagNotAnyMatchNewLine, flagUnGreedy, flagNotUnGreedy,
  flagUnicode, flagNotUnicode, flagVerbose, flagNotVerbose
Nfa = object
  s*: seq[Node]
Node = object
  kind*: NodeKind
  cp*: Rune
  next*: seq[int16]
  isGreedy*: bool
  uid*: NodeUid
  idx*: int16
  isCapturing*: bool
  name*: string
  flags*: seq[Flag]
  min*, max*: int16
  cps*: HashSet[Rune]
  ranges*: seq[Slice[Rune]]
  shorthands*: seq[Node]
  cc*: UnicodeCategorySet
  subExp*: SubExp
NodeKind = enum
  reChar, reCharCi, reJoiner, reGroupStart, reGroupEnd, reFlags, reOr,
  reZeroOrMore, reOneOrMore, reZeroOrOne, reRepRange, reStartSym, reEndSym,
  reStartSymML, reEndSymML, reStart, reEnd, reWordBoundary, reNotWordBoundary,
  reWord, reDigit, reWhiteSpace, reUCC, reNotAlphaNum, reNotDigit,
  reNotWhiteSpace, reNotUCC, reAny, reAnyNl, reWordBoundaryAscii,
  reNotWordBoundaryAscii, reWordAscii, reDigitAscii, reWhiteSpaceAscii,
  reNotAlphaNumAscii, reNotDigitAscii, reNotWhiteSpaceAscii, reInSet, reNotSet,
  reLookahead, reLookbehind, reNotLookahead, reNotLookbehind, reSkip, reEoe
NodeUid = int16
RegexFlag = enum
  regexArbitraryBytes, regexAscii, regexCaseless, regexDotAll, regexExtended,
  regexMultiline, regexUngreedy
RpnExp = object
  s*: seq[Node]
SubExp = object
  nfa*: Nfa
  rpn*: RpnExp
  reverseCapts*: bool

Consts

assertionKind = {reStartSym, reEndSym, reStartSymML, reEndSymML, reStart, reEnd,
                 reWordBoundary, reNotWordBoundary, reWordBoundaryAscii,
                 reNotWordBoundaryAscii, reLookahead, reLookbehind,
                 reNotLookahead, reNotLookbehind}
groupKind = {reGroupStart, reGroupEnd}
groupStartKind = {reGroupStart, reLookahead..reNotLookbehind}
lookaheadKind = {reLookahead, reNotLookahead}
lookaroundKind = {reLookahead, reLookbehind, reNotLookahead, reNotLookbehind}
lookbehindKind = {reLookbehind, reNotLookbehind}
matchableKind = {reChar, reCharCi, reWord, reDigit, reWhiteSpace, reUCC,
                 reNotAlphaNum, reNotDigit, reNotWhiteSpace, reNotUCC, reAny,
                 reAnyNl, reInSet, reNotSet, reWordAscii, reDigitAscii,
                 reWhiteSpaceAscii, reNotAlphaNumAscii, reNotDigitAscii,
                 reNotWhiteSpaceAscii}
opKind = {reJoiner, reOr, reZeroOrMore, reOneOrMore, reZeroOrOne, reRepRange}
repetitionKind = {reZeroOrMore, reOneOrMore, reRepRange}
shorthandKind = {reWord, reDigit, reWhiteSpace, reUCC, reNotAlphaNum,
                 reNotDigit, reNotWhiteSpace, reNotUCC, reWordAscii,
                 reDigitAscii, reWhiteSpaceAscii, reNotAlphaNumAscii,
                 reNotDigitAscii, reNotWhiteSpaceAscii}

Procs

func `$`(n: Node): string {....raises: [], tags: [].}
return the string representation of a Node. The string is always equivalent to the original expression but not necessarily equal
func initEoeNode(): Node {....raises: [], tags: [].}
return the end-of-expression Node. This is a dummy node that marks a match as successful
func initGroupStart(name: string = ""; flags: seq[Flag] = @[];
                    isCapturing = true): Node {....raises: [], tags: [].}
return a reGroupStart node
func initJoinerNode(): Node {....raises: [], tags: [].}
return a Node of reJoiner kind. Joiners are temporary nodes, they serve to generate the NFA but they are never part of it
func initNotSetNode(): Node {....raises: [], tags: [].}
return a negated set Node, parsed from an expression such as [^a-z]
func initSetNode(): Node {....raises: [], tags: [].}
return a set Node, parsed from an expression such as [a-z]
func initSkipNode(): Node {....raises: [], tags: [].}
func initSkipNode(next: openArray[int16]): Node {....raises: [], tags: [].}
Return a dummy node that should be skipped while traversing the NFA
func isEmpty(n: Node): bool {....raises: [], tags: [].}
check if a set Node is empty
func isEpsilonTransition(n: Node): bool {.inline, ...raises: [], tags: [].}
func toCharNode(r: Rune): Node {....raises: [], tags: [].}
return a Node that is meant to be matched against text characters
func toFlag(fl: RegexFlag): Flag {....raises: [], tags: [].}
Public flag to internal flag
func toFlags(fls: RegexFlags): set[Flag] {....raises: [], tags: [].}
Public flags to internal flags
func toFlagsSeq(fls: RegexFlags): seq[Flag] {....raises: [], tags: [].}
func toString(n: seq[Node]): string {....raises: [], tags: [].}