diff --git a/src/main.rs b/src/main.rs --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,7 @@ use std::collections::{HashMap, HashSet}; +const START: usize = usize::MAX; + trait Token { fn is_skippable(&self) -> bool {false} fn list_first(&self) -> Vec; @@ -130,8 +132,8 @@ fn parse(pattern: &String, offset: usize i = j+1; } '*' => { - let segment = res.pop().unwrap(); - res.push(Box::new(Asterisk{content: segment})); + let token = res.pop().unwrap(); + res.push(Box::new(Asterisk{content: token})); i += 1; } c => { @@ -157,7 +159,7 @@ impl Regexp { for i in r.list_first() { let c = pattern_chars[i]; - let key = (99, c); + let key = (START, c); match rules.get_mut(&key) { Some(set) => {set.insert(i);}, None => {rules.insert(key, HashSet::from([i]));} @@ -179,7 +181,7 @@ impl Regexp { } pub fn eval(&self, s: String) -> bool { - let mut multistate = HashSet::from([99]); + let mut multistate = HashSet::from([START]); for c in s.chars() { let mut new_multistate = HashSet::new();