Vcsn
2.2
Be Rational
|
#include <fwd.hh>
Classes | |
struct | visit_tuple |
struct | visit_tuple< false, Dummy > |
Public Types | |
using | expressionset_t = ExpSet |
using | context_t = context_t_of< expressionset_t > |
using | identities_t = typename expressionset_t::identities_t |
using | labelset_t = labelset_t_of< context_t > |
using | label_t = label_t_of< context_t > |
using | weight_t = weight_t_of< context_t > |
using | super_t = typename expressionset_t::const_visitor |
using | node_t = typename super_t::node_t |
Actual node, without indirection. More... | |
using | value_t = typename node_t::value_t |
A shared_ptr to node_t. More... | |
using | inner_t = typename super_t::inner_t |
template<type_t Type> | |
using | unary_t = typename super_t::template unary_t< Type > |
template<type_t Type> | |
using | variadic_t = typename super_t::template variadic_t< Type > |
using | leaf_t = typename super_t::leaf_t |
Public Member Functions | |
printer (const expressionset_t &rs, std::ostream &out) | |
A printer. More... | |
void | format (format fmt) |
Set output format. More... | |
std::ostream & | operator() (const node_t &v) |
Entry point: print v. More... | |
std::ostream & | operator() (const std::shared_ptr< const node_t > &v) |
Entry point: print v. More... | |
void | print_child (const node_t &child, precedence_t parent) |
Print the given child node, also knowing its parent's precedence. More... | |
template<type_t Type> | |
auto | print_ (const unary_t< Type > &v, const char *op) -> void |
template<type_t Type> | |
auto | print_ (const variadic_t< Type > &n, const char *op) -> void |
Static Public Member Functions | |
static constexpr const char * | me () |
Name of this algorithm, for error messages. More... | |
Private Types | |
using | tuple_t = typename super_t::tuple_t |
Private Member Functions | |
VCSN_RAT_VISIT (atom, v) | |
VCSN_RAT_VISIT (complement, v) | |
VCSN_RAT_VISIT (conjunction, v) | |
VCSN_RAT_VISIT (infiltration, v) | |
VCSN_RAT_VISIT (ldiv, v) | |
VCSN_RAT_VISIT (lweight, v) | |
VCSN_RAT_VISIT (one, v) | |
VCSN_RAT_VISIT (prod, v) | |
VCSN_RAT_VISIT (rweight, v) | |
VCSN_RAT_VISIT (shuffle, v) | |
VCSN_RAT_VISIT (star, v) | |
VCSN_RAT_VISIT (sum, v) | |
VCSN_RAT_VISIT (transposition, v) | |
VCSN_RAT_VISIT (zero, v) | |
void | visit (const tuple_t &v, std::true_type) override |
bool | is_letter_ (const node_t &v) const |
Whether v is an atom whose label is a letter. More... | |
bool | is_word_ (const node_t &v) const |
Whether v is an atom whose label is not a letter. More... | |
bool | is_braced_ (const node_t &v) const |
Whether is naturally braced. More... | |
precedence_t | precedence_ (const node_t &v) const |
The precedence of v (to decide when to print parens). More... | |
void | print_child_ (const node_t &child, const node_t &parent) |
Print the given child node, also knowing its parent. More... | |
template<rat::exp::type_t Type> | |
void | print_ (const unary_t< Type > &n, const char *op) |
Print a unary node. More... | |
template<rat::exp::type_t Type> | |
void | print_ (const variadic_t< Type > &n, const char *op) |
Print an n-ary node. More... | |
ATTRIBUTE_PURE bool | shows_left_weight_ (const node_t &n) |
Whether the left weight shows. More... | |
template<typename Iterator > | |
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. More... | |
template<typename LS = 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. More... | |
for (auto i=std::begin(v), end=std::end(v);i!=end;) | |
template<typename LS = 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 does not have a genset() function. More... | |
Private Attributes | |
void | |
std::ostream & | out_ |
Output stream. More... | |
class format | fmt_ |
Output format. More... | |
const expressionset_t & | rs_ |
The expressionset. More... | |
const bool | debug_ = !!getenv("VCSN_PARENS") |
Whether to be overly verbose. More... | |
const char * | lgroup_ = nullptr |
Left and right boundaries (typically braces for LaTeX). More... | |
const char * | rgroup_ = nullptr |
const char * | langle_ = nullptr |
Left and right angle brackets for weights. More... | |
const char * | rangle_ = nullptr |
const char * | lparen_ = nullptr |
Left and right parentheses. More... | |
const char * | rparen_ = nullptr |
const char * | lexponent_ = nullptr |
Left and right braces for exponents. More... | |
const char * | rexponent_ = nullptr |
const char * | lmul_ = nullptr |
External product. More... | |
const char * | rmul_ = nullptr |
const char * | ldiv_ = nullptr |
Quotient. More... | |
const char * | star_ = nullptr |
The expression operators. More... | |
const char * | complement_ = nullptr |
const char * | transposition_ = nullptr |
const char * | conjunction_ = nullptr |
const char * | infiltration_ = nullptr |
const char * | shuffle_ = nullptr |
const char * | product_ = nullptr |
const char * | sum_ = nullptr |
const char * | tuple_left = nullptr |
Left tuple delimiter. More... | |
const char * | tuple_middle = nullptr |
Tuple tape separator. More... | |
const char * | tuple_right = nullptr |
Right tuple delimiter. More... | |
const char * | zero_ = nullptr |
The constants. More... | |
const char * | one_ = nullptr |
unsigned int | exponent_threshold_ = 0 |
using vcsn::rat::printer< ExpSet >::context_t = context_t_of<expressionset_t> |
Definition at line 69 of file printer.hh.
using vcsn::rat::printer< ExpSet >::expressionset_t = ExpSet |
Definition at line 68 of file printer.hh.
using vcsn::rat::printer< ExpSet >::identities_t = typename expressionset_t::identities_t |
Definition at line 70 of file printer.hh.
using vcsn::rat::printer< ExpSet >::inner_t = typename super_t::inner_t |
Definition at line 80 of file printer.hh.
using vcsn::rat::printer< ExpSet >::label_t = label_t_of<context_t> |
Definition at line 72 of file printer.hh.
using vcsn::rat::printer< ExpSet >::labelset_t = labelset_t_of<context_t> |
Definition at line 71 of file printer.hh.
using vcsn::rat::printer< ExpSet >::leaf_t = typename super_t::leaf_t |
Definition at line 85 of file printer.hh.
using vcsn::rat::printer< ExpSet >::node_t = typename super_t::node_t |
Actual node, without indirection.
Definition at line 77 of file printer.hh.
using vcsn::rat::printer< ExpSet >::super_t = typename expressionset_t::const_visitor |
Definition at line 75 of file printer.hh.
|
private |
Definition at line 125 of file printer.hh.
using vcsn::rat::printer< ExpSet >::unary_t = typename super_t::template unary_t<Type> |
Definition at line 82 of file printer.hh.
using vcsn::rat::printer< ExpSet >::value_t = typename node_t::value_t |
A shared_ptr to node_t.
Definition at line 79 of file printer.hh.
using vcsn::rat::printer< ExpSet >::variadic_t = typename super_t::template variadic_t<Type> |
Definition at line 84 of file printer.hh.
using vcsn::rat::printer< ExpSet >::weight_t = weight_t_of<context_t> |
Definition at line 73 of file printer.hh.
|
inline |
A printer.
Definition at line 41 of file printer.hxx.
|
inlineprivate |
Definition at line 276 of file printer.hh.
References vcsn::rat::printer< ExpSet >::fmt_, vcsn::rat::printer< ExpSet >::letter_range(), vcsn::rat::printer< ExpSet >::out_, vcsn::rat::printer< ExpSet >::print_child_(), vcsn::detail::print_label_class(), vcsn::rat::printer< ExpSet >::rs_, vcsn::rat::printer< ExpSet >::sum_, and vcsn::detail::v.
|
inline |
Set output format.
Definition at line 71 of file printer.hxx.
References vcsn::dyn::detail::conjunction_(), vcsn::dyn::detail::infiltration_(), vcsn::format::latex, vcsn::dyn::detail::shuffle_(), vcsn::format::text, and vcsn::format::utf8.
|
inlineprivate |
Whether is naturally braced.
This is the case of sums of letters printed as range: we want to print [a-z]*
, not ([a-z])*
.
Definition at line 217 of file printer.hh.
References vcsn::rat::printer< ExpSet >::letter_range().
|
inlineprivate |
Whether v is an atom whose label is a letter.
Used to know if we can print a sum of expressions as a letter range.
Definition at line 185 of file printer.hh.
References vcsn::rat::printer< ExpSet >::rs_, vcsn::detail::v, and vcsn::rat::atom< Context >::value().
Referenced by vcsn::rat::printer< ExpSet >::letter_range().
|
inlineprivate |
Whether v is an atom whose label is not a letter.
Used to decide when to issues parens via precedence ("letter" and "word" have different precedence). Actually, this routine checks whether this node is a self-delimited atom. Letters are of course self-delimited, so we don't add parens to "a" in "a*". Tuples printed as labels are not, so we need to add parens to "a|x" in "(a|x)*".
Note that 1-tape tuple are self-delimited (well, if what they contain is self-delimited). But then visually there is no difference between a lal and a lat<lal>. I think there should be one, so let's keep it this way. Likewise for 0-tape tuples.
Definition at line 205 of file printer.hh.
References vcsn::rat::printer< ExpSet >::rs_, vcsn::detail::v, and vcsn::rat::atom< Context >::value().
|
inlineprivate |
Return the longest range of expressions that are letters, in strictly increasing order.
Definition at line 253 of file printer.hh.
References vcsn::detail::initial_sorted_range(), vcsn::rat::printer< ExpSet >::is_letter_(), and vcsn::rat::printer< ExpSet >::rs_.
Referenced by vcsn::rat::printer< ExpSet >::for(), and vcsn::rat::printer< ExpSet >::is_braced_().
|
inlinestatic |
Name of this algorithm, for error messages.
Definition at line 88 of file printer.hh.
|
inline |
Entry point: print v.
Definition at line 54 of file printer.hxx.
References vcsn::address(), vcsn::decendl(), vcsn::incendl(), vcsn::format::latex, vcsn::print(), and vcsn::detail::v.
Referenced by vcsn::rat::printer< ExpSet >::operator()().
|
inline |
Entry point: print v.
Definition at line 101 of file printer.hh.
References vcsn::rat::printer< ExpSet >::operator()().
|
inlineprivate |
The precedence of v (to decide when to print parens).
Definition at line 162 of file printer.hxx.
References CASE, vcsn::detail::v, and vcsn::rat::word.
|
private |
Print a unary node.
Referenced by vcsn::rat::printer< ExpSet >::VCSN_RAT_VISIT().
|
private |
Print an n-ary node.
|
inline |
Definition at line 308 of file printer.hxx.
References vcsn::detail::v.
|
inline |
Definition at line 319 of file printer.hxx.
|
inline |
Print the given child node, also knowing its parent's precedence.
Definition at line 277 of file printer.hxx.
References vcsn::rat::unary.
|
inlineprivate |
Print the given child node, also knowing its parent.
Definition at line 298 of file printer.hxx.
Referenced by vcsn::rat::printer< ExpSet >::for().
|
inlineprivate |
Print a sum, when the labelset has a genset() function.
Definition at line 271 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::VCSN_RAT_VISIT().
|
inlineprivate |
Print a sum, when the labelset does not have a genset() function.
Definition at line 307 of file printer.hh.
|
inlineprivate |
Whether the left weight shows.
Definition at line 245 of file printer.hh.
References vcsn::rat::lweight.
|
private |
|
inlineprivate |
Definition at line 111 of file printer.hh.
References vcsn::rat::printer< ExpSet >::complement_, vcsn::rat::printer< ExpSet >::print_(), and vcsn::detail::v.
|
inlineprivate |
Definition at line 112 of file printer.hh.
References vcsn::rat::printer< ExpSet >::conjunction_, vcsn::rat::printer< ExpSet >::print_(), and vcsn::detail::v.
|
inlineprivate |
Definition at line 113 of file printer.hh.
References vcsn::rat::printer< ExpSet >::infiltration_, vcsn::rat::printer< ExpSet >::print_(), and vcsn::detail::v.
|
inlineprivate |
Definition at line 114 of file printer.hh.
References vcsn::rat::printer< ExpSet >::ldiv_, vcsn::rat::printer< ExpSet >::print_(), and vcsn::detail::v.
|
private |
|
private |
|
private |
|
private |
|
inlineprivate |
Definition at line 119 of file printer.hh.
References vcsn::rat::printer< ExpSet >::print_(), vcsn::rat::printer< ExpSet >::shuffle_, and vcsn::detail::v.
|
inlineprivate |
Definition at line 120 of file printer.hh.
References vcsn::rat::printer< ExpSet >::print_(), vcsn::rat::printer< ExpSet >::star_, and vcsn::detail::v.
|
inlineprivate |
Definition at line 121 of file printer.hh.
References vcsn::rat::printer< ExpSet >::print_sum_(), and vcsn::detail::v.
|
inlineprivate |
Definition at line 122 of file printer.hh.
References vcsn::rat::printer< ExpSet >::print_(), vcsn::rat::printer< ExpSet >::transposition_, and vcsn::detail::v.
|
private |
|
inlineoverrideprivate |
Definition at line 175 of file printer.hh.
References vcsn::detail::v.
|
private |
Definition at line 344 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::VCSN_RAT_VISIT().
|
private |
Definition at line 346 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::VCSN_RAT_VISIT().
|
private |
Whether to be overly verbose.
Definition at line 320 of file printer.hh.
|
private |
Definition at line 362 of file printer.hh.
|
private |
Output format.
Definition at line 316 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::for(), and vcsn::rat::printer< ExpSet >::visit_tuple< bool, Dummy >::print_().
|
private |
Definition at line 347 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::VCSN_RAT_VISIT().
|
private |
Left and right angle brackets for weights.
Definition at line 329 of file printer.hh.
|
private |
Quotient.
Definition at line 341 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::VCSN_RAT_VISIT().
|
private |
Left and right braces for exponents.
Definition at line 335 of file printer.hh.
|
private |
Left and right boundaries (typically braces for LaTeX).
Used to group operand of unary operators, e.g. "a" -> "a", "a*" -> "{a}^{*}" and "a**" -> "{{a}^{*}}^{*}".
Definition at line 326 of file printer.hh.
|
private |
External product.
Definition at line 338 of file printer.hh.
|
private |
Left and right parentheses.
Definition at line 332 of file printer.hh.
|
private |
Definition at line 361 of file printer.hh.
|
private |
Output stream.
Definition at line 314 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::for(), vcsn::rat::printer< ExpSet >::visit_tuple< bool, Dummy >::operator()(), and vcsn::rat::printer< ExpSet >::visit_tuple< bool, Dummy >::print_().
|
private |
Definition at line 349 of file printer.hh.
|
private |
Definition at line 330 of file printer.hh.
|
private |
Definition at line 336 of file printer.hh.
|
private |
Definition at line 327 of file printer.hh.
|
private |
Definition at line 339 of file printer.hh.
|
private |
Definition at line 333 of file printer.hh.
|
private |
The expressionset.
Definition at line 318 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::for(), vcsn::rat::printer< ExpSet >::is_letter_(), vcsn::rat::printer< ExpSet >::is_word_(), vcsn::rat::printer< ExpSet >::letter_range(), and vcsn::rat::printer< ExpSet >::visit_tuple< bool, Dummy >::print_().
|
private |
Definition at line 348 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::VCSN_RAT_VISIT().
|
private |
The expression operators.
Definition at line 343 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::VCSN_RAT_VISIT().
|
private |
Definition at line 350 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::for().
|
private |
Definition at line 345 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::VCSN_RAT_VISIT().
|
private |
Left tuple delimiter.
Definition at line 353 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::visit_tuple< bool, Dummy >::operator()().
|
private |
Tuple tape separator.
Definition at line 355 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::visit_tuple< bool, Dummy >::print_().
|
private |
Right tuple delimiter.
Definition at line 357 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::visit_tuple< bool, Dummy >::operator()().
|
private |
Definition at line 273 of file printer.hh.
Referenced by vcsn::rat::printer< ExpSet >::visit_tuple< bool, Dummy >::print_().
|
private |
The constants.
Definition at line 360 of file printer.hh.