The matching engine for timelib's re2c scanner: a Thompson NFA built
from the rule definitions of parse_date.re, simulated to find what the
re2c DFA finds: the longest match over all rules, the earliest rule on a
tie.
The simulation is cached as a lazily built DFA (each set of NFA states seen becomes a DFA state, each transition is computed once), so a format seen before is scanned at one table lookup per byte.
Contents
use php_std::datetime::scanner::ByteSet;pub struct ByteSet([u64; 4])A set of bytes.
use php_std::datetime::scanner::Lazy;pub struct Lazy(OnceLock<Nfa>, fn() -> Vec<P>)A lazily built NFA.
use php_std::datetime::scanner::Nfa;pub struct NfaAll rules compiled into one NFA.
use php_std::datetime::scanner::P;pub enum PA pattern (a re2c regular expression).
use php_std::datetime::scanner::alt;pub fn alt(ps: Vec<P>) -> PA pattern matching any one of ps.
use php_std::datetime::scanner::ci;pub fn ci(s: &str) -> P'...': an ASCII case-insensitive literal.
use php_std::datetime::scanner::digit;pub fn digit() -> PA pattern matching one ASCII digit.
use php_std::datetime::scanner::lit;pub fn lit(s: &str) -> P"...": a case-sensitive literal.
use php_std::datetime::scanner::opt;pub fn opt(p: P) -> PA pattern matching p or nothing.
use php_std::datetime::scanner::plus;pub fn plus(p: P) -> PA pattern matching p one or more times.
use php_std::datetime::scanner::range;pub fn range(a: u8, b: u8) -> P[a-b].
use php_std::datetime::scanner::ranges;pub fn ranges(rs: &[(u8, u8)]) -> PA union of byte ranges.
use php_std::datetime::scanner::rep;pub fn rep(p: P, min: u32, max: u32) -> PA pattern matching p from min to max times.
use php_std::datetime::scanner::seq;pub fn seq(ps: Vec<P>) -> PA pattern matching each of ps in turn.
use php_std::datetime::scanner::set;pub fn set(chars: &str) -> P[...] of the listed bytes.
use php_std::datetime::scanner::star;pub fn star(p: P) -> PA pattern matching p zero or more times.