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))
45 letterset(
const std::initializer_list<letter_t>& letters)
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
221 template <
typename Fun>
222 void convs(std::istream& i, Fun fun)
const
245 raise(
sname(),
": lgcd: impossible operation");
251 raise(
sname(),
": ldiv: impossible operation");
258 return this->
genset().print(l, o, fmt);
265 this->
genset().print_set(o, fmt);
269 this->
genset().print_set(o, fmt);
273 raise("invalid format: ", fmt);
281 template <typename GenSet>
282 struct letterized_traits<letterset<GenSet>>
284 static constexpr bool is_letterized = true;
286 using labelset_t = nullableset<letterset<GenSet>>;
288 static labelset_t labelset(const letterset<GenSet>& ls)
290 return {ls.genset()};
295 template <typename GenSet>
296 struct nullableset_traits<letterset<GenSet>>
298 using type = nullableset<letterset<GenSet>>;
299 static type value(const letterset<GenSet>& ls)
306 template <typename GenSet>
307 struct law_traits<letterset<GenSet>>
309 using type = wordset<GenSet>;
310 static type value(const letterset<GenSet>& ls)
320 template <typename GenSet>
321 struct join_impl<letterset<GenSet>, letterset<GenSet>>
323 using type = letterset<GenSet>;
324 static type join(const letterset<GenSet>& lhs,
325 const letterset<GenSet>& rhs)
327 return {get_union(lhs.genset(), rhs.genset())};
333 template <typename GenSet>
335 meet(const letterset<GenSet>& lhs, const letterset<GenSet>& rhs)
337 return {intersection(lhs.genset(), rhs.genset())};
static word_t letters_of_padded(word_t v, letter_t)
Prepare to iterate over the letters of v.
bool open(bool o) const
Whether unknown letters should be added, or rejected.
std::ostream & str_escape(std::ostream &os, const std::string &str)
Output a string, escaping special characters.
Implementation of labels are letters.
std::ostream & print_set(std::ostream &o, format fmt={}) const
static word_t letters_of(letter_t v)
Prepare to iterate over v.
This class has no modeling purpose, it only serves to factor code common to letterset, nullableset and wordset.
static word_t letters_of(word_t v)
Prepare to iterate over the letters of v.
static value_t lgcd(value_t, value_t)
The longest common prefix.
ATTRIBUTE_PURE auto has(Args &&...args) const -> decltype(this->genset().has(std::forward< Args >(args)...))
typename genset_t::letters_t letters_t
void convs(std::istream &i, Fun fun) const
Read a range of labels.
typename helper_t::value_t value_t
static size_t size(value_t)
std::istringstream is
The input stream: the specification to translate.
static word_t letters_of_padded(letter_t v, letter_t)
Prepare to iterate over v.
static value_t special() ATTRIBUTE_PURE
char eat(std::istream &is, char c)
Check lookahead character and advance.
std::shared_ptr< const genset_t > genset_ptr
static word_t word(value_t v)
Convert to a word.
auto hash_value(const T &v) -> decltype(std::hash< T >
Following the naming convention of Boost.
std::ostream & print(const value_t &l, std::ostream &o, format fmt={}) const
letterset(const genset_t &gs={})
letterset(const std::initializer_list< letter_t > &letters)
static bool less(const value_t l, const value_t r)
Whether l < r.
std::set< value_t, vcsn::less< self_t >> values_t
bool is_valid(value_t v) const
static letterset make(std::istream &is)
Build from the description in is.
const genset_t & genset() const
static ATTRIBUTE_PURE bool is_one(value_t l)
Provide a variadic mul on top of a binary mul(), and one().
static constexpr bool is_letterized()
static bool is_special(value_t v) ATTRIBUTE_PURE
static constexpr bool is_expressionset()
static value_t ldiv(value_t, value_t)
Compute w1 \ w2 = w1^{-1}w2.
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
void require(bool b, Args &&...args)
If b is not verified, raise an error with args as message.
const labelset_ptr labelset() const
value_t conv(self_t, value_t v) const
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
static size_t hash(value_t v)
static bool equal(const value_t l, const value_t r)
Whether l == r.
value_t value(Args &&...args) const
Value constructor.
letterset(const genset_ptr &gs)
typename genset_t::letter_t letter_t
typename genset_t::word_t word_t
static labelset_t::value_t get_value(const value_t &v)
The (inner) value when it (the outer value) is not one.
static constexpr bool has_one()
static constexpr bool is_free()
value_t conv(std::istream &i, bool quoted=true) const
Read one letter from i, return the corresponding label.
letter_t get_letter(std::istream &i, bool quoted=true) const
Read one letter from i.
typename genset_t::letter_t letter_t
static constexpr bool is_one(value_t)
void convs_(std::istream &i, Fun fun) const
Read and process a class of letters.
Implementation of labels are nullables (letter or empty).