5 #include <boost/range/algorithm/sort.hpp>
27 template <Automaton Aut>
74 std::vector<transition_t> ts;
89 for (
auto s:
aut_->states())
108 res.emplace_back(
aut_->dst_of(t));
118 res.emplace_back(
aut_->src_of(t));
148 template <Automaton Aut>
152 "fado: requires letter or nullable labels");
154 "fado: requires Boolean weights");
166 using super_t::super_t;
174 os_ << (is_deter ?
"@DFA" :
"@NFA");
185 template <Automaton A>
186 std::enable_if_t<labelset_t_of<A>::is_free(),
bool>
192 template <Automaton A>
193 std::enable_if_t<!labelset_t_of<A>::is_free(),
bool>
202 template <Automaton Aut>
224 template <Automaton Aut>
228 "grail: requires letter or nullable labels");
230 "grail: requires Boolean weights");
245 using super_t::super_t;
252 const char* sep =
"";
257 aut_->print_state(s, os_);
264 aut_->print_state(s, os_) <<
" -| (FINAL)";
270 template <Automaton Aut>
const weightset_t & ws_
Short-hand to the weightset.
const labelset_t_of< automaton_t > & ls_
Short-hand to the labelset.
std::ostream & grail(const Aut &aut, std::ostream &out)
typename polynomialset_t::value_t polynomial_t
Format an automaton into Fado.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
std::ostream & os_
Output stream.
std::string to_string(direction d)
Conversion to string.
virtual std::string label_(const label_t &l) const
Convert a label to its representation.
const polynomialset_t ps_
Short-hand to the polynomialset used to print the entries.
std::ostream & fado(const Aut &aut, std::ostream &out)
void list_states_(const states_t &ss)
List names of states in ss, preceded by ' '.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
transition_t_of< automaton_t > transition_t
Provide a variadic mul on top of a binary mul(), and one().
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
std::enable_if_t< labelset_t_of< A >::is_free(), bool > is_deterministic_(const A &a)
void operator()()
Actually output aut_ on os_.
printer(const automaton_t &aut, std::ostream &out)
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
states_t initials_()
The list of initial states, sorted.
virtual void print_transition_(transition_t t) const
Output the transition t.
bool is_deterministic(const Aut &aut, state_t_of< Aut > s)
Whether state s is deterministic in aut.
void print_state_(const state_t s)
Output transitions, sorted lexicographically on (Label, Dest).
std::vector< state_t > states_t
A list of states.
auto initial_transitions(const Aut &aut) -> decltype(aut->all_out(aut->pre()))
Indexes of transitions to (visible) initial states.
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
weight_t_of< automaton_t > weight_t
void print_transitions_()
Output transitions, sorted lexicographically.
Format an automaton into Fado.
automaton_t aut_
The automaton we have to output.
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
Compare transitions of an automaton.
states_t finals_()
The list of final states, sorted.
state_t_of< automaton_t > state_t
auto sort(const Aut &a) -> permutation_automaton< Aut >
auto final_transitions(const Aut &aut) -> decltype(aut->all_in(aut->post()))
Indexes of transitions from (visible) final states.
std::enable_if_t<!labelset_t_of< A >::is_free(), bool > is_deterministic_(const A &)
void operator()()
Actually output aut_ on os_.
label_t_of< automaton_t > label_t
Factor common bits in automaton formatting.
context_t_of< automaton_t > context_t
weightset_t_of< automaton_t > weightset_t