60 "⁰",
"¹",
"²",
"³",
"⁴",
"⁵",
"⁶",
"⁷",
"⁸",
"⁹"
64 template <
typename ExpSet>
66 :
public ExpSet::const_visitor
70 using super_t =
typename expressionset_t::const_visitor;
80 using node_t =
typename super_t::node_t;
83 using inner_t =
typename super_t::inner_t;
84 template <type_t Type>
86 template <type_t Type>
88 using leaf_t =
typename super_t::leaf_t;
91 constexpr
static const char*
me() {
return "print"; }
139 template <
bool = context_t::is_lat,
140 typename Dummy =
void>
156 template <
size_t... I>
159 using swallow =
int[];
171 print_(v, labelset_t::indices);
177 template <
typename Dummy>
199 auto atom =
dynamic_cast<const atom_t*
>(&
v);
219 auto atom =
dynamic_cast<const atom_t*
>(&
v);
221 && (context_t::is_lat
231 if (
auto s = dynamic_cast<const add_t*>(&v))
234 return (end(range) == s->end()
235 && 3 < boost::distance(range));
248 template <rat::exp::type_t Type>
249 void print_(
const unary_t<Type>& n,
const char* op);
252 template <rat::exp::type_t Type>
253 void print_(
const variadic_t<Type>& n,
const char* op);
264 template <
typename Iterator>
266 -> boost::iterator_range<Iterator>
273 auto l = std::dynamic_pointer_cast<
const atom_t>(lhs)->value();
274 auto r = std::dynamic_pointer_cast<
const atom_t>(rhs)->value();
275 const auto& ls = *
rs_.labelset();
277 return ls.less(l,
r) || ls.equal(l,
r);
282 template <
typename LS = labelset_t>
284 -> std::enable_if_t<detail::has_generators_mem_fn<LS>{},
void>
288 for (
auto i = std::begin(
v), end = std::end(
v);
301 auto letters = std::vector<label_t>{};
302 for (; i !=
r.end(); ++i)
304 .emplace_back(down_pointer_cast<const atom_t>(*i)->value());
318 template <
typename LS = labelset_t>
320 -> std::enable_if_t<!detail::has_generators_mem_fn<LS>{},
void>
332 const bool debug_ = !!getenv(
"VCSN_PARENS");
379 template <
typename ExpSet>
void visit(const tuple_t &v, std::true_type) override
Specific handling to using exponents as syntactic sugar.
VCSN_RAT_VISIT(shuffle, v)
void operator()(const tuple_t &)
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
typename expressionset_t::const_visitor super_t
labelset_t_of< context_t > labelset_t
auto print_add_(const add_t &v) -> std::enable_if_t<!detail::has_generators_mem_fn< LS >
Print a sum, when the labelset does not have a genset() function.
const char * lweight_
External product.
VCSN_RAT_VISIT(infiltrate, v)
#define BUILTIN_UNREACHABLE()
boost::iterator_range< Iterator > initial_sorted_range(Iterator begin, Iterator end, Pred pred, Less less)
The longest initial range of elements matching the predicate.
const char * lexponent_
Left and right braces for exponents.
const char * ldivide_
Left-quotient.
unsigned int exponent_threshold_
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.
VCSN_RAT_VISIT(compose, v)
typename expressionset_t::identities_t identities_t
void print_(const tuple_t &v, detail::index_sequence< I... >)
Print all the tapes.
const char * tuple_middle
Tuple tape separator.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
VCSN_RAT_VISIT(ldivide, v)
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
context_t_of< expressionset_t > context_t
typename super_t::tuple_t tuple_t
VCSN_RAT_VISIT(complement, v)
bool is_word_(const node_t &v) const
Whether v is an atom whose label is not a letter.
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
An inner node implementing a weight.
const char * tuple_left
Left tuple delimiter.
const char * lgroup_
Left and right boundaries (typically braces for LaTeX).
bool is_letter_(const node_t &v) const
Whether v is an atom whose label is a letter.
typename super_t::template unary_t< Type > unary_t
precedence_t precedence_(const node_t &v) const
The precedence of v (to decide when to print parens).
std::ostream & out_
Output stream.
const label_t & value() const
void print_(const weight_t &w)
Print a weight.
VCSN_RAT_VISIT(transposition, v)
weight_t_of< context_t > weight_t
precedence_t
The possible node precedence levels, increasing.
bool is_braced_(const node_t &v) const
Whether is naturally braced.
std::ostream & operator()(const value_t &v)
Entry point: print v.
std::ostream & print(const Aut &aut, std::ostream &out=std::cout, const std::string &fmt="default")
printer(const expressionset_t &rs, std::ostream &out)
A printer.
const char * transposition_
const char * tuple_right
Right tuple delimiter.
void print_child_(const node_t &child, const node_t &parent)
Print a child node, given its parent.
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
const expressionset_t & rs_
The expressionset.
void format(format fmt)
Set output format.
const char * conjunction_
An input/output format for valuesets.
std::ostream & print_(const node_t &v)
Print v.
static constexpr const char * me()
Name of this algorithm, for error messages.
const char * lparen_
Left and right parentheses.
typename super_t::inner_t inner_t
void operator()(const tuple_t &v)
Entry point.
Pretty-printer for rational expressions.
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 node_t::value_t value_t
A shared_ptr to node_t.
label_t_of< context_t > label_t
const char * compose_
Operator for composition: @.
const char * langle_
Left and right angle brackets for weights.
const char * star_
The expression operators.
const bool debug_
Whether to be overly verbose.
void print_child(const node_t &child, precedence_t parent)
Print a child node, given its parent's precedence.
void print_(const tuple_t &v)
Print one tape.
auto print_add_(const add_t &v) -> std::enable_if_t< detail::has_generators_mem_fn< LS >
Print a sum, when the labelset has a genset() function.
An inner node with multiple children.
ATTRIBUTE_PURE bool shows_left_weight_(const node_t &n)
Whether the left weight shows.
static constexpr const char *const superscripts[]
Exponents in UTF-8.
Provide a variadic mul on top of a binary mul(), and one().
VCSN_RAT_VISIT(conjunction, v)
typename super_t::node_t node_t
Actual node, without indirection.
class format fmt_
Output format.
typename super_t::template variadic_t< Type > variadic_t
printer< ExpSet > make_printer(const ExpSet &rs, std::ostream &out)
format for_weights() const
A copy of this format, but to print weights.