$ show pemistahl/grex
grex is a regular expression generator that creates regex patterns from user-provided test cases. It implements DFA construction, Hopcroft's minimization algorithm, and Brzozowski's algebraic method to produce Perl-compatible regexes. The system serves dual purposes as a command-line utility and a library with bindings for Rust, Python, and WebAssembly. Key features include Unicode grapheme handling, configurable character class conversions (digits/whitespace/word), case insensitivity, repetition detection, and syntax highlighting. The architecture separates core regex building logic from CLI, Python, and WASM extension points, enabling reuse across multiple contexts.
The LLM identified 3 files worth highlighting for reuse:
Implements DFA construction from input strings and Hopcroft's minimization algorithm. Self-contained module that could be extracted for any DFA-based application (e.g., lexical analysis, string matching). Demonstrates solid automata theory implementation with clear state transition handling.
Defines the Expression enum (literal, concatenation, alternation, repetition) and implements Brzozowski's algebraic method to convert minimized DFAs to regex expressions. Isolated core algorithm that handles operator precedence and parentheses correctly. Non-trivial implementation of formal language theory suitable for reuse in projects needing regex generation from state machines.
Provides Unicode grapheme cluster segmentation and escaping utilities. Handles surrogate pairs, combining marks, and Unicode categories correctly. Could be extracted as a standalone Unicode text processing component for any application requiring proper grapheme-aware string manipulation (e.g., text editors, i18n libraries).