/** * Finite regex generator. * * This is intentionally not a full JavaScript RegExp implementation. * It parses a deterministic, portable subset that is useful for data * construction and rejects patterns with unbounded output length. */ import type { Generator } from './generator.js'; export declare const DEFAULT_REGEX_MAX_LENGTH = 32; export interface RegexGenAttrs { readonly pattern: string; readonly regexMaxLength?: number | string | undefined; } export interface RegexProgram { readonly maxLength: number; readonly captureCount: number; } export declare class RegexGeneratorError extends Error { readonly name = "RegexGeneratorError"; } export declare function parseRegexMaxLength(raw: number | string | undefined, fallback?: number): number; export declare function parseRegexProgram(pattern: string, attrs?: Pick): RegexProgram; export declare function regexGenerator(attrs: RegexGenAttrs): Generator; /** * The ceiling `regexSpaceSize` saturates at, rather than overflowing. * * Five languages have to arrive at the same number, and past this point the only question * anyone asks of it — is there room for this many rows? — has the same answer whatever the * pattern: yes. 2^53 − 1 is the largest integer every one of the five holds exactly. */ export declare const REGEX_SPACE_CAP: number; /** * The most different strings a pattern can produce — what `uniq="true"` checks a count against * before it draws anything. * * Counted over the parse tree. A character class contributes its distinct characters, a * sequence multiplies, an alternation adds, and `{m,n}` adds up every length it allows — so * `[A-Z]{2}-[0-9]{4}` is 26² · 10⁴ = 6 760 000, and `[0-9]{2,3}` is 10² + 10³ = 1 100. * * That is EXACT for what identifiers are made of: letters, digits, literals, fixed and bounded * repeats. Otherwise it is an UPPER BOUND — never a lower one, because every string needs at * least one way to be produced and some have two. `(a|ab)(c|bc)` reaches `abc` along both and is * counted twice; a conditional counts both its branches although a row takes one. A * back-reference counts once, because what it repeats was already counted where the group * stands. An overstatement never lets a request through that cannot be met: the draw notices * the space running dry and says so (see `uniq-simple.ts`). */ export declare function regexSpaceSize(attrs: RegexGenAttrs): number; //# sourceMappingURL=regex.d.ts.map