4 #include <initializer_list>
7 #include <boost/container/flat_set.hpp>
8 #include <boost/optional.hpp>
9 #include <boost/version.hpp>
22 template <
typename Key,
typename Compare,
typename Allocator>
25 has(
const boost::container::flat_set<Key, Compare, Allocator>& s,
28 return s.find(e) != s.end();
41 = boost::container::flat_set<letter_t, vcsn::less<L, letter_t>>;
72 boost::optional<letter_t> prev;
77 raise(
sname(),
": make: invalid end-of-file");
100 prev = L::get_letter(is);
117 #if 105700 <= BOOST_VERSION
140 require(l != this->
template special<letter_t>(),
141 "add_letter: the special letter is reserved: ", l);
148 template <
typename Letter,
typename Enable =
void>
151 template <
typename Letter>
153 decltype((++
std::declval<Letter&>(),
void()))>
161 return add_range_<letter_t>(l1, l2);
164 template <
typename Letter>
168 for (; L::less(l1, l2); ++l1)
173 if (L::equal(l1, l2))
178 template <
typename Letter>
180 -> std::enable_if_t<!has_range<Letter>{},
set_alphabet&>
182 raise(
sname(),
": does not support letter ranges");
203 require(!i.bad(),
"conv: invalid stream");
205 if (i.good() && i.peek() ==
'\\')
227 && (c = i.peek()) != EOF
235 letter_t l = L::get_letter(i,
true);
239 res = this->mul(res, l);
244 using iterator =
typename letters_t::const_iterator;
286 const char *sep =
"";
290 if (! this->is_letter(l))
292 this->
print(l, o, fmt);
293 if (! this->is_letter(l))
298 o << sep <<
"\\ldots";
#define VCSN_REQUIRE(Cond,...)
A macro similar to require.
word_t get_word(std::istream &i) const
Extract and return the next word from i.
Print as rich UTF-8 text, escaped.
set_alphabet &bool has(letter_t l) const
Whether l is a letter.
friend set_alphabet set_union(const set_alphabet &lhs, const set_alphabet &rhs)
Compute the union with another alphabet.
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
auto add_range_(Letter l1, Letter l2) -> std::enable_if_t< has_range< Letter >
std::ostream & str_escape(std::ostream &os, const std::string &str, const char *special=nullptr)
Output a string, escaping special characters.
typename letters_t::const_iterator iterator
Print as is. For instance, don't try to escape labels.
An input/output format for valuesets.
char eat(std::istream &is, char c)
Check lookahead character and advance.
bool open(bool o) const
Whether unknown letters should be added, or rejected.
bool empty() const
Whether this alphabet has no letters.
letter_t value_type
The type of our values, when seen as a container.
auto add_range(letter_t l1, letter_t l2) -> set_alphabet &
Add a range of letters, if it is accepted by the labelset.
typename L::word_t word_t
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
Print as plain (ASCII) text, escaped.
set_alphabet & add_letter(letter_t l)
Modify this by adding l, and return *this.
set_alphabet(std::initializer_list< letter_t > l)
static set_alphabet make(std::istream &is)
const_iterator find(letter_t l) const
std::istringstream is
The input stream: the specification to translate.
std::ostream & print(const Aut &aut, std::ostream &out, const std::string &fmt)
std::ostream & print_set(std::ostream &o, format fmt={}) const
const_iterator cend() const
Print as a parsable type string.
typename L::letter_t letter_t
A set of letters of type L.
const_iterator end() const
const_iterator cbegin() const
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
const_iterator begin() const
auto add_range_(Letter, Letter) -> std::enable_if_t<!has_range< Letter >
typename letters_t::const_iterator const_iterator
Whether the genset supports the range concept: whether we can use '++' on letters.
set_alphabet(const letters_t &l)
friend set_alphabet set_intersection(const set_alphabet &lhs, const set_alphabet &rhs)
Compute the intersection with another alphabet.
boost::container::flat_set< letter_t, vcsn::less< L, letter_t >> letters_t