brzozowski/lib.rs
1/*!
2 * This crate provides an alternative implementation of a toy Regex engine that uses Brzozowski derivatives
3 * instead of building an automaton (either NFA or a DFA).
4 * This implementation closely follows the very educational [Python implementation] and provides similar
5 * APIs to it. Note that the set of supported regular expressions in general is minimal but in line with the Python implementation.
6 *
7 * The recommended way to build an [`Expr`] out of a regular expression is via [`std::string::FromStr`]. For example:
8 *
9 * ```rust
10 * use brzozowski::Expr;
11 *
12 * let re = "b(a*)(na)*".parse::<Expr>().unwrap();
13 * assert!(re.is_match("banana"));
14 * ```
15 *
16 * [Python implementation]: https://github.com/aalekhpatel07/brzozowski/tree/main?tab=readme-ov-file#brzozowski-derivative
17 *
18 * The [`Expr`]'s are essentially a tree representation of the regular expression where the following operations are possible:
19 * - [`Expr::Concat`]\: Concatenate two strings together (i.e. `<expr>ยท<expr>`)
20 * - [`Expr::Union`]\: Take union of two strings (i.e. `<expr>|<expr>`)
21 * - [`Expr::Kleene`]\: Describe the Kleene star for a string (i.e. `<expr>*`).
22 * - [`Expr::Term`]\: The leaf nodes in the tree that represent characters of the alphabet.
23 *
24 * To explore how the derivatives are calculated, check out the [`Expr::derivative`], [`Expr::nulled`], and [`Expr::simplify`] methods.
25 *
26 */
27
28mod expr;
29pub use expr::*;