17 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_SERIES_KRAT_EXP_PATTERN_HH
18 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_KRAT_EXP_PATTERN_HH
21 # include <vaucanson/algebra/implementation/series/series.hh>
22 # include <vaucanson/algebra/implementation/series/rat/dispatch_visitor.hh>
35 template <
class T,
class U>
38 typedef T lhs_node_type;
39 typedef U rhs_node_type;
43 BinaryOp(
const T& lhs,
const U& rhs);
70 const T& value()
const;
91 const T& value()
const;
109 template <
class Self,
class T,
class U,
class F>
112 typedef U return_type;
128 #define DecBinaryOp(N, T, U) \
129 struct N : public vcsn::algebra::BinaryOp<T, U> \
131 N(const T& lhs, const U& rhs) : vcsn::algebra::BinaryOp<T, U>(lhs, rhs) \
135 #define DecUnaryOp(N, T) \
136 struct N : public vcsn::algebra::UnaryOp<T> \
138 N(const T& node) : vcsn::algebra::UnaryOp<T>(node) \
142 #define DecLeaf(N, U) \
143 struct N : public vcsn::algebra::Value<U> \
146 vcsn::algebra::Value<U>(v) \
150 #define DecFinalLeaf(N) \
157 #define MATCH__(N, Lhs, Rhs) \
159 match_node##N(const N& p____) \
161 typename N::lhs_node_type Lhs = p____.lhs(); \
162 typename N::rhs_node_type Rhs = p____.rhs();
164 #define MATCH_(N, Val) \
166 match_node##N(const N& p____) \
168 typename N::value_type Val(p____.value());
172 match_node##N(const N&) \
178 template <
class Self,
class T,
class U,
class F>
181 typedef U return_type;
182 typedef typename T::semiring_elt_value_t semiring_elt_value_t;
183 typedef typename T::monoid_elt_value_t monoid_elt_value_t;
185 DecBinaryOp(Product, T, T);
186 DecBinaryOp(Sum, T, T);
188 DecBinaryOp(LeftWeight, semiring_elt_value_t, T);
189 DecBinaryOp(RightWeight, T, semiring_elt_value_t);
190 DecLeaf(Constant, monoid_elt_value_t);
198 #define INHERIT_CONSTRUCTORS(Self, T, U, F) \
199 typedef ::vcsn::algebra::KRatExpMatcher<Self, T, U, F> krat_exp_matcher_t; \
200 typedef typename krat_exp_matcher_t::Product Product; \
201 typedef typename krat_exp_matcher_t::Sum Sum; \
202 typedef typename krat_exp_matcher_t::Star Star; \
203 typedef typename krat_exp_matcher_t::LeftWeight LeftWeight; \
204 typedef typename krat_exp_matcher_t::RightWeight RightWeight; \
205 typedef typename krat_exp_matcher_t::Constant Constant; \
206 typedef typename krat_exp_matcher_t::One One; \
207 typedef typename krat_exp_matcher_t::Zero Zero;
209 template <
class Self,
class Series,
class T,
class Dispatch>
210 struct KRatExpIdentity : vcsn::algebra::KRatExpMatcher<
218 typedef Element<Series, T> return_type;
219 typedef typename Element<Series, T>::semiring_elt_t semiring_elt_t;
220 typedef typename semiring_elt_t::value_t semiring_elt_value_t;
221 typedef typename Element<Series, T>::monoid_elt_t monoid_elt_t;
222 typedef typename monoid_elt_t::set_t monoid_t;
223 typedef typename monoid_t::alphabet_t alphabet_t;
224 typedef typename alphabet_t::letter_t letter_t;
225 INHERIT_CONSTRUCTORS(self_t, T, semiring_elt_t, Dispatch);
227 KRatExpIdentity(
const Element<Series, T>& exp) :
231 MATCH__(Product, lhs, rhs)
237 MATCH__(Sum, lhs, rhs)
245 return_type r (this->
match(e));
251 MATCH__(LeftWeight, w, e)
253 semiring_elt_t welt (exp_.structure().semiring(), w);
254 return welt * this->
match(e);
258 MATCH__(RightWeight, e, w)
260 semiring_elt_t welt (exp_.structure().semiring(), w);
261 return this->
match(e) * welt;
267 monoid_elt_t melt (exp_.structure().monoid(), m);
268 return Element<Series, T> (exp_.structure(), melt);
274 return zero_as<T>::of(exp_.structure());
280 return identity_as<T>::of(exp_.structure());
285 Element<Series, T> exp_;
293 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
294 # include <vaucanson/algebra/implementation/series/krat_exp_pattern.hxx>
295 # endif // VCSN_USE_INTERFACE_ONLY
297 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_KRAT_EXP_PATTERN_HH