TOC Toolkit API - v0.1.0
    Preparing search index...

    toc-toolkit/automata/regex

    Parses regular expression source into a spanned syntax tree and then into an immutable term. Other packages use it to compile, compare and print regular expressions.

    Union uses | or ∪. Intersection uses & and binds more tightly than union. Concatenation binds more tightly than intersection and can use ·. Prefix ~ complements its operand over the model alphabet. Postfix *, +, ?, {n}, {n,} and {n,m} bind most tightly. Parentheses group expressions. ε denotes the empty word and ∅ the empty language.

    A class such as [abc] expands into a union. A range such as [a-c] follows the declared alphabet order. Without a declared alphabet, single-code-point endpoints follow Unicode scalar order. Reversed ranges and empty classes are invalid. Counts expand under the supplied budget. Unquoted &, ~ and [ introduce the new operators and classes. A { after an atom introduces a count. Quote or escape these symbols to use them literally, as in "&", "~", "[" and "{". The printer quotes these literals. Closing delimiters, commas and hyphens keep their literal meaning outside their own contexts. Quoted tokens accept Unicode escapes such as "\u{1F642}".

    • Regex parsing. Reads regular expression text into a spanned syntax tree and reports issues with source positions. (parseSyntax)
    • Term construction. Orders written union alternatives while retaining repeated alternatives, written repetitions and Boolean operators. The builder's language operations flatten and deduplicate unions, absorb the empty language and collapse nested stars. (buildRegex, RegexBuilder)
    • Classical preparation. Normalizes expressions with Boolean operators for classical constructions and leaves other expressions unchanged. (normalizeForClassical)
    • Brzozowski derivatives. Computes the derivative of a term by a symbol with memoization. Repeated derivatives of a term give word recognition. (derivative)
    • Nullability and symbol collection. Reads the nullable flag stored when a node is created and lists the distinct literals of a term. (isNullable, symbolsOf)
    • Source checking. Checks regular expression source under a budget and returns the term with every declared literal, including those that normalization removes, or the issues. (checkRegex)
    • Precedence-aware printing. Writes a normalized term back as regular expression text and measures its printed length. (printRegex, printedLength)
    • Text codec. Pairs the checker and the printer of terms under one budget. The printer includes alphabet symbols needed by Boolean terms. (regexTextCodec)
    • Dumps and codecs. Print a term or a syntax tree as stable text, and decode and encode a term and its issues. (dumpRegex, dumpSyntax, regexDecoder, encodeRegex, regexIssueDecoder)
    • Syntax tree. A tree with source spans for every node. (SyntaxTree)
    • Hash-consed regex term. A pool of interned nodes in which equal subterms share one identifier. (Regex, RegexBuilder, RegexId, RegexNode)
    • Enumerations. Name the closed sets of strings that the types and the wire data of the package use. (RegexEscape, RegexIssueCode, RegexOperator, RegexToken, SyntaxKind)
    • Constants. Fix the limits and tables that the package exports. (MAX_NESTING_DEPTH, MAX_SOURCE_LENGTH)