diff options
| author | Jonas Maier <jonas@x77.dev> | 2026-06-02 22:05:15 +0200 |
|---|---|---|
| committer | Jonas Maier <jonas@x77.dev> | 2026-06-02 22:05:15 +0200 |
| commit | 8dbff3c028ed9a441e90b39dfe59ad4124cf6195 (patch) | |
| tree | a4f4487be836d0d6e56bc096bd49eeebbbb90bd1 | |
| parent | 10defcf9f7132bdcc88c1fe32d9550a0d5952042 (diff) | |
| download | pish-8dbff3c028ed9a441e90b39dfe59ad4124cf6195.tar.gz | |
negative lookahead seems to work too ?!
| -rw-r--r-- | src/parse/regex/enfa.rs | 21 | ||||
| -rw-r--r-- | test-cases/case3_negative_lookahead/script.sh | 2 |
2 files changed, 10 insertions, 13 deletions
diff --git a/src/parse/regex/enfa.rs b/src/parse/regex/enfa.rs index fea2976..b0588ab 100644 --- a/src/parse/regex/enfa.rs +++ b/src/parse/regex/enfa.rs @@ -233,13 +233,12 @@ impl Thread { .into_iter() .map(|t| t.step(enfa, input)) .collect(); - let negatives = self + let negatives: Vec<_> = self .negatives .into_iter() - .map(|t| t.step(enfa, input)) + .flat_map(|t| t.step(enfa, input)) .collect(); let positives = cartesian_product(positives); - let negatives = cartesian_product(negatives); let next_states: Vec<StateId> = enfa.states[self.state] .trans .iter() @@ -258,15 +257,13 @@ impl Thread { for s in next_states { for p in positives.clone() { - for n in negatives.clone() { - if let Some(thread) = Self::new(enfa, s, p.clone(), n) { - thread.step_epsilon0( - enfa, - ret, - &mut vec![false; enfa.states.len()], - Vec::new(), - ); - } + if let Some(thread) = Self::new(enfa, s, p.clone(), negatives.clone()) { + thread.step_epsilon0( + enfa, + ret, + &mut vec![false; enfa.states.len()], + Vec::new(), + ); } } } diff --git a/test-cases/case3_negative_lookahead/script.sh b/test-cases/case3_negative_lookahead/script.sh index 3246f74..837f208 100644 --- a/test-cases/case3_negative_lookahead/script.sh +++ b/test-cases/case3_negative_lookahead/script.sh @@ -40,4 +40,4 @@ fun x4 { } match x4 x yes match x4 xa no -match x4 xy no +match x4 xy yes |
