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 {
00110 alphabet_t alphabet;
00111 for (Iterator i = begin; i != end; ++i)
00112 alphabet.insert(*i);
00113 monoid_t monoid (alphabet);
00114 semiring_t semiring;
00115 series_set_t series (semiring, monoid);
00116
00117 rat_exp_t r (series);
00118 std::pair<bool, std::string> p = parse(exp, r);
00119
00120 postcondition_ (not p.first, p.second);
00121
00122 return r;
00123 }
00124
00125 template <class T>
00126 rat_exp_t
00127 make_rat_exp(const T& alphabet, const std::string& exp)
00128 {
00129 return make_rat_exp(alphabet.begin(), alphabet.end(), exp);
00130 }
00131
00132
00133
00134
00135
00136 template <class SeriesImpl>
00137 automaton_t
00138 do_standard_of(const series_set_t& structure, const SeriesImpl& impl)
00139 {
00140 automaton_t r = make_automaton(structure.monoid().alphabet());
00141 standard_of(r, impl);
00142 return r;
00143 }
00144
00145 template <class SeriesSet, class SeriesImpl>
00146 automaton_t
00147 standard_of(const Element<SeriesSet, SeriesImpl>& e)
00148 {
00149 return do_standard_of(e.structure(), e.value());
00150 }
00151
00152
00153
00154
00155
00156 template <class SeriesImpl>
00157 automaton_t
00158 do_thompson_of(const series_set_t& structure, const SeriesImpl& impl)
00159 {
00160 automaton_t r = make_automaton(structure.monoid().alphabet());
00161 thompson_of(r, impl);
00162 return r;
00163 }
00164
00165 template <class SeriesSet, class SeriesImpl>
00166 automaton_t
00167 thompson_of(const Element<SeriesSet, SeriesImpl>& e)
00168 {
00169 return do_thompson_of(e.structure(), e.value());
00170 }
00171
00172
00173
00174
00175
00176 inline
00177 rat_exp_t
00178 aut_to_exp(const automaton_t& a)
00179 {
00180 return aut_to_exp(generalized(a));
00181 }
00182
00183 template <class Chooser>
00184 rat_exp_t
00185 aut_to_exp(const automaton_t& a, const Chooser& c)
00186 {
00187 return aut_to_exp(generalized(a), c);
00188 }
00189
00190 }
00191 }
00192 }