1 #ifndef VCSN_LABELSET_NULLABLESET_HH
2 # define VCSN_LABELSET_NULLABLESET_HH
25 template <
typename LabelSet>
30 using value_t = std::pair<typename labelset_t::value_t, bool>;
31 using kind_t =
typename LabelSet::kind_t;
40 auto ls = null::labelset_t::make(is);
49 return value_t{null::labelset_t::special(),
true};
56 return value_t{null::labelset_t::special(),
false};
59 template <
typename Ls>
61 static typename std::enable_if<Ls::has_one(), bool>::type
64 return std::get<1>(l) || Ls::is_one(
get_value(l));
67 template <
typename Ls>
69 static typename std::enable_if<!Ls::has_one(), bool>::type
72 return std::get<1>(l);
79 return is_one_<labelset_t>(l);
82 template <
typename... Args>
86 return {ls.value(std::forward<Args>(args)...),
false};
90 static typename labelset_t::value_t
93 return std::get<0>(v);
99 template <
typename GenSet>
119 if (is.peek() ==
'_')
122 auto gs = genset_t::make(is);
127 auto ls = labelset_t::make(is);
136 return genset_t::special();
143 return genset_t::one_letter();
153 template <
typename... Args>
157 return ls.
value(std::forward<Args>(args)...);
161 static typename labelset_t::value_t
170 template <
typename LabelSet>
181 using word_t =
typename labelset_t::word_t;
184 :
labelset_t{ls},
ls_{std::make_shared<const labelset_t>(ls)}
196 std::string
vname(
bool full =
true)
const
198 return "lan<" +
labelset()->vname(full) +
">";
215 static constexpr
bool
221 static constexpr
bool
227 static constexpr
bool
230 return labelset_t::is_letterized();
273 template <
typename LabelSet_>
275 conv(
const LabelSet_& ls,
typename LabelSet_::value_t v)
const
285 template <
typename... Args>
339 std::hash_combine(res, labelset_t::hash(
get_value(v)));
364 auto l =
ls_->convs(i);
365 std::set<value_t> res;
367 res.emplace(
value(v));
376 o << (format ==
"latex" ?
"\\varepsilon" :
"\\e");
417 if (format ==
"latex")
423 else if (format ==
"text")
426 raise(
"invalid format: ", format);
431 static typename labelset_t::value_t
443 template <
typename LabelSet>
454 template <
typename LabelSet>
469 template <
typename LS>
481 template <
typename LS>
493 template <
typename LS1,
typename LS2>
507 template <
typename LS1,
typename LS2>
513 return {
::vcsn::join(*ls1.labelset(), *ls2.labelset())};
522 #define DEFINE(Lhs, Rhs, Res) \
523 template <typename GenSet> \
525 meet(const Lhs& lhs, const Rhs& rhs) \
527 return {intersection(lhs.genset(), rhs.genset())}; \
540 template <
typename Lls,
typename Rls>
551 #endif // !VCSN_LABELSET_NULLABLESET_HH
value_t value(Args &&...args) const
Value constructor.
std::ostream & print_set(std::ostream &o, symbol format=symbol{"text"}) const
typename LabelSet::kind_t kind_t
word_t word(const value_t &l) const
Add support for an empty word to a LabelSet that does not provide such special label to this end...
static type value(const nullableset< LabelSet > &ls)
bool is_valid(value_t v) const
value_t conv(oneset, typename oneset::value_t) const
std::ostream & print(value_t l, std::ostream &o, symbol format=symbol{"text"}) const
static type join(const nullableset< LS1 > &ls1, const nullableset< LS2 > &ls2)
static ATTRIBUTE_PURE labelset_t::value_t get_value(const value_t &v)
static std::string sname()
static type join(const oneset &, const LS &ls)
value_t transpose(const value_t &l) const
typename helper_t::kind_t kind_t
typename std::enable_if< Cond, T >::type enable_if_t
static bool is_special(const value_t &v)
std::string vname(bool full=true) const
static ATTRIBUTE_PURE bool is_one(value_t l)
Implementation of labels are nullables (letter or empty).
static bool less_than(const value_t &l, const value_t &r)
Whether l < r.
boost::flyweight< std::string, boost::flyweights::no_tracking > symbol
An internalized string.
static null make(std::istream &is)
typename helper_t::value_t value_t
std::ostream & str_escape(std::ostream &os, const std::string &str)
Output a string, escaping special characters.
static ATTRIBUTE_PURE constexpr null::value_t special()
std::pair< typename labelset_t::value_t, bool > value_t
Implementation of labels are ones: there is a single instance of label.
static void make_nullableset_kind(std::istream &is)
const labelset_ptr labelset() const
static type join(const LS1 &ls1, const nullableset< LS2 > &ls2)
value_t conv(const LabelSet_ &ls, typename LabelSet_::value_t v) const
Conversion from another type: first by the wrapped labelset, and then by our wrappers (in case the wr...
#define DEFINE(Lhs, Rhs, Res)
static ATTRIBUTE_PURE constexpr value_t one()
typename labelset_t::value_t value_t
value_t conv(std::istream &i) const
std::shared_ptr< const labelset_t > labelset_ptr
typename law_traits< LabelSet >::type law_t
The smallest wordset that includes LabelSet.
static constexpr bool is_free()
size_t size(const value_t &v) const
static constexpr bool is_letterized()
law_t< LabelSet > make_wordset(const LabelSet &ls)
The wordset of a labelset.
static value_t value(const labelset_t &ls, Args &&...args)
auto meet(const ratexpset< Ctx1 > &a, const ratexpset< Ctx2 > &b) -> ratexpset< meet_t< Ctx1, Ctx2 >>
The meet of two ratexpsets.
static size_t hash(const value_t &v)
std::istringstream is
The input stream: the specification to translate.
static ATTRIBUTE_PURE std::enable_if< Ls::has_one(), bool >::type is_one_(value_t l)
A structure that implements the computation of join(V1, V2).
value_t conv(self_type, value_t v) const
static constexpr bool is_ratexpset()
static bool equals(const value_t &l, const value_t &r)
Whether l == r.
Provide a variadic mul on top of a binary mul(), and one().
nullableset(const labelset_t &ls)
bool is_zero(const value_t &v) const
bool open(bool o) const
Whether unknown letters should be added, or rejected.
static nullableset make(std::istream &i)
Build from the description in is.
static type value(const nullableset< LabelSet > &ls)
static ATTRIBUTE_PURE labelset_t::value_t get_value(const value_t &v)
char eat(std::istream &is, char c)
Check lookahead character and advance.
typename labelset_t::word_t word_t
static ATTRIBUTE_PURE bool is_one(value_t l)
bool is_letter(const value_t &v) const
Implementation of labels are letters.
static value_t value(const labelset_t &ls, Args &&...args)
static ATTRIBUTE_PURE bool is_one(value_t l)
auto join(const ValueSet &vs) -> ValueSet
The join of a single valueset.
static ATTRIBUTE_PURE constexpr value_t one()
static labelset_t::value_t get_value(const value_t &v)
Return the value when it's not one.
RatExpSet::value_t less_than(const RatExpSet &rs, const typename RatExpSet::value_t &v)
static constexpr bool has_one()
static ATTRIBUTE_PURE constexpr value_t special()
std::set< value_t > convs(std::istream &i) const
nullableset(const std::shared_ptr< const labelset_t > &ls)
The smallest nullableset which includes LabelSet.
static type join(const oneset &, const LS &ls)
static null make(std::istream &is)
value_t value(Args &&...args) const
void require(bool b, Args &&...args)
If b is not verified, raise an error with args as message.
static ATTRIBUTE_PURE constexpr null::value_t one()
static ATTRIBUTE_PURE std::enable_if<!Ls::has_one(), bool >::type is_one_(value_t l)