5 #include <boost/bimap.hpp>
6 #include <boost/bimap/set_of.hpp>
7 #include <boost/bimap/unordered_set_of.hpp>
20 template <Automaton Aut>
45 static auto res =
symbol{
"expression_automaton<"
52 o <<
"expression_automaton<";
59 = boost::bimaps::unordered_set_of<expression_t,
60 vcsn::hash<expressionset_t>,
61 vcsn::equal_to<expressionset_t>>;
63 using right_t = boost::bimaps::set_of<state_t>;
65 using bimap_t = boost::bimap<left_t, right_t>;
69 state_t state(const expression_t& r)
72 const auto& map_ = bimap_.left;
73 auto i = map_.find(r);
74 if (i == std::end(map_))
76 res = super_t::new_state();
77 bimap_.insert({r, res});
78 todo_.emplace(res, r);
79 super_t::set_lazy(res);
86 using super_t::add_transition;
88 add_transition(state_t src, const expression_t& dst,
89 label_t l, const weight_t& w)
91 super_t::add_transition(src, state(dst), l, w);
94 using super_t::new_transition;
96 new_transition(state_t src, const expression_t& dst,
97 label_t l, const weight_t& w)
99 super_t::new_transition(src, state(dst), l, w);
102 using super_t::set_initial;
104 set_initial(const expression_t& s, const weight_t& w)
106 super_t::set_initial(state(s), w);
109 bool state_has_name(state_t s) const
111 return has(origins(), s);
115 print_state_name(state_t s, std::ostream& o,
119 auto i = origins().find(s);
120 if (i == std::end(origins()))
121 this->print_state(s, o);
123 rs_.print(i->second, o, fmt);
128 using origins_t = typename bimap_t::right_map;
129 const origins_t& origins() const
138 std::stack<std::pair<state_t, const state_name_t>> todo_;
static symbol sname()
Static name.
weight_t_of< super_t > weight_t
label_t_of< super_t > label_t
expressionset_t rs_
The expression's set.
Aggregate an automaton, and forward calls to it.
An input/output format for valuesets.
auto print_set(Args &&...args) const -> decltype(aut_-> print_set(std::forward< Args >(args)...))
typename expressionset_t::value_t expression_t
Provide a variadic mul on top of a binary mul(), and one().
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
context_t_of< automaton_t > context_t
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
expression_t state_name_t
State are named by expressions.
expression_automaton_impl(const expressionset_t &rs)
state_t_of< super_t > state_t
std::ostream & print_set(std::ostream &o, format fmt={}) const
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
An incremental automaton whose states are expressions.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of