00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 #include <vaucanson/algorithms/krat_exp_expand.hh>
00025 #include <vaucanson/algorithms/aut_to_exp.hh>
00026 #include <vaucanson/algorithms/standard_of.hh>
00027 #include <vaucanson/algorithms/thompson.hh>
00028 
00029 namespace vcsn
00030 {
00031   namespace VCSN_GRAPH_IMPL
00032   {
00033     VCSN_CONTEXT_NAMESPACE
00034     {
00035 
00036       
00037 
00038 
00039 
00040       template <class InputIterator>
00041       automata_set_t
00042       make_automata_set(InputIterator begin,
00043                         InputIterator end)
00044       {
00045         alphabet_t              alpha;
00046         for (InputIterator e = begin; e != end; ++e)
00047           alpha.insert(*e);
00048         semiring_t              semiring;
00049         monoid_t                freemonoid (alpha);
00050         series_set_t            series (semiring, freemonoid);
00051         return automata_set_t (series);
00052       }
00053 
00054       template <class InputIterator>
00055       automaton_t
00056       make_automaton(InputIterator begin,
00057                      InputIterator end)
00058       {
00059         return automaton_t (make_automata_set(begin, end));
00060       }
00061 
00062       template <class T>
00063       automaton_t
00064       make_automaton(const T& alphabet)
00065       {
00066         return make_automaton(alphabet.begin(), alphabet.end());
00067       }
00068 
00069       template <class InputIterator>
00070       automaton_letter_t
00071       make_automaton_letter(InputIterator begin,
00072                             InputIterator end)
00073       {
00074         return automaton_letter_t (make_automata_set(begin, end));
00075       }
00076 
00077       template <class T>
00078       automaton_letter_t
00079       make_automaton_letter(const T& alphabet)
00080       {
00081         return make_automaton_letter(alphabet.begin(), alphabet.end());
00082       }
00083 
00084       template <class InputIterator>
00085       gen_automaton_t
00086       make_gen_automaton(InputIterator begin,
00087                          InputIterator end)
00088       {
00089         return gen_automaton_t (make_automata_set(begin, end));
00090       }
00091 
00092       template <class T>
00093       gen_automaton_t
00094       make_gen_automaton(const T& alphabet)
00095       {
00096         return make_gen_automaton(alphabet.begin(), alphabet.end());
00097       }
00098 
00099 
00100       
00101 
00102 
00103 
00104       template <class Iterator>
00105       rat_exp_t
00106       make_rat_exp(const Iterator& begin,
00107                    const Iterator& end,
00108                    const std::string& exp,
00109                    const vcsn::algebra::token_representation_t tok_rep = vcsn::algebra::token_representation_t())
00110       {
00111         alphabet_t      alphabet;
00112         for (Iterator i = begin; i != end; ++i)
00113           alphabet.insert(*i);
00114         monoid_t                monoid (alphabet);
00115         semiring_t      semiring;
00116         series_set_t    series (semiring, monoid);
00117 
00118         rat_exp_t       r (series);
00119         std::pair<bool, std::string> p = parse(exp, r, tok_rep);
00120 
00121         postcondition_ (not p.first, p.second);
00122 
00123         return r;
00124       }
00125 
00126       template <class T>
00127       rat_exp_t
00128       make_rat_exp(const T& alphabet,
00129                    const std::string& exp,
00130                    const vcsn::algebra::token_representation_t tok_rep = vcsn::algebra::token_representation_t())
00131       {
00132         return make_rat_exp(alphabet.begin(), alphabet.end(), exp, tok_rep);
00133       }
00134 
00135       
00136 
00137 
00138 
00139       template <class SeriesImpl>
00140       automaton_t
00141       do_standard_of(const series_set_t& structure, const SeriesImpl& impl)
00142       {
00143         automaton_t r = make_automaton(structure.monoid().alphabet());
00144         standard_of(r, impl);
00145         return r;
00146       }
00147 
00148       template <class SeriesSet, class SeriesImpl>
00149       automaton_t
00150       standard_of(const Element<SeriesSet, SeriesImpl>& e)
00151       {
00152         return do_standard_of(e.structure(), e.value());
00153       }
00154 
00155       
00156 
00157 
00158 
00159       template <class SeriesImpl>
00160       automaton_t
00161       do_thompson_of(const series_set_t& structure, const SeriesImpl& impl)
00162       {
00163         automaton_t r = make_automaton(structure.monoid().alphabet());
00164         thompson_of(r, impl);
00165         return r;
00166       }
00167 
00168       template <class SeriesSet, class SeriesImpl>
00169       automaton_t
00170       thompson_of(const Element<SeriesSet, SeriesImpl>& e)
00171       {
00172         return do_thompson_of(e.structure(), e.value());
00173       }
00174 
00175       
00176 
00177 
00178 
00179       inline
00180       rat_exp_t
00181       aut_to_exp(const automaton_t& a)
00182       {
00183         return aut_to_exp(generalized(a));
00184       }
00185 
00186       template <class Chooser>
00187       rat_exp_t
00188       aut_to_exp(const automaton_t& a, const Chooser& c)
00189       {
00190         return aut_to_exp(generalized(a), c);
00191       }
00192 
00193     } 
00194   } 
00195 }