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

A literal alternation (every branch a run of byte ops converging on one exit) factored into a trie that keeps leftmost-first priority. More...

#include <lazy_dfa.hpp>

Classes

struct  item
 One alternative of a node: a byte leading to a child, or the END of a branch. More...
 
struct  node
 One trie node: its alternatives in priority order. More...
 

Public Member Functions

constexpr void insert (std::span< const instr > code, std::size_t b, std::size_t e)
 Adds the branch whose bytes are code[b, e).
 
constexpr void layout ()
 Orders the nodes and sizes the emission: preorder with each node's last child right after it, so a chain of one-child nodes is a straight run of byte ops.
 
constexpr void emit (byte_program &bp, std::int32_t after) const
 Emits the trie at the end of bp.
 

Public Attributes

std::vector< node > nodes {node {}}
 The trie; node 0 is the root.
 
std::vector< std::int32_t > order
 Emission order, root first.
 
std::vector< std::int32_t > node_pc
 Each node's pc, relative to the trie's first.
 
std::vector< bool > falls
 The node's last item falls through into its child (no jump).
 
std::size_t size {0}
 Instructions the trie emits.
 

Detailed Description

A literal alternation (every branch a run of byte ops converging on one exit) factored into a trie that keeps leftmost-first priority.

Flat, every seeded state holds all N threads (a 14 500-word alternation: 15 000 pcs per state); factored, one pc per live trie node.

Priority is kept by chunks: a branch ending at a node closes its current chunk with an END item (a jump to the exit), and a later branch merges only into the last chunk. Items of one chunk are on distinct bytes, so no text reaches two; items of different chunks keep the branches' declared order.

Member Function Documentation

◆ emit()

constexpr void real::detail::literal_alt_trie::emit ( byte_program &  bp,
std::int32_t  after 
) const
inlineconstexpr

Emits the trie at the end of bp.

Parameters
[in,out]bpThe byte program.
[in]afterThe exit's pc in bp.

◆ insert()

constexpr void real::detail::literal_alt_trie::insert ( std::span< const instr >  code,
std::size_t  b,
std::size_t  e 
)
inlineconstexpr

Adds the branch whose bytes are code[b, e).

Parameters
[in]codeThe program.
[in]bThe branch's first byte.
[in]eOne past its last.

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