Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
vcsn::rat::printer< Context > Class Template Reference

#include <fwd.hh>

Inheritance diagram for vcsn::rat::printer< Context >:
Collaboration diagram for vcsn::rat::printer< Context >:

Public Types

using ratexpset_t = RatExpSet
 
using context_t = context_t_of< ratexpset_t >
 
using identities_t = typename ratexpset_t::identities_t
 
using weight_t = typename context_t::weightset_t::value_t
 
using super_t = typename ratexpset_t::const_visitor
 
using node_t = typename super_t::node_t
 
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 ratexpset_t &rs, std::ostream &out, const bool debug=!!getenv("VCSN_PARENS"))
 
void format (symbol format)
 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...
 
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
 

Private Types

enum  precedence_t {
  precedence_t::sum, precedence_t::shuffle, precedence_t::conjunction, precedence_t::ldiv,
  precedence_t::prod, precedence_t::word = prod, precedence_t::lweight, precedence_t::rweight,
  precedence_t::star, precedence_t::complement, precedence_t::transposition, precedence_t::zero,
  precedence_t::one, precedence_t::atom
}
 The possible node precedence levels, increasing. More...
 
using atom_t = typename super_t::atom_t
 
using complement_t = typename super_t::complement_t
 
using conjunction_t = typename super_t::conjunction_t
 
using ldiv_t = typename super_t::ldiv_t
 
using lweight_t = typename super_t::lweight_t
 
using one_t = typename super_t::one_t
 
using prod_t = typename super_t::prod_t
 
using rweight_t = typename super_t::rweight_t
 
using shuffle_t = typename super_t::shuffle_t
 
using star_t = typename super_t::star_t
 
using sum_t = typename super_t::sum_t
 
using transposition_t = typename super_t::transposition_t
 
using zero_t = typename super_t::zero_t
 

Private Member Functions

virtual void visit (const atom_t &v)
 
virtual void visit (const complement_t &v)
 
virtual void visit (const conjunction_t &v)
 
virtual void visit (const ldiv_t &v)
 
virtual void visit (const lweight_t &v)
 
virtual void visit (const one_t &v)
 
virtual void visit (const prod_t &v)
 
virtual void visit (const rweight_t &v)
 
virtual void visit (const shuffle_t &v)
 
virtual void visit (const star_t &v)
 
virtual void visit (const sum_t &v)
 
virtual void visit (const transposition_t &v)
 
virtual void visit (const zero_t &v)
 
bool is_word_ (const node_t &v) const
 Whether is an atom whose label is not a letter. 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...
 

Private Attributes

std::ostream & out_
 Output stream. More...
 
std::string format_
 Output format. More...
 
const context_tctx_
 Context to decode labels and weights. More...
 
const identities_t identities_
 
const bool debug_
 Whether to be overly verbose. More...
 
const charlgroup_ = nullptr
 Left and right boundaries (typically braces for LaTeX). More...
 
const charrgroup_ = nullptr
 
const charlangle_ = nullptr
 Left and right angle brackets for weights. More...
 
const charrangle_ = nullptr
 
const charlparen_ = nullptr
 Left and right parentheses. More...
 
const charrparen_ = nullptr
 
const charlmul_ = nullptr
 External product. More...
 
const charrmul_ = nullptr
 
const charldiv_ = nullptr
 Quotient. More...
 
const charstar_ = nullptr
 The ratexp operators. More...
 
const charcomplement_ = nullptr
 
const chartransposition_ = nullptr
 
const charconjunction_ = nullptr
 
const charshuffle_ = nullptr
 
const charproduct_ = nullptr
 
const charsum_ = nullptr
 
const charzero_ = nullptr
 The constants. More...
 
const charone_ = nullptr
 

Detailed Description

template<typename Context>
class vcsn::rat::printer< Context >

Definition at line 24 of file fwd.hh.

Member Typedef Documentation

template<typename Context >
using vcsn::rat::printer< Context >::atom_t = typename super_t:: atom_t
private

Definition at line 59 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::complement_t = typename super_t:: complement_t
private

Definition at line 60 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::conjunction_t = typename super_t:: conjunction_t
private

Definition at line 61 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::context_t = context_t_of<ratexpset_t>

Definition at line 24 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::identities_t = typename ratexpset_t::identities_t

Definition at line 25 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::inner_t = typename super_t::inner_t

Definition at line 29 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::ldiv_t = typename super_t:: ldiv_t
private

Definition at line 62 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::leaf_t = typename super_t::leaf_t

Definition at line 34 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::lweight_t = typename super_t:: lweight_t
private

Definition at line 63 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::node_t = typename super_t::node_t

Definition at line 28 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::one_t = typename super_t:: one_t
private

Definition at line 64 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::prod_t = typename super_t:: prod_t
private

Definition at line 65 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::ratexpset_t = RatExpSet

Definition at line 23 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::rweight_t = typename super_t:: rweight_t
private

Definition at line 66 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::shuffle_t = typename super_t:: shuffle_t
private

Definition at line 67 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::star_t = typename super_t:: star_t
private

Definition at line 68 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::sum_t = typename super_t:: sum_t
private

Definition at line 69 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::super_t = typename ratexpset_t::const_visitor

Definition at line 27 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::transposition_t = typename super_t:: transposition_t
private

Definition at line 70 of file printer.hh.

template<typename Context >
template<type_t Type>
using vcsn::rat::printer< Context >::unary_t = typename super_t::template unary_t<Type>

Definition at line 31 of file printer.hh.

template<typename Context >
template<type_t Type>
using vcsn::rat::printer< Context >::variadic_t = typename super_t::template variadic_t<Type>

Definition at line 33 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::weight_t = typename context_t::weightset_t::value_t

Definition at line 26 of file printer.hh.

template<typename Context >
using vcsn::rat::printer< Context >::zero_t = typename super_t:: zero_t
private

Definition at line 71 of file printer.hh.

Member Enumeration Documentation

template<typename Context >
enum vcsn::rat::printer::precedence_t
strongprivate

The possible node precedence levels, increasing.

When printing a word (i.e., a label with several letters), beware that it may require parens. Think of star(atom(ab)): if we print it as 'ab*', it actually means 'a(b*)'. Then give words a precedence lower than that of star. This is the role of 'word' below.

Enumerator
sum 
shuffle 
conjunction 
ldiv 
prod 
word 
lweight 
rweight 
star 
complement 
transposition 
zero 
one 
atom 

Definition at line 89 of file printer.hh.

Constructor & Destructor Documentation

template<typename RatExpSet >
vcsn::rat::printer< RatExpSet >::printer ( const ratexpset_t rs,
std::ostream &  out,
const bool  debug = !!getenv("VCSN_PARENS") 
)
inline

Definition at line 41 of file printer.hxx.

Member Function Documentation

template<typename RatExpSet >
auto vcsn::rat::printer< RatExpSet >::format ( symbol  format)
inline

Set output format.

Definition at line 75 of file printer.hxx.

References vcsn::dyn::detail::product_(), vcsn::rat::series, vcsn::dyn::detail::shuffle_(), and vcsn::str_escape().

Here is the call graph for this function:

template<typename Context >
bool vcsn::rat::printer< Context >::is_word_ ( const node_t v) const
inlineprivate

Whether is an atom whose label is not a letter.

Definition at line 76 of file printer.hh.

References vcsn::rat::printer< Context >::ctx_.

template<typename RatExpSet >
auto vcsn::rat::printer< RatExpSet >::operator() ( const node_t v)
inline

Entry point: print v.

Definition at line 57 of file printer.hxx.

References vcsn::address(), vcsn::decendl(), vcsn::incendl(), vcsn::print(), and vcsn::rat::series.

Referenced by vcsn::rat::printer< Context >::operator()().

Here is the call graph for this function:

template<typename Context >
std::ostream& vcsn::rat::printer< Context >::operator() ( const std::shared_ptr< const node_t > &  v)
inline

Entry point: print v.

Definition at line 48 of file printer.hh.

References vcsn::rat::printer< Context >::operator()().

Here is the call graph for this function:

template<typename RatExpSet >
auto vcsn::rat::printer< RatExpSet >::precedence_ ( const node_t v) const
inlineprivate

The precedence of v (to decide when to print parens).

Definition at line 126 of file printer.hxx.

References CASE.

template<typename Context >
template<rat::exp::type_t Type>
void vcsn::rat::printer< Context >::print_ ( const unary_t< Type > &  n,
const char op 
)
private

Print a unary node.

Referenced by vcsn::rat::printer< Context >::visit().

template<typename Context >
template<rat::exp::type_t Type>
void vcsn::rat::printer< Context >::print_ ( const variadic_t< Type > &  n,
const char op 
)
private

Print an n-ary node.

template<typename Context >
template<type_t Type>
auto vcsn::rat::printer< Context >::print_ ( const unary_t< Type > &  v,
const char op 
) -> void
inline

Definition at line 216 of file printer.hxx.

template<typename Context >
template<type_t Type>
auto vcsn::rat::printer< Context >::print_ ( const variadic_t< Type > &  n,
const char op 
) -> void
inline

Definition at line 227 of file printer.hxx.

template<typename RatExpSet >
auto vcsn::rat::printer< RatExpSet >::print_child_ ( const node_t child,
const node_t parent 
)
inlineprivate

Print the given child node, also knowing its parent.

Definition at line 192 of file printer.hxx.

template<typename Context >
ATTRIBUTE_PURE bool vcsn::rat::printer< Context >::shows_left_weight_ ( const node_t n)
inlineprivate

Whether the left weight shows.

Definition at line 123 of file printer.hh.

References vcsn::rat::lweight.

template<typename RatExpSet >
auto vcsn::rat::printer< RatExpSet >::visit ( const atom_t v)
inlineprivatevirtual

Definition at line 187 of file printer.hxx.

template<typename Context >
virtual void vcsn::rat::printer< Context >::visit ( const complement_t v)
inlineprivatevirtual

Definition at line 60 of file printer.hh.

References vcsn::rat::printer< Context >::complement_, and vcsn::rat::printer< Context >::print_().

Here is the call graph for this function:

template<typename Context >
virtual void vcsn::rat::printer< Context >::visit ( const conjunction_t v)
inlineprivatevirtual

Definition at line 61 of file printer.hh.

References vcsn::rat::printer< Context >::conjunction_, and vcsn::rat::printer< Context >::print_().

Here is the call graph for this function:

template<typename Context >
virtual void vcsn::rat::printer< Context >::visit ( const ldiv_t v)
inlineprivatevirtual

Definition at line 62 of file printer.hh.

References vcsn::rat::printer< Context >::ldiv_, and vcsn::rat::printer< Context >::print_().

Here is the call graph for this function:

template<typename RatExpSet >
auto vcsn::rat::printer< RatExpSet >::visit ( const lweight_t v)
inlineprivatevirtual

Definition at line 159 of file printer.hxx.

template<typename RatExpSet >
auto vcsn::rat::printer< RatExpSet >::visit ( const one_t v)
inlineprivatevirtual

Definition at line 181 of file printer.hxx.

template<typename Context >
virtual void vcsn::rat::printer< Context >::visit ( const prod_t v)
inlineprivatevirtual

Definition at line 65 of file printer.hh.

References vcsn::rat::printer< Context >::print_(), and vcsn::rat::printer< Context >::product_.

Here is the call graph for this function:

template<typename RatExpSet >
auto vcsn::rat::printer< RatExpSet >::visit ( const rweight_t v)
inlineprivatevirtual

Definition at line 167 of file printer.hxx.

template<typename Context >
virtual void vcsn::rat::printer< Context >::visit ( const shuffle_t v)
inlineprivatevirtual

Definition at line 67 of file printer.hh.

References vcsn::rat::printer< Context >::print_(), and vcsn::rat::printer< Context >::shuffle_.

Here is the call graph for this function:

template<typename Context >
virtual void vcsn::rat::printer< Context >::visit ( const star_t v)
inlineprivatevirtual

Definition at line 68 of file printer.hh.

References vcsn::rat::printer< Context >::print_(), and vcsn::rat::printer< Context >::star_.

Here is the call graph for this function:

template<typename Context >
virtual void vcsn::rat::printer< Context >::visit ( const sum_t v)
inlineprivatevirtual

Definition at line 69 of file printer.hh.

References vcsn::rat::printer< Context >::print_(), and vcsn::rat::printer< Context >::sum_.

Here is the call graph for this function:

template<typename Context >
virtual void vcsn::rat::printer< Context >::visit ( const transposition_t v)
inlineprivatevirtual

Definition at line 70 of file printer.hh.

References vcsn::rat::printer< Context >::print_(), and vcsn::rat::printer< Context >::transposition_.

Here is the call graph for this function:

template<typename RatExpSet >
auto vcsn::rat::printer< RatExpSet >::visit ( const zero_t v)
inlineprivatevirtual

Definition at line 175 of file printer.hxx.

Member Data Documentation

template<typename Context >
const char* vcsn::rat::printer< Context >::complement_ = nullptr
private

Definition at line 157 of file printer.hh.

Referenced by vcsn::rat::printer< Context >::visit().

template<typename Context >
const char* vcsn::rat::printer< Context >::conjunction_ = nullptr
private

Definition at line 159 of file printer.hh.

Referenced by vcsn::rat::printer< Context >::visit().

template<typename Context >
const context_t& vcsn::rat::printer< Context >::ctx_
private

Context to decode labels and weights.

Definition at line 133 of file printer.hh.

Referenced by vcsn::rat::printer< Context >::is_word_().

template<typename Context >
const bool vcsn::rat::printer< Context >::debug_
private

Whether to be overly verbose.

Definition at line 136 of file printer.hh.

template<typename Context >
std::string vcsn::rat::printer< Context >::format_
private

Output format.

Definition at line 131 of file printer.hh.

template<typename Context >
const identities_t vcsn::rat::printer< Context >::identities_
private

Definition at line 134 of file printer.hh.

template<typename Context >
const char* vcsn::rat::printer< Context >::langle_ = nullptr
private

Left and right angle brackets for weights.

Definition at line 145 of file printer.hh.

template<typename Context >
const char* vcsn::rat::printer< Context >::ldiv_ = nullptr
private

Quotient.

Definition at line 154 of file printer.hh.

Referenced by vcsn::rat::printer< Context >::visit().

template<typename Context >
const char* vcsn::rat::printer< Context >::lgroup_ = nullptr
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 142 of file printer.hh.

template<typename Context >
const char* vcsn::rat::printer< Context >::lmul_ = nullptr
private

External product.

Definition at line 151 of file printer.hh.

template<typename Context >
const char* vcsn::rat::printer< Context >::lparen_ = nullptr
private

Left and right parentheses.

Definition at line 148 of file printer.hh.

template<typename Context >
const char* vcsn::rat::printer< Context >::one_ = nullptr
private

Definition at line 165 of file printer.hh.

template<typename Context >
std::ostream& vcsn::rat::printer< Context >::out_
private

Output stream.

Definition at line 129 of file printer.hh.

template<typename Context >
const char* vcsn::rat::printer< Context >::product_ = nullptr
private

Definition at line 161 of file printer.hh.

Referenced by vcsn::rat::printer< Context >::visit().

template<typename Context >
const char* vcsn::rat::printer< Context >::rangle_ = nullptr
private

Definition at line 146 of file printer.hh.

template<typename Context >
const char* vcsn::rat::printer< Context >::rgroup_ = nullptr
private

Definition at line 143 of file printer.hh.

template<typename Context >
const char* vcsn::rat::printer< Context >::rmul_ = nullptr
private

Definition at line 152 of file printer.hh.

template<typename Context >
const char* vcsn::rat::printer< Context >::rparen_ = nullptr
private

Definition at line 149 of file printer.hh.

template<typename Context >
const char* vcsn::rat::printer< Context >::shuffle_ = nullptr
private

Definition at line 160 of file printer.hh.

Referenced by vcsn::rat::printer< Context >::visit().

template<typename Context >
const char* vcsn::rat::printer< Context >::star_ = nullptr
private

The ratexp operators.

Definition at line 156 of file printer.hh.

Referenced by vcsn::rat::printer< Context >::visit().

template<typename Context >
const char* vcsn::rat::printer< Context >::sum_ = nullptr
private

Definition at line 162 of file printer.hh.

Referenced by vcsn::rat::printer< Context >::visit().

template<typename Context >
const char* vcsn::rat::printer< Context >::transposition_ = nullptr
private

Definition at line 158 of file printer.hh.

Referenced by vcsn::rat::printer< Context >::visit().

template<typename Context >
const char* vcsn::rat::printer< Context >::zero_ = nullptr
private

The constants.

Definition at line 164 of file printer.hh.


The documentation for this class was generated from the following files: