1 #ifndef VCSN_CORE_RAT_PRINTER_HXX
2 # define VCSN_CORE_RAT_PRINTER_HXX
20 # define CASE(T) case type_t::T: o << #T; break
39 template <
typename RatExpSet>
52 template <typename RatExpSet> \
60 static bool print = !! getenv(
"VCSN_PRINT");
61 static bool debug = !! getenv(
"VCSN_DEBUG");
64 if (debug && format_ ==
"latex")
66 ?
"{\\color{red}{" :
"{\\color{blue}{");
68 if (debug && format_ ==
"latex")
79 if (format_ ==
"latex")
83 langle_ =
" \\left\\langle ";
84 rangle_ =
" \\right\\rangle ";
89 transposition_ =
"^{T}";
90 conjunction_ =
" \\& ";
94 ?
" \\oplus " :
" + ");
96 one_ =
"\\varepsilon";
99 ldiv_ =
" \\backslash ";
101 else if (format_ ==
"text")
111 transposition_ =
"{T}";
123 raise(
"invalid output format for ratexp: ",
str_escape(format));
126 DEFINE::precedence_(
const node_t& v)
const
130 return precedence_t::word;
134 # define CASE(Type) \
135 case exp::type_t::Type: \
136 return precedence_t::Type;
155 # define VISIT(Type) \
156 DEFINE::visit(const Type ## _t& v) \
162 ctx_.weightset()->print(v.weight(), out_, format_);
163 out_ << rangle_ << lmul_;
164 print_child_(*v.sub(), v);
169 print_child_(*v.sub(), v);
170 out_ << rmul_ << langle_;
171 ctx_.weightset()->print(v.weight(), out_, format_);
189 ctx_.labelset()->print(v.value(), out_, format_);
195 static bool force = !! getenv(
"VCSN_PARENS");
196 bool parent_has_precedence = precedence_(child) <= precedence_(parent);
199 || (parent_has_precedence
200 && ! (parent.is_unary() && child.is_unary())));
203 else if (parent.is_unary())
208 else if (parent.is_unary())
212 template <
typename RatExpSet>
213 template <type_t Type>
219 print_child_(*v.sub(), v);
223 template <
typename RatExpSet>
224 template <type_t Type>
246 #endif // !VCSN_CORE_RAT_PRINTER_HXX
precedence_t
The possible node precedence levels, increasing.
An inner node with multiple children.
std::ostream & operator<<(std::ostream &o, type_t t)
Indentation relative functions.
std::ostream & incendl(std::ostream &o)
Increment the indentation, print an end of line, and set the indentation.
typename super_t::template unary_t< Type > unary_t
boost::flyweight< std::string, boost::flyweights::no_tracking > symbol
An internalized string.
automaton shuffle_(const std::vector< automaton > &as, vcsn::detail::index_sequence< I...>)
Variadic bridge helper.
std::ostream & str_escape(std::ostream &os, const std::string &str)
Output a string, escaping special characters.
typename super_t::template variadic_t< Type > variadic_t
void print_(const unary_t< Type > &n, const char *op)
Print a unary node.
int address(const void *t)
Name pointers, to make them easier to read.
std::ostream & print(const ValueSet &vs, const typename ValueSet::value_t &v, std::ostream &o, const std::string &format)
Applies to (ValueSet, Value, ostream, string): for expansionset, polynomialset, ratexpset, and weightset.
type_t
The possible types of ratexps.
typename super_t::node_t node_t
Trivial identities plus series identities.
std::ostream & decendl(std::ostream &o)
Decrement the indentation, print an end of line, and set the indentation.
An inner node implementing a weight.
printer(const ratexpset_t &rs, std::ostream &out, const bool debug=!!getenv("VCSN_PARENS"))
identities
A ratexpset can implement several different sets of identities on expressions.
automaton product_(const std::vector< automaton > &as, vcsn::detail::index_sequence< I...>)