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
224 template <
typename Fun>
225 void convs(std::istream& i, Fun fun)
const
248 raise(
sname(),
": lgcd: impossible operation");
254 raise(
sname(),
": ldiv: impossible operation");
262 raise(
"conjunction: invalid operation (lhs and rhs are not equal)");
269 return this->
genset()->print(l, o, fmt);
278 this->
genset()->print_set(o, fmt);
282 this->
genset()->print_set(o, fmt);
287 this->genset()->print_set(o, fmt);
300 template <typename GenSet>
301 struct letterized_traits<letterset<GenSet>>
303 static constexpr bool is_letterized = true;
305 using labelset_t = nullableset<letterset<GenSet>>;
307 static labelset_t labelset(const letterset<GenSet>& ls)
309 return {ls.genset()};
314 template <typename GenSet>
315 struct nullableset_traits<letterset<GenSet>>
317 using type = nullableset<letterset<GenSet>>;
318 static type value(const letterset<GenSet>& ls)
325 template <typename GenSet>
326 struct law_traits<letterset<GenSet>>
328 using type = wordset<GenSet>;
329 static type value(const letterset<GenSet>& ls)
339 template <typename GenSet>
340 struct join_impl<letterset<GenSet>, letterset<GenSet>>
342 using type = letterset<GenSet>;
343 static type join(const letterset<GenSet>& lhs,
344 const letterset<GenSet>& rhs)
346 return {set_union(*lhs.genset(), *rhs.genset())};
352 template <typename GenSet>
354 meet(const letterset<GenSet>& lhs, const letterset<GenSet>& rhs)
356 return {set_intersection(*lhs.genset(), *rhs.genset())};
This class has no modeling purpose, it only serves to factor code common to letterset and wordset...
static bool equal(const value_t l, const value_t r)
Whether l == r.
#define VCSN_REQUIRE(Cond,...)
A macro similar to require.
void convs(std::istream &i, Fun fun) const
Process a label class.
letterset(const genset_ptr &gs)
typename genset_t::letters_t letters_t
auto hash_value(const T &v) -> decltype(std::hash< T >
Following the naming convention of Boost.
Implementation of labels are nullables (letter or empty).
genset_ptr genset() const
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
static constexpr bool is_one(value_t)
static bool is_special(value_t v) ATTRIBUTE_PURE
std::ostream & str_escape(std::ostream &os, const std::string &str, const char *special=nullptr)
Output a string, escaping special characters.
bool open(bool o) const
Whether unknown letters should be added, or rejected.
An input/output format for valuesets.
char eat(std::istream &is, char c)
Check lookahead character and advance.
static bool less(const value_t l, const value_t r)
Whether l < r.
Provide a variadic mul on top of a binary mul(), and one().
std::set< value_t, vcsn::less< self_t >> values_t
bool is_valid(value_t v) const
static word_t letters_of(letter_t v)
Prepare to iterate over v.
static value_t lgcd(value_t, value_t)
The longest common prefix.
static word_t word(value_t v)
Convert to a word.
letter_t get_letter(std::istream &i, bool quoted=true) const
Read one letter from i.
std::ostream & print(const value_t &l, std::ostream &o, format fmt={}) const
letterset(const genset_t &gs={})
static word_t letters_of_padded(letter_t v, letter_t)
Prepare to iterate over v.
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
value_t conv(self_t, value_t v) const
static letterset make(std::istream &is)
Build from the description in is.
static constexpr bool is_letterized()
static constexpr bool has_one()
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)
std::istringstream is
The input stream: the specification to translate.
Print as a parsable type string.
Implementation of labels are letters.
static word_t letters_of_padded(word_t v, letter_t)
Prepare to iterate over the letters of v.
typename genset_t::letter_t letter_t
typename helper_t::value_t value_t
const labelset_ptr labelset() const
typename genset_t::word_t word_t
letterset(std::initializer_list< letter_t > letters)
std::ostream & print_set(std::ostream &o, format fmt={}) const
static constexpr bool is_expressionset()
static value_t ldiv(value_t, value_t)
Compute w1 \ w2 = w1^{-1}w2.
static word_t letters_of(word_t v)
Prepare to iterate over the letters of v.
value_t conv(const nullableset< LabelSet_ > &ls, typename nullableset< LabelSet_ >::value_t v) const
Convert from nullableset to letterset.
static constexpr bool is_free()
static labelset_t::value_t get_value(const value_t &v)
The (inner) value when it (the outer value) is not one.
value_t value(Args &&...args) const
Value constructor.
value_t conjunction(const value_t &l, const value_t &r) const
typename genset_t::letter_t letter_t
static size_t size(value_t)
void convs_(std::istream &i, Fun fun) const
Read and process a class of letters.
typename genset_t::word_t word_t
static value_t special() ATTRIBUTE_PURE
std::shared_ptr< const genset_t > genset_ptr
ATTRIBUTE_PURE auto has(Args &&...args) const -> decltype(this->genset() -> has(std::forward< Args >(args)...))