The start-finder companion to lazy_dfa. Given a match end, it finds the leftmost start (the design guide §7.6 contract). It runs the inverted program — the forward program's edges transposed, its consuming bytes kept — as a cached DFA over the text scanned right-to-left from the end, recording an accept each time it reaches the original start (reverse-kLongest: the furthest-back accept is the start). It needs no priority ordering — its states are plain unordered (sorted) PC sets and its rule is longest — so it is simpler than the forward pass. Dynamic only.
More...
#include <lazy_dfa.hpp>
|
| constexpr | reverse_dfa (std::span< const instr > code, std::span< const char_class > classes, std::size_t budget=state_budget, const lazy_byte_alphabet *shared_alpha=nullptr) |
| |
| bool | eligible () const |
| |
| std::size_t | reverse_start (std::string_view text, std::size_t e, std::size_t resume) |
| | The leftmost start of the match ending at e, not before resume. Scans the text backward from e over the inverted program, keeping the furthest-back position that reaches the program start (reverse-kLongest). Precondition: a match ends at e; eligible programs only.
|
| |
|
| constexpr void | rev_closure (std::vector< std::int32_t > &set, std::vector< char > &seen) const |
| |
| std::uint32_t | step (std::uint32_t state, std::uint8_t byte) |
| |
| bool | consumes (std::int32_t pc, std::uint8_t byte) const |
| |
| constexpr std::uint32_t | intern (const std::vector< std::int32_t > &pcs) |
| |
| constexpr void | flush () |
| |
The start-finder companion to lazy_dfa. Given a match end, it finds the leftmost start (the design guide §7.6 contract). It runs the inverted program — the forward program's edges transposed, its consuming bytes kept — as a cached DFA over the text scanned right-to-left from the end, recording an accept each time it reaches the original start (reverse-kLongest: the furthest-back accept is the start). It needs no priority ordering — its states are plain unordered (sorted) PC sets and its rule is longest — so it is simpler than the forward pass. Dynamic only.
Definition at line 867 of file lazy_dfa.hpp.
◆ reverse_dfa()
◆ compute_eligibility()
| static constexpr bool real::detail::reverse_dfa::compute_eligibility |
( |
std::span< const instr > |
code | ) |
|
|
inlinestaticconstexprprivate |
◆ consumes()
| bool real::detail::reverse_dfa::consumes |
( |
std::int32_t |
pc, |
|
|
std::uint8_t |
byte |
|
) |
| const |
|
inlineprivate |
◆ eligible()
| bool real::detail::reverse_dfa::eligible |
( |
| ) |
const |
|
inline |
◆ flush()
| constexpr void real::detail::reverse_dfa::flush |
( |
| ) |
|
|
inlineconstexprprivate |
◆ intern()
| constexpr std::uint32_t real::detail::reverse_dfa::intern |
( |
const std::vector< std::int32_t > & |
pcs | ) |
|
|
inlineconstexprprivate |
◆ rev_closure()
| constexpr void real::detail::reverse_dfa::rev_closure |
( |
std::vector< std::int32_t > & |
set, |
|
|
std::vector< char > & |
seen |
|
) |
| const |
|
inlineconstexprprivate |
◆ reverse_start()
| std::size_t real::detail::reverse_dfa::reverse_start |
( |
std::string_view |
text, |
|
|
std::size_t |
e, |
|
|
std::size_t |
resume |
|
) |
| |
|
inline |
The leftmost start of the match ending at e, not before resume. Scans the text backward from e over the inverted program, keeping the furthest-back position that reaches the program start (reverse-kLongest). Precondition: a match ends at e; eligible programs only.
Definition at line 924 of file lazy_dfa.hpp.
◆ step()
| std::uint32_t real::detail::reverse_dfa::step |
( |
std::uint32_t |
state, |
|
|
std::uint8_t |
byte |
|
) |
| |
|
inlineprivate |
◆ alpha_
◆ budget_
| std::size_t real::detail::reverse_dfa::budget_ {state_budget} |
|
private |
◆ cache_
◆ classes_
| std::span<const char_class> real::detail::reverse_dfa::classes_ |
|
private |
◆ code_
| std::span<const instr> real::detail::reverse_dfa::code_ |
|
private |
◆ dead_state
| constexpr std::uint32_t real::detail::reverse_dfa::dead_state {0} |
|
staticconstexpr |
◆ eligible_
| bool real::detail::reverse_dfa::eligible_ {false} |
|
private |
◆ match_pc_
| std::int32_t real::detail::reverse_dfa::match_pc_ {-1} |
|
private |
◆ no_transition
| constexpr std::uint32_t real::detail::reverse_dfa::no_transition {0xFFFFFFFFU} |
|
staticconstexpr |
◆ rev_consume_
| std::vector<std::vector<std::int32_t> > real::detail::reverse_dfa::rev_consume_ |
|
private |
transposed consuming edges (the pred consuming pcs).
Definition at line 1064 of file lazy_dfa.hpp.
◆ rev_eps_
| std::vector<std::vector<std::int32_t> > real::detail::reverse_dfa::rev_eps_ |
|
private |
◆ start_state_
| std::uint32_t real::detail::reverse_dfa::start_state_ {0} |
|
private |
◆ state_budget
| constexpr std::size_t real::detail::reverse_dfa::state_budget {4096} |
|
staticconstexpr |
◆ state_has_start_
| std::vector<char> real::detail::reverse_dfa::state_has_start_ |
|
private |
state -> reaches the program start (an accept).
Definition at line 1067 of file lazy_dfa.hpp.
◆ state_pcs_
| std::vector<std::vector<std::int32_t> > real::detail::reverse_dfa::state_pcs_ |
|
private |
◆ trans_
| std::vector<std::uint32_t> real::detail::reverse_dfa::trans_ |
|
private |
flat [state*stride + class] -> next.
Definition at line 1066 of file lazy_dfa.hpp.
The documentation for this class was generated from the following file: