openparser/regex/parser

Types

CharClassItem {.acyclic.} = object
  case isRange*: bool
  of true:
    lo*, hi*: char
  of false:
    ch*: char
  isEscape*: bool            ## true when item is \d \w \s \D \W \S
  escapeChar*: char          ## the escape letter, e.g. 's' for \s
RegexNode {.acyclic.} = ref object
  line*, col*, pos*: int
  case kind*: RegexNodeKind
  of rnChar:
    ch*: char
  of rnEscaped:
    escape*: char
  of rnDot, rnAnchorStart, rnAnchorEnd:
    nil
  of rnConcat, rnAlternation:
    children*: seq[RegexNode]
  of rnGroup:
    capture*: bool
    index*: int
    groupName*: string
    child*: RegexNode
  of rnCharClass:
    negated*: bool
    items*: seq[CharClassItem]
  of rnQuantifier:
    qkind*: RegexQuantifierKind
    min*: int
    max*: int
    lazy*: bool
    operand*: RegexNode
RegexNodeKind = enum
  rnChar, rnEscaped, rnDot, rnAnchorStart, rnAnchorEnd, rnConcat, rnAlternation,
  rnGroup, rnCharClass, rnQuantifier
RegexParser = object
  lexer*: RegexLexer
  current*: RegexToken
  prev*: RegexToken
RegexQuantifierKind = enum
  rqStar, rqPlus, rqQuestion, rqRange

Procs

proc `$`(n: RegexNode; indent = 0): string {....raises: [], tags: [], forbids: [].}
proc captureCount(p: RegexParser): lent int {....raises: [], tags: [], forbids: [].}
proc close(p: var RegexParser) {....raises: [OSError], tags: [], forbids: [].}
proc initRegexParser(input: string): RegexParser {.
    ...raises: [OpenParserRegexError, ValueError], tags: [], forbids: [].}
proc initRegexParser(mf: MemFile): RegexParser {.
    ...raises: [OpenParserRegexError, ValueError], tags: [], forbids: [].}
proc parse(p: var RegexParser): RegexNode {.
    ...raises: [OpenParserRegexError, ValueError, Exception], tags: [RootEffect],
    forbids: [].}