Vcsn  2.3a
Be Rational
vcsn::rat Namespace Reference

Classes

class  atom
 
struct  braced_expression
 An expression that "remembers" whether it was in parentheses. More...
 
class  const_visitor
 
class  constant
 
class  constant_term_visitor
 A functor to compute the constant term of an expression. More...
 
class  copy_impl
 Functor to copy/convert a rational expression. More...
 
class  derivation_visitor
 Functor to compute the derivation of an expression. More...
 
class  dot_printer
 Pretty-printer for rational expressions. More...
 
class  driver
 State and public interface for rational expression parsing. More...
 
class  exp
 The abstract, non-parameterized, root for all rational expression node types. More...
 
struct  expansionset
 
class  expressionset_impl
 A typed expression set. More...
 
class  hash
 
class  identities
 An expressionset can implement several different sets of identities on expressions. More...
 
class  inductive_visitor
 Build an automaton by induction from an expression. More...
 
class  info
 Gather information of the number of the different node types. More...
 
class  inner
 An inner node. More...
 
class  leaf
 The root from which to derive the final node types. More...
 
class  less
 A functor to check whether one rational expression is (strictly) less than another one. More...
 
class  location
 Abstract a location. More...
 
class  node
 The abstract parameterized, root for all rational expression types. More...
 
class  parser
 A Bison parser. More...
 
class  partial_identity_impl
 Functor to partial_identity/convert a rational expression. More...
 
class  position
 Abstract a position. More...
 
class  printer
 Pretty-printer for rational expressions. More...
 
class  project_impl
 Functor to project a rational expression. More...
 
class  sizer
 Functor to compute the size of a rational expression. More...
 
class  slice
 Present a slice of the top of a stack. More...
 
class  split_visitor
 Break a rational expression into a polynomial. More...
 
class  stack
 
class  standard_visitor
 Build a standard automaton from an expression. More...
 
class  star_normal_form_visitor
 
class  thompson_visitor
 Build a Thompson automaton from an expression. More...
 
class  to_expansion_visitor
 Functor to compute the expansion of an expression. More...
 
class  tuple
 Implementation of nodes of tuple of rational expressions. More...
 
class  tuple< Context, false >
 
class  unary
 
class  variadic
 An inner node with multiple children. More...
 
struct  variant
 A char[S] buffer to store and retrieve objects. More...
 
class  weight_node
 An inner node implementing a weight. More...
 
class  zpc_visitor
 Build a ZPC automaton from an expression. More...
 

Typedefs

template<typename ExpSet >
using expression_polynomialset_t = polynomialset< context< ExpSet, weightset_t_of< ExpSet >>>
 Type of PolynomialSet of expressions from the ExpSet type. More...
 
template<typename ExpSet >
using expression_polynomial_t = typename expression_polynomialset_t< ExpSet >::value_t
 Type of polynomials of expressions from the ExpSet type. More...
 
using exp_t = std::shared_ptr< const exp >
 
template<typename Context >
using zero = constant< type_t::zero, Context >
 
template<typename Context >
using one = constant< type_t::one, Context >
 
template<typename Context >
using complement = unary< type_t::complement, Context >
 
template<typename Context >
using star = unary< type_t::star, Context >
 
template<typename Context >
using transposition = unary< type_t::transposition, Context >
 
template<typename Context >
using compose = variadic< type_t::compose, Context >
 
template<typename Context >
using conjunction = variadic< type_t::conjunction, Context >
 
template<typename Context >
using infiltrate = variadic< type_t::infiltrate, Context >
 
template<typename Context >
using ldivide = variadic< type_t::ldivide, Context >
 
template<typename Context >
using mul = variadic< type_t::mul, Context >
 
template<typename Context >
using shuffle = variadic< type_t::shuffle, Context >
 
template<typename Context >
using add = variadic< type_t::add, Context >
 
template<typename Context >
using lweight = weight_node< type_t::lweight, Context >
 
template<typename Context >
using rweight = weight_node< type_t::rweight, Context >
 
template<typename Context >
using expression = std::shared_ptr< const node< Context >>
 
using class_t = std::set< std::pair< std::string, std::string >>
 A set of label ranges. More...
 
using irange_type = std::tuple< int, int >
 An integer range, for quantifiers/exponents. More...
 

Enumerations

enum  type_t {
  type_t::zero, type_t::one, type_t::atom, type_t::add,
  type_t::mul, type_t::ldivide, type_t::conjunction, type_t::shuffle,
  type_t::infiltrate, type_t::star, type_t::transposition, type_t::lweight,
  type_t::rweight, type_t::complement, type_t::tuple, type_t::compose
}
 The possible types of expressions. More...
 
enum  precedence_t {
  precedence_t::add, precedence_t::compose, precedence_t::tuple, precedence_t::products,
  precedence_t::shuffle = products, precedence_t::conjunction = products, precedence_t::infiltrate = products, precedence_t::ldivide,
  precedence_t::mul, precedence_t::word = mul, precedence_t::lweight, precedence_t::rweight,
  precedence_t::unary, precedence_t::star = unary, precedence_t::complement = unary, precedence_t::transposition = unary,
  precedence_t::exponent = unary, precedence_t::zero, precedence_t::one, precedence_t::atom
}
 The possible node precedence levels, increasing. More...
 

Functions

template<typename ExpSet >
expression_polynomialset_t< ExpSet > make_expression_polynomialset (const ExpSet &rs)
 From a ExpSet to its polynomialset. More...
 
template<typename InExpSet , typename OutExpSet = InExpSet>
OutExpSet::value_t copy (const InExpSet &in_rs, const OutExpSet &out_rs, const typename InExpSet::value_t &v)
 Copy/convert a rational expression. More...
 
template<typename ExpSet >
dot_printer< ExpSet > make_dot_printer (const ExpSet &rs, std::ostream &out, bool physical=false)
 
template<typename ExpSet >
info< ExpSet > make_info (const typename ExpSet::value_t &r)
 
template<typename ExpSet >
printer< ExpSet > make_printer (const ExpSet &rs, std::ostream &out)
 
constexpr bool is_constant (type_t t)
 Whether is a constant (\\z or \\e). More...
 
constexpr bool is_unary (type_t t)
 Whether star, complement. More...
 
constexpr bool is_variadic (type_t t)
 Whether one of the variadic types. More...
 
std::ostream & operator<< (std::ostream &o, type_t t)
 Print a expression type. More...
 
template<typename ExpSet >
size_t size (const ExpSet &rs, const typename ExpSet::value_t &r)
 
std::string to_string (identities i)
 Wrapper around operator<<. More...
 
std::istream & operator>> (std::istream &is, identities &i)
 Read from string form. More...
 
std::ostream & operator<< (std::ostream &os, identities i)
 Output in string form. More...
 
identities meet (identities i1, identities i2)
 
template<typename InExpSet , typename OutExpSet = InExpSet>
OutExpSet::value_t partial_identity (const InExpSet &in_rs, const OutExpSet &out_rs, const typename InExpSet::value_t &v)
 Partial identity of a rational expression. More...
 
template<size_t Tape, typename InExpSet , typename OutExpSet >
auto project (const InExpSet &in_rs, const OutExpSet &out_rs, const typename InExpSet::value_t &v) -> typename OutExpSet::value_t
 Project a rational expression. More...
 
template<size_t Tape, typename InExpSet >
auto project (const InExpSet &in_rs, const typename InExpSet::value_t &v) -> typename InExpSet::template project_t< Tape >::value_t
 Project a rational expression. More...
 
template<typename ExpSet >
size_t size (const typename ExpSet::value_t &r)
 
static int debug_level_ ()
 The nesting limit for parser traces, as specified per $YYDEBUG. More...
 
locationoperator+= (location &res, const location &end)
 Join two locations, in place. More...
 
location operator+ (location res, const location &end)
 Join two locations. More...
 
locationoperator+= (location &res, int width)
 Add width columns to the end position, in place. More...
 
location operator+ (location res, int width)
 Add width columns to the end position. More...
 
locationoperator-= (location &res, int width)
 Subtract width columns to the end position, in place. More...
 
location operator- (location res, int width)
 Subtract width columns to the end position. More...
 
bool operator== (const location &loc1, const location &loc2)
 Compare two location objects. More...
 
bool operator!= (const location &loc1, const location &loc2)
 Compare two location objects. More...
 
template<typename YYChar >
std::basic_ostream< YYChar > & operator<< (std::basic_ostream< YYChar > &ostr, const location &loc)
 Intercept output stream redirection. More...
 
static dyn::expression prefer (const dyn::expression &e, const dyn::expression &f)
 Generate an expression for "e <+ f = e % f + f". More...
 
static dyn::context ctx (const driver &d)
 Get the context of the driver. More...
 
static identities ids (const driver &d)
 Get the identities of the driver. More...
 
static parser::symbol_type yylex (driver &d)
 Use our local scanner object. More...
 
positionoperator+= (position &res, int width)
 Add width columns, in place. More...
 
position operator+ (position res, int width)
 Add width columns. More...
 
positionoperator-= (position &res, int width)
 Subtract width columns, in place. More...
 
position operator- (position res, int width)
 Subtract width columns. More...
 
bool operator== (const position &pos1, const position &pos2)
 Compare two position objects. More...
 
bool operator!= (const position &pos1, const position &pos2)
 Compare two position objects. More...
 
template<typename YYChar >
std::basic_ostream< YYChar > & operator<< (std::basic_ostream< YYChar > &ostr, const position &pos)
 Intercept output stream redirection. More...
 
dyn::expression read (const dyn::context &ctx, rat::identities ids, std::istream &is, const location &l=location{})
 The expression in stream is. More...
 

Variables

static constexpr const char *const superscripts []
 Exponents in UTF-8. More...
 

Typedef Documentation

template<typename Context >
using vcsn::rat::add = typedef variadic<type_t::add, Context>

Definition at line 157 of file fwd.hh.

using vcsn::rat::class_t = typedef std::set<std::pair<std::string, std::string>>

A set of label ranges.

Definition at line 12 of file fwd.hh.

template<typename Context >
using vcsn::rat::complement = typedef unary<type_t::complement, Context>

Definition at line 123 of file fwd.hh.

template<typename Context >
using vcsn::rat::compose = typedef variadic<type_t::compose, Context>

Definition at line 139 of file fwd.hh.

template<typename Context >
using vcsn::rat::conjunction = typedef variadic<type_t::conjunction, Context>

Definition at line 142 of file fwd.hh.

using vcsn::rat::exp_t = typedef std::shared_ptr<const exp>

Definition at line 16 of file fwd.hh.

template<typename Context >
using vcsn::rat::expression = typedef std::shared_ptr<const node<Context>>

Definition at line 187 of file fwd.hh.

template<typename ExpSet >
using vcsn::rat::expression_polynomial_t = typedef typename expression_polynomialset_t<ExpSet>::value_t

Type of polynomials of expressions from the ExpSet type.

Definition at line 26 of file split.hh.

template<typename ExpSet >
using vcsn::rat::expression_polynomialset_t = typedef polynomialset<context<ExpSet, weightset_t_of<ExpSet>>>

Type of PolynomialSet of expressions from the ExpSet type.

Definition at line 21 of file split.hh.

template<typename Context >
using vcsn::rat::infiltrate = typedef variadic<type_t::infiltrate, Context>

Definition at line 145 of file fwd.hh.

using vcsn::rat::irange_type = typedef std::tuple<int, int>

An integer range, for quantifiers/exponents.

Definition at line 78 of file parse.hh.

template<typename Context >
using vcsn::rat::ldivide = typedef variadic<type_t::ldivide, Context>

Definition at line 148 of file fwd.hh.

template<typename Context >
using vcsn::rat::lweight = typedef weight_node<type_t::lweight, Context>

Definition at line 179 of file fwd.hh.

template<typename Context >
using vcsn::rat::mul = typedef variadic<type_t::mul, Context>

Definition at line 151 of file fwd.hh.

template<typename Context >
using vcsn::rat::one = typedef constant<type_t::one, Context>

Definition at line 113 of file fwd.hh.

template<typename Context >
using vcsn::rat::rweight = typedef weight_node<type_t::rweight, Context>

Definition at line 182 of file fwd.hh.

template<typename Context >
using vcsn::rat::shuffle = typedef variadic<type_t::shuffle, Context>

Definition at line 154 of file fwd.hh.

template<typename Context >
using vcsn::rat::star = typedef unary<type_t::star, Context>

Definition at line 126 of file fwd.hh.

template<typename Context >
using vcsn::rat::transposition = typedef unary<type_t::transposition, Context>

Definition at line 129 of file fwd.hh.

template<typename Context >
using vcsn::rat::zero = typedef constant<type_t::zero, Context>

Definition at line 110 of file fwd.hh.

Enumeration Type Documentation

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*)'. So give words a lower precedence than star. This is the role of 'word' below.

Was part of printer<ExpSet>, but it resulted in different incompatible types between, for instance, printer<lat<lal_char, lal_char>> and printer<lal_char>, which is a problem when the former calls print_child of the latter, passing an argument of type precedence_t.

Enumerator
add 
compose 
tuple 
products 
shuffle 
conjunction 
infiltrate 
ldivide 
mul 
word 
lweight 
rweight 
unary 
star 
complement 
transposition 
exponent 
zero 
one 
atom 

Definition at line 34 of file printer.hh.

enum vcsn::rat::type_t
strong

The possible types of expressions.

They also code the order in which they are sorted by less, so that, for instance, polynomials always display \\e + a, and never a + \\e.

Enumerator
zero 
one 
atom 
add 
mul 
ldivide 
conjunction 
shuffle 
infiltrate 
star 
transposition 
lweight 
rweight 
complement 
tuple 
compose 

Definition at line 39 of file fwd.hh.

Function Documentation

template<typename InExpSet , typename OutExpSet = InExpSet>
OutExpSet::value_t vcsn::rat::copy ( const InExpSet &  in_rs,
const OutExpSet &  out_rs,
const typename InExpSet::value_t &  v 
)

Copy/convert a rational expression.

Template Parameters
InExpSetthe input expressionset type.
OutExpSetthe output expressionset type.

Definition at line 174 of file copy.hh.

Referenced by vcsn::rat::expressionset_impl< Context >::conv(), vcsn::dyn::copy(), vcsn::dyn::detail::copy_expression(), and vcsn::rat::copy_impl< InExpSet, OutExpSet >::visit_tuple< Dummy >::work_().

static dyn::context vcsn::rat::ctx ( const driver d)
inlinestatic

Get the context of the driver.

Definition at line 82 of file parse.cc.

References vcsn::rat::driver::context().

Referenced by vcsn::rat::driver::context(), vcsn::rat::expressionset_impl< Context >::make(), vcsn::rat::parser::parse(), and read().

Here is the call graph for this function:

static int vcsn::rat::debug_level_ ( )
static

The nesting limit for parser traces, as specified per $YYDEBUG.

Definition at line 89 of file driver.cc.

References vcsn::res.

Referenced by vcsn::rat::driver::parse().

static identities vcsn::rat::ids ( const driver d)
inlinestatic

Get the identities of the driver.

Definition at line 89 of file parse.cc.

References vcsn::rat::driver::identities().

Referenced by vcsn::ast::context_parser::expressionset_(), vcsn::dyn::detail::lift_automaton(), vcsn::rat::expressionset_impl< Context >::make(), vcsn::rat::parser::parse(), vcsn::dyn::read_expression(), vcsn::to_expression(), and vcsn::tuple_expressionset().

Here is the call graph for this function:

constexpr bool vcsn::rat::is_constant ( type_t  t)
inline

Whether is a constant (\\z or \\e).

Definition at line 60 of file fwd.hh.

References one, and zero.

Referenced by vcsn::rat::exp::is_leaf().

constexpr bool vcsn::rat::is_unary ( type_t  t)
inline

Whether star, complement.

Definition at line 67 of file fwd.hh.

References complement, star, and transposition.

Referenced by vcsn::rat::exp::is_unary().

constexpr bool vcsn::rat::is_variadic ( type_t  t)
inline

Whether one of the variadic types.

Definition at line 75 of file fwd.hh.

References add, compose, conjunction, infiltrate, ldivide, mul, and shuffle.

template<typename ExpSet >
dot_printer<ExpSet> vcsn::rat::make_dot_printer ( const ExpSet &  rs,
std::ostream &  out,
bool  physical = false 
)

Definition at line 421 of file dot.hh.

References vcsn::detail::out(), and vcsn::detail::rs.

Referenced by vcsn::print().

Here is the call graph for this function:

template<typename ExpSet >
expression_polynomialset_t<ExpSet> vcsn::rat::make_expression_polynomialset ( const ExpSet &  rs)

From a ExpSet to its polynomialset.

Definition at line 31 of file split.hh.

References vcsn::detail::rs.

Referenced by vcsn::dyn::derivation(), vcsn::derivation(), vcsn::split(), and vcsn::dyn::split().

template<typename ExpSet >
info< ExpSet > vcsn::rat::make_info ( const typename ExpSet::value_t &  r)

Definition at line 195 of file info.hh.

template<typename ExpSet >
printer< ExpSet > vcsn::rat::make_printer ( const ExpSet &  rs,
std::ostream &  out 
)
identities vcsn::rat::meet ( identities  i1,
identities  i2 
)

Definition at line 76 of file identities.cc.

Referenced by vcsn::meet().

bool vcsn::rat::operator!= ( const position pos1,
const position pos2 
)
inline

Compare two position objects.

Definition at line 159 of file position.hh.

bool vcsn::rat::operator!= ( const location loc1,
const location loc2 
)
inline

Compare two location objects.

Definition at line 161 of file location.hh.

location vcsn::rat::operator+ ( location  res,
const location end 
)
inline

Join two locations.

Definition at line 122 of file location.hh.

position vcsn::rat::operator+ ( position  res,
int  width 
)
inline

Add width columns.

Definition at line 127 of file position.hh.

location vcsn::rat::operator+ ( location  res,
int  width 
)
inline

Add width columns to the end position.

Definition at line 135 of file location.hh.

location& vcsn::rat::operator+= ( location res,
const location end 
)
inline

Join two locations, in place.

Definition at line 115 of file location.hh.

References vcsn::res.

position& vcsn::rat::operator+= ( position res,
int  width 
)
inline

Add width columns, in place.

Definition at line 119 of file position.hh.

References vcsn::res.

location& vcsn::rat::operator+= ( location res,
int  width 
)
inline

Add width columns to the end position, in place.

Definition at line 128 of file location.hh.

References vcsn::res.

position vcsn::rat::operator- ( position  res,
int  width 
)
inline

Subtract width columns.

Definition at line 141 of file position.hh.

location vcsn::rat::operator- ( location  res,
int  width 
)
inline

Subtract width columns to the end position.

Definition at line 147 of file location.hh.

position& vcsn::rat::operator-= ( position res,
int  width 
)
inline

Subtract width columns, in place.

Definition at line 134 of file position.hh.

location& vcsn::rat::operator-= ( location res,
int  width 
)
inline

Subtract width columns to the end position, in place.

Definition at line 141 of file location.hh.

std::ostream & vcsn::rat::operator<< ( std::ostream &  o,
type_t  t 
)
inline

Print a expression type.

Definition at line 13 of file printer.hxx.

References CASE.

std::ostream & vcsn::rat::operator<< ( std::ostream &  os,
identities  i 
)

Output in string form.

Definition at line 62 of file identities.cc.

References to_string().

Here is the call graph for this function:

template<typename YYChar >
std::basic_ostream<YYChar>& vcsn::rat::operator<< ( std::basic_ostream< YYChar > &  ostr,
const position pos 
)
inline

Intercept output stream redirection.

Parameters
ostrthe destination output stream
posa reference to the position to redirect

Definition at line 170 of file position.hh.

References vcsn::rat::position::filename.

template<typename YYChar >
std::basic_ostream<YYChar>& vcsn::rat::operator<< ( std::basic_ostream< YYChar > &  ostr,
const location loc 
)
inline

Intercept output stream redirection.

Parameters
ostrthe destination output stream
loca reference to the location to redirect

Avoid duplicate information.

Definition at line 174 of file location.hh.

References vcsn::rat::position::column, vcsn::rat::location::end, and vcsn::if().

Here is the call graph for this function:

bool vcsn::rat::operator== ( const position pos1,
const position pos2 
)
inline

Compare two position objects.

Definition at line 148 of file position.hh.

bool vcsn::rat::operator== ( const location loc1,
const location loc2 
)
inline

Compare two location objects.

Definition at line 154 of file location.hh.

std::istream & vcsn::rat::operator>> ( std::istream &  is,
identities i 
)

Read from string form.

Definition at line 67 of file identities.cc.

template<typename InExpSet , typename OutExpSet = InExpSet>
OutExpSet::value_t vcsn::rat::partial_identity ( const InExpSet &  in_rs,
const OutExpSet &  out_rs,
const typename InExpSet::value_t &  v 
)

Partial identity of a rational expression.

Template Parameters
InExpSetthe input expressionset type.
OutExpSetthe output expressionset type.
InExpSetthe input expressionset type
OutExpSetthe output expressionset type

Definition at line 195 of file partial-identity.hh.

Referenced by vcsn::dyn::partial_identity(), and vcsn::rat::partial_identity_impl< InExpSet, OutExpSet >::visit_tuple< bool, Dummy >::work_().

static dyn::expression vcsn::rat::prefer ( const dyn::expression e,
const dyn::expression f 
)
inlinestatic

Generate an expression for "e <+ f = e % f + f".

Definition at line 1483 of file parse.cc.

References add, complement, and conjunction.

Referenced by vcsn::rat::parser::parse().

template<size_t Tape, typename InExpSet , typename OutExpSet >
auto vcsn::rat::project ( const InExpSet &  in_rs,
const OutExpSet &  out_rs,
const typename InExpSet::value_t &  v 
) -> typename OutExpSet::value_t

Project a rational expression.

Template Parameters
Tapethe selected tape
InExpSetthe input expressionset type
OutExpSetthe output expressionset type

Definition at line 163 of file project.hh.

References vcsn::v.

template<size_t Tape, typename InExpSet >
auto vcsn::rat::project ( const InExpSet &  in_rs,
const typename InExpSet::value_t &  v 
) -> typename InExpSet::template project_t<Tape>::value_t

Project a rational expression.

Template Parameters
Tapethe selected tape
InExpSetthe expressionset type

Definition at line 177 of file project.hh.

References vcsn::v.

dyn::expression vcsn::rat::read ( const dyn::context ctx,
rat::identities  ids,
std::istream &  is,
const location l 
)

The expression in stream is.

Definition at line 11 of file read.cc.

References ctx(), and vcsn::res.

Referenced by vcsn::dyn::read_expression().

Here is the call graph for this function:

template<typename ExpSet >
size_t vcsn::rat::size ( const typename ExpSet::value_t &  r)

Definition at line 128 of file size.hh.

static parser::symbol_type vcsn::rat::yylex ( driver d)
inlinestatic

Use our local scanner object.

Definition at line 96 of file parse.cc.

References vcsn::rat::driver::scanner_.

Referenced by vcsn::rat::parser::parse().

Variable Documentation

constexpr const char* const vcsn::rat::superscripts[]
static
Initial value:
=
{
"⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹"
}

Exponents in UTF-8.

Definition at line 59 of file printer.hh.