-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmodelspec.hpp
More file actions
42 lines (32 loc) · 1.09 KB
/
modelspec.hpp
File metadata and controls
42 lines (32 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef MODELSPEC_HPP
#define MODELSPEC_HPP
#include <string>
#include <vector>
#include "coefficient.hpp"
#include "spec_parser/RandomVariable.hpp"
#include "spec_parser/Driver.hpp"
namespace Exception {
namespace ModelSpec {
struct InvalidModel : public std::runtime_error {
InvalidModel(const std::string& why)
: runtime_error("Error: invalid model (" + why + ").") {}
};
struct UnrecoverableParseError : public std::runtime_error {
UnrecoverableParseError() : runtime_error("Error: unrecoverable parse error.") {}
};
} // namespace Exception
} // namespace ModelSpec
struct ModelSpec {
using Variable = spec_parser::Driver::VarType;
using Expression = spec_parser::Driver::ExpType;
void from_string(const std::string& str);
void from_stream(std::istream& is);
Expression rate_expr, odds_expr;
std::unordered_map<std::string, Variable> variables;
private:
spec_parser::Driver parser;
};
void log(const std::function<void(const std::string& s)> log_func,
const ModelSpec& model_spec);
std::istream& operator>>(std::istream& is, ModelSpec& model_spec);
#endif // MODELSPEC_HPP