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

The Pike VM — a Thompson NFA simulation — and its fast paths. More...

#include "real/version.hpp"
#include <algorithm>
#include <array>
#include <cassert>
#include <cstdint>
#include <memory>
#include <string_view>
#include <bit>
#include <cstring>
#include <type_traits>
#include <utility>
#include <vector>
#include "real/core/charclass.hpp"
#include "real/engine/prefilter.hpp"
#include "real/engine/simd.hpp"
#include <mutex>
#include <optional>
#include "real/automata/lazy_dfa.hpp"
#include "real/automata/onepass.hpp"
#include "real/core/program.hpp"
#include "real/core/profile.hpp"
#include "real/engine/aho_corasick.hpp"
#include "real/unicode/unicode_props.hpp"
#include "real/unicode/utf8.hpp"
Include dependency graph for pike.hpp:

Classes

struct  real::detail::eps_entry
 One frame on the epsilon-closure DFS stack (COW): a program counter to explore, plus the capture block the branch carries. The block travels with the branch — a split shares it and a save copies it on write — so there is no slot-restore entry and no shared working array. More...
 
struct  real::detail::basic_capture_pool< DataVec, RefVec, FreeVec >
 Copy-on-write pool of capture blocks (COW) — the one capture-slot mechanism for both storages. More...
 
struct  real::detail::basic_thread_list< PcVec, SlotVec, MarkVec >
 One priority-ordered list of NFA threads (leftmost-greedy semantics). More...
 
struct  real::detail::cp_hi_table
 Unicode-property sparse 2-stage membership for code points > U+07FF (page = cp>>8 → 256-bit block). Thread-local heap cache only — basic_pike_state's size is unchanged, which is what keeps the ASCII class loop clear of it. More...
 
struct  real::detail::basic_pike_state< ThreadList, EpsVec >
 Reusable VM scratch state. More...
 
struct  real::detail::lookaround_scratch
 Reusable, isolated scratch for one level of lookaround evaluation (dynamic only). More...
 
struct  real::detail::pike_state
 VM scratch state for the dynamic storage mode, plus the lookaround sub-scratch. More...
 
class  real::detail::pike_vm< State, StateBoundToProgram >
 The Pike VM, generic over the scratch-state container policy. More...
 
struct  real::detail::pike_vm< State, StateBoundToProgram >::cp_hi_cache_entry
 Cache entry for cp_hi_cached (thread-local, not on basic_pike_state). Keyed by a content fingerprint of the class (never a pointer into a program): programs die while this cache lives for the thread, and the allocator can recycle the same cp_ranges address for a different class — a pointer key then returns the wrong sparse table (false membership, e.g. emoji matching [\w€] after a prior high-range class was destroyed). Seen as a deterministic wrong-match on macos-clang CI after a long test binary has churned many classes (find_iter euro empty-alt pin). More...
 
struct  real::detail::pike_vm< State, StateBoundToProgram >::cp_span
 One buffered cp_class_loop match: the whole-match span, which for this route is the whole answer (a capturing wrap mirrors it, and fill_span_slots reconstructs that). More...
 
struct  real::detail::pike_vm< State, StateBoundToProgram >::slot_pair
 A two-slot sink, for a filler that must call a route function expecting a slot container. 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.
 

Typedefs

using real::detail::capture_pool = basic_capture_pool< std::vector< std::size_t >, std::vector< std::int32_t >, std::vector< std::uint32_t > >
 The dynamic-storage capture pool: heap vectors, grows on demand.
 
using real::detail::thread_list = basic_thread_list< std::vector< std::int32_t >, std::vector< std::size_t >, std::vector< std::uint64_t > >
 Thread list specialized on std::vector (the dynamic storage mode).
 

Enumerations

enum class  real::detail::run_mode : std::uint8_t { real::detail::prefix , real::detail::full , real::detail::search }
 How a VM run is anchored. More...
 

Detailed Description

The Pike VM — a Thompson NFA simulation — and its fast paths.

Linear time in the input: every program counter is added to a list at most once per position (generation-marked dedup), so no pattern can backtrack catastrophically.

The VM is generic over its container policy — std::vector for the dynamic storage mode, fixed-capacity static_vec (storage.hpp) for compile-time sized patterns, where a whole run performs zero heap allocations.