62 "⁰",
"¹",
"²",
"³",
"⁴",
"⁵",
"⁶",
"⁷",
"⁸",
"⁹" 66 template <
typename ExpSet>
68 :
public ExpSet::const_visitor
72 using super_t =
typename expressionset_t::const_visitor;
82 using node_t =
typename super_t::node_t;
85 using inner_t =
typename super_t::inner_t;
86 template <type_t Type>
88 template <type_t Type>
90 using leaf_t =
typename super_t::leaf_t;
93 constexpr
static const char*
me() {
return "print"; }
120 rs_.weightset()->print(w, out_, fmt_.for_weights());
142 template <
typename Dummy =
void>
150 self_.out_ << self_.tuple_middle;
151 auto rs = detail::project<I>(self_.rs_);
153 print.format(self_.fmt_);
158 template <
size_t... I>
161 using swallow =
int[];
172 self_.out_ << self_.tuple_left;
173 print_(v, labelset_t::indices);
174 self_.out_ << self_.tuple_right;
181 detail::static_if<context_t::is_lat>
193 auto atom =
dynamic_cast<const atom_t*
>(&
v);
213 auto atom =
dynamic_cast<const atom_t*
>(&
v);
215 && (context_t::is_lat
216 || ! rs_.labelset()->is_letter(
atom->
value())));
225 if (
auto s = dynamic_cast<const add_t*>(&v))
227 auto range = letter_range(s->begin(), s->end());
228 return (end(range) == s->end()
229 && 3 < boost::distance(range));
239 void print_child_(
const node_t& child,
const node_t& parent);
242 template <rat::exp::type_t Type>
243 void print_(
const unary_t<Type>& n,
const char* op);
246 template <rat::exp::type_t Type>
247 void print_(
const variadic_t<Type>& n,
const char* op);
258 template <
typename Iterator>
260 -> boost::iterator_range<Iterator>
264 [
this](
const value_t& c) {
return is_letter_(*c); },
267 auto l = std::dynamic_pointer_cast<
const atom_t>(lhs)->value();
268 auto r = std::dynamic_pointer_cast<
const atom_t>(rhs)->value();
269 const auto& ls = *rs_.labelset();
271 return ls.compare(l,
r) <= 0;
276 template <
typename LS = labelset_t>
278 -> std::enable_if_t<detail::has_generators_mem_fn<LS>{},
void>
282 for (
auto i = std::begin(v), end = std::end(v);
291 auto r = letter_range(i, end);
295 auto letters = std::vector<label_t>{};
296 for (; i !=
r.end(); ++i)
298 .emplace_back(down_pointer_cast<const atom_t>(*i)->value());
305 print_child_(**i, v);
312 template <
typename LS = labelset_t>
314 -> std::enable_if_t<!detail::has_generators_mem_fn<LS>{},
void>
326 const bool parens_ = !!getenv(
"VCSN_PARENS");
328 const bool tagged_ = !!getenv(
"VCSN_PRINT");
334 const char* lgroup_ =
nullptr;
335 const char* rgroup_ =
nullptr;
337 const char* langle_ =
nullptr;
338 const char* rangle_ =
nullptr;
340 const char* lparen_ =
nullptr;
341 const char* rparen_ =
nullptr;
343 const char* lexponent_ =
nullptr;
344 const char* rexponent_ =
nullptr;
346 const char* lweight_ =
nullptr;
347 const char* rweight_ =
nullptr;
349 const char* ldivide_ =
nullptr;
351 const char* star_ =
nullptr;
352 const char* complement_ =
nullptr;
354 const char* compose_ =
nullptr;
355 const char* transposition_ =
nullptr;
359 const char* product_ =
nullptr;
360 const char* add_ =
nullptr;
363 const char* tuple_left =
nullptr;
365 const char* tuple_middle =
nullptr;
367 const char* tuple_right =
nullptr;
370 const char* zero_ =
nullptr;
371 const char* one_ =
nullptr;
374 unsigned int exponent_threshold_ = 0;
377 template <
typename ExpSet>
bool is_braced_(const node_t &v) const
Whether is naturally braced.
bool is_word_(const node_t &v) const
Whether v is an atom whose label is not a letter.
std::ostream & print(const Aut &aut, std::ostream &out=std::cout, const std::string &fmt="default")
static constexpr const char *const superscripts[]
Exponents in UTF-8.
An inner node with multiple children.
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 expressionset_t & rs_
The expressionset.
void print_(const tuple_t &v, detail::index_sequence< I... >)
Print all the tapes.
VCSN_RAT_VISIT(compose, v)
void visit(const tuple_t &v, std::true_type) override
Specific handling to using exponents as syntactic sugar.
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.
precedence_t
The possible node precedence levels, increasing.
automaton conjunction_(const std::vector< automaton > &as, bool lazy, vcsn::detail::index_sequence< I... >)
Bridge helper.
An inner node to name the subexpression.
typename detail::context_t_of_impl< base_t< ValueSet > >::type context_t_of
An input/output format for valuesets.
Provide a variadic mul on top of a binary mul(), and one().
VCSN_RAT_VISIT(transposition, v)
printer< ExpSet > make_printer(const ExpSet &rs, std::ostream &out)
VCSN_RAT_VISIT(complement, v)
VCSN_RAT_VISIT(infiltrate, v)
typename expressionset_t::const_visitor super_t
typename detail::labelset_t_of_impl< base_t< ValueSet > >::type labelset_t_of
typename super_t::template unary_t< Type > unary_t
void print_(const weight_t &w)
Print a weight.
weight_t_of< context_t > weight_t
typename detail::label_t_of_impl< base_t< ValueSet > >::type label_t_of
typename super_t::template variadic_t< Type > variadic_t
typename expressionset_t::identities_t identities_t
typename super_t::tuple_t tuple_t
labelset_t_of< context_t > labelset_t
bool is_letter_(const node_t &v) const
Whether v is an atom whose label is a letter.
static constexpr const char * me()
Name of this algorithm, for error messages.
std::ostream & operator()(const value_t &v)
Entry point: print v.
An inner node implementing a weight.
typename super_t::inner_t inner_t
Pretty-printer for rational expressions.
const label_t & value() const
automaton infiltrate_(const std::vector< automaton > &as, vcsn::detail::index_sequence< I... >)
Variadic bridge helper.
label_t_of< context_t > label_t
context_t_of< expressionset_t > context_t
ATTRIBUTE_PURE bool shows_left_weight_(const node_t &n)
Whether the left weight shows.
#define VCSN_RAT_VISIT(Type, Val)
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.
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.
std::string format(const Value &v, const std::string &format="default")
VCSN_RAT_VISIT(shuffle, v)
VCSN_RAT_VISIT(conjunction, v)
automaton shuffle_(const std::vector< automaton > &as, vcsn::detail::index_sequence< I... >)
Variadic bridge helper.
typename detail::weight_t_of_impl< base_t< ValueSet > >::type weight_t_of
std::ostream & out_
Output stream.
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 print_(std::ostream &o, const T &arg, long)
Serialize arg into o.
VCSN_RAT_VISIT(ldivide, v)
void operator()(const tuple_t &v)
Entry point.
void print_(const tuple_t &v)
Print one tape.
typename super_t::leaf_t leaf_t
typename node_t::value_t value_t
A shared_ptr to node_t.
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
typename super_t::node_t node_t
Actual node, without indirection.