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

The best required inner literal of a pattern (the memmem candidate). More...

#include <inner_literal.hpp>

Public Member Functions

constexpr bool found () const
 Whether an inner literal was found at all.
 

Public Attributes

std::array< std::uint8_t, 16 > bytes {}
 The literal's bytes, the first len of which are meaningful. Fixed capacity, so an inner_literal is copyable and needs no allocation; inner_literal_max is that bound.
 
std::uint8_t len {0}
 Bytes held in bytes; 0 means the pattern declined.
 
std::uint32_t score {0}
 
std::int32_t prefix_child_count {-1}
 Top-level concat children BEFORE the literal — the sub-pattern the prefix-reverse matches backwards from a candidate to find the match start. 0 = the literal is at the head (identity: start = candidate). -1 = the literal is nested in a group/repeat, so no clean top-level prefix boundary exists (the prefix-reverse does not apply; the memmem candidate still does).
 
std::int32_t prefix_skip {0}
 Leading top-level children to skip when building the reverse-prefix (peeled lead \b/\B). prefix_child_count is counted from the first non-peeled body child, so the reverse program is children[prefix_skip .. prefix_skip + prefix_child_count).
 
std::uint8_t wb_lead {0}
 0/1/2 — peeled lead \b/\B (informational; confirm checks).
 
std::uint8_t wb_trail {0}
 0/1/2 — peeled trail \b/\B.
 

Detailed Description

The best required inner literal of a pattern (the memmem candidate).

len == 0 means the pattern declined: a non-literal alternation, an optional (?/*/{0,n}), a lookaround or a non-wb anchor at the level walked, or simply no literal run — anything that would make a required literal unsound. Top-level \b/\B are peeled: they set wb_lead / wb_trail and prefix_skip so the reverse-prefix excludes them (asserts are not byte-DFA-eligible) while confirm_at still runs the full program (boundaries checked there).

A pure-literal alternation (info|error|warn) does not abort the walk: it flushes and continues, so a later required run (req=) can still arm. No branch's bytes are ever appended — none are shared. Mono-byte optionals (s?) stay declined; see real::detail::inner_literal_detail::walk for why continuing past one is sound and still not wanted.

Member Function Documentation

◆ found()

constexpr bool real::detail::inner_literal::found ( ) const
inlineconstexpr

Whether an inner literal was found at all.

Returns
true if len is non-zero, i.e. the pattern did not decline.

Member Data Documentation

◆ score

std::uint32_t real::detail::inner_literal::score {0}

Selectivity: higher = rarer/longer = fewer memmem candidates.


The documentation for this struct was generated from the following file: