Skip to content

Commit

Permalink
remove oblivion in favor of is_empty
Browse files Browse the repository at this point in the history
  • Loading branch information
jdonszelmann committed Nov 20, 2023
1 parent 44d5d1e commit 8361f47
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 35 deletions.
7 changes: 0 additions & 7 deletions scopegraphs-regular-expressions/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub type StateID = usize;
pub struct MatchState {
non_final: bool,
nullable: bool,
empty: bool,
pub transition_table: HashMap<Rc<Symbol>, StateID>,
#[cfg(feature = "dynamic")]
pub string_transition_table: HashMap<String, StateID>,
Expand All @@ -26,10 +25,6 @@ impl MatchState {
pub fn is_accepting(&self) -> bool {
self.nullable
}

pub fn is_oblivion(&self) -> bool {
self.empty
}
}

pub struct Automaton {
Expand Down Expand Up @@ -181,14 +176,12 @@ impl RegexCompiler {

let non_final = non_final.contains(state);
let nullable = state.is_nullable();
let empty = state.is_oblivion();

match_states.insert(
*state_ids.get(state).unwrap(),
MatchState {
non_final,
nullable,
empty,
#[cfg(feature = "dynamic")]
string_transition_table: transition_table
.iter()
Expand Down
12 changes: 0 additions & 12 deletions scopegraphs-regular-expressions/src/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ impl<'a> RegexMatcher<&'a str> for DynamicMatcher<'_> {
.map(MatchState::is_accepting)
.unwrap_or_default()
}

fn is_oblivion(&self) -> bool {
self.compiled_regex
.states
.get(self.current_state)
.map(MatchState::is_oblivion)
.unwrap_or_default()
}
}

impl RegexMatcher<char> for DynamicMatcher<'_> {
Expand All @@ -68,10 +60,6 @@ impl RegexMatcher<char> for DynamicMatcher<'_> {
fn is_accepting(&self) -> bool {
RegexMatcher::<&str>::is_accepting(self)
}

fn is_oblivion(&self) -> bool {
RegexMatcher::<&str>::is_oblivion(self)
}
}

#[cfg(test)]
Expand Down
10 changes: 0 additions & 10 deletions scopegraphs-regular-expressions/src/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ impl Automaton {

let finals: Vec<_> = states.iter().map(MatchState::is_final).collect();
let accepting: Vec<_> = states.iter().map(MatchState::is_accepting).collect();
let oblivions: Vec<_> = states.iter().map(MatchState::is_oblivion).collect();

quote!(
struct #name {
Expand Down Expand Up @@ -77,15 +76,6 @@ impl Automaton {
_ => unreachable!(),
}
}

fn is_oblivion(&self) -> bool {
match self.state {
#(
#ids => {return #oblivions;}
),*
_ => unreachable!(),
}
}
}
)
}
Expand Down
1 change: 0 additions & 1 deletion scopegraphs-regular-expressions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ pub trait RegexMatcher<A> {

fn is_final(&self) -> bool;
fn is_accepting(&self) -> bool;
fn is_oblivion(&self) -> bool;
fn is_empty(&self) -> bool {
self.is_final() && !self.is_accepting()
}
Expand Down
5 changes: 0 additions & 5 deletions scopegraphs-regular-expressions/src/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ impl Regex {
}
}

/// Returns whether this regex accepts the empty set or oblivion
pub fn is_oblivion(&self) -> bool {
matches!(self, Regex::EmptySet)
}

/// Returns whether this regex is nullable.
///
/// That's either the empty string `e`, or some regex which has the empty string in the right place, like `e | a` is nullable because `e` is nullable.
Expand Down

0 comments on commit 8361f47

Please sign in to comment.