@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
71 lines • 3.78 kB
TypeScript
export type Span = [number, number];
export type Groups = (Span | null)[];
export type PosixDialect = 'sed' | 'posix';
export type LineSyntax = 'basic' | 'extended' | 'fixed' | 'perl';
/** `text` as a POSIX extended expression that matches only itself. Mirrors Python's posix_escape. */
export declare function posixEscape(text: string): string;
/**
* One POSIX expression, searched against whole subjects. A match is the
* leftmost one and the longest there; its groups lie where the first way of
* matching that text puts them, trying a repetition's longer counts and an
* alternation's earlier branches first. Offsets count elements of the byte
* view the subject arrives as. `dialect` `sed` reads the expression as GNU
* sed does, `posix` as regcomp does for expr, nl, bash and git; `multiline`
* is sed's `M`, and `word` git grep's -w. A long search yields to the loop
* between its bounded calls. A refused expression throws
* RegexError in regerror's wording. Mirrors Python's PosixRegex.
*/
export declare class PosixRegex {
readonly utf8: boolean;
readonly groups: number;
private readonly streams;
constructor(pattern: string, extended?: boolean, dialect?: PosixDialect, ignoreCase?: boolean, utf8?: boolean, multiline?: boolean, word?: boolean);
private spans;
/** The leftmost-longest match at or after `at`, and its groups. */
search(text: string, at?: number, signal?: AbortSignal): Promise<Groups | null>;
/** Every match a global substitution replaces, as sed walks them. */
all(text: string, signal?: AbortSignal): Promise<Groups[]>;
/**
* How many times git's pickaxe counts the expression in `text`: each match
* stays in its line, each search resumes where the last one ended (a
* character further after an empty one), and `^` never holds where it
* resumes.
*/
contains(text: string, signal?: AbortSignal): Promise<number>;
/**
* Whether the expression matches anywhere in `text`, as sed's addresses
* ask: with no groups to place, a `$` reads a newline the match goes on to
* consume even in a pattern with groups.
*/
matches(text: string, signal?: AbortSignal): Promise<boolean>;
}
/** A compiled PosixRegex, shared by every caller asking the same. Mirrors Python's posix_regex. */
export declare function posixRegex(pattern: string, extended?: boolean, dialect?: PosixDialect, ignoreCase?: boolean, utf8?: boolean, multiline?: boolean, word?: boolean): PosixRegex;
/**
* grep's pattern list, matched against one line at a time: a line matches
* when any pattern does, and `extents` reads matches as -o prints them, the
* leftmost and longest across the list. `line` (-x) outranks `word` (-w). A
* refused pattern throws RegexError in GNU grep's wording. Mirrors Python's
* LineRegex.
*/
export declare class LineRegex {
readonly ignoreCase: boolean;
readonly utf8: boolean;
readonly warnings: readonly string[];
readonly needles: string[] | null;
/** Letters fold by Unicode, so `ſ` matches `s` and the Kelvin sign `k`. */
readonly unicodeFolds: boolean;
private readonly streams;
constructor(patterns: readonly string[], syntax: LineSyntax, ignoreCase?: boolean, utf8?: boolean, word?: boolean, line?: boolean);
/**
* Whether the line, without its terminator, matches. Throws SearchLimit when
* a -P search gives up at PCRE2's match limit.
*/
matches(line: string, signal?: AbortSignal): Promise<boolean>;
/**
* Each match grep -o prints from the line. Throws SearchLimit, carrying the
* matches found before it, when a -P search gives up at PCRE2's match limit.
*/
extents(line: string, signal?: AbortSignal): Promise<Span[]>;
}
//# sourceMappingURL=regex.d.ts.map