25 using word_t = std::vector<letter_t>;
29 static auto res =
symbol{
"string_letters"};
69 res.reserve(l.size() + 1);
70 res.insert(end(res), begin(l), end(l));
71 res.insert(end(res), r);
84 res.reserve(1 + r.size());
85 res.insert(end(res), l);
86 res.insert(end(res), begin(r), end(r));
101 res.reserve(l.size() + r.size());
102 res.insert(end(res), begin(l), end(l));
103 res.insert(end(res), begin(r), end(r));
121 return {begin(w) + 1, begin(w) + (s - 1)};
140 return {w.rbegin(), w.rend()};
182 return w.size() == 1;
213 raise(
sname(),
": get_letter: invalid end-of-file");
227 res = std::string{std::istreambuf_iterator<char>(i), {}};
240 o <<
"`\\mathit{" << l <<
"}\\textrm{'}";
246 if (l.get().size() == 1)
249 o <<
'\'' << l <<
'\'';
270 template <
typename T = letter_t>
277 string_letters::special<string_letters::letter_t>()
285 string_letters::special<string_letters::word_t>()
static bool less(const word_t &l, const word_t &r)
Whether l < r.
static letter_t one_letter()
The reserved letter used to forge the "one" label (the unit, the identity).
Print as is. For instance, don't try to escape labels.
static letter_t special_letter()
The reserved letter used to forge the labels for initial and final transitions.
bool is_letter(const letter_t) const
Print as a parsable type string.
static bool less(const letter_t l, const letter_t r)
Whether l < r.
std::vector< letter_t > word_t
word_t to_word(const letter_t l) const
static word_t empty_word()
word_t mul(const letter_t l, const letter_t r) const
word_t delimit(const word_t &w) const
Add the special character first and last.
An input/output format for valuesets.
weightset_mixin< detail::r_impl > r
Provide a variadic mul on top of a binary mul(), and one().
word_t mul(const word_t &l, const letter_t r) const
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
std::ostream & print(const letter_t l, std::ostream &o, const format &fmt={}) const
word_t mul(const letter_t l, const word_t &r) const
Represent alphabets whose "letters" are strings.
bool is_letter(const word_t &w) const
Print as rich UTF-8 text, escaped.
const word_t & to_word(const word_t &l) const
Print as plain (ASCII) text, escaped.
static bool equal(const letter_t l, const letter_t r)
Whether l == r.
symbol letter_t
Internalize the letters to save trees.
char get_char(std::istream &i)
Read a single char, with possible -escape support.
std::ostream & str_escape(std::ostream &os, const std::string &str, const char *special=nullptr)
Output a string, escaping special characters.
static bool is_empty_word(const word_t &w)
letter_t transpose(letter_t l) const
static letter_t get_letter(std::istream &i, bool quoted=true)
Read one letter from i.
static T special()
Special character, used to label transitions from pre() and to post().
word_t mul(const word_t &l, const word_t &r) const
word_t undelimit(const word_t &w) const
Remove first and last characters, that must be "special".
static bool equal(const word_t &l, const word_t &r)
Whether l == r.
std::ostream & print(const word_t &w, std::ostream &o, const format &fmt={}) const
word_t transpose(const word_t &w) const