1 #ifndef VCSN_ALGOS_EFSM_HH
2 # define VCSN_ALGOS_EFSM_HH
22 template <
typename LabelSet>
25 static constexpr
size_t value = 1;
31 static constexpr
size_t value =
sizeof...(LabelSet);
39 template <
typename Aut>
56 using super_t::super_t;
64 "me=$(basename \"$0\")\n"
65 "medir=$(mktemp -d \"/tmp/$me.XXXXXX\") || exit 1\n"
73 "cat >$medir/transitions.fsm <<\\EOFSM";
88 "fstcompile" << (
is_transducer ?
"" :
" --acceptor") <<
" \\\n"
89 " --keep_isymbols --isymbols=" <<
isymbols_ <<
" \\\n"
90 " --keep_osymbols --osymbols=" <<
osymbols_ <<
" \\\n"
91 " $medir/transitions.fsm \"$@\"\n"
100 template <
typename LS>
103 if (ls.is_special(l))
110 template <
typename Label>
117 template <
typename Label>
128 if (
aut_->dst_of(t) !=
aut_->post())
136 if (
ws_.show_one() || !
ws_.is_one(
aut_->weight_of(t)))
150 auto inis =
aut_->initial_transitions();
152 || !
ws_.is_one(
aut_->weight_of(inis.front())))
165 std::vector<state_t> states(std::begin(
aut_->states()),
166 std::end(
aut_->states()));
170 return (std::forward_as_tuple(!
aut_->is_initial(l), l)
171 < std::forward_as_tuple(!
aut_->is_initial(r),
r));
176 for (
auto t :
aut_->final_transitions())
183 template <
typename LabelSet,
typename Labels,
typename GetLabel>
185 GetLabel get_label,
int)
186 -> decltype(ls.genset(), void())
188 for (
auto l : ls.genset())
189 labels.insert(get_label(ls.value(l)));
192 template <
typename LabelSet,
typename Labels,
typename GetLabel>
219 template <
typename LabelSet,
typename GetLabel>
226 using label_t =
typename labelset_t::value_t;
228 std::set<label_t, vcsn::less<labelset_t>> labels;
230 for (
auto t :
aut_->transitions())
231 labels.insert(get_label(
aut_->label_of(t)));
236 "cat >" << name <<
" <<\\EOFSM\n"
239 for (
const auto& l: labels)
243 os_ <<
'\t' << ++num <<
'\n';
266 ls_.template set<0>(),
267 [](
const label_t& l) { return std::get<0>(l); });
269 ls_.template set<1>(),
270 [](
const label_t& l) { return std::get<1>(l); });
282 std::integral_constant<bool,
288 is_transducer ?
"$medir/isymbols.txt" :
"$medir/symbols.txt";
291 is_transducer ?
"$medir/osymbols.txt" :
"$medir/symbols.txt";
299 template <
typename Aut>
301 efsm(
const Aut& aut, std::ostream& out)
313 template <
typename Aut,
typename Ostream>
316 return efsm(aut->as<Aut>(), out);
320 (
const automaton& aut, std::ostream& out) -> std::ostream&);
325 #endif // !VCSN_ALGOS_EFSM_HH
std::integral_constant< bool, 2<=rank< labelset_t_of< automaton_t >>::value > is_transducer_t
Whether is a transducer (two-tape automaton) as opposed to an acceptor.
void output_symbols_(const std::string &name, const LabelSet &ls, GetLabel get_label)
Output the mapping from label name, to label number.
typename super_t::label_t label_t
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
typename super_t::transition_t transition_t
void output_label_(const Label &l, std::true_type)
Two-tape automaton.
void output_transition_(const transition_t t)
const weightset_t & ws_
Short-hand to the weightset.
A ValueSet which is a Cartesian product of ValueSets.
const labelset_t_of< automaton_t > & ls_
Short-hand to the labelset.
void output_state_(const state_t s)
Output transitions, sorted lexicographically on (Label, Dest).
std::ostream & efsm(const Aut &aut, std::ostream &out)
Format automaton to EFSM format, based on FSM format.
typename super_t::state_t state_t
std::ostream & os_
Output stream.
static constexpr size_t value
const is_transducer_t is_transducer
transition_t_of< automaton_t > transition_t
const char * osymbols_
File name for output tape symbols.
void output_label_(const Label &l, std::false_type)
Acceptor.
void output_symbols_impl_(std::false_type)
Labels of an acceptor.
auto sort(const Aut &a) -> permutation_automaton< Aut >
Factor common bits in automaton formatting.
auto add_alphabet(const LabelSet &ls, Labels &labels, GetLabel get_label, int) -> decltype(ls.genset(), void())
std::ostream & efsm(const automaton &aut, std::ostream &out)
Bridge.
void output_symbols_impl_(std::true_type)
Labels of a two-tape automaton.
void add_alphabet(const LabelSet &, Labels &, GetLabel, long)
void operator()()
Actually output aut_ on os_.
Provide a variadic mul on top of a binary mul(), and one().
void output_label_(const LS &ls, const typename LS::value_t &l)
label_t_of< automaton_t > label_t
Format automaton to EFSM format, based on FSM format.
const automaton_t & aut_
The automaton we have to output.
state_t_of< automaton_t > state_t
const char * isymbols_
File name for input tape symbols.
variadic_mul_mixin< detail::r_impl > r
void output_transitions_()
Output all the transitions, and final states.