19 template <
typename GenSet>
20 class letterset:
public detail::genset_labelset<GenSet>
29 using word_t =
typename genset_t::word_t;
30 using letters_t = std::set<letter_t, vcsn::less<self_t, letter_t>>;
33 using values_t = std::set<value_t, vcsn::less<self_t>>;
42 :
letterset(std::make_shared<const genset_t>(gs))
61 eat(is,
"letterset<");
62 auto gs = genset_t::make(is);
72 return this->
genset()->open(o);
81 template <
typename... Args>
84 return value_t{std::forward<Args>(args)...};
127 return genset_t::template special<value_t>();
134 return genset_t::equal(l, r);
140 return genset_t::less(l, r);
143 static constexpr
bool
149 static constexpr
bool
155 static constexpr
bool
167 static constexpr
bool
193 *
this,
": conv: invalid label: ",
str_escape(v));
198 template <
typename LabelSet_>
204 *
this,
": conv: invalid label: \\e");
210 conv(std::istream& i,
bool quoted =
true)
const
214 if (i.good() && i.peek() ==
'\\')
218 *
this,
": cannot represent \\e");
233 template <
typename Fun>
234 void convs(std::istream& i, Fun fun)
const
257 raise(*
this,
": lgcd: impossible operation");
263 raise(*
this,
": ldivide: impossible operation");
271 raise(
"conjunction: invalid operation (lhs and rhs are not equal)");
278 return this->
genset()->print(l, o, fmt);
287 this->
genset()->print_set(o, fmt);
291 this->
genset()->print_set(o, fmt);
296 this->genset()->print_set(o, fmt);
309 template <typename GenSet>
310 struct letterized_traits<letterset<GenSet>>
312 static constexpr bool is_letterized = true;
314 using labelset_t = nullableset<letterset<GenSet>>;
316 static labelset_t labelset(const letterset<GenSet>& ls)
318 return {ls.genset()};
323 template <typename GenSet>
324 struct nullableset_traits<letterset<GenSet>>
326 using type = nullableset<letterset<GenSet>>;
327 static type value(const letterset<GenSet>& ls)
334 template <typename GenSet>
335 struct law_traits<letterset<GenSet>>
337 using type = wordset<GenSet>;
338 static type value(const letterset<GenSet>& ls)
348 template <typename GenSet>
349 struct join_impl<letterset<GenSet>, letterset<GenSet>>
351 using type = letterset<GenSet>;
352 static type join(const letterset<GenSet>& lhs,
353 const letterset<GenSet>& rhs)
355 return {set_union(*lhs.genset(), *rhs.genset())};
361 template <typename GenSet>
363 meet(const letterset<GenSet>& lhs, const letterset<GenSet>& rhs)
365 return {set_intersection(*lhs.genset(), *rhs.genset())};
static ATTRIBUTE_PURE bool is_one(value_t l)
value_t conv(std::istream &i, bool quoted=true) const
Read one letter from i, return the corresponding label.
static size_t hash(value_t v)
value_t ldivide(value_t, value_t) const
Compute w1 \ w2 = w1^{-1}w2.
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
static value_t special() ATTRIBUTE_PURE
static labelset_t::value_t get_value(const value_t &v)
The (inner) value when it (the outer value) is not one.
static word_t letters_of(letter_t v)
Prepare to iterate over v.
std::shared_ptr< const genset_t > genset_ptr
std::ostream & print(const value_t &l, std::ostream &o=std::cout, format fmt={}) const
std::ostream & str_escape(std::ostream &os, const std::string &str, const char *special=nullptr)
Output a string, escaping special characters.
Implementation of labels are letters.
static bool equal(const value_t l, const value_t r)
Whether l == r.
void convs(std::istream &i, Fun fun) const
Process a label class.
typename helper_t::value_t value_t
letterset(const genset_ptr &gs)
Print as a parsable type string.
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
letter_t get_letter(std::istream &i, bool quoted=true) const
Read one letter from i.
static word_t letters_of_padded(letter_t v, letter_t)
Prepare to iterate over v.
bool is_valid(value_t v) const
Implementation of labels are nullables (letter or empty).
void convs_(std::istream &i, Fun fun) const
Read and process a class of letters.
static constexpr bool has_one()
auto hash_value(const T &v) -> decltype(std::hash< T >
Following the naming convention of Boost.
value_t lgcd(value_t, value_t) const
The longest common prefix.
This class has no modeling purpose, it only serves to factor code common to letterset and wordset...
typename genset_t::letters_t letters_t
value_t conjunction(const value_t &l, const value_t &r) const
value_t conv(const nullableset< LabelSet_ > &ls, typename nullableset< LabelSet_ >::value_t v) const
Convert from nullableset to letterset.
typename genset_t::word_t word_t
genset_ptr genset() const
static letterset make(std::istream &is)
Build from the description in is.
static bool less(const value_t l, const value_t r)
Whether l < r.
value_t conv(self_t, value_t v) const
#define VCSN_REQUIRE(Cond,...)
A macro similar to require.
static constexpr bool is_letterized()
letterset(std::initializer_list< letter_t > letters)
static constexpr bool is_expressionset()
static constexpr bool is_free()
An input/output format for valuesets.
ATTRIBUTE_PURE auto has(Args &&...args) const -> decltype(this->genset() -> has(std::forward< Args >(args)...))
static size_t size(value_t)
static word_t letters_of_padded(word_t v, letter_t)
Prepare to iterate over the letters of v.
typename genset_t::word_t word_t
value_t value(Args &&...args) const
Value constructor.
bool open(bool o) const
Whether unknown letters should be added, or rejected.
static word_t letters_of(word_t v)
Prepare to iterate over the letters of v.
typename genset_t::letter_t letter_t
static word_t word(value_t v)
Convert to a word.
static bool is_special(value_t v) ATTRIBUTE_PURE
static constexpr bool is_one(value_t)
letterset(const genset_t &gs={})
const labelset_ptr labelset() const
typename genset_t::letter_t letter_t
Provide a variadic mul on top of a binary mul(), and one().
char eat(std::istream &is, char c)
Check lookahead character and advance.
std::set< value_t, vcsn::less< self_t >> values_t
std::ostream & print_set(std::ostream &o, format fmt={}) const