60 "⁰",
"¹",
"²",
"³",
"⁴",
"⁵",
"⁶",
"⁷",
"⁸",
"⁹"
63 template <
typename ExpSet>
65 :
public ExpSet::const_visitor
75 using super_t =
typename expressionset_t::const_visitor;
77 using node_t =
typename super_t::node_t;
80 using inner_t =
typename super_t::inner_t;
81 template <type_t Type>
83 template <type_t Type>
85 using leaf_t =
typename super_t::leaf_t;
88 constexpr
static const char*
me() {
return "print"; }
127 template <
bool = context_t::is_lat,
128 typename Dummy =
void>
144 template <
size_t... I>
147 using swallow =
int[];
159 print_(v, labelset_t::indices);
165 template <
typename Dummy>
187 auto atom =
dynamic_cast<const atom_t*
>(&
v);
207 auto atom =
dynamic_cast<const atom_t*
>(&
v);
209 && (context_t::is_lat
219 if (
auto s = dynamic_cast<const sum_t*>(&v))
222 return (end(range) == s->end()
223 && 3 < boost::distance(range));
236 template <rat::exp::type_t Type>
237 void print_(
const unary_t<Type>& n,
const char* op);
240 template <rat::exp::type_t Type>
241 void print_(
const variadic_t<Type>& n,
const char* op);
252 template <
typename Iterator>
254 -> boost::iterator_range<Iterator>
261 auto l = std::dynamic_pointer_cast<
const atom_t>(lhs)->value();
262 auto r = std::dynamic_pointer_cast<
const atom_t>(rhs)->value();
263 const auto& ls = *
rs_.labelset();
265 return ls.less(l,
r) || ls.equal(l,
r);
270 template <
typename LS = labelset_t>
272 -> std::enable_if_t<detail::has_generators_mem_fn<LS>{},
void>
276 for (
auto i = std::begin(
v), end = std::end(
v);
289 auto letters = std::vector<label_t>{};
290 for (; i !=
r.end(); ++i)
292 .emplace_back(down_pointer_cast<const atom_t>(*i)->value());
306 template <
typename LS = labelset_t>
308 -> std::enable_if_t<!detail::has_generators_mem_fn<LS>{},
void>
320 const bool debug_ = !!getenv(
"VCSN_PARENS");
365 template <
typename ExpSet>
const char * star_
The expression operators.
printer(const expressionset_t &rs, std::ostream &out)
A printer.
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.
const char * lparen_
Left and right parentheses.
void print_(const tuple_t &v)
Print one tape.
VCSN_RAT_VISIT(transposition, v)
void visit(const tuple_t &v, std::true_type) override
const expressionset_t & rs_
The expressionset.
const char * transposition_
std::ostream & out_
Output stream.
static constexpr const char * me()
Name of this algorithm, for error messages.
typename super_t::inner_t inner_t
weight_t_of< context_t > weight_t
VCSN_RAT_VISIT(infiltration, v)
const char * conjunction_
const char * tuple_left
Left tuple delimiter.
const char * langle_
Left and right angle brackets for weights.
void print_child_(const node_t &child, const node_t &parent)
Print the given child node, also knowing its parent.
const char * tuple_middle
Tuple tape separator.
bool is_braced_(const node_t &v) const
Whether is naturally braced.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
context_t_of< expressionset_t > context_t
An input/output format for valuesets.
Provide a variadic mul on top of a binary mul(), and one().
void operator()(const tuple_t &)
An inner node with multiple children.
std::ostream & operator()(const std::shared_ptr< const node_t > &v)
Entry point: print v.
typename super_t::template unary_t< Type > unary_t
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
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.
#define BUILTIN_UNREACHABLE()
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
const char * ldiv_
Quotient.
static constexpr const char *const superscripts[]
Exponents in UTF-8.
const char * infiltration_
typename expressionset_t::const_visitor super_t
labelset_t_of< context_t > labelset_t
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.
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.
typename super_t::template variadic_t< Type > variadic_t
unsigned int exponent_threshold_
void print_(const tuple_t &v, detail::index_sequence< I... >)
Print all the tapes.
printer< ExpSet > make_printer(const ExpSet &rs, std::ostream &out)
typename node_t::value_t value_t
A shared_ptr to node_t.
void format(format fmt)
Set output format.
VCSN_RAT_VISIT(shuffle, v)
precedence_t precedence_(const node_t &v) const
The precedence of v (to decide when to print parens).
ATTRIBUTE_PURE bool shows_left_weight_(const node_t &n)
Whether the left weight shows.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
std::ostream & print(const Aut &aut, std::ostream &out, const std::string &fmt)
const char * zero_
The constants.
VCSN_RAT_VISIT(conjunction, v)
precedence_t
The possible node precedence levels, increasing.
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
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.
An inner node implementing a weight.
typename expressionset_t::identities_t identities_t
label_t_of< context_t > label_t
bool is_word_(const node_t &v) const
Whether v is an atom whose label is not a letter.
void operator()(const tuple_t &v)
Entry point.
const char * lgroup_
Left and right boundaries (typically braces for LaTeX).
std::ostream & operator()(const node_t &v)
Entry point: print v.
const char * tuple_right
Right tuple delimiter.
const bool debug_
Whether to be overly verbose.
const label_t & value() const
void print_(const unary_t< Type > &n, const char *op)
Print a unary node.
const char * lmul_
External product.
typename super_t::leaf_t leaf_t
void print_child(const node_t &child, precedence_t parent)
Print the given child node, also knowing its parent's precedence.
typename super_t::tuple_t tuple_t
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.
VCSN_RAT_VISIT(complement, v)
typename super_t::node_t node_t
Actual node, without indirection.
class format fmt_
Output format.