@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
24 lines • 1.33 kB
TypeScript
/**
* A POSIX extended regular expression reader, independent of the host's regex engine (senpi#5349). It answers the
* three questions the kill guard asks of a `pkill`/`killall` pattern: does some alternative branch match nothing at
* all, can the whole pattern match the empty string, and how few literal characters can a match carry. glibc
* compiles `a||b` to "matches every line" while BSD libc rejects it, so the guard reads patterns itself.
*
* Grammar: alternation, groups, bracket expressions (classes, equivalence classes, collating symbols, negation),
* `*` `+` `?` `{m}` `{m,}` `{m,n}`, anchors `^` `$`, and the glibc/BSD escapes: `\w \W \s \S \d \D` match one
* arbitrary character, `\b \B \< \> \` \'` are zero width, any other escaped character is that literal.
*/
export type PatternReading = {
readonly kind: "unparsable";
readonly why: string;
} | {
readonly kind: "parsed";
/** Some alternative branch, at any group level, is empty (`a||b`, `(|x)`, `()`). */
readonly emptyBranch: boolean;
/** The whole pattern can match the empty string. */
readonly nullable: boolean;
/** The fewest literal characters any match path carries. */
readonly minLiterals: number;
};
export declare function readPattern(pattern: string): PatternReading;
//# sourceMappingURL=ere.d.ts.map