17 #ifndef AWALI_WEIGHTSET_Z_HH
18 # define AWALI_WEIGHTSET_Z_HH
28 #include <awali/common/parse_exception.cc>
44 std::string
vname(
bool =
true)
const
93 "Z: div: invalid division: ", l,
'/',
r);
109 raise(
"Z: star: invalid value: ",
format(*
this, v));
178 parse(
const std::string & s,
size_t& p) {
194 const std::string& =
"text")
204 else if (
format ==
"text")
207 raise(
"invalid format: ",
format);
211 template<
unsigned version = version::fsm_json>
216 version::check_fsmjson<version>();
226 template<
unsigned version = version::fsm_json>
231 version::check_fsmjson<version>();
240 template<
unsigned version = version::fsm_json>
244 version::check_fsmjson<version>();
257 inline z join(
const z&,
const z&) {
return {}; }
258 inline z join(
const n&,
const z&) {
return {}; }
259 inline z join(
const z&,
const n&) {
return {}; }
260 inline z join(
const b&,
const z&) {
return {}; }
261 inline z join(
const z&,
const b&) {
return {}; }
virtual int to_int() const
Coerces this node_t to int.
Definition: node.hh:321
object_t * push_back(std::string key, node_t *node)
The Boolean semring.
Definition: b.hh:38
bool value_t
Definition: b.hh:56
The semiring of Natural numbers.
Definition: n.hh:34
unsigned int value_t
Definition: n.hh:55
The semiring of floating Numbers.
Definition: r.hh:35
The semiring of Integers.
Definition: z.hh:35
static constexpr star_status_t star_status()
Definition: z.hh:144
constexpr static bool is_special(value_t)
Definition: z.hh:112
static bool is_zero(const value_t v)
Definition: z.hh:118
static z make(std::istream &is)
Build from the description in is.
Definition: z.hh:50
static value_t sub(const value_t l, const value_t r)
Definition: z.hh:77
std::ostream & print_set(std::ostream &o, const std::string &format="text") const
Definition: z.hh:200
json::node_t * value_to_json(value_t v) const
Definition: z.hh:228
value_t value_from_json(json::node_t const *p) const
Definition: z.hh:213
value_t star(const value_t v) const
Definition: z.hh:104
static value_t conv(std::istream &stream)
Definition: z.hh:183
static std::ostream & print(const value_t v, std::ostream &o, const std::string &="text")
Definition: z.hh:193
static value_t transpose(const value_t v)
Definition: z.hh:147
static constexpr bool show_one()
Definition: z.hh:143
static value_t add(const value_t l, const value_t r)
Definition: z.hh:71
static value_t ldiv(const value_t l, const value_t r)
Definition: z.hh:98
static bool less_than(value_t lhs, value_t rhs)
Whether lhs < rhs.
Definition: z.hh:136
static value_t zero()
Definition: z.hh:59
static value_t one()
Definition: z.hh:65
static value_t rdiv(const value_t l, const value_t r)
Definition: z.hh:89
static constexpr bool is_commutative_semiring()
Definition: z.hh:141
static value_t parse(const std::string &s, size_t &p)
Definition: z.hh:178
static value_t mul(const value_t l, const value_t r)
Definition: z.hh:83
static std::string sname()
Definition: z.hh:39
static bool is_one(const value_t v)
Definition: z.hh:124
static value_t conv(n, n::value_t v)
Definition: z.hh:164
int value_t
Definition: z.hh:56
json::node_t * to_json() const
Definition: z.hh:242
static size_t hash(value_t v)
Definition: z.hh:152
std::string vname(bool=true) const
Definition: z.hh:44
static bool equals(const value_t l, const value_t r)
Definition: z.hh:130
static value_t conv(self_type, value_t v)
Definition: z.hh:158
static value_t conv(b, b::value_t v)
Definition: z.hh:171
star_status_t
The different behaviours a weightset may have with respect to the star.
Definition: enums.hh:163
@ NON_STARRABLE
Definition: enums.hh:166
int lr_parse_int(std::string const &s, size_t &p, bool allow_empty=false, int value_if_empty=0)
Reads an int written in decimal left of position p in string s, by using as many characters as possib...
Definition: lr_parse_number.hh:239
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