59 "⁰",
"¹",
"²",
"³",
"⁴",
"⁵",
"⁶",
"⁷",
"⁸",
"⁹"
63 template <
typename ExpSet>
65 :
public ExpSet::const_visitor
69 using super_t =
typename expressionset_t::const_visitor;
79 using node_t =
typename super_t::node_t;
82 using inner_t =
typename super_t::inner_t;
83 template <type_t Type>
85 template <type_t Type>
87 using leaf_t =
typename super_t::leaf_t;
90 constexpr
static const char*
me() {
return "print"; }
137 template <
bool = context_t::is_lat,
138 typename Dummy =
void>
154 template <
size_t... I>
157 using swallow =
int[];
169 print_(v, labelset_t::indices);
175 template <
typename Dummy>
197 auto atom =
dynamic_cast<const atom_t*
>(&
v);
217 auto atom =
dynamic_cast<const atom_t*
>(&
v);
219 && (context_t::is_lat
229 if (
auto s = dynamic_cast<const sum_t*>(&v))
232 return (end(range) == s->end()
233 && 3 < boost::distance(range));
246 template <rat::exp::type_t Type>
247 void print_(
const unary_t<Type>& n,
const char* op);
250 template <rat::exp::type_t Type>
251 void print_(
const variadic_t<Type>& n,
const char* op);
262 template <
typename Iterator>
264 -> boost::iterator_range<Iterator>
271 auto l = std::dynamic_pointer_cast<
const atom_t>(lhs)->value();
272 auto r = std::dynamic_pointer_cast<
const atom_t>(rhs)->value();
273 const auto& ls = *
rs_.labelset();
275 return ls.less(l,
r) || ls.equal(l,
r);
280 template <
typename LS = labelset_t>
282 -> std::enable_if_t<detail::has_generators_mem_fn<LS>{},
void>
286 for (
auto i = std::begin(
v), end = std::end(
v);
299 auto letters = std::vector<label_t>{};
300 for (; i !=
r.end(); ++i)
302 .emplace_back(down_pointer_cast<const atom_t>(*i)->value());
316 template <
typename LS = labelset_t>
318 -> std::enable_if_t<!detail::has_generators_mem_fn<LS>{},
void>
330 const bool debug_ = !!getenv(
"VCSN_PARENS");
375 template <
typename ExpSet>
const char * conjunction_
void print_(const tuple_t &v, detail::index_sequence< I... >)
Print all the tapes.
const char * tuple_left
Left tuple delimiter.
printer< ExpSet > make_printer(const ExpSet &rs, std::ostream &out)
Provide a variadic mul on top of a binary mul(), and one().
typename super_t::leaf_t leaf_t
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
typename super_t::tuple_t tuple_t
bool is_braced_(const node_t &v) const
Whether is naturally braced.
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
An inner node implementing a weight.
#define BUILTIN_UNREACHABLE()
context_t_of< expressionset_t > context_t
VCSN_RAT_VISIT(complement, v)
class format fmt_
Output format.
const char * lparen_
Left and right parentheses.
std::ostream & print(const Aut &aut, std::ostream &out, const std::string &fmt)
const expressionset_t & rs_
The expressionset.
const char * ldiv_
Quotient.
void print_(const tuple_t &v)
Print one tape.
std::ostream & out_
Output stream.
static constexpr const char * me()
Name of this algorithm, for error messages.
auto print_sum_(const sum_t &v) -> std::enable_if_t< detail::has_generators_mem_fn< LS >
Print a sum, when the labelset has a genset() function.
typename super_t::inner_t inner_t
void operator()(const tuple_t &)
void print_(const weight_t &w)
Print a weight.
weight_t_of< context_t > weight_t
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 operator()(const tuple_t &v)
Entry point.
VCSN_RAT_VISIT(infiltration, v)
std::ostream & operator()(const value_t &v)
Entry point: print v.
typename super_t::template variadic_t< Type > variadic_t
const char * langle_
Left and right angle brackets for weights.
unsigned int exponent_threshold_
void print_child_(const node_t &child, const node_t &parent)
Print a child node, given its parent.
typename node_t::value_t value_t
A shared_ptr to node_t.
void format(format fmt)
Set output format.
const char * tuple_middle
Tuple tape separator.
ATTRIBUTE_PURE bool shows_left_weight_(const node_t &n)
Whether the left weight shows.
bool is_letter_(const node_t &v) const
Whether v is an atom whose label is a letter.
const char * lexponent_
Left and right braces for exponents.
Pretty-printer for rational expressions.
typename super_t::template unary_t< Type > unary_t
auto print_sum_(const sum_t &v) -> std::enable_if_t<!detail::has_generators_mem_fn< LS >
Print a sum, when the labelset does not have a genset() function.
precedence_t
The possible node precedence levels, increasing.
const char * lmul_
External product.
const char * infiltration_
typename expressionset_t::const_visitor super_t
labelset_t_of< context_t > labelset_t
static constexpr const char *const superscripts[]
Exponents in UTF-8.
format for_weights() const
A copy of this format, but to print weights.
void print_child(const node_t &child, precedence_t parent)
Print a child node, given its parent's precedence.
std::ostream & print_(const node_t &v)
Print v.
An inner node with multiple children.
typename super_t::node_t node_t
Actual node, without indirection.
const label_t & value() const
VCSN_RAT_VISIT(shuffle, v)
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
precedence_t precedence_(const node_t &v) const
The precedence of v (to decide when to print parens).
const char * star_
The expression operators.
printer(const expressionset_t &rs, std::ostream &out)
A printer.
const char * zero_
The constants.
VCSN_RAT_VISIT(conjunction, v)
VCSN_RAT_VISIT(transposition, v)
void visit(const tuple_t &v, std::true_type) override
typename expressionset_t::identities_t identities_t
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
label_t_of< context_t > label_t
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.
bool is_word_(const node_t &v) const
Whether v is an atom whose label is not a letter.
const char * transposition_
const char * lgroup_
Left and right boundaries (typically braces for LaTeX).
const char * tuple_right
Right tuple delimiter.
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.
const bool debug_
Whether to be overly verbose.
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
An input/output format for valuesets.