|
REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
|
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. | |
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.
|
inlineconstexpr |
Emits the trie at the end of bp.
| [in,out] | bp | The byte program. |
| [in] | after | The exit's pc in bp. |
|
inlineconstexpr |
Adds the branch whose bytes are code[b, e).
| [in] | code | The program. |
| [in] | b | The branch's first byte. |
| [in] | e | One past its last. |