/**
 * The line-matching port. Widget patterns are model-written, so the production engine must run in
 * linear time (RE2 semantics); a JS `RegExp` can backtrack catastrophically and is not shipped as
 * an engine. {@link compilePatterns} rejects what RE2 cannot run (lookaround, backreferences,
 * recursion and subroutine calls, conditionals, backtracking verbs) in every spelling before an
 * engine sees a pattern, and hands it one group spelling, `(?<name>…)`.
 */
/** Span of one named group's capture in a line, in UTF-16 units. */
export interface GroupSpan {
    start: number;
    end: number;
}
export interface LineMatch {
    /** Index of the matched line in the input. */
    line: number;
    /** Index of the pattern that matched. */
    pattern: number;
    /** Per named group of the pattern, in `groupNames[pattern]` order; `undefined` when it took no part. */
    spans: readonly (GroupSpan | undefined)[];
}
export interface CompiledLineMatcher {
    /** Named groups of each pattern, in pattern order. */
    readonly groupNames: readonly (readonly string[])[];
    /** Every pattern's leftmost match on every line, ordered by line, then by pattern. */
    matchLines(lines: readonly string[]): LineMatch[];
}
/** A linear-time regex engine. `compile` throws {@link MatcherCompileError} for a pattern it rejects. */
export interface LineMatcher {
    compile(patterns: readonly string[]): CompiledLineMatcher;
}
export declare class MatcherCompileError extends Error {
    /** Index of the rejected pattern. */
    readonly pattern: number;
    readonly reason: string;
    constructor(pattern: number, reason: string);
}
export interface PatternScan {
    /** Named groups in pattern order. */
    groups: string[];
    /** The pattern with every `(?P<name>` spelled `(?<name>`. */
    normalized: string;
    /** Why the pattern cannot run on a linear-time engine. */
    error?: string;
}
/**
 * Reads a pattern's named groups and constructs outside escapes, character classes and `\Q\E`
 * quoted text (literal in RE2, up to `\E` or the end of the pattern), so the groups it reports are
 * the ones RE2's `namedGroups()` reports.
 */
export declare function scanPattern(pattern: string): PatternScan;
/** Named groups a pattern declares, in pattern order. */
export declare function patternGroupNames(pattern: string): string[];
/** Checks every pattern's syntax, then compiles the normalized patterns on `matcher`. */
export declare function compilePatterns(matcher: LineMatcher, patterns: readonly string[]): CompiledLineMatcher;
//# sourceMappingURL=matcher.d.ts.map