-
Notifications
You must be signed in to change notification settings - Fork 4
/
ast.hpp
66 lines (50 loc) · 1.13 KB
/
ast.hpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef __AST_HPP__INCLUDED__
#define __AST_HPP__INCLUDED__
// This file defines the AST (abstract syntax tree) for the Citip grammar,
// i.e. the data structures that hold all the information from the parsed
// input statements.
# include <string>
# include <vector>
namespace ast
{
enum {
SIGN_PLUS,
SIGN_MINUS
};
enum {
REL_EQ,
REL_LE,
REL_GE
};
typedef std::vector<std::string> VarList;
typedef std::vector<VarList> VarCore;
struct Quantity
{
VarCore parts;
VarList cond;
};
struct Term
{
double coefficient;
Quantity quantity;
inline Term& flip_sign(int s)
{
if (s == SIGN_MINUS) {
coefficient = -coefficient;
}
return *this;
}
};
typedef std::vector<Term> Expression;
struct Relation {
Expression left;
int relation;
Expression right;
};
typedef VarCore MutualIndependence;
typedef VarCore MarkovChain;
struct FunctionOf {
VarList function, of;
};
}
#endif // include-guard