aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authoromagdy7 <omar.professional8777@gmail.com>2023-12-02 01:40:49 +0200
committeromagdy7 <omar.professional8777@gmail.com>2023-12-02 01:40:49 +0200
commitef3ef65e3c6d1cb1b799b8d65847e6f4f228ca3c (patch)
tree0cd0e710e3a3dd6990f44137fffd0dde92555db3 /src/main.rs
parentd66f8a4749cdc2bfe51527c50b846eef87be4e17 (diff)
downloadrex-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-xsrc/main.rs9
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"))
}