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

Search-acceleration hints extracted from a compiled program. More...

Collaboration diagram for real::detail::pattern_hints:
[legend]

Public Attributes

std::array< char, 16 > prefix {}
 Required literal prefix (possibly truncated).
 
std::uint8_t prefix_size {}
 Valid bytes in prefix.
 
bool anchored_start {}
 \A / ^ (no multiline): only position 0.
 
bool line_anchored {}
 ^ multiline: position 0 or after \n.
 
bool first_bytes_valid {}
 False when an empty match is possible.
 
bool empty_match_possible {}
 The pattern can match the empty string (the nullable gate; conservative: assertions/lookarounds pass through, so e.g. ^$ is flagged nullable).
 
std::int16_t single_first {-1}
 The unique possible first byte, or -1.
 
char_class first_bytes
 All possible first bytes.
 
std::array< char, 4 > small_set {}
 The 2..4 possible first bytes, enumerated (the memchr-cascade set). Empty unless small_set_size is set.
 
std::uint8_t small_set_size {}
 Number of valid members in small_set — 0 when not a small set, else 2..4. Drives the memchr-cascade scan in place of the bitmap loop.
 
std::int32_t greedy_class_loop {-1}
 Class index if the whole pattern is "class+", else -1.
 
std::int32_t greedy_cp_class {-1}
 cp_class index if the whole pattern is a code-point class klass_cp (optionally +), else -1.
 
bool greedy_cp_class_plus {}
 The greedy_cp_class pattern is a greedy + loop (vs a single code point).
 
std::int16_t greedy_group_start {-1}
 For a class-loop wrapped in one capturing group ((\w+), ([a-z]+)): the group's start slot to mirror the whole-match start into (-1 = no enveloping group).
 
std::int16_t greedy_group_end {-1}
 The enveloping group's end slot (mirrors the whole-match end).
 
bool fixed_shape {}
 Whole pattern is a fixed-width byte/klass sequence (no branches/asserts/captures).
 
std::int32_t codepoint_class_ascii {-1}
 ASCII-class index when the whole pattern is ./negated-class (optionally +), else -1.
 
bool codepoint_class_plus {}
 The codepoint_class_ascii pattern is a greedy + loop (vs a single codepoint).
 
bool fixed_alternation {}
 Whole pattern is an alternation of straight-line branches (no captures/asserts).
 
std::uint8_t exact_literal_len {}
 Length of the pure-literal match, or 0.
 
std::array< char, 6 > stop_set {}
 For a whole-pattern class+ run whose accepted set has a small (<= 6-byte) complement: the STOP bytes (the complement), driving the memchr-cascade run scan (OPT-C). Empty unless stop_set_size is set. Placed last so it never shifts the hot fields' offsets.
 
std::uint8_t stop_set_size {}
 Members in stop_set — 0 when the complement is too large, else 1..6.
 
std::int16_t rare_byte {-1}
 A required literal byte at a fixed offset from the match start that is statically rarer than the pattern's first-byte set (OPT: the date - at offset 4). The search jumps by memchr-ing this one byte (SIMD) and back-verifies from found - rare_offset, instead of the per-byte first-byte bitmap loop on a common class. -1 when no such byte was found.
 
std::uint8_t rare_offset {}
 The fixed byte offset of rare_byte from the match start.
 
std::array< std::uint8_t, 16 > inner_literal {}
 A required inner literal every match must contain (the memmem candidate the inner-literal prefilter scans for), and how many top-level children precede it — the prefix the prefilter reverse-matches from a candidate back to the match start. inner_literal_len == 0 = none; inner_literal_prefix == 0 = the literal is at the head (reverse is the identity), -1 = it is nested with no clean prefix boundary. Filled at compile from the AST (raw bytes, so pattern_hints — a core type — need not know the frontend literal type). Not yet routed on.
 
std::uint8_t inner_literal_len {}
 
std::int32_t inner_literal_prefix {-1}
 

Detailed Description

Search-acceleration hints extracted from a compiled program.

Filled by analyze_program (prefilter.hpp). The engine consults them to skip positions that cannot start a match and to take fast paths; they never change what matches, only how fast.

Definition at line 266 of file program.hpp.

Member Data Documentation

◆ anchored_start

bool real::detail::pattern_hints::anchored_start {}

\A / ^ (no multiline): only position 0.

Definition at line 270 of file program.hpp.

◆ codepoint_class_ascii

std::int32_t real::detail::pattern_hints::codepoint_class_ascii {-1}

ASCII-class index when the whole pattern is ./negated-class (optionally +), else -1.

Definition at line 284 of file program.hpp.

◆ codepoint_class_plus

bool real::detail::pattern_hints::codepoint_class_plus {}

The codepoint_class_ascii pattern is a greedy + loop (vs a single codepoint).

Definition at line 285 of file program.hpp.

◆ empty_match_possible

bool real::detail::pattern_hints::empty_match_possible {}

The pattern can match the empty string (the nullable gate; conservative: assertions/lookarounds pass through, so e.g. ^$ is flagged nullable).

Definition at line 273 of file program.hpp.

◆ exact_literal_len

std::uint8_t real::detail::pattern_hints::exact_literal_len {}

Length of the pure-literal match, or 0.

Non-zero when the whole pattern is a fixed literal (the prefix bytes are the entire match content, possibly with internal group saves but no branches or further consuming ops). Enables a direct slot-replay bypass of the full Pike VM — the major win for "search for a fixed string".

Definition at line 296 of file program.hpp.

◆ first_bytes

char_class real::detail::pattern_hints::first_bytes

All possible first bytes.

Definition at line 275 of file program.hpp.

◆ first_bytes_valid

bool real::detail::pattern_hints::first_bytes_valid {}

False when an empty match is possible.

Definition at line 272 of file program.hpp.

◆ fixed_alternation

bool real::detail::pattern_hints::fixed_alternation {}

Whole pattern is an alternation of straight-line branches (no captures/asserts).

Definition at line 286 of file program.hpp.

◆ fixed_shape

bool real::detail::pattern_hints::fixed_shape {}

Whole pattern is a fixed-width byte/klass sequence (no branches/asserts/captures).

Definition at line 283 of file program.hpp.

◆ greedy_class_loop

std::int32_t real::detail::pattern_hints::greedy_class_loop {-1}

Class index if the whole pattern is "class+", else -1.

Definition at line 278 of file program.hpp.

◆ greedy_cp_class

std::int32_t real::detail::pattern_hints::greedy_cp_class {-1}

cp_class index if the whole pattern is a code-point class klass_cp (optionally +), else -1.

Definition at line 279 of file program.hpp.

◆ greedy_cp_class_plus

bool real::detail::pattern_hints::greedy_cp_class_plus {}

The greedy_cp_class pattern is a greedy + loop (vs a single code point).

Definition at line 280 of file program.hpp.

◆ greedy_group_end

std::int16_t real::detail::pattern_hints::greedy_group_end {-1}

The enveloping group's end slot (mirrors the whole-match end).

Definition at line 282 of file program.hpp.

◆ greedy_group_start

std::int16_t real::detail::pattern_hints::greedy_group_start {-1}

For a class-loop wrapped in one capturing group ((\w+), ([a-z]+)): the group's start slot to mirror the whole-match start into (-1 = no enveloping group).

Definition at line 281 of file program.hpp.

◆ inner_literal

std::array<std::uint8_t, 16> real::detail::pattern_hints::inner_literal {}

A required inner literal every match must contain (the memmem candidate the inner-literal prefilter scans for), and how many top-level children precede it — the prefix the prefilter reverse-matches from a candidate back to the match start. inner_literal_len == 0 = none; inner_literal_prefix == 0 = the literal is at the head (reverse is the identity), -1 = it is nested with no clean prefix boundary. Filled at compile from the AST (raw bytes, so pattern_hints — a core type — need not know the frontend literal type). Not yet routed on.

Definition at line 317 of file program.hpp.

◆ inner_literal_len

std::uint8_t real::detail::pattern_hints::inner_literal_len {}

Definition at line 318 of file program.hpp.

◆ inner_literal_prefix

std::int32_t real::detail::pattern_hints::inner_literal_prefix {-1}

Definition at line 319 of file program.hpp.

◆ line_anchored

bool real::detail::pattern_hints::line_anchored {}

^ multiline: position 0 or after \n.

Definition at line 271 of file program.hpp.

◆ prefix

std::array<char, 16> real::detail::pattern_hints::prefix {}

Required literal prefix (possibly truncated).

Definition at line 268 of file program.hpp.

◆ prefix_size

std::uint8_t real::detail::pattern_hints::prefix_size {}

Valid bytes in prefix.

Definition at line 269 of file program.hpp.

◆ rare_byte

std::int16_t real::detail::pattern_hints::rare_byte {-1}

A required literal byte at a fixed offset from the match start that is statically rarer than the pattern's first-byte set (OPT: the date - at offset 4). The search jumps by memchr-ing this one byte (SIMD) and back-verifies from found - rare_offset, instead of the per-byte first-byte bitmap loop on a common class. -1 when no such byte was found.

Definition at line 308 of file program.hpp.

◆ rare_offset

std::uint8_t real::detail::pattern_hints::rare_offset {}

The fixed byte offset of rare_byte from the match start.

Definition at line 309 of file program.hpp.

◆ single_first

std::int16_t real::detail::pattern_hints::single_first {-1}

The unique possible first byte, or -1.

Definition at line 274 of file program.hpp.

◆ small_set

std::array<char, 4> real::detail::pattern_hints::small_set {}

The 2..4 possible first bytes, enumerated (the memchr-cascade set). Empty unless small_set_size is set.

Definition at line 276 of file program.hpp.

◆ small_set_size

std::uint8_t real::detail::pattern_hints::small_set_size {}

Number of valid members in small_set — 0 when not a small set, else 2..4. Drives the memchr-cascade scan in place of the bitmap loop.

Definition at line 277 of file program.hpp.

◆ stop_set

std::array<char, 6> real::detail::pattern_hints::stop_set {}

For a whole-pattern class+ run whose accepted set has a small (<= 6-byte) complement: the STOP bytes (the complement), driving the memchr-cascade run scan (OPT-C). Empty unless stop_set_size is set. Placed last so it never shifts the hot fields' offsets.

Definition at line 301 of file program.hpp.

◆ stop_set_size

std::uint8_t real::detail::pattern_hints::stop_set_size {}

Members in stop_set — 0 when the complement is too large, else 1..6.

Definition at line 302 of file program.hpp.


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