17 #ifndef AWALI_LABELSET_WORDSET_HH 
   18 # define AWALI_LABELSET_WORDSET_HH 
   30 namespace awali { 
namespace sttc {
 
   33     template <
typename GenSet>
 
   53       : genset_{std::make_shared<const genset_t>(gs)}
 
   62       return "law_" + genset_t::sname();
 
   99     template <
typename... Args>
 
  102       return value_t{std::forward<Args>(args)...};
 
  135       w.insert(w.end(),
r.begin(),
r.end());      
 
  143       w.insert(w.end(),
r.begin(),
r.end());      
 
  164       if(l.size()<
r.size())
 
  166       if(l.size()>
r.size())
 
  174       return {genset_t::special_letter()};
 
  192     static constexpr 
bool 
  198     static constexpr 
bool 
  204     static constexpr 
bool 
  231       s.insert(s.end(),w.begin(),w.end());
 
  232       s.push_back(
genset().special_letter());
 
  241       assert(w[0] == 
genset().special_letter());
 
  242       assert(w[s-1] == 
genset().special_letter());
 
  243       word_t r(++w.begin(), --w.end());
 
  269     parse(
const std::string& s, 
size_t& p, 
bool fixed_alphabet=
true)
 const {
 
  273       const std::string& sep=genset_t::separation_mark();
 
  274       size_t sep_length=sep.length();
 
  276       letter_t l= genset_t::parse_one_letter(s, p);
 
  287         for(
size_t i=0; find_sep && i<sep_length; ++i)
 
  288           find_sep=(s[
q+i]==sep[i]);
 
  292         l= genset_t::parse_one_letter(s, p);
 
  296         else if(sep_length>0)
 
  304       for(
size_t i=tmp.size(); i!=0; --i)
 
  305         result.push_back(tmp[i-1]);
 
  330           const std::string& 
format = 
"text")
 const 
  333         o << (
format == 
"latex" ? 
"\\varepsilon" : 
"\\e");
 
  336         for(
auto letter : l) {
 
  340             o<< genset_t::separation_mark();
 
  341           genset().print(letter, o);
 
  355       else if (
format == 
"text")
 
  358         raise(
"invalid format: ", 
format);
 
  362     template<
unsigned version = version::fsm_json>
 
  364       version::check_fsmjson<version>();
 
  368           GenSet 
const& gs = this->
genset();
 
  370           obj = gs.template to_json<version>()->
object();
 
  377     template<
unsigned version = version::fsm_json>
 
  394     template<
unsigned version = version::fsm_json>
 
  404             size_t pos=s.length();
 
  411               for(
auto val : *(p->
array())) {
 
  412                 res.push_back(this->
genset().
template letter_from_json<version>(val));
 
  423         for(
size_t i=v.size(); i!=0; --i)
 
  431   template <
typename GenSet>
 
  439   template <
typename GenSet>
 
array_t * push_back(node_t *p)
 
virtual string_t const  * string() const
Casts this node to string_t.
Definition: node.hh:215
 
node_kind_t const kind
Definition: node.hh:196
 
virtual array_t const  * array() const
Casts this node to array_t.
Definition: node.hh:207
 
virtual object_t * object() override
Casts this node to object_t.
Definition: node.hh:404
 
object_t * push_front(std::string key, node_t *node)
 
std::string value
Definition: node.hh:531
 
The semiring of rational numbers.
Definition: q.hh:42
 
The semiring of floating Numbers.
Definition: r.hh:35
 
Implementation of labels are words.
Definition: wordset.hh:35
 
static word_t letters_of(word_t v)
Prepare to iterate over the letters of v.
Definition: wordset.hh:149
 
std::set< letter_t > letters_t
Definition: wordset.hh:43
 
value_t parse(const std::string &s, size_t &p, bool fixed_alphabet=true) const
Definition: wordset.hh:269
 
GenSet genset_t
Definition: wordset.hh:37
 
word_t concat(const word_t &l, const word_t &r) const
Definition: wordset.hh:140
 
word_t delimit(const word_t &w) const
Add the special character first and last.
Definition: wordset.hh:228
 
static std::string sname()
Definition: wordset.hh:60
 
static size_t hash(const value_t &v)
Definition: wordset.hh:247
 
std::shared_ptr< const genset_t > genset_ptr
Definition: wordset.hh:39
 
word_t concat(const letter_t l, const letter_t r) const
Definition: wordset.hh:118
 
static bool less_than(const value_t l, const value_t r)
Whether l < r.
Definition: wordset.hh:162
 
std::ostream & print(const value_t &l, std::ostream &o, const std::string &format="text") const
Definition: wordset.hh:329
 
static size_t size(const value_t &v)
Definition: wordset.hh:222
 
std::string vname(bool full=true) const
Definition: wordset.hh:65
 
wordset(const genset_t &gs={})
Definition: wordset.hh:52
 
word_t undelimit(const word_t &w) const
Remove first and last characters, that must be "special".
Definition: wordset.hh:237
 
json::node_t * value_to_json(value_t v) const
Definition: wordset.hh:378
 
static value_t one()
Definition: wordset.hh:211
 
json::node_t * to_json() const
Definition: wordset.hh:363
 
bool is_valid(const value_t &v) const
Definition: wordset.hh:184
 
static value_t special()
Definition: wordset.hh:172
 
word_t value_t
Definition: wordset.hh:45
 
const genset_t & genset() const
Definition: wordset.hh:56
 
word_t word(const letter_t &l) const
Convert to a word.
Definition: wordset.hh:112
 
static value_t conv(self_type, value_t v)
Definition: wordset.hh:253
 
static bool is_special(const value_t &v)
Definition: wordset.hh:178
 
typename genset_t::letter_t letter_t
Definition: wordset.hh:41
 
value_t parse(const std::string &s) const
Definition: wordset.hh:310
 
static bool is_one(const value_t &l)
Definition: wordset.hh:217
 
word_t word(const value_t &v) const
Convert to a word.
Definition: wordset.hh:106
 
bool open(bool o) const
Whether unknown letters should be added, or rejected.
Definition: wordset.hh:87
 
typename genset_t::word_t word_t
Definition: wordset.hh:42
 
static constexpr bool is_ratexpset()
Definition: wordset.hh:193
 
word_t concat(const letter_t l, const word_t &r) const
Definition: wordset.hh:132
 
static constexpr bool has_one()
Definition: wordset.hh:199
 
static bool equals(const value_t l, const value_t r)
Whether l == r.
Definition: wordset.hh:156
 
static constexpr bool is_free()
Definition: wordset.hh:93
 
static constexpr bool is_letterized()
Definition: wordset.hh:205
 
value_t value_from_json(json::node_t const *p) const
Definition: wordset.hh:396
 
value_t transpose(const value_t &v) const
Definition: wordset.hh:421
 
value_t value(Args &&... args) const
Value constructor.
Definition: wordset.hh:100
 
std::ostream & print_set(std::ostream &o, const std::string &format="text") const
Definition: wordset.hh:348
 
word_t concat(const word_t &l, const letter_t r) const
Definition: wordset.hh:124
 
any_t word_t
Type for words; it is an alias to any_t since the precise type depends on the context (most of the ti...
Definition: typedefs.hh:67
 
@ ARRAY
Definition: node.hh:94
 
@ STRING
Definition: node.hh:97
 
bool has(const std::map< Key, Value, Compare, Alloc > &s, const Key &e)
Definition: map.hh:53
 
std::string to_string(identities i)
 
auto join(const ratexpset< Ctx1 > &a, const ratexpset< Ctx2 > &b) -> ratexpset< join_t< Ctx1, Ctx2 >>
The union of two ratexpsets.
Definition: ratexpset.hh:449
 
auto meet(const ratexpset< Ctx1 > &a, const ratexpset< Ctx2 > &b) -> ratexpset< meet_t< Ctx1, Ctx2 >>
The meet of two ratexpsets.
Definition: ratexpset.hh:438
 
set_alphabet< L2 > get_union(const set_alphabet< L2 > &lhs, const set_alphabet< L2 > &rhs)
Definition: setalpha.hh:364
 
set_alphabet< L2 > intersection(const set_alphabet< L2 > &lhs, const set_alphabet< L2 > &rhs)
Definition: setalpha.hh:357
 
auto format(const ValueSet &vs, const typename ValueSet::value_t &v, Args &&... args) -> std::string
Format v via vs.print.
Definition: stream.hh:109
 
std::size_t hash_value(const T &v)
Definition: hash.hh:76
 
static const std::string full
Completely version of Awali as a std::string.
Definition: version.hh:42
 
Main namespace of Awali.
Definition: ato.hh:22
 
Exceptions thrown during parsing.
Definition: parse_exception.hh:26
 
marker type for labelsets where labels are words
Definition: kind.hh:86