hydra.print.regex module
Canonical printer for Hydra’s translingual regular-expression syntax (docs/specification/regex.md): hydra.regex AST -> canonical text. Escapes minimally (a character is escaped only where it is special in its context), so that print.regex . parse.regex is idempotent on well-formed input. Per-dialect renderers (hydra.print.<dialect>.regex) build on this. See issue #567.
- hydra.print.regex.alternation(alt: Sequence[Sequence[Quantified]]) str
Render an alternation, joining its branches with the | operator.
- hydra.print.regex.atom(a: Atom) str
Render a single atom (literal, ., anchor, group, or class) to canonical text.
- hydra.print.regex.character_class(cc: CharacterClass) str
Render a character class, including the leading ^ for a negated class.
- hydra.print.regex.class_item(item: ClassItem) str
Render one character-class member (a single character or an inclusive range) to canonical text.
- hydra.print.regex.escape_class_char(c: int) str
Render a code point inside a character class, backslash-escaping it iff it is one of the class metacharacters ] ^ -. Escaping is uniform, with no positional exceptions (a literal ‘-’ always prints as -).
- hydra.print.regex.escape_literal(c: int) str
Render a literal code point in top-level context, backslash-escaping it iff it is one of the top-level metacharacters . ^ $ * + ? ( ) [ ] { } | . A ‘-’ is not special at top level and prints bare.
- hydra.print.regex.print_code_point(c: int) str
Render a single Unicode code point as a one-character string.
- hydra.print.regex.print_regex(r: Sequence[Sequence[Quantified]]) str
Render a hydra.regex AST to canonical Hydra regex text. Escapes minimally, so that printRegex . parseRegex is the identity on well-formed patterns.
- hydra.print.regex.quantified(qa: Quantified) str
Render an atom followed by its quantifier suffix.
- hydra.print.regex.quantifier(q: Quantifier) str
Render a quantifier suffix; the ‘one’ quantifier renders as the empty string.
- hydra.print.regex.regex_sequence(s: Sequence[Quantified]) str
Render a sequence of quantified atoms by concatenation.