blob: c1ecd22faf06b426607fb20addc024ac27ba1009 (
plain)
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
|
#include <iterator>
#include <ostream>
#include <string>
#include <vector>
#include <iostream>
#include "include/parser.hpp"
#include "include/expressions.hpp"
#include "include/exceptions.hpp"
#include "include/differentiator.hpp"
#include "include/simplifier.hpp"
using std::string, std::cin, std::cout, std::getline, std::vector,
std::begin, std::end, std::endl;
int main(){
string input;
Parser parser;
Expression *tree;
Expression *simplified = NULL;
getline(cin, input);
try {
tree = parser.parse(input);
cout << tree->getRepr() << '\n';
} catch(const ParserException &e) {
cout << e.showMsg() << endl;
tree = NULL;
}
if(tree != NULL) {
simplified = simplify(tree);
cout << simplified->getRepr() << endl;
delete tree;
delete simplified;
}
return 0;
}
|