hydra.print.emacs.regex module
Per-dialect printer rendering the hydra.regex AST into GNU Emacs regexp syntax. Emacs inverts several escaping conventions relative to POSIX ERE (probe-verified, Emacs 28.2): alternation is | (bare | is literal), grouping is ( ) (bare ( ) are literal), and bounded quantifiers are {n,m} (bare braces are literal). The quantifiers * + ? are bare as usual, and character classes are POSIX-like. Hydra’s . (any incl. newline) renders as [^z-a] — an empty negated range that matches every character including newline (Emacs . excludes newline). See docs/specification/regex.md and issue #567.
- hydra.print.emacs.regex.alternation(alt: Sequence[Sequence[Quantified]]) str
Render an alternation, joining its branches with Emacs’s | operator.
- hydra.print.emacs.regex.atom(a: Atom) str
Render a single atom; . -> [^z-a], and groups use Emacs’s ( ) escaping.
- hydra.print.emacs.regex.character_class(cc: CharacterClass) str
Render a character class, including the leading ^ for a negated class (POSIX-like in Emacs).
- hydra.print.emacs.regex.class_item(item: ClassItem) str
Render one character-class member (a single character or an inclusive range).
- hydra.print.emacs.regex.escape_class_char(c: int) str
Render a code point inside a character class, uniformly escaping the class metacharacters ] ^ -.
- hydra.print.emacs.regex.escape_literal(c: int) str
Render a literal code point in top-level context under Emacs regexp, escaping only the characters that are special bare in Emacs: . * + ? [ ] ^ $ . Note | ( ) { } are literal in Emacs and are NOT escaped here.
- hydra.print.emacs.regex.print_code_point(c: int) str
Render a single Unicode code point as a one-character string.
- hydra.print.emacs.regex.print_regex(r: Sequence[Sequence[Quantified]]) str
Render a hydra.regex AST into GNU Emacs regexp syntax (escaped | ( ) {..}, . as [^z-a]).
- hydra.print.emacs.regex.quantified(qa: Quantified) str
Render an atom followed by its quantifier suffix.
- hydra.print.emacs.regex.quantifier(q: Quantifier) str
Render a quantifier suffix; bounded {..} forms use Emacs’s escaped braces {..}.
- hydra.print.emacs.regex.regex_sequence(s: Sequence[Quantified]) str
Render a sequence of quantified atoms by concatenation.