From ef3ef65e3c6d1cb1b799b8d65847e6f4f228ca3c Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Sat, 2 Dec 2023 01:40:49 +0200 Subject: NFA implementation with support for kleene*, union and simple concatination using thomposon's construction with simulation function that matches a given regex --- src/main.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index bcc0f01..6b4612d 100755 --- a/src/main.rs +++ b/src/main.rs @@ -5,17 +5,12 @@ use regex::*; fn test(regex: &str, input: &str) -> bool { let token = Regex::new(String::from(regex)); - dbg!(&token); let mut nfa = NFA::new(); nfa.regex_to_nfa(token); - let mut x: Vec<(&usize, &State)> = nfa.states.iter().map(|(k, v)| (k, v)).collect(); - x.sort(); - dbg!(x); - // nfa.match_re(String::from(input)) - true + nfa.matches(String::from(input)) } fn main() { // println!("{}", test("a.b..", "a.bxb")); - println!("{}", test(".*b", "aaaaaabbb")) + println!("{}", test(".b", "ab")) } -- cgit v1.2.3