REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
Loading...
Searching...
No Matches
inner_literal.hpp File Reference

Extracts a required inner literal from a pattern's AST — the substring that every match must contain ((\w+)@(\w+) -> @, key=(\w+) -> key=, \d{4}-\d{2} -> -). It is the memmem candidate an inner-literal prefilter scans for: find the literal, then confirm the surrounding pattern from that candidate. A pure function over the node pool: compiler.hpp records the result in pattern_hints, and pike_vm::run dispatches to run_inner_literal on it. More...

#include <real/version.hpp>
#include <array>
#include <cstdint>
#include <span>
#include <string_view>
#include <vector>
#include <real/engine/prefilter.hpp>
#include <real/frontend/ast.hpp>
Include dependency graph for inner_literal.hpp:

Classes

struct  real::detail::inner_literal
 The best required inner literal of a pattern (the memmem candidate). More...
 
struct  real::detail::inner_literal_detail::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...
 

Namespaces

namespace  real
 REAL's public API: real::regex, real::static_regex, real::flags and the match/iterator types built on them.
 
namespace  real::detail
 DFA construction internals: subset construction over a flattened NFA. Not a stable API.
 
namespace  real::detail::inner_literal_detail
 Helpers for real::detail::extract_inner_literal; not part of any interface.
 

Functions

constexpr std::uint32_t real::detail::inner_literal_detail::score_run (std::span< const std::uint8_t > run)
 Selectivity of a byte run.
 
constexpr void real::detail::inner_literal_detail::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 real::detail::inner_literal_detail::is_pure_byte_run (const ast &tree, std::int32_t idx) noexcept
 Whether idx is a pure fixed byte run: only byte / nested concat / group of the same.
 
constexpr bool real::detail::inner_literal_detail::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 walk_state::run.
 
constexpr bool real::detail::inner_literal_detail::is_top_wb_anchor (const ast &tree, std::int32_t idx) noexcept
 Whether idx is a top-level \b or \B anchor — a peel candidate.
 
constexpr std::uint8_t real::detail::inner_literal_detail::wb_hint_from_anchor (anchor_kind k) noexcept
 Encodes a peeled word-boundary anchor as the hint value inner_literal::wb_lead and inner_literal::wb_trail carry.
 
constexpr inner_literal real::detail::extract_inner_literal (const ast &tree)
 Extract the best required inner literal from a pattern's AST (a pure function on the node pool).
 
ast real::detail::build_prefix_ast (const ast &tree, std::int32_t count, std::int32_t skip=0)
 Build the prefix sub-AST: count top-level concat children starting after skip lead children.
 

Variables

constexpr std::size_t real::detail::inner_literal_max {16}
 The most bytes an inner literal keeps; past this a longer needle costs storage without shrinking the candidate set much.
 

Detailed Description

Extracts a required inner literal from a pattern's AST — the substring that every match must contain ((\w+)@(\w+) -> @, key=(\w+) -> key=, \d{4}-\d{2} -> -). It is the memmem candidate an inner-literal prefilter scans for: find the literal, then confirm the surrounding pattern from that candidate. A pure function over the node pool: compiler.hpp records the result in pattern_hints, and pike_vm::run dispatches to run_inner_literal on it.