00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef VCSN_TOOLS_FSM_DUMP_HXX
00018 # define VCSN_TOOLS_FSM_DUMP_HXX
00019 
00020 # include <vaucanson/tools/fsm_dump.hh>
00021 # include <map>
00022 # include <set>
00023 # include <vaucanson/automata/concept/handlers.hh>
00024 # include <vaucanson/misc/usual_macros.hh>
00025 # include <vaucanson/automata/concept/automata_base.hh>
00026 
00027 namespace vcsn {
00028 
00029   namespace tools {
00030 
00031     
00032 
00033 
00034     
00035     
00036     
00037     
00038     
00039     
00040     template <typename St, typename auto_t>
00041     void fsm_dump(St& out, const auto_t& a)
00042     {
00043       AUTOMATON_TYPES(auto_t);
00044       if (a.initial().size() > 1)
00045       {
00046         auto_t b(a);
00047         hstate_t i = b.add_state();
00048         for_all_initial_states(j, b)
00049           b.add_spontaneous(i, *j);
00050         b.clear_initial();
00051         b.set_initial(i);
00052         fsm_dump(out, b);
00053         return ;
00054       }
00055       if (a.states().size() == 0)
00056         return;
00057 
00058       typename auto_t::initial_iterator initial = a.initial().begin();
00059 
00060       for (delta_iterator e(a.value(), *initial); ! e.done(); e.next())
00061         out << *initial << "\t" << a.dst_of(*e) << "\t"
00062             << a.series_of(*e) << "\t 0"
00063             << std::endl;
00064       for_all_states(s, a)
00065         if (!a.is_initial(*s))
00066         {
00067           for (delta_iterator e(a.value(), *s); ! e.done(); e.next())
00068             out << *s << "\t" << a.dst_of(*e) << "\t"
00069                 << a.series_of(*e) << "\t 0"
00070                 << std::endl;
00071         }
00072       for_all_final_states(f, a)
00073         out << *f << "\t 0" << std::endl;
00074     }
00075 
00076   } 
00077 
00078 } 
00079 
00080 #endif // ! VCSN_TOOLS_FSM_DUMP_HXX