pub struct TermStore { /* private fields */ }Expand description
Interning store and derivative engine.
Implementations§
Source§impl TermStore
impl TermStore
Sourcepub fn approx_bytes(&self) -> u64
pub fn approx_bytes(&self) -> u64
Estimated heap bytes held by terms and memo tables (for the memory limit).
Sourcepub fn nullable(&self, t: TermId) -> bool
pub fn nullable(&self, t: TermId) -> bool
Does the term accept the empty string, ignoring context? Exact only when
TermStore::ctx_dep is false; use TermStore::accepting otherwise.
Sourcepub fn tracker_body(&self, i: u8) -> Option<TermId>
pub fn tracker_body(&self, i: u8) -> Option<TermId>
Body of lookbehind tracker i.
Sourcepub fn class(&mut self, set: &CharSet) -> TermId
pub fn class(&mut self, set: &CharSet) -> TermId
One symbol from set (restricted to the universe).
Sourcepub fn any_symbol(&mut self) -> TermId
pub fn any_symbol(&mut self) -> TermId
Any one symbol of the universe.
Sourcepub fn concat_all(&mut self, factors: &[TermId]) -> TermId
pub fn concat_all(&mut self, factors: &[TermId]) -> TermId
Concatenation of factors, right-nested and normalised. Iterative along
the sequence, so long chains cannot overflow the stack.
Sourcepub fn union(&mut self, items: &[TermId]) -> TermId
pub fn union(&mut self, items: &[TermId]) -> TermId
Union, flattened, sorted and de-duplicated; classes are merged.
Sourcepub fn inter(&mut self, items: &[TermId]) -> TermId
pub fn inter(&mut self, items: &[TermId]) -> TermId
Intersection, flattened, sorted and de-duplicated; classes are merged.
Sourcepub fn assertion(
&mut self,
kind: AssertKind,
word: Option<&CharSet>,
line: Option<&CharSet>,
) -> Option<TermId>
pub fn assertion( &mut self, kind: AssertKind, word: Option<&CharSet>, line: Option<&CharSet>, ) -> Option<TermId>
An assertion. word is the word-character set for word assertions,
line the line-terminator set for line assertions. None when too many
distinct sets are in use.
Sourcepub fn look_ahead(&mut self, neg: bool, body: TermId) -> TermId
pub fn look_ahead(&mut self, neg: bool, body: TermId) -> TermId
(?=body) or (?!body); the body is a complete pattern.
Sourcepub fn look_behind(&mut self, neg: bool, body: TermId) -> Option<TermId>
pub fn look_behind(&mut self, neg: bool, body: TermId) -> Option<TermId>
(?<=body) or (?<!body). None when the body is context-dependent or
too many trackers are in use.
Sourcepub fn advance_ctx(&mut self, id: u32, c: u32) -> u32
pub fn advance_ctx(&mut self, id: u32, c: u32) -> u32
Context after consuming symbol c in context id.
Sourcepub fn nullable_in(&self, t: TermId, ctx: &Ctx, next: Option<u32>) -> bool
pub fn nullable_in(&self, t: TermId, ctx: &Ctx, next: Option<u32>) -> bool
Does t accept the empty remainder at a position described by ctx,
when the next input symbol is next (None = end of input)?
Sourcepub fn accepting(&self, t: TermId, ctx_id: u32) -> bool
pub fn accepting(&self, t: TermId, ctx_id: u32) -> bool
Acceptance at the end of input in context ctx_id.
Sourcepub fn deriv(&mut self, t: TermId, c: u32) -> TermId
pub fn deriv(&mut self, t: TermId, c: u32) -> TermId
Derivative of t with respect to c, for terms that do not depend on
context. For general terms use TermStore::deriv_in.
Sourcepub fn deriv_in(&mut self, t: TermId, c: u32, ctx_id: u32) -> TermId
pub fn deriv_in(&mut self, t: TermId, c: u32, ctx_id: u32) -> TermId
Brzozowski derivative of t with respect to the symbol c, where the
input so far is described by context ctx_id.
Iterative (explicit work stack): terms from counted repetition are thousands of levels deep, and recursion would overflow the stack (NFR-R01).
Sourcepub fn may_consume(&self, t: TermId) -> bool
pub fn may_consume(&self, t: TermId) -> bool
Can the term match a non-empty string? (Conservative: true when unsure.)
Sourcepub fn to_spec(&self, t: TermId) -> String
pub fn to_spec(&self, t: TermId) -> String
Serialise a term in the documented interchange format shared with the
independent checker: 0 empty, e epsilon, [lo-hi,lo] hex ranges,
(. a b) concatenation, (| ...) union, (& ...) intersection,
(* a) star, (! a) complement, (#K w l) assertion (_ for an
unused set), (?= x) / (?! x) lookahead and (<= x) / (<! x)
lookbehind. Iterative, so deep terms are fine.
Sourcepub fn partition(&mut self, t: TermId) -> Arc<Vec<CharSet>> ⓘ
pub fn partition(&mut self, t: TermId) -> Arc<Vec<CharSet>> ⓘ
Coarsest partition of the universe such that every class set occurring
in t (including the sets used by assertions) is a union of blocks (the
term’s symbol classes, FR-B02). Blocks are ordered by smallest member.
Derivatives never introduce new sets, so the partition of the start term
serves for the whole automaton. Iterative for the same reason as
TermStore::deriv_in.