Skip to main content

Module regex

Module regex 

Source
Expand description

XSD §F regex engine — native parser, NFA, Pike VM.

XSD Part 2 §F defines its own regex flavour: implicit whole-string anchoring, an \i / \c shortcut family for XML Name characters, character class subtraction ([a-z-[aeiou]]), the spec’s own \s / \w definitions, and \p{IsBlock} named Unicode blocks. It also forbids back-references, lookaround, and inline modifiers — XSD patterns are pure regular languages.

§Pipeline

  1. parser consumes XSD §F source into an parser::Expr AST.
  2. [nfa::Program] compiles the AST via Thompson’s construction into a flat state list with a side table of character classes (Vec<ClassSet>, hash-consed for dedup).
  3. [vm] runs the NFA against an input string using two state-set buffers and a generation-counter dedup, owned by a thread-local scratch arena so is_match stays allocation-free in steady state.

The matcher is O(N · M) in the input length times NFA state count and never backtracks — pathological patterns like (a|a)*b cost the same as a*b.

Re-exports§

pub use parser::Dialect;

Modules§

parser
XSD §F regex parser — XSD-flavour source → Expr AST.

Structs§

Pattern
A compiled XSD §F pattern.

Enums§

UnicodeVersion
Which Unicode snapshot the regex engine should consult when resolving \p{…} properties. Latest defers to the unicode-properties crate (production code path); the older variants force lookup against the bundled snapshots.

Functions§

compile_with_cached
Cached compile through the thread-local pattern cache. See [COMPILE_CACHE] for the cache lifetime / scope. Misses fall through to Pattern::compile_with; the resulting Pattern is wrapped in Arc and inserted before being returned.
with_unicode_version
Run f with the regex engine’s bundled Unicode snapshot temporarily set to version. Restores the previous value on return. Only affects pattern compilation; once compiled, an NFA’s classes are baked in.