61 "⁰",
"¹",
"²",
"³",
"⁴",
"⁵",
"⁶",
"⁷",
"⁸",
"⁹"
65 template <
typename ExpSet>
67 :
public ExpSet::const_visitor
71 using super_t =
typename expressionset_t::const_visitor;
81 using node_t =
typename super_t::node_t;
84 using inner_t =
typename super_t::inner_t;
85 template <type_t Type>
87 template <type_t Type>
89 using leaf_t =
typename super_t::leaf_t;
92 constexpr
static const char*
me() {
return "print"; }
140 template <
typename Dummy =
void>
156 template <
size_t... I>
159 using swallow =
int[];
171 print_(v, labelset_t::indices);
179 detail::static_if<context_t::is_lat>
191 auto atom =
dynamic_cast<const atom_t*
>(&
v);
211 auto atom =
dynamic_cast<const atom_t*
>(&
v);
213 && (context_t::is_lat
223 if (
auto s = dynamic_cast<const add_t*>(&v))
226 return (end(range) == s->end()
227 && 3 < boost::distance(range));
240 template <rat::exp::type_t Type>
241 void print_(
const unary_t<Type>& n,
const char* op);
244 template <rat::exp::type_t Type>
245 void print_(
const variadic_t<Type>& n,
const char* op);
256 template <
typename Iterator>
258 -> boost::iterator_range<Iterator>
265 auto l = std::dynamic_pointer_cast<
const atom_t>(lhs)->value();
266 auto r = std::dynamic_pointer_cast<
const atom_t>(rhs)->value();
267 const auto& ls = *
rs_.labelset();
269 return ls.less(l,
r) || ls.equal(l,
r);
274 template <
typename LS = labelset_t>
276 -> std::enable_if_t<detail::has_generators_mem_fn<LS>{},
void>
280 for (
auto i = std::begin(
v), end = std::end(
v);
293 auto letters = std::vector<label_t>{};
294 for (; i !=
r.end(); ++i)
296 .emplace_back(down_pointer_cast<const atom_t>(*i)->value());
310 template <
typename LS = labelset_t>
312 -> std::enable_if_t<!detail::has_generators_mem_fn<LS>{},
void>
324 const bool debug_ = !!getenv(
"VCSN_PARENS");
371 template <
typename ExpSet>
std::ostream & print_(const node_t &v)
Print v.
std::ostream & out_
Output stream.
void print_(const tuple_t &v, detail::index_sequence< I... >)
Print all the tapes.
void print_(const weight_t &w)
Print a weight.
VCSN_RAT_VISIT(complement, v)
typename super_t::node_t node_t
Actual node, without indirection.
const char * conjunction_
class format fmt_
Output format.
const char * langle_
Left and right angle brackets for weights.
VCSN_RAT_VISIT(transposition, v)
void visit(const tuple_t &v, std::true_type) override
Specific handling to using exponents as syntactic sugar.
bool is_braced_(const node_t &v) const
Whether is naturally braced.
const expressionset_t & rs_
The expressionset.
An inner node implementing a weight.
Pretty-printer for rational expressions.
const char * transposition_
static constexpr const char * me()
Name of this algorithm, for error messages.
context_t_of< expressionset_t > context_t
typename super_t::inner_t inner_t
weight_t_of< context_t > weight_t
An input/output format for valuesets.
typename super_t::template unary_t< Type > unary_t
Provide a variadic mul on top of a binary mul(), and one().
const char * tuple_left
Left tuple delimiter.
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
void print_child_(const node_t &child, const node_t &parent)
Print a child node, given its parent.
void operator()(const tuple_t &v)
Entry point.
void print_(const tuple_t &v)
Print one tape.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
const char * tuple_middle
Tuple tape separator.
typename expressionset_t::const_visitor super_t
VCSN_RAT_VISIT(ldivide, v)
std::ostream & print(const Aut &aut, std::ostream &out=std::cout, const std::string &fmt="default")
const label_t & value() const
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
const char * ldivide_
Left-quotient.
static constexpr const char *const superscripts[]
Exponents in UTF-8.
const char * lweight_
External product.
boost::iterator_range< Iterator > initial_sorted_range(Iterator begin, Iterator end, Pred pred, Less less)
The longest initial range of elements matching the predicate.
VCSN_RAT_VISIT(compose, v)
VCSN_RAT_VISIT(shuffle, v)
labelset_t_of< context_t > labelset_t
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
bool is_letter_(const node_t &v) const
Whether v is an atom whose label is a letter.
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.
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.
std::ostream & operator()(const value_t &v)
Entry point: print v.
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.
const char * compose_
Operator for composition: @.
typename super_t::template variadic_t< Type > variadic_t
VCSN_RAT_VISIT(infiltrate, v)
const bool debug_
Whether to be overly verbose.
unsigned int exponent_threshold_
An inner node with multiple children.
precedence_t
The possible node precedence levels, increasing.
typename node_t::value_t value_t
A shared_ptr to node_t.
void format(format fmt)
Set output format.
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.
printer< ExpSet > make_printer(const ExpSet &rs, std::ostream &out)
format for_weights() const
A copy of this format, but to print weights.
typename super_t::leaf_t leaf_t
const char * zero_
The constants.
VCSN_RAT_VISIT(conjunction, v)
typename super_t::tuple_t tuple_t
const char * lexponent_
Left and right braces for exponents.
typename expressionset_t::identities_t identities_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 * lgroup_
Left and right boundaries (typically braces for LaTeX).
const char * tuple_right
Right tuple delimiter.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
const char * star_
The expression operators.
printer(const expressionset_t &rs, std::ostream &out)
A printer.
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 char * lparen_
Left and right parentheses.
void print_child(const node_t &child, precedence_t parent)
Print a child node, given its parent's precedence.