Vcsn  2.5.dev
Be Rational
nullableset.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <sstream>
5 
6 #include <boost/optional.hpp>
7 
8 #include <vcsn/alphabets/setalpha.hh> // intersect
9 #include <vcsn/core/kind.hh>
10 #include <vcsn/labelset/fwd.hh>
13 #include <vcsn/labelset/oneset.hh>
14 #include <vcsn/misc/escape.hh>
15 #include <vcsn/misc/functional.hh>
16 #include <vcsn/misc/raise.hh>
17 
18 namespace vcsn
19 {
20  namespace detail
21  {
28  template <typename LabelSet>
30  {
31  using labelset_t = LabelSet;
32  using value_t = std::pair<typename labelset_t::value_t, bool>;
33 
34  ATTRIBUTE_PURE
35  static constexpr value_t
36  one()
37  {
38  return value_t{labelset_t::special(), true};
39  }
40 
41  ATTRIBUTE_PURE
42  static constexpr value_t
44  {
45  return value_t{labelset_t::special(), false};
46  }
47 
48  template <typename Ls>
49  ATTRIBUTE_PURE
50  static std::enable_if_t<Ls::has_one(), bool>
51  is_one_(const value_t& l)
52  {
53  return std::get<1>(l) || Ls::is_one(get_value(l));
54  }
55 
56  template <typename Ls>
57  ATTRIBUTE_PURE
58  static std::enable_if_t<!Ls::has_one(), bool>
59  is_one_(const value_t& l)
60  {
61  return std::get<1>(l);
62  }
63 
64  ATTRIBUTE_PURE
65  static bool
66  is_one(const value_t& l)
67  {
68  return is_one_<labelset_t>(l);
69  }
70 
71  template <typename Value>
72  static Value
73  transpose(const labelset_t& ls, Value l)
74  {
75  // This is not robust enough: Value is word_t, then it's not
76  // valid to call is_one on it. Since I'm unsure of the future
77  // of nullableset, let's not waste time on this now.
78  if (is_one(l))
79  return l;
80  else
81  return {ls.transpose(get_value(l)), false};
82  }
83 
84  template <typename... Args>
85  static value_t
86  value(const labelset_t& ls, Args&&... args)
87  {
88  return {ls.value(std::forward<Args>(args)...), false};
89  }
90 
91  ATTRIBUTE_PURE
92  static typename labelset_t::value_t
94  {
95  return std::get<0>(v);
96  }
97 
98  static auto generators(const labelset_t& ls)
99  {
100  return ls.generators();
101  }
102 
103  static auto pregenerators(const labelset_t& ls)
104  {
105  return ls.pregenerators();
106  }
107  };
108 
115  template <typename GenSet>
116  struct nullable_helper<letterset<GenSet>>
117  {
118  using genset_t = GenSet;
120  using value_t = typename labelset_t::value_t;
121 
122  ATTRIBUTE_PURE
123  static constexpr value_t
125  {
126  return genset_t::special();
127  }
128 
129  ATTRIBUTE_PURE
130  static constexpr value_t
131  one()
132  {
133  return genset_t::one_letter();
134  }
135 
136  ATTRIBUTE_PURE
137  static bool
139  {
140  return l == one();
141  }
142 
143  template <typename Value>
144  static Value
145  transpose(const labelset_t& ls, const Value& l)
146  {
147  return ls.transpose(l);
148  }
149 
150  template <typename... Args>
151  static value_t
152  value(const labelset_t& ls, Args&&... args)
153  {
154  return ls.value(std::forward<Args>(args)...);
155  }
156 
157  ATTRIBUTE_PURE
158  static value_t
160  {
161  return v;
162  }
163 
164  static auto generators(const labelset_t& ls)
165  {
166  return ls.generators();
167  }
168 
169  static auto pregenerators(const labelset_t& ls)
170  {
171  return ls.genset()->pregenerators();
172  }
173  };
174  }
175 
177  template <typename LabelSet>
178  class nullableset
179  {
180  public:
181  using labelset_t = LabelSet;
182  using labelset_ptr = std::shared_ptr<const labelset_t>;
186 
187  using value_t = typename helper_t::value_t;
188  using letter_t = typename labelset_t::letter_t;
189  using word_t = typename labelset_t::word_t;
190 
191  private:
195 
196  public:
197  using genset_ptr = decltype(ls_->genset());
198  using genset_t = decltype(ls_->generators());
199 
200  public:
202  : ls_{ls}
203  {}
204 
205  nullableset(const labelset_t& ls = {})
206  : nullableset{std::make_shared<const labelset_t>(ls)}
207  {}
208 
210  {}
211 
212  static symbol sname()
213  {
214  static auto res = symbol{"nullableset<" + labelset_t::sname() + '>'};
215  return res;
216  }
217 
219  static nullableset make(std::istream& is)
220  {
221  // name: nullableset<lal_char(abc)>.
222  // ^^^^^^^^^^^^
223  // labelset
224  eat(is, "nullableset<");
225  auto ls = labelset_t::make(is);
226  eat(is, '>');
227  return {ls};
228  }
229 
233  bool open(bool o) const
234  {
235  return this->ls_->open(o);
236  }
237 
238  static constexpr bool
240  {
241  return true;
242  }
243 
244  static constexpr bool
246  {
247  return false;
248  }
249 
250  static constexpr bool
252  {
253  return labelset_t::is_letterized();
254  }
255 
256  static constexpr bool is_free()
257  {
258  return false;
259  }
260 
261  ATTRIBUTE_PURE
262  static constexpr value_t
263  one()
264  {
265  return helper_t::one();
266  }
267 
268  ATTRIBUTE_PURE
269  static bool
271  {
272  return helper_t::is_one(l);
273  }
274 
275  bool
277  {
278  return is_one(v) || ls_->is_valid(get_value(v));
279  }
280 
281  genset_ptr
282  genset() const
283  {
284  return ls_->genset();
285  }
286 
288  decltype(auto)
289  generators() const
290  {
291  return helper_t::generators(*ls_);
292  }
293 
295  decltype(auto)
297  {
298  return helper_t::pregenerators(*ls_);
299  }
300 
301  value_t
303  {
304  return v;
305  }
306 
307  value_t
308  conv(oneset, typename oneset::value_t) const
309  {
310  return one();
311  }
312 
316  template <typename LabelSet_>
317  value_t
318  conv(const LabelSet_& ls, typename LabelSet_::value_t v) const
319  {
320  return value(ls_->conv(ls, v));
321  }
322 
323  const labelset_ptr labelset() const
324  {
325  return ls_;
326  }
327 
328  template <typename... Args>
329  value_t
330  value(Args&&... args) const
331  {
332  return helper_t::value(*ls_, std::forward<Args>(args)...);
333  }
334 
335  word_t
336  word(const value_t& l) const
337  {
338  if (is_one(l))
339  return make_wordset(*labelset()).one();
340  else
341  return ls_->word(get_value(l));
342  }
343 
345  auto static
347  -> decltype(labelset_t::letters_of(v))
348  {
349  return labelset_t::letters_of(v);
350  }
351 
354  auto
356  -> decltype(ls_->letters_of_padded(v, l))
357  {
358  return ls_->letters_of_padded(v, l);
359  }
360 
361  auto
363  -> decltype(this->letters_of_padded(this->word(v), l))
364  {
365  return letters_of_padded(word(v), l);
366  }
367 
369  static int compare(const value_t& l, const value_t& r)
370  {
371  if (auto res = int(is_one(r)) - int(is_one(l)))
372  return res;
373  else
374  return labelset_t::compare(get_value(l), get_value(r));
375  }
376 
378  static bool equal(const value_t& l, const value_t& r)
379  {
380  if (is_one(l))
381  return is_one(r);
382  else
383  return !is_one(r) && labelset_t::equal(get_value(l), get_value(r));
384  }
385 
387  static bool less(const value_t& l, const value_t& r)
388  {
389  if (is_one(r))
390  return false;
391  else if (is_one(l))
392  return true;
393  else
394  return labelset_t::less(get_value(l), get_value(r));
395  }
396 
398  value_t mul(const value_t& l, const value_t& r) const
399  {
400  if (is_one(r))
401  return l;
402  else if (is_one(l))
403  return r;
404  else
405  raise(*this, ": mul: invalid arguments: ",
406  to_string(*this, l), ", ", to_string(*this, r));
407  }
408 
410  value_t lgcd(const value_t& l, const value_t& r) const
411  {
412  if (equal(l, r))
413  return l;
414  else if (is_one(l) || is_one(r))
415  return one();
416  else
417  return value(ls_->lgcd(get_value(l), get_value(r)));
418  }
419 
421  value_t ldivide(const value_t& l, const value_t& r) const
422  {
423  if (auto res = maybe_ldivide(l, r))
424  return *res;
425  else
426  raise(*this, ": ldivide: invalid arguments: ",
427  to_string(*this, l), ", ", to_string(*this, r));
428  }
429 
430  boost::optional<value_t>
431  maybe_ldivide(const value_t& l, const value_t& r) const
432  {
433  if (equal(l, r))
434  return one();
435  else if (is_one(l))
436  return r;
437  else if (is_one(r))
438  return boost::none;
439  else if (auto res = ls_->maybe_ldivide(get_value(l), get_value(r)))
440  return value(*res);
441  else
442  return boost::none;
443  }
444 
446  value_t rdivide(const value_t& l, const value_t& r) const
447  {
448  if (auto res = maybe_rdivide(l, r))
449  return *res;
450  else
451  raise(*this, ": rdivide: invalid arguments: ",
452  to_string(*this, l), ", ", to_string(*this, r));
453  }
454 
455  boost::optional<value_t>
456  maybe_rdivide(const value_t& l, const value_t& r) const
457  {
458  if (equal(l, r))
459  return one();
460  else if (is_one(l))
461  return boost::none;
462  else if (is_one(r))
463  return l;
464  else if (auto res = ls_->maybe_rdivide(get_value(l), get_value(r)))
465  return value(*res);
466  else
467  return boost::none;
468  }
469 
470  static value_t
472  {
473  return helper_t::special();
474  }
475 
476  static bool
478  {
479  return !is_one(v) && labelset_t::is_special(get_value(v));
480  }
481 
482  static size_t size(const value_t& v)
483  {
484  return is_one(v) ? 0 : labelset_t::size(get_value(v));
485  }
486 
487  // FIXME: specialize for both implementation.
488  static size_t hash(const value_t& v)
489  {
490  // Do not use get_value when is_one. Let's hash one() as 0.
491  return is_one(v) ? 0 : labelset_t::hash(get_value(v));
492  }
493 
494  letter_t
495  get_letter(std::istream& i, bool quoted = true) const
496  {
497  return ls_->get_letter(i, quoted);
498  }
499 
501  value_t
502  conv(std::istream& i, bool quoted = true) const
503  {
504  // Check for '\e', otherwise pass it to the inner labelset.
505  if (i.good() && i.peek() == '\\')
506  {
507  i.ignore();
508  int c = i.peek();
509  if (c == 'e')
510  {
511  i.ignore();
512  return {};
513  }
514  else
515  i.unget();
516  }
517  return value(ls_->conv(i, quoted));
518  }
519 
529  template <typename Fun>
530  void convs(std::istream& i, Fun&& fun) const
531  {
532  ls_->convs(i,
533  [this,fun](const typename labelset_t::value_t& l)
534  {
535  fun(value(l));
536  });
537  }
538 
539  value_t conjunction(const value_t& l, const value_t& r) const
540  {
541  if (is_one(l) && is_one(r))
542  return l;
543  else if (!is_one(l) && !is_one(r))
544  return ls_->conjunction(get_value(l), get_value(r));
545  else
546  raise(*this,
547  ": conjunction: invalid operation (lhs and rhs are not equal): ",
548  to_string(*this, l), ", ", to_string(*this, r));
549  }
550 
552  std::ostream&
553  print(const value_t& l, std::ostream& o = std::cout,
554  format fmt = {}) const
555  {
556  if (is_one(l))
557  o << (fmt == format::latex ? "\\varepsilon"
558  : fmt == format::utf8 ? "ε"
559  : "\\e");
560  else
561  ls_->print(get_value(l), o, fmt);
562  return o;
563  }
564 
565  bool
566  is_letter(const value_t& v) const
567  {
568  return !is_one(v) && ls_->is_letter(get_value(v));
569  }
570 
572  template <typename Value>
573  Value
574  transpose(const Value& l) const
575  {
576  return helper_t::transpose(*ls_, l);
577  }
578 
580  std::ostream&
581  print_set(std::ostream& o, format fmt = {}) const
582  {
583  switch (fmt.kind())
584  {
585  case format::latex:
586  o << "(";
587  ls_->print_set(o, fmt);
588  o << ")^?";
589  break;
590 
591  case format::sname:
592  o << "nullableset<";
593  ls_->print_set(o, fmt);
594  o << '>';
595  break;
596 
597  case format::text:
598  case format::utf8:
599  ls_->print_set(o, fmt);
600  o << '?';
601  break;
602 
603  case format::raw:
604  assert(0);
605  break;
606  }
607 
608  return o;
609  }
610 
612  static typename labelset_t::value_t
613  get_value(const value_t& v)
614  {
615  assert(!is_one(v));
616  return helper_t::get_value(v);
617  }
618  };
619 
620  namespace detail
621  {
623  template <typename LabelSet>
624  struct letterized_traits<nullableset<LabelSet>>
625  {
626  using traits = letterized_traits<LabelSet>;
627  static constexpr bool is_letterized = traits::is_letterized;
628 
629  using labelset_t = typename traits::labelset_t;
630 
631  static labelset_t labelset(const nullableset<LabelSet>& ls)
632  {
633  return make_letterized(*ls.labelset());
634  }
635  };
636 
638  template <typename LabelSet>
639  struct nullableset_traits<nullableset<LabelSet>>
640  {
641  using type = nullableset<LabelSet>;
642  static type value(const nullableset<LabelSet>& ls)
643  {
644  return ls;
645  }
646  };
647 
648  template <typename LabelSet>
649  struct proper_traits<nullableset<LabelSet>>
650  {
651  using type = LabelSet;
652  static type value(const nullableset<LabelSet>& ls)
653  {
654  return *ls.labelset();
655  }
656  };
657 
659  template <typename LabelSet>
660  struct law_traits<nullableset<LabelSet>>
661  {
662  using type = law_t<LabelSet>;
663  static type value(const nullableset<LabelSet>& ls)
664  {
665  return make_wordset(*ls.labelset());
666  }
667  };
668 
669  /*-------.
670  | Join. |
671  `-------*/
672 
674  template <typename LS>
675  struct join_impl<oneset, LS,
676  std::enable_if_t<!LS::has_one()>>
677  {
678  using type = nullableset<LS>;
679  static type join(const oneset&, const LS& ls)
680  {
681  return {ls};
682  }
683  };
684 
686  template <typename LS>
687  struct join_impl<oneset, LS,
688  std::enable_if_t<LS::has_one()>>
689  {
690  using type = LS;
691  static type join(const oneset&, const LS& ls)
692  {
693  return ls;
694  }
695  };
696 
698  template <typename LS1, typename LS2>
699  struct join_impl<nullableset<LS1>, LS2>
700  {
701  using type = std::conditional_t<LS2::has_one(),
702  join_t<LS1, LS2>,
703  nullableset<join_t<LS1, LS2>>>;
704  static type join(const nullableset<LS1>& ls1, const LS2& ls2)
705  {
706  return {::vcsn::join(*ls1.labelset(), ls2)};
707  }
708  };
709 
714  template <typename LS1, typename LS2>
715  struct join_impl<nullableset<LS1>, nullableset<LS2>>
716  {
717  using type = nullableset<join_t<LS1, LS2>>;
718  static type join(const nullableset<LS1>& ls1,
719  const nullableset<LS2>& ls2)
720  {
721  return {::vcsn::join(*ls1.labelset(), *ls2.labelset())};
722  }
723  };
724  }
725 
726  /*-------.
727  | Meet. |
728  `-------*/
729 
730 #define DEFINE(Lhs, Rhs, Res) \
731  template <typename GenSet> \
732  Res \
733  meet(const Lhs& lhs, const Rhs& rhs) \
734  { \
735  return {set_intersection(*lhs.genset(), *rhs.genset())}; \
736  }
737 
739  DEFINE(nullableset<letterset<GenSet>>,
740  nullableset<letterset<GenSet>>, nullableset<letterset<GenSet>>);
741 
742  DEFINE(letterset<GenSet>,
743  nullableset<letterset<GenSet>>, nullableset<letterset<GenSet>>);
744 
745  DEFINE(nullableset<letterset<GenSet>>,
746  letterset<GenSet>, nullableset<letterset<GenSet>>);
747 
748  template <typename Lls, typename Rls>
749  nullableset<meet_t<Lls, Rls>>
750  meet(const nullableset<Lls>& lhs, const nullableset<Rls>& rhs)
751  {
752  return nullableset<meet_t<Lls, Rls>>{meet(*lhs.labelset(),
753  *rhs.labelset())};
754  }
755 
756 #undef DEFINE
757 
758 
759  /*----------------.
760  | random_label. |
761  `----------------*/
762 
764  template <typename LabelSet,
765  typename RandomGenerator = std::default_random_engine>
766  typename nullableset<LabelSet>::value_t
767  random_label(const nullableset<LabelSet>& ls,
768  RandomGenerator& gen = RandomGenerator())
769  {
770  // FIXME: the proportion should be controllable.
771  auto dis = std::bernoulli_distribution(0.5);
772  if (dis(gen) || ls.generators().empty())
773  return ls.one();
774  else
775  return ls.value(random_label(*ls.labelset(), gen));
776  }
777 }
weightset_mixin< detail::r_impl > r
Definition: fwd.hh:54
static Value transpose(const labelset_t &ls, const Value &l)
Definition: nullableset.hh:145
decltype(ls_->genset()) genset_ptr
Definition: nullableset.hh:197
Implementation of labels are letters.
Definition: fwd.hh:10
static ATTRIBUTE_PURE constexpr value_t special()
Definition: nullableset.hh:124
static bool less(const value_t &l, const value_t &r)
Whether l < r.
Definition: nullableset.hh:387
value_t conv(oneset, typename oneset::value_t) const
Definition: nullableset.hh:308
static ATTRIBUTE_PURE std::enable_if_t<!Ls::has_one(), bool > is_one_(const value_t &l)
Definition: nullableset.hh:59
decltype(ls_->generators()) genset_t
Definition: nullableset.hh:198
labelset_ptr ls_
The wrapped LabelSet.
Definition: nullableset.hh:194
static ATTRIBUTE_PURE constexpr value_t special()
Definition: nullableset.hh:43
static auto generators(const labelset_t &ls)
Definition: nullableset.hh:98
bool is_valid(value_t v) const
Definition: nullableset.hh:276
std::string to_string(direction d)
Conversion to string.
Definition: direction.cc:7
static symbol sname()
Definition: nullableset.hh:212
value_t rdivide(const value_t &l, const value_t &r) const
Compute l / r.
Definition: nullableset.hh:446
static ATTRIBUTE_PURE constexpr value_t one()
Definition: nullableset.hh:36
static auto generators(const labelset_t &ls)
Definition: nullableset.hh:164
Print as a parsable type string.
Definition: format.hh:26
value_t mul(const value_t &l, const value_t &r) const
The concatenation.
Definition: nullableset.hh:398
law_t< LabelSet > make_wordset(const LabelSet &ls)
The wordset of a labelset.
Definition: labelset.hh:259
auto generators() const
Definition: letterset.hh:81
static auto pregenerators(const labelset_t &ls)
Definition: nullableset.hh:103
Aut transpose(const transpose_automaton< Aut > &aut)
The transpose of a transpose automaton is the original automaton.
Definition: transpose.hh:253
static size_t hash(const value_t &v)
Definition: nullableset.hh:488
static constexpr bool is_letterized()
Definition: nullableset.hh:251
auto letters_of_padded(const word_t &v, letter_t l) const -> decltype(ls_->letters_of_padded(v, l))
Prepare to iterate over the letters of v.
Definition: nullableset.hh:355
bool is_special(const Aut &aut, transition_t_of< Aut > t)
Whether this transition is from pre or to post.
Definition: automaton.hh:229
value_t conjunction(const value_t &l, const value_t &r) const
Definition: nullableset.hh:539
std::ostream & print_set(std::ostream &o, format fmt={}) const
Print labelset description.
Definition: nullableset.hh:581
static ATTRIBUTE_PURE constexpr value_t one()
Definition: nullableset.hh:131
std::pair< typename labelset_t::value_t, bool > value_t
Definition: nullableset.hh:32
typename labelset_t::word_t word_t
Definition: nullableset.hh:189
std::ostream & print(const value_t &l, std::ostream &o=std::cout, format fmt={}) const
Print label to stream.
Definition: nullableset.hh:553
auto letters_of_padded(value_t v, letter_t l) const -> decltype(this->letters_of_padded(this->word(v), l))
Definition: nullableset.hh:362
nullableset(const labelset_ptr &ls)
Definition: nullableset.hh:201
symbol sname()
Definition: name.hh:65
static value_t value(const labelset_t &ls, Args &&... args)
Definition: nullableset.hh:152
static bool is_special(const value_t &v)
Definition: nullableset.hh:477
return res
Definition: multiply.hh:399
static ATTRIBUTE_PURE std::enable_if_t< Ls::has_one(), bool > is_one_(const value_t &l)
Definition: nullableset.hh:51
char eat(std::istream &is, char c)
Check lookahead character and advance.
Definition: stream.cc:130
size_t size(const ExpSet &rs, const typename ExpSet::value_t &r)
genset_ptr genset() const
Definition: nullableset.hh:282
static Value transpose(const labelset_t &ls, Value l)
Definition: nullableset.hh:73
static auto letters_of(const word_t &v) -> decltype(labelset_t::letters_of(v))
Prepare to iterate over the letters of v.
Definition: nullableset.hh:346
value_t lgcd(const value_t &l, const value_t &r) const
The longest common prefix.
Definition: nullableset.hh:410
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...
Definition: nullableset.hh:318
ATTRIBUTE_PURE auto transpose(Args &&... args) const -> decltype(this->genset() -> transpose(std::forward< Args >(args)...))
static value_t special()
Definition: nullableset.hh:471
static ATTRIBUTE_PURE bool is_one(const value_t &l)
Definition: nullableset.hh:66
static bool equal(const value_t &l, const value_t &r)
Whether l == r.
Definition: nullableset.hh:378
static value_t value(const labelset_t &ls, Args &&... args)
Definition: nullableset.hh:86
static int compare(const value_t &l, const value_t &r)
Three way comparison between l and r.
Definition: nullableset.hh:369
static constexpr bool has_one()
Definition: nullableset.hh:239
nullableset(const labelset_t &ls={})
Definition: nullableset.hh:205
const labelset_ptr labelset() const
Definition: nullableset.hh:323
static size_t size(const value_t &v)
Definition: nullableset.hh:482
boost::optional< value_t > maybe_ldivide(const value_t &l, const value_t &r) const
Definition: nullableset.hh:431
static nullableset make(std::istream &is)
Build from the description in is.
Definition: nullableset.hh:219
value_t value(Args &&... args) const
Definition: nullableset.hh:330
Print for LaTeX.
Definition: format.hh:22
static constexpr bool is_expressionset()
Definition: nullableset.hh:245
Print as rich UTF-8 text, escaped.
Definition: format.hh:30
typename helper_t::value_t value_t
Definition: nullableset.hh:187
constant< type_t::one, Context > one
Definition: fwd.hh:121
Add support for an empty word to a LabelSet that does not provide such special label to this end...
Definition: nullableset.hh:29
letter_t value_t
Definition: letterset.hh:33
word_t word(const value_t &l) const
Definition: nullableset.hh:336
value_t conv(std::istream &i, bool quoted=true) const
Read a label from a stream.
Definition: nullableset.hh:502
typename labelset_t::letter_t letter_t
Definition: nullableset.hh:188
std::shared_ptr< const labelset_t > labelset_ptr
Definition: nullableset.hh:182
Definition: a-star.hh:8
std::enable_if_t<!is_letterized_t< labelset_t_of< Aut > >{}, bool > is_letterized(const Aut &aut)
Definition: letterize.hh:161
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
Definition: symbol.hh:21
value_t value(Args &&... args) const
Value constructor.
Definition: letterset.hh:93
An input/output format for valuesets.
Definition: format.hh:13
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
static auto pregenerators(const labelset_t &ls)
Definition: nullableset.hh:169
bool open(bool o) const
Whether unknown letters should be added, or rejected.
Definition: nullableset.hh:233
bool is_letter(const value_t &v) const
Definition: nullableset.hh:566
static constexpr bool is_free()
Definition: nullableset.hh:256
static ATTRIBUTE_PURE value_t get_value(const value_t &v)
Definition: nullableset.hh:159
Value transpose(const Value &l) const
Mirror label.
Definition: nullableset.hh:574
Implementation of labels are ones: there is a single instance of label.
Definition: oneset.hh:19
void convs(std::istream &i, Fun &&fun) const
Process a label class.
Definition: nullableset.hh:530
letter_t get_letter(std::istream &i, bool quoted=true) const
Definition: nullableset.hh:495
static ATTRIBUTE_PURE bool is_one(value_t l)
Definition: nullableset.hh:138
static ATTRIBUTE_PURE constexpr value_t one()
Definition: nullableset.hh:263
Implementation of labels are nullables (letter or empty).
Definition: fwd.hh:14
boost::optional< value_t > maybe_rdivide(const value_t &l, const value_t &r) const
Definition: nullableset.hh:456
int compare(const Lhs &lhs, const Rhs &rhs)
Comparison between lhs and rhs.
static ATTRIBUTE_PURE labelset_t::value_t get_value(const value_t &v)
Definition: nullableset.hh:93
static ATTRIBUTE_PURE bool is_one(value_t l)
Definition: nullableset.hh:270
value_t ldivide(const value_t &l, const value_t &r) const
Compute l \ r = l^{-1}r.
Definition: nullableset.hh:421
bool value_t
Definition: oneset.hh:23
value_t conv(self_t, value_t v) const
Definition: nullableset.hh:302