rexact-core 0.2.0

Derivative-based regex engine for Rexact: symbol classes, lazy DFA, minimisation, per-dialect semantics
Documentation
//! A resolved view of a pattern for backtracking analysis (milestone M8).
//!
//! Every leaf is already a [`CharSet`] under the dialect's rules (case folding,
//! shorthand definitions, alphabet mode), so analyses need no dialect logic.
//! Zero-width constructs are kept as terms of the shared [`TermStore`], which
//! knows how to evaluate them against the input seen so far.

use crate::charset::CharSet;
use crate::term::TermId;

/// A pattern node with leaves resolved to symbol sets.
#[derive(Debug, Clone)]
pub struct RNode {
    /// Shape.
    pub kind: RKind,
    /// Byte-free source range (scalar offsets) in the original pattern text.
    pub span: (usize, usize),
}

/// Node shapes.
#[derive(Debug, Clone)]
pub enum RKind {
    /// Matches the empty string.
    Empty,
    /// One symbol from the set.
    Set(CharSet),
    /// Sequence.
    Cat(Vec<RNode>),
    /// Ordered alternation (backtracking engines try left to right).
    Alt(Vec<RNode>),
    /// Repetition; `max == None` is unbounded.
    Repeat {
        /// Body.
        node: Box<RNode>,
        /// Minimum count.
        min: u64,
        /// Maximum count.
        max: Option<u64>,
        /// Greedy (try more first) or lazy.
        greedy: bool,
    },
    /// Zero-width assertion, evaluated by the term store at a position.
    Assert(TermId),
    /// `(?=x)` / `(?!x)`.
    LookAhead {
        /// Negative form.
        neg: bool,
        /// Body.
        node: Box<RNode>,
    },
    /// `(?<=x)` / `(?<!x)`.
    LookBehind {
        /// Negative form.
        neg: bool,
        /// Body.
        node: Box<RNode>,
    },
}