-
Notifications
You must be signed in to change notification settings - Fork 1
/
Simplifier.hpp
46 lines (35 loc) · 1003 Bytes
/
Simplifier.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
#ifndef SIMPLIFIER_h
#define SIMPLIFIER_h
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <fstream>
#include <memory>
#include "Operator.hpp"
#include "Node.hpp"
#include "RuleSet.hpp"
using namespace std;
class Simplifier
{
protected:
static vector<string> operators;
static map<string, shared_ptr<OperatorNode>> operatorsInfo;
shared_ptr<RuleSet> rules;
vector<int> counter;
public:
Simplifier(string rulesPath, string operatorsPath);
Simplifier();
static void loadOperators(string file_in);
static void loadOperators(map<string, int> ops);
void setRules(shared_ptr<RuleSet> rules);
shared_ptr<RuleSet> getRules();
int simplify(shared_ptr<ExpressionTree> tree);
static bool isOperatorLoaded(string name);
static shared_ptr<OperatorNode> getOperatorInfo(string name);
bool reduceConstants(shared_ptr<Node> n);
vector<int> getCounter();
};
#endif // SIMPLIFIER_h