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 
00032   VCSN_CONTEXT_NAMESPACE
00033   {
00034 
00035     
00036 
00037 
00038 
00039     template <class InputIterator>
00040     automata_set_t 
00041     make_automata_set(InputIterator begin,
00042                       InputIterator end)
00043     {
00044       alphabet_t                alpha;
00045       for (InputIterator e = begin; e != end; ++e)
00046         alpha.insert(*e);
00047       semiring_t                semiring;
00048       monoid_t          freemonoid (alpha);
00049       series_set_t              series (semiring, freemonoid);
00050       return automata_set_t (series);
00051     }
00052 
00053     template <class InputIterator>
00054     automaton_t 
00055     make_automaton(InputIterator begin,
00056                    InputIterator end)
00057     {
00058       return automaton_t (make_automata_set(begin, end));
00059     }
00060 
00061     template <class T>
00062     automaton_t 
00063     make_automaton(const T& alphabet)
00064     {
00065       return make_automaton(alphabet.begin(), alphabet.end());
00066     }
00067 
00068     template <class InputIterator>
00069     gen_automaton_t 
00070     make_gen_automaton(InputIterator begin,
00071                        InputIterator end)
00072     {
00073       return gen_automaton_t (make_automata_set(begin, end));
00074     }
00075 
00076     template <class T>
00077     gen_automaton_t 
00078     make_gen_automaton(const T& alphabet)
00079     {
00080       return make_gen_automaton(alphabet.begin(), alphabet.end());
00081     }
00082 
00083 
00084     
00085 
00086 
00087 
00088     template <class Iterator>
00089     rat_exp_t 
00090     make_rat_exp(const Iterator& begin,
00091                  const Iterator& end,
00092                  const std::string& exp)
00093     {
00094       alphabet_t        alphabet;
00095       for (Iterator i = begin; i != end; ++i)
00096         alphabet.insert(*i);
00097       monoid_t          monoid (alphabet);
00098       semiring_t        semiring;
00099       series_set_t      series (semiring, monoid);
00100 
00101       rat_exp_t r (series);
00102       std::pair<bool, std::string> p = parse(exp, r);
00103 
00104       postcondition_ (not p.first, p.second);
00105 
00106       return r;
00107     }
00108 
00109     template <class T>
00110     rat_exp_t 
00111     make_rat_exp(const T& alphabet, const std::string& exp)
00112     {
00113       return make_rat_exp(alphabet.begin(), alphabet.end(), exp);
00114     }
00115 
00116     
00117 
00118 
00119 
00120     template <class SeriesImpl>
00121     automaton_t
00122     do_standard_of(const series_set_t& structure, const SeriesImpl& impl)
00123     {
00124       automaton_t r = make_automaton(structure.monoid().alphabet());
00125       standard_of(r, impl);
00126       return r;
00127     }
00128 
00129     template <class SeriesSet, class SeriesImpl>
00130     automaton_t
00131     standard_of(const Element<SeriesSet, SeriesImpl>& e)
00132     {
00133       return do_standard_of(e.structure(), e.value());
00134     }
00135 
00136     
00137 
00138 
00139 
00140     template <class SeriesImpl>
00141     automaton_t
00142     do_thompson_of(const series_set_t& structure, const SeriesImpl& impl)
00143     {
00144       automaton_t r = make_automaton(structure.monoid().alphabet());
00145       thompson_of(r, impl);
00146       return r;
00147     }
00148 
00149     template <class SeriesSet, class SeriesImpl>
00150     automaton_t
00151     thompson_of(const Element<SeriesSet, SeriesImpl>& e)
00152     {
00153       return do_thompson_of(e.structure(), e.value());
00154     }
00155 
00156     
00157 
00158 
00159 
00160     inline
00161     rat_exp_t
00162     aut_to_exp(const automaton_t& a)
00163     {
00164       return aut_to_exp(generalized(a));
00165     }
00166 
00167     template <class Chooser>
00168     rat_exp_t
00169     aut_to_exp(const automaton_t& a, const Chooser& c)
00170     {
00171       return aut_to_exp(generalized(a), c);
00172     }
00173 
00174   } 
00175 
00176 }