Files @ 4f7b6352013d
Branch filter:

Location: Regular-Expresso/src/main.rs - annotation

4f7b6352013d 473 B application/rls-services+xml Show Source Show as Raw Download as Raw
Laman
added the automaton normalization
use regexp::Regexp;

fn main() {
	let tests = ["", "a", "ab", "aabb", "abab", "abcd", "abcbcdbcd"];
	for pattern in ["a(b|c)", "a*b*", "(ab)*", "a((bc)*d)*", "(a|b)*a(a|b)(a|b)(a|b)"] {
		println!("# {pattern}");
		let r = match Regexp::new(&pattern.to_string()) {
			Ok(r1) => r1.determinize().reduce().normalize(),
			Err(e) => {
				println!("{e}");
				continue;
			}
		};
		for &t in tests.iter() {
			println!("{t} {}", r.eval(t.to_string()));
		}
		println!();
	}
}