5#include <absl/container/btree_map.h>
20 constexpr int id() const noexcept {
return id_; }
26 if (erroring_)
return;
27 if (
auto it = transitions_.find(c); it != transitions_.end()) f(it->second);
32 if (erroring_)
return;
33 for (
auto& [c, to] : transitions_) f(c, to);
38 assert(!(accepting && erroring_) &&
"state cannot be accepting and erroring");
39 accepting_ = accepting;
44 assert(!(accepting_ && erroring) &&
"state cannot be accepting and erroring");
52 absl::flat_hash_map<std::uint16_t, const DFANode*> transitions_;
53 bool accepting_ =
false;
54 bool erroring_ =
false;
57extern template class AutomatonBase<DFANode>;
68template<
class To>
using DFAMap = absl::btree_map<const DFANode*, To, DFANode::Lt>;
void set_erroring(bool erroring) noexcept
friend std::ostream & operator<<(std::ostream &os, const DFANode &node)
void for_transitions(F &&f) const
bool is_accepting() const noexcept
const DFANode * get_transition(std::uint16_t c) const
void add_transition(const DFANode *to, std::uint16_t c)
constexpr int id() const noexcept
bool is_erroring() const noexcept
void set_accepting(bool accepting) noexcept
void for_transitions(F &&f, std::uint16_t c) const
DFA & operator=(const DFA &)=delete
absl::btree_map< const DFANode *, To, DFANode::Lt > DFAMap
constexpr bool operator()(const DFANode *n, const DFANode *m) const noexcept