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"; }
119 rs_.weightset()->print(w, out_, fmt_.for_weights());
140 template <
typename Dummy =
void>
148 self_.out_ << self_.tuple_middle;
149 auto rs = detail::project<I>(self_.rs_);
151 print.format(self_.fmt_);
156 template <
size_t... I>
159 using swallow =
int[];
170 self_.out_ << self_.tuple_left;
171 print_(v, labelset_t::indices);
172 self_.out_ << self_.tuple_right;
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
214 || ! rs_.labelset()->is_letter(
atom->
value())));
223 if (
auto s = dynamic_cast<const add_t*>(&v))
225 auto range = letter_range(s->begin(), s->end());
226 return (end(range) == s->end()
227 && 3 < boost::distance(range));
237 void print_child_(
const node_t& child,
const node_t& parent);
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>
262 [
this](
const value_t& c) {
return is_letter_(*c); },
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);
289 auto r = letter_range(i, end);
293 auto letters = std::vector<label_t>{};
294 for (; i !=
r.end(); ++i)
296 .emplace_back(down_pointer_cast<const atom_t>(*i)->value());
303 print_child_(**i, v);
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");
330 const char* lgroup_ =
nullptr;
331 const char* rgroup_ =
nullptr;
333 const char* langle_ =
nullptr;
334 const char* rangle_ =
nullptr;
336 const char* lparen_ =
nullptr;
337 const char* rparen_ =
nullptr;
339 const char* lexponent_ =
nullptr;
340 const char* rexponent_ =
nullptr;
342 const char* lweight_ =
nullptr;
343 const char* rweight_ =
nullptr;
345 const char* ldivide_ =
nullptr;
347 const char* star_ =
nullptr;
348 const char* complement_ =
nullptr;
350 const char* compose_ =
nullptr;
351 const char* transposition_ =
nullptr;
355 const char* product_ =
nullptr;
356 const char* add_ =
nullptr;
359 const char* tuple_left =
nullptr;
361 const char* tuple_middle =
nullptr;
363 const char* tuple_right =
nullptr;
366 const char* zero_ =
nullptr;
367 const char* one_ =
nullptr;
368 unsigned int exponent_threshold_ = 0;
371 template <
typename ExpSet>
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.
automaton conjunction_(const std::vector< automaton > &as, bool lazy, vcsn::detail::index_sequence< I... >)
Bridge helper.
VCSN_RAT_VISIT(shuffle, v)
typename super_t::template variadic_t< Type > variadic_t
Pretty-printer for rational expressions.
#define VCSN_RAT_VISIT(Type, Val)
typename super_t::template unary_t< Type > unary_t
typename super_t::inner_t inner_t
printer< ExpSet > make_printer(const ExpSet &rs, std::ostream &out)
weight_t_of< context_t > weight_t
labelset_t_of< context_t > labelset_t
static constexpr const char *const superscripts[]
Exponents in UTF-8.
VCSN_RAT_VISIT(ldivide, v)
VCSN_RAT_VISIT(compose, v)
std::ostream & out_
Output stream.
std::ostream & operator()(const value_t &v)
Entry point: print v.
void print_(const tuple_t &v)
Print one tape.
const label_t & value() const
void print_(const weight_t &w)
Print a weight.
precedence_t
The possible node precedence levels, increasing.
typename super_t::node_t node_t
Actual node, without indirection.
automaton infiltrate_(const std::vector< automaton > &as, vcsn::detail::index_sequence< I... >)
Variadic bridge helper.
typename expressionset_t::identities_t identities_t
bool is_braced_(const node_t &v) const
Whether is naturally braced.
std::string format(const Value &v, const std::string &format="default")
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.
typename detail::labelset_t_of_impl< base_t< ValueSet > >::type labelset_t_of
VCSN_RAT_VISIT(complement, v)
typename detail::weight_t_of_impl< base_t< ValueSet > >::type weight_t_of
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.
boost::iterator_range< Iterator > initial_sorted_range(Iterator begin, Iterator end, Pred pred, Less less)
The longest initial range of elements matching the predicate.
label_t_of< context_t > label_t
context_t_of< expressionset_t > context_t
typename super_t::leaf_t leaf_t
typename node_t::value_t value_t
A shared_ptr to node_t.
void print_(std::ostream &o, const T &arg, long)
Serialize arg into o.
void visit(const tuple_t &v, std::true_type) override
Specific handling to using exponents as syntactic sugar.
An input/output format for valuesets.
Provide a variadic mul on top of a binary mul(), and one().
typename expressionset_t::const_visitor super_t
An inner node with multiple children.
typename super_t::tuple_t tuple_t
An inner node implementing a weight.
void operator()(const tuple_t &v)
Entry point.
std::ostream & print(const Aut &aut, std::ostream &out=std::cout, const std::string &fmt="default")
const expressionset_t & rs_
The expressionset.
VCSN_RAT_VISIT(conjunction, v)
VCSN_RAT_VISIT(transposition, v)
ATTRIBUTE_PURE bool shows_left_weight_(const node_t &n)
Whether the left weight shows.
VCSN_RAT_VISIT(infiltrate, v)
automaton shuffle_(const std::vector< automaton > &as, vcsn::detail::index_sequence< I... >)
Variadic bridge helper.
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.
void print_(const tuple_t &v, detail::index_sequence< I... >)
Print all the tapes.
static constexpr const char * me()
Name of this algorithm, for error messages.
bool is_letter_(const node_t &v) const
Whether v is an atom whose label is a letter.
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 detail::label_t_of_impl< base_t< ValueSet > >::type label_t_of
typename detail::context_t_of_impl< base_t< ValueSet > >::type context_t_of