28 template <
typename Aut,
typename... Auts>
45 o <<
"tuple_automaton";
60 using label_t =
typename labelset_t::value_t;
61 using weight_t =
typename weightset_t::value_t;
89 format fmt = {},
bool delimit =
false)
112 for (
const auto& p:
pmap_)
113 origins_.emplace(p.second, p.first);
119 template <std::size_t... I>
130 const char* sep =
"";
131 using swallow =
int[];
146 template <
size_t... I>
151 aut_->print_set(o, fmt);
153 const char* sep =
"";
154 using swallow =
int[];
166 state_name_t pre_() const
168 return pre_(indices);
171 template <size_t... I>
172 state_name_t pre_(seq<I...>) const
174 // clang 3.4 on top of libstdc++ wants this ctor to be
175 // explicitly called.
176 return state_name_t{(std::get<I>(auts_)->pre())...};
180 state_name_t post_() const
182 return post_(indices);
185 template <size_t... I>
186 state_name_t post_(seq<I...>) const
188 // clang 3.4 on top of libstdc++ wants this ctor to be
189 // explicitly called.
190 return state_name_t{(std::get<I>(auts_)->post())...};
199 state_t state(const state_name_t& state)
201 auto lb = pmap_.lower_bound(state);
202 if (lb == pmap_.end() || pmap_.key_comp()(state, lb->first))
204 state_t s = aut_->new_state();
205 lb = pmap_.emplace_hint(lb, state, s);
206 todo_.emplace_back(state, s);
211 state_t state(state_t_of<Auts>... ss)
213 return state(std::make_tuple(ss...));
216 template <size_t... I>
218 print_state_name_(typename super_t::state_t s, std::ostream& o,
222 const auto& origs = origins();
223 auto i = origs.find(s);
224 if (i == std::end(origs))
225 this->print_state(s, o);
228 const char* sep = "";
229 using swallow = int[];
233 std::get<I>(auts_)->print_state_name(std::get<I>(i->second),
246 using map = std::map<state_name_t, state_t>;
250 std::deque<std::pair<state_name_t, state_t>> todo_;
252 mutable origins_t origins_;
257 template <typename... Auts>
258 using tuple_automaton
259 = std::shared_ptr<detail::tuple_automaton_impl<Auts...>>;
261 template <typename... Auts>
264 make_tuple_automaton(const Auts&... auts)
265 -> tuple_automaton<Auts...>
267 using res_t = tuple_automaton<Auts...>;
268 return make_shared_ptr<res_t>(auts...);
std::ostream & print_state_name(typename super_t::state_t s, std::ostream &o, format fmt={}, bool delimit=false) const
state_t_of< automaton_t > state_t
remove_cv_t< remove_reference_t< T >> base_t
T without reference or const/volatile qualifiers.
std::ostream & print_set(std::ostream &o, format fmt={}) const
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
labelset_t_of< context_t > labelset_t
state_t_of< automaton_t > state_t
Result state type.
context_t_of< Aut > context_t
The type of context of the result.
static std::string sname_()
The sname of the sub automata.
std::tuple< state_t_of< Auts >...> state_name_t
State names: Tuple of states of input automata.
std::map< state_t, state_name_t > origins_t
A map from result state to tuple of original states.
Aggregate an automaton, and forward calls to it.
ValueSet::value_t tuple(const ValueSet &vs, const typename ValueSets::value_t &...v)
const origins_t & origins() const
A map from result state to tuple of original states.
state_name_t post_() const
The name of the post of the output automaton.
base_t< tuple_element_t< I, automata_t >> input_automaton_t
The type of the Ith input automaton, unqualified.
weightset_t_of< context_t > weightset_t
std::ostream & print_set_(std::ostream &o, format fmt) const
The setname of the sub automata.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
std::ostream & print_set_(std::ostream &o, format fmt, seq< I...>) const
typename weightset_t::value_t weight_t
Aut automaton_t
The type of the resulting automaton.
tuple_automaton_impl(const automaton_t &aut, const Auts &...auts)
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
automata_t auts_
Input automata, supplied at construction time.
std::tuple< Auts...> automata_t
The type of input automata.
state_name_t pre_() const
The name of the pre of the output automaton.
static constexpr indices_t indices
ATTRIBUTE_PURE bool has(const std::deque< T, Allocator > &s, const T &e)
Whether e is member of s.
std::ostream & print_state_name_(typename super_t::state_t s, std::ostream &o, format fmt, seq< I...>) const
automaton_t aut_
The wrapped automaton, possibly const.
typename labelset_t::value_t label_t
An automaton whose states are tuples of states of automata.
bool state_has_name(typename super_t::state_t s) const