17 #ifndef AWALI_WEIGHTSET_B_HH
18 # define AWALI_WEIGHTSET_B_HH
26 #include <awali/common/parse_exception.cc>
32 #include <awali/common/json/node.cc>
46 static std::string
vname(
bool =
true) {
51 static b make(std::istream& is) {
136 if (i == 0 || i == 1)
147 if ((p>=4)&&(!s.compare(p-4,4,
"true"))) {
151 if ((p>=5)&&(!s.compare(p-5,5,
"false"))) {
163 const std::string&
format =
"text") {
165 o << (v ?
"\\top" :
"\\bot");
167 o << (v?
"true" :
"false");
174 else if (
format ==
"text")
177 raise(
"invalid format: ",
format);
182 template<
unsigned version = version::fsm_json>
197 template<
unsigned version = version::fsm_json>
211 template<
unsigned version = version::fsm_json>
224 inline b join(
const b&,
const b&) {
return {}; }
virtual bool to_bool() const
Coerces this node_t to bool.
Definition: node.hh:306
The Boolean semring.
Definition: b.hh:38
static size_t hash(value_t v)
Definition: b.hh:124
static json::node_t * to_json()
Definition: b.hh:184
static value_t conv(std::istream &is)
Definition: b.hh:132
static value_t star(value_t)
Definition: b.hh:85
static value_t add(value_t l, value_t r)
Definition: b.hh:68
static const finite_t finite
Definition: b.hh:58
static bool is_one(value_t v)
Definition: b.hh:108
constexpr static bool is_special(value_t)
Definition: b.hh:100
static value_t one()
Definition: b.hh:64
static value_t conv(self_type, value_t v)
Definition: b.hh:128
static std::ostream & print(value_t v, std::ostream &o, const std::string &format="text")
Definition: b.hh:162
static bool equals(value_t l, value_t r)
Definition: b.hh:89
static value_t zero()
Definition: b.hh:60
static value_t rdiv(value_t l, value_t r)
Definition: b.hh:76
static bool less_than(value_t lhs, value_t rhs)
Whether lhs < rhs.
Definition: b.hh:95
static value_t parse(const std::string &s, size_t &p)
Definition: b.hh:146
constexpr static bool show_one()
Definition: b.hh:114
static value_t ldiv(value_t l, value_t r)
Definition: b.hh:81
static json::node_t * value_to_json(value_t v)
Definition: b.hh:199
constexpr static bool is_commutative_semiring()
Definition: b.hh:112
static bool is_zero(value_t v)
Definition: b.hh:104
static std::string vname(bool=true)
Definition: b.hh:46
bool finite_t
Definition: b.hh:57
static b make(std::istream &is)
Build from the description in is.
Definition: b.hh:51
bool value_t
Definition: b.hh:56
static value_t value_from_json(json::node_t const *p)
Definition: b.hh:212
static std::ostream & print_set(std::ostream &o, const std::string &format="text")
Definition: b.hh:171
static std::string sname()
Definition: b.hh:42
static value_t mul(value_t l, value_t r)
Definition: b.hh:72
static value_t transpose(value_t v)
Definition: b.hh:120
constexpr static star_status_t star_status()
Definition: b.hh:116
The semiring of floating Numbers.
Definition: r.hh:35
star_status_t
The different behaviours a weightset may have with respect to the star.
Definition: enums.hh:163
@ STARRABLE
The star of every element exists.
Definition: enums.hh:165
std::string to_string(identities i)
void eat(std::istream &is, char c)
Check lookahead character and advance.
Definition: stream.hh:62
ATTRIBUTE_NORETURN void fail_reading(std::istream &is, std::string explanation)
Throw an exception after failing to read from is.
Definition: stream.hh:93
auto join(const ratexpset< Ctx1 > &a, const ratexpset< Ctx2 > &b) -> ratexpset< join_t< Ctx1, Ctx2 >>
The union of two ratexpsets.
Definition: ratexpset.hh:445
auto format(const ValueSet &vs, const typename ValueSet::value_t &v, Args &&... args) -> std::string
Format v via vs.print.
Definition: stream.hh:109
void require(bool b, Args &&... args)
If b is not verified, raise an error with args as message.
Definition: raise.hh:55
std::size_t hash_value(const T &v)
Definition: hash.hh:76
Main namespace of Awali.
Definition: ato.hh:22
Exceptions thrown during parsing.
Definition: parse_exception.hh:26