From b306fe88edcb3d7c7628e155f67fd7e1c8c29c19 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Tue, 28 Feb 2023 22:14:15 +0800 Subject: Add a type Reducer for recording extra reductions In the chain-rule machine, we need to skip through edges whose labels are "accepting", otherwise the time complexity will be high even for simple grammars. This implies that we will skip some "jumping up" in the item derivation forest. So we need to record these extra jumping up, in order to jump up at a later point. This Reducer type plays this role. But I still need more experiments to see if this approach works out as I intended. --- grammar/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'grammar/src') diff --git a/grammar/src/lib.rs b/grammar/src/lib.rs index 21ce2b4..54d9ebc 100644 --- a/grammar/src/lib.rs +++ b/grammar/src/lib.rs @@ -374,9 +374,9 @@ impl Grammar { for (index, accumulator) in self.accumulators.iter().copied().enumerate() { let shifted_accumulator = accumulator << 1; - // NOTE: Clippy suggests to call `cmp`, but it seems - // compiler might not yet be smart enough to inline that - // call, so I just silence clippy here. + // NOTE: Clippy suggests to call `cmp`, but it seems that + // the compiler might not yet be smart enough to inline + // that call, so I just silence clippy here. #[allow(clippy::comparison_chain)] if pos == shifted_accumulator { return Some(index); -- cgit v1.2.3-18-g5258