Skip to content

Commit

Permalink
fix subsumption check
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Sep 4, 2024
1 parent 14c4e9c commit 395772f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
toktrie = { git = "https://github.com/microsoft/toktrie", rev = "7cb20cd594428f5397f6159115d5e070e8c0935f" }
derivre = { git = "https://github.com/microsoft/derivre", rev = "677799cfa3abb1a33928d40f81972b3a9c965e4f" }
derivre = { git = "https://github.com/microsoft/derivre", rev = "30bf07f634426121d1cd003187d96a40af387c19" }
serde = { version = "1.0.192", features = ["derive"] }
serde_json = "1.0.108"
anyhow = "1.0.75"
Expand Down
14 changes: 11 additions & 3 deletions parser/src/earley/regexvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,24 @@ impl RegexVec {
assert!(self.subsume_possible(state));
let small = self.rx_list[lexeme_idx];
self.set_fuel(u64::MAX);
let mut res = false;
for (idx, e) in iter_state(&self.rx_sets, state) {
assert!(!self.lazy[idx]);
let big = self.exprs.mk_not(e);
let pref = self.exprs.mk_prefixes(e);
let big = self.exprs.mk_not(pref);
let check = self.exprs.mk_and(vec![small, big]);
let c0 = self.exprs.cost();
let not_contained =
self.relevance
.is_non_empty_limited(&mut self.exprs, check, budget)?;
// println!(
// "{} -> contained={}",
// self.exprs.expr_to_string(check),
// !not_contained
// );
if !not_contained {
return Ok(true);
res = true;
break;
}
let cost = self.exprs.cost() - c0;
budget = budget.saturating_sub(cost);
Expand All @@ -155,7 +163,7 @@ impl RegexVec {
if false && cost > 10 {
println!("check_subsume: {}/{} {:?}", cost, budget0, t0.elapsed());
}
Ok(false)
Ok(res)
}

/// Estimate the size of the regex tables in bytes.
Expand Down
2 changes: 1 addition & 1 deletion rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 395772f

Please sign in to comment.