6 #include <boost/range/algorithm/mismatch.hpp> 
    7 #include <boost/algorithm/string/predicate.hpp>  
   21   template <
typename GenSet>
 
   22   class wordset: 
public detail::genset_labelset<GenSet>
 
   31     using word_t = 
typename genset_t::word_t;
 
   43       : 
wordset{std::make_shared<const genset_t>(gs)}
 
   46     wordset(std::initializer_list<letter_t> letters)
 
   63       auto gs = genset_t::make(is);
 
   73       return this->
genset()->open(o);
 
   82     template <
typename... Args>
 
   85       return value_t{std::forward<Args>(args)...};
 
  119       return genset_t::less(l, r);
 
  133         return genset_t::less(l, r);
 
  139       return genset_t::template special<value_t>();
 
  157     static constexpr 
bool 
  163     static constexpr 
bool 
  169     static constexpr 
bool 
  178       return genset_t::empty_word();
 
  184       return genset_t::is_empty_word(l);
 
  205     template <
typename GenSet_>
 
  216                        *
this, 
": conv: invalid label: ", 
str_escape(v));
 
  221     template <
typename LabelSet_>
 
  234     conv(std::istream& i, 
bool = 
true)
 const 
  236       return this->
genset()->get_word(i);
 
  248     template <
typename Fun>
 
  249     void convs(std::istream& i, Fun fun)
 const 
  261         this->
genset()->print(l, o, fmt);
 
  271           this->
genset()->print_set(o, fmt);
 
  276           this->
genset()->print_set(o, fmt);
 
  281           this->genset()->print_set(o, fmt); 
  292     static value_t lgcd(const value_t& w1, const value_t& w2) 
  294       return {w1.begin(), boost::mismatch(w1, w2).first}; 
  299     static value_t ldiv(const value_t& w1, const value_t& w2) 
  301       using boost::algorithm::starts_with; 
  302       VCSN_REQUIRE(starts_with(w2, w1), 
  303                    sname(), ": ldiv: invalid arguments: ", str_escape(w1), 
  304                    ", ", str_escape(w2)); 
  305       return {begin(w2) + size(w1), end(w2)}; 
  309     static value_t& ldiv_here(const value_t& w1, value_t& w2) 
  315     const value_t& conjunction(const value_t& l, const value_t& r) const 
  320         raise("conjunction: invalid operation (lhs and rhs are not equal)"); 
  327     template <typename GenSet> 
  328     struct letterized_traits<wordset<GenSet>> 
  330       static constexpr bool is_letterized = false; 
  332       using labelset_t = nullableset<letterset<GenSet>>; 
  334       static labelset_t labelset(const wordset<GenSet>& ls) 
  336         return {ls.genset()}; 
  341     template <typename GenSet> 
  342     struct nullableset_traits<wordset<GenSet>> 
  344       using type = wordset<GenSet>; 
  345       static type value(const wordset<GenSet>& ls) 
  351     template <typename GenSet> 
  352     struct law_traits<wordset<GenSet>> 
  354       using type = wordset<GenSet>; 
  355       static type value(const wordset<GenSet>& ls) 
  366 #define DEFINE(Lhs, Rhs)                                  \ 
  367     template <typename GenSet>                            \ 
  368     struct join_impl<Lhs, Rhs>                            \ 
  371       static type join(const Lhs& lhs, const Rhs& rhs)    \ 
  373         return {set_union(*lhs.genset(), *rhs.genset())}; \ 
  378     DEFINE(letterset<GenSet>,              wordset<GenSet>); 
  379     DEFINE(nullableset<letterset<GenSet>>, wordset<GenSet>); 
  380     DEFINE(wordset<GenSet>,                wordset<GenSet>); 
  385   // FIXME: Factor in genset_labelset? 
  386   template <typename GenSet> 
  388   meet(const wordset<GenSet>& lhs, const wordset<GenSet>& rhs) 
  390     return {set_intersection(*lhs.genset(), *rhs.genset())}; 
ATTRIBUTE_PURE auto has(Args &&...args) const  -> decltype(this->genset() -> has(std::forward< Args >(args)...))
std::istringstream is
The input stream: the specification to translate. 
auto hash_value(const T &v) -> decltype(std::hash< T >
Following the naming convention of Boost. 
Provide a variadic mul on top of a binary mul(), and one(). 
static size_t hash(const value_t &v)
bool open(bool o) const 
Whether unknown letters should be added, or rejected. 
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string. 
wordset(const genset_t &gs={})
Implementation of labels are words. 
static bool is_special(value_t v) ATTRIBUTE_PURE
static bool is_one(const value_t &l) ATTRIBUTE_PURE
typename helper_t::value_t value_t
static bool is_special(const value_t &v)
value_t value(Args &&...args) const 
Value constructor. 
word_t word(const value_t &v) const 
Convert to a word. 
void convs(std::istream &i, Fun fun) const 
Process a label class. 
static constexpr bool is_free()
Implementation of labels are nullables (letter or empty). 
Print as a parsable type string. 
static labelset_t::value_t get_value(const value_t &v)
The (inner) value when it (the outer value) is not one. 
value_t conv(std::istream &i, bool=true) const 
Read a word from this stream. 
Implementation of labels are letters. 
std::ostream & print_set(std::ostream &o, format fmt={}) const 
static constexpr bool is_letterized()
#define VCSN_REQUIRE(Cond,...)                              
A macro similar to require. 
wordset(std::initializer_list< letter_t > letters)
typename genset_t::letter_t letter_t
void convs_(std::istream &i, Fun fun) const 
Read and process a class of letters. 
std::ostream & print(const value_t &l, std::ostream &o, format fmt={}) const 
static wordset make(std::istream &is)
Build from the description in is. 
typename genset_t::word_t word_t
std::ostream & str_escape(std::ostream &os, const std::string &str, const char *special=nullptr)
Output a string, escaping special characters. 
This class has no modeling purpose, it only serves to factor code common to letterset and wordset...
value_t conv(const nullableset< LabelSet_ > &ls, const typename nullableset< LabelSet_ >::value_t &v) const 
typename genset_t::letters_t letters_t
static bool equal(const value_t &l, const value_t &r)
Whether l == r. 
static ATTRIBUTE_PURE bool is_one(value_t l)
weightset_mixin< detail::r_impl > r
static constexpr bool is_expressionset()
char eat(std::istream &is, char c)
Check lookahead character and advance. 
static word_t letters_of(const value_t &v)
Prepare to iterate over the letters of v. 
static word_t letters_of_padded(const value_t &v, letter_t)
Prepare to iterate over the letters of v. 
const labelset_ptr labelset() const 
value_t conv(self_t, const value_t &v) const 
static size_t size(const value_t &v)
static bool less(const value_t &l, const value_t &r)
Whether l < r. 
value_t conv(const letterset< GenSet_ > &ls, typename letterset< GenSet_ >::value_t v) const 
bool is_valid(const value_t &v) const 
static bool less(const letter_t &l, const letter_t &r)
Whether l < r. 
genset_ptr genset() const 
static constexpr bool has_one()
std::shared_ptr< const genset_t > genset_ptr
wordset(const genset_ptr &gs)
An input/output format for valuesets.