diff --git a/parser/Cargo.toml b/parser/Cargo.toml index ac240cfd..87f1f9d1 100644 --- a/parser/Cargo.toml +++ b/parser/Cargo.toml @@ -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" diff --git a/parser/src/earley/regexvec.rs b/parser/src/earley/regexvec.rs index 4cebfe96..24205426 100644 --- a/parser/src/earley/regexvec.rs +++ b/parser/src/earley/regexvec.rs @@ -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); @@ -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. diff --git a/rust/Cargo.lock b/rust/Cargo.lock index ebe3f049..4fe3e92e 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -65,7 +65,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "derivre" version = "0.1.0" -source = "git+https://github.com/microsoft/derivre?rev=677799cfa3abb1a33928d40f81972b3a9c965e4f#677799cfa3abb1a33928d40f81972b3a9c965e4f" +source = "git+https://github.com/microsoft/derivre?rev=30bf07f634426121d1cd003187d96a40af387c19#30bf07f634426121d1cd003187d96a40af387c19" dependencies = [ "ahash", "anyhow",