|
REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
|
A maximal-munch DFA over an ordered set of patterns. More...
#include <dfa.hpp>
Public Member Functions | |
| dfa (std::span< const detail::program_view > programs) | |
| Builds the DFA from compiled programs (the embedder path). | |
| dfa (std::span< const regex > patterns) | |
| Builds the DFA from regexes (a convenience over regex::raw_program). | |
| std::optional< dfa_match > | match (std::string_view rest) const noexcept |
Matches the longest pattern anchored at the start of rest. | |
| std::size_t | state_count () const noexcept |
| The number of states in the minimized automaton (includes the dead state). | |
| std::size_t | rule_count () const noexcept |
| The number of patterns the DFA was built from. | |
| std::size_t | class_count () const noexcept |
| The number of byte-equivalence classes (the reduced alphabet width). | |
Static Private Member Functions | |
| static std::vector< detail::program_view > | views_of (std::span< const regex > patterns) |
Materializes program views from patterns (helper for the regex ctor). | |
Private Attributes | |
| detail::dfa_tables | tables_ |
| The immutable baked tables. | |
A maximal-munch DFA over an ordered set of patterns.
Built once (heap-allocated tables), then immutable and cheap to copy-share. match returns the longest match at the cursor, breaking ties toward the earliest pattern — the lexer's maximal munch, in one pass over the input.
|
inlineexplicit |
Builds the DFA from compiled programs (the embedder path).
| [in] | programs | The patterns' programs, in priority order (see regex::raw_program). |
| real::dfa_error | if any program holds a non-head zero-width assertion. |
|
inlineexplicit |
Builds the DFA from regexes (a convenience over regex::raw_program).
| [in] | patterns | The patterns, in priority order; they must outlive this call. |
| real::dfa_error | if any pattern holds a non-head zero-width assertion. |
|
inlinenoexcept |
|
inlinenoexcept |
Matches the longest pattern anchored at the start of rest.
Maximal munch: the longest match wins; on equal length the earliest pattern (lowest index passed to the constructor) wins; an empty match never wins.
| [in] | rest | The text to match at its start. |
std::nullopt if nothing non-empty matches.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinestaticprivate |
|
private |