diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2023-12-02 01:40:49 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2023-12-02 01:40:49 +0200 |
| commit | ef3ef65e3c6d1cb1b799b8d65847e6f4f228ca3c (patch) | |
| tree | 0cd0e710e3a3dd6990f44137fffd0dde92555db3 /src/main.rs | |
| parent | d66f8a4749cdc2bfe51527c50b846eef87be4e17 (diff) | |
| download | rex-ef3ef65e3c6d1cb1b799b8d65847e6f4f228ca3c.tar.xz rex-ef3ef65e3c6d1cb1b799b8d65847e6f4f228ca3c.zip | |
NFA implementation with support for kleene*, union and simple concatination using thomposon's construction with simulation function that matches a given regex
Diffstat (limited to 'src/main.rs')
| -rwxr-xr-x | src/main.rs | 9 |
1 files changed, 2 insertions, 7 deletions
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")) } |
