56 template <
typename ExpSet>
58 :
public ExpSet::const_visitor
68 using super_t =
typename expressionset_t::const_visitor;
70 using node_t =
typename super_t::node_t;
73 using inner_t =
typename super_t::inner_t;
74 template <type_t Type>
76 template <type_t Type>
78 using leaf_t =
typename super_t::leaf_t;
81 constexpr
static const char*
me() {
return "print"; }
120 template <
bool = context_t::is_lat,
121 typename Dummy =
void>
137 template <
size_t... I>
140 using swallow =
int[];
158 template <
typename Dummy>
180 auto atom =
dynamic_cast<const atom_t*
>(&
v);
200 auto atom =
dynamic_cast<const atom_t*
>(&
v);
202 && (context_t::is_lat
212 if (
auto s = dynamic_cast<const sum_t*>(&v))
215 return (end(range) == s->end()
216 && 3 < boost::distance(range));
229 template <rat::exp::type_t Type>
230 void print_(
const unary_t<Type>& n,
const char* op);
233 template <rat::exp::type_t Type>
234 void print_(
const variadic_t<Type>& n,
const char* op);
245 template <
typename Iterator>
247 -> boost::iterator_range<Iterator>
254 auto l = std::dynamic_pointer_cast<
const atom_t>(lhs)->value();
255 auto r = std::dynamic_pointer_cast<
const atom_t>(rhs)->value();
256 const auto& ls = *
rs_.labelset();
258 return ls.less(l,
r) || ls.equal(l,
r);
263 template <
typename LS = labelset_t>
269 for (
auto i = std::begin(
v), end = std::end(
v);
282 auto letters = std::vector<label_t>{};
283 for (; i !=
r.end(); ++i)
285 .emplace_back(down_pointer_cast<const atom_t>(*i)->value());
299 template <
typename LS = labelset_t>
313 const bool debug_ = !!getenv(
"VCSN_PARENS");
354 template <
typename ExpSet>
std::ostream & print_label_class(const LabelSet &ls, const std::vector< typename LabelSet::value_t > &letters, std::ostream &out, format fmt)
Print a set of labels (letterized) with classes.
typename super_t::tuple_t tuple_t
typename super_t::template unary_t< Type > unary_t
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
const char * lgroup_
Left and right boundaries (typically braces for LaTeX).
std::ostream & operator()(const std::shared_ptr< const node_t > &v)
Entry point: print v.
void print_child(const node_t &child, precedence_t parent)
Print the given child node, also knowing its parent's precedence.
typename node_t::value_t value_t
A shared_ptr to node_t.
const char * star_
The expression operators.
void print_(const tuple_t &v, detail::index_sequence< I...>)
Print all the tapes.
typename super_t::leaf_t leaf_t
const char * zero_
The constants.
auto letter_range(Iterator i, Iterator end) const -> boost::iterator_range< Iterator >
Return the longest range of expressions that are letters, in strictly increasing order.
void print_(const unary_t< Type > &n, const char *op)
Print a unary node.
bool is_word_(const node_t &v) const
Whether v is an atom whose label is not a letter.
typename expressionset_t::identities_t identities_t
const char * tuple_middle
Tuple tape separator.
typename super_t::template variadic_t< Type > variadic_t
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
const char * lparen_
Left and right parentheses.
void operator()(const tuple_t &)
typename std::enable_if< Cond, T >::type enable_if_t
VCSN_RAT_VISIT(complement, v)
printer< ExpSet > make_printer(const ExpSet &rs, std::ostream &out)
typename super_t::node_t node_t
Actual node, without indirection.
std::ostream & out_
Output stream.
std::ostream & operator()(const node_t &v)
Entry point: print v.
bool is_letter_(const node_t &v) const
Whether v is an atom whose label is a letter.
label_t_of< context_t > label_t
void visit(const tuple_t &v, std::true_type) override
const char * langle_
Left and right angle brackets for weights.
precedence_t precedence_(const node_t &v) const
The precedence of v (to decide when to print parens).
const bool debug_
Whether to be overly verbose.
weight_t_of< context_t > weight_t
const char * ldiv_
Quotient.
void print_child_(const node_t &child, const node_t &parent)
Print the given child node, also knowing its parent.
void operator()(const tuple_t &v)
Entry point.
std::ostream & print(const Aut &aut, std::ostream &out, const std::string &format)
Provide a variadic mul on top of a binary mul(), and one().
auto print_sum_(const sum_t &v) -> enable_if_t<!detail::has_genset_mem_fn< LS >
Print a sum, when the labelset does not have a genset() function.
const char * transposition_
typename super_t::inner_t inner_t
VCSN_RAT_VISIT(conjunction, v)
const char * tuple_right
Right tuple delimiter.
precedence_t
The possible node precedence levels, increasing.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
bool is_braced_(const node_t &v) const
Whether is naturally braced.
const expressionset_t & rs_
The expressionset.
const char * tuple_left
Left tuple delimiter.
printer(const expressionset_t &rs, std::ostream &out)
A printer.
const label_t & value() const
static constexpr const char * me()
Name of this algorithm, for error messages.
context_t_of< expressionset_t > context_t
VCSN_RAT_VISIT(shuffle, v)
const char * infiltration_
labelset_t_of< context_t > labelset_t
VCSN_RAT_VISIT(transposition, v)
An inner node implementing a weight.
void format(format fmt)
Set output format.
void print_(const tuple_t &v)
Print one tape.
#define BUILTIN_UNREACHABLE()
auto print_sum_(const sum_t &v) -> enable_if_t< detail::has_genset_mem_fn< LS >
Print a sum, when the labelset has a genset() function.
VCSN_RAT_VISIT(infiltration, v)
const char * conjunction_
class format fmt_
Output format.
typename expressionset_t::const_visitor super_t
const char * lmul_
External product.
boost::iterator_range< Iterator > initial_sorted_range(Iterator begin, Iterator end, Pred pred, Less less)
The return the longest initial range of elements matching the predicate.
ATTRIBUTE_PURE bool shows_left_weight_(const node_t &n)
Whether the left weight shows.
An inner node with multiple children.
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of