17 #ifndef AWALI_ALGOS_PRINT_EXP_HH
18 # define AWALI_ALGOS_PRINT_EXP_HH
27 # define DEBUG_IFELSE(Then, Else) Then
29 # define DEBUG_IFELSE(Then, Else) Else
32 # define DEBUG_IF(Then) DEBUG_IFELSE(Then,)
44 template <
typename RatExpSet>
46 :
public RatExpSet::const_visitor
52 using ratexp_t =
typename ratexpset_t::value_t;
55 using node_t =
typename super_type::node_t;
57 constexpr
static const char*
me() {
return "print-exp"; }
60 : rs_(rs), stream_(o), with_dot_(with_dot)
84 ls_.print(e.value(), stream_);
89 for (
unsigned i = 0,
n = e.size(); i <
n; ++i) {
103 for (
unsigned i = 0,
n = e.size(); i <
n; ++i) {
104 const auto& v = e[i];
118 for (
unsigned i = 0,
n = e.size(); i <
n; ++i) {
121 const auto& v = e[i];
130 for (
unsigned i = 0,
n = e.size(); i <
n; ++i) {
133 const auto& v = e[i];
142 e.sub()->accept(*
this);
148 const auto& v = e.sub();
159 const auto& v = e.sub();
161 ws_.print(e.weight(), stream_);
163 if( v->type()==type_t::sum
164 || v->type()==type_t::prod
165 || v->type()==type_t::star )
168 if( v->type()==type_t::sum
169 || v->type()==type_t::prod
170 || v->type()==type_t::star )
174 AWALI_RAT_VISIT(rweight, e)
176 const auto& v = e.sub();
177 if(v->type()==type_t::sum || v->type()==type_t::prod || v->type()==type_t::star)
180 if(v->type()==type_t::sum || v->type()==type_t::prod || v->type()==type_t::star)
183 ws_.print(e.weight(), stream_);
189 std::ostream& stream_;
192 const weightset_t& ws_ = *rs_.weightset();
193 const labelset_t& ls_ = *rs_.labelset();
198 template <typename RatExpSet>
201 print(const RatExpSet& rs,
202 const typename RatExpSet::ratexp_t& e,
206 rat::print_visitor<RatExpSet> printer{rs,o,with_dot};
211 }}//end of ns awali::stc
213 #endif // !AWALI_ALGOS_PRINT_EXP_HH
The semiring of complex numbers.
Definition: c.hh:44
The semiring of Natural numbers.
Definition: n.hh:34
Definition: ratexp.hh:280
Definition: ratexp.hh:262
Definition: print_exp.hh:47
std::ostream & operator()(const ratexp_t &v)
Definition: print_exp.hh:63
print_visitor(const ratexpset_t &rs, std::ostream &o, bool with_dot)
Definition: print_exp.hh:59
AWALI_RAT_VISIT(prod, e)
Definition: print_exp.hh:101
AWALI_RAT_VISIT(conjunction, e)
Definition: print_exp.hh:115
context_t_of< ratexpset_t > context_t
Definition: print_exp.hh:50
constexpr static const char * me()
Definition: print_exp.hh:57
AWALI_RAT_VISIT(one,)
Definition: print_exp.hh:77
AWALI_RAT_VISIT(zero,)
Definition: print_exp.hh:72
AWALI_RAT_VISIT(shuffle, e)
Definition: print_exp.hh:127
RatExpSet ratexpset_t
Definition: print_exp.hh:49
AWALI_RAT_VISIT(atom, e)
Definition: print_exp.hh:82
AWALI_RAT_VISIT(lweight, e)
Definition: print_exp.hh:157
AWALI_RAT_VISIT(star, e)
Definition: print_exp.hh:146
labelset_t_of< context_t > labelset_t
Definition: print_exp.hh:51
AWALI_RAT_VISIT(complement, e)
Definition: print_exp.hh:139
typename ratexpset_t::const_visitor super_type
Definition: print_exp.hh:54
AWALI_RAT_VISIT(sum, e)
Definition: print_exp.hh:87
typename super_type::node_t node_t
Definition: print_exp.hh:55
weightset_t_of< ratexpset_t > weightset_t
Definition: print_exp.hh:53
typename ratexpset_t::value_t ratexp_t
Definition: print_exp.hh:52
Definition: ratexp.hh:176
An inner node with multiple children.
Definition: ratexp.hh:115
An inner node implementing a weight.
Definition: ratexp.hh:208
typename internal::context_t_of_impl< internal::base_t< ValueSet > >::type context_t_of
Helper to retrieve the type of the context of a value set.
Definition: traits.hh:66
typename internal::labelset_t_of_impl< internal::base_t< ValueSet > >::type labelset_t_of
Helper to retrieve the type of the labelset of a value set.
Definition: traits.hh:76
typename internal::weightset_t_of_impl< internal::base_t< ValueSet > >::type weightset_t_of
Helper to retrieve the type of the weightset of a value set.
Definition: traits.hh:86
Main namespace of Awali.
Definition: ato.hh:22
#define AWALI_RAT_UNSUPPORTED(Type)
Definition: visitor.hh:73