REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
Loading...
Searching...
No Matches
real::detail::inner_literal_detail Namespace Reference

Classes

struct  walk_state
 Extraction state threaded through the walk: the growing byte run, the best literal so far, and the top-level concat child each run began at (so the winner carries its prefix boundary). More...
 

Functions

constexpr std::uint32_t score_run (std::span< const std::uint8_t > run)
 Selectivity of a byte run: the sum of per-byte rarity (2000 - byte_frequency). A sum (rather than the rarest byte alone) approximates the product of per-byte match probabilities, so it rewards both a rare byte and a longer literal — the two things that shrink the candidate count.
 
constexpr void flush (walk_state &st)
 Score the current byte run and keep it (with its prefix boundary) if it beats best, then clear it (capped at inner_literal_max).
 
constexpr bool walk (const ast &tree, std::int32_t idx, walk_state &st, std::int32_t top_child)
 Walk one node, appending guaranteed-present literal bytes to st.run. top_child is the top-level concat child index this node belongs to (-1 when nested in a group/repeat, so any run it starts has no clean top-level prefix boundary). Returns false to DECLINE the whole extraction — an alternation, an optional (repeat min 0), a lookaround or an anchor would make a required inner literal unsound (a path could bypass it) or the pattern VM-routed. Every byte appended is present in every match; the confirming scan then verifies the surrounding context.
 

Function Documentation

◆ flush()

constexpr void real::detail::inner_literal_detail::flush ( walk_state st)
constexpr

Score the current byte run and keep it (with its prefix boundary) if it beats best, then clear it (capped at inner_literal_max).

Definition at line 72 of file inner_literal.hpp.

◆ score_run()

constexpr std::uint32_t real::detail::inner_literal_detail::score_run ( std::span< const std::uint8_t >  run)
constexpr

Selectivity of a byte run: the sum of per-byte rarity (2000 - byte_frequency). A sum (rather than the rarest byte alone) approximates the product of per-byte match probabilities, so it rewards both a rare byte and a longer literal — the two things that shrink the candidate count.

Definition at line 61 of file inner_literal.hpp.

◆ walk()

constexpr bool real::detail::inner_literal_detail::walk ( const ast tree,
std::int32_t  idx,
walk_state st,
std::int32_t  top_child 
)
constexpr

Walk one node, appending guaranteed-present literal bytes to st.run. top_child is the top-level concat child index this node belongs to (-1 when nested in a group/repeat, so any run it starts has no clean top-level prefix boundary). Returns false to DECLINE the whole extraction — an alternation, an optional (repeat min 0), a lookaround or an anchor would make a required inner literal unsound (a path could bypass it) or the pattern VM-routed. Every byte appended is present in every match; the confirming scan then verifies the surrounding context.

Definition at line 95 of file inner_literal.hpp.