17 #ifndef AWALI_CORE_RAT_PRINTER_HXX 
   18 # define AWALI_CORE_RAT_PRINTER_HXX 
   21 #include <awali/sttc/misc/indent.hh> 
   24 namespace awali { 
namespace sttc
 
   35 # define CASE(T) case type_t::T: o << #T; break 
   54     template <
typename RatExpSet>
 
   67     template <typename RatExpSet>               \ 
   75       static bool print = !! getenv(
"AWALI_PRINT");
 
   76       static bool debug = !! getenv(
"AWALI_DEBUG");
 
   78         out_ << 
'<' << v.type() << 
'>' << sttc::incendl;
 
   79       if (debug && format_ == 
"latex" && identities_ == identities_t::series)
 
   80         out_ << 
"{\\color{red}{";
 
   81       else if (debug && format_ == 
"latex" && identities_ == identities_t::trivial)
 
   82         out_ << 
"{\\color{blue}{";
 
   84       if (debug && format_ == 
"latex" && identities_ == identities_t::series)
 
   86       else if (debug && format_ == 
"latex" && identities_ == identities_t::trivial)
 
   89         out_ << sttc::decendl << 
"</" << v.type() << 
'>';
 
   97       if (format_ == 
"latex")
 
  101           langle_       = 
" \\langle ";
 
  102           rangle_       = 
" \\rangle ";
 
  104           rparen_       = 
"\\right)";
 
  106           complement_   = 
"^{c}";
 
  107           transposition_ = 
"^{T}";
 
  108           conjunction_  = 
" \\& ";
 
  109           shuffle_      = 
" \\between ";
 
  112             = (identities_ == identities_t::series) ? 
" \\oplus " : 
" + ";
 
  113           zero_         = 
"\\emptyset";
 
  114           one_          = 
"\\varepsilon";
 
  117           ldiv_         = 
" \\backslash ";
 
  119       else if (format_ == 
"text")
 
  129           transposition_ = 
"{T}";
 
  144     DEFINE::precedence(
const node_t& v) 
const 
  147       const atom_t* 
atom = 
dynamic_cast<const atom_t*
>(&v);
 
  149         return precedence_t::word;
 
  153 # define CASE(Type)                             \ 
  154             case exp::type_t::Type:             \ 
  155               return precedence_t::Type; 
  174 # define VISIT(Type)                          \ 
  175     DEFINE::visit(const Type ## _t& v)        \ 
  181       ctx_.weightset()->print(v.weight(), out_, format_);
 
  182       out_ << rangle_ << lmul_;
 
  183       print_child(*v.sub(), v);
 
  188       print_child(*v.sub(), v);
 
  189       out_ << rmul_ << langle_;
 
  190       ctx_.weightset()->print(v.weight(), out_, format_);
 
  208       ctx_.labelset()->print(v.value(), out_, format_);
 
  211     DEFINE::print_child(
const node_t& child, 
const node_t& parent)
 
  214       static bool force = !! getenv(
"AWALI_PARENS");
 
  215       bool parent_has_precedence = precedence(child) <= precedence(parent);
 
  218          || (parent_has_precedence
 
  219              && ! (parent.is_unary() && child.is_unary())));
 
  222       else if (parent.is_unary())
 
  227       else if (parent.is_unary())
 
  231     template <
typename RatExpSet>
 
  232     template <type_t Type>
 
  238       print_child(*v.sub(), v);
 
  242     template <
typename RatExpSet>
 
  243     template <type_t Type>
 
carries the algebraic settings of automata
Definition: context.hh:40
 
The semiring of Natural numbers.
Definition: n.hh:33
 
Definition: ratexp.hh:280
 
const label_t & value() const
Definition: ratexp.hxx:53
 
Definition: ratexp.hh:262
 
Definition: printer.hh:36
 
typename super_type::node_t node_t
Definition: printer.hh:43
 
RatExpSet ratexpset_t
Definition: printer.hh:38
 
typename super_type::template unary_t< Type > unary_t
Definition: printer.hh:46
 
printer(const ratexpset_t &rs, std::ostream &out, const bool debug=!!getenv("AWALI_PARENS"))
Definition: printer.hxx:56
 
typename super_type::template variadic_t< Type > variadic_t
Definition: printer.hh:48
 
Definition: ratexp.hh:176
 
An inner node with multiple children.
Definition: ratexp.hh:115
 
An inner node implementing a weight.
Definition: ratexp.hh:208
 
weight_node< type_t::lweight, Label, Weight > lweight
Definition: fwd.hh:164
 
constant< type_t::zero, Label, Weight > zero
Definition: fwd.hh:113
 
type_t
The possible types of ratexps.
Definition: fwd.hh:48
 
weight_node< type_t::rweight, Label, Weight > rweight
Definition: fwd.hh:167
 
std::ostream & operator<<(std::ostream &o, type_t t)
Definition: printer.hxx:31
 
constant< type_t::one, Label, Weight > one
Definition: fwd.hh:116
 
identities
A ratexpset can implement several different sets of identities on expressions.
Definition: identities.hh:32
 
std::ostream & str_escape(std::ostream &os, const int c)
Definition: escape.hh:30
 
auto format(const ValueSet &vs, const typename ValueSet::value_t &v, Args &&... args) -> std::string
Format v via vs.print.
Definition: stream.hh:109
 
std::ostream & print(const RatExpSet &rs, const typename RatExpSet::ratexp_t &e, std::ostream &o, bool with_dot=false)
Definition: print_exp.hh:201
 
Main namespace of Awali.
Definition: ato.hh:22
 
#define VISIT(Type)
Definition: printer.hxx:174