summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/main.cpp b/main.cpp
index 0d95196..fb8b8df 100644
--- a/main.cpp
+++ b/main.cpp
@@ -6,6 +6,7 @@
#include "include/parser.hpp"
#include "include/expressions.hpp"
#include "include/exceptions.hpp"
+#include "include/differentiator.hpp"
using std::string, std::cin, std::cout, std::getline, std::vector,
std::begin, std::end, std::endl;
@@ -13,16 +14,23 @@ using std::string, std::cin, std::cout, std::getline, std::vector,
int main(){
string input;
Parser parser;
-
+ Expression *tree;
+ Expression *differential = NULL;
getline(cin, input);
- //try {
- Expression *tree = parser.parse(input);
- cout << tree->getRepr() << endl;
- //} catch(const ParserException &e) {
- //cout << e.showMsg() << endl;
- //}
- delete tree;
+ try {
+ tree = parser.parse(input);
+ cout << tree->getRepr() << '\n';
+ } catch(const ParserException &e) {
+ cout << e.showMsg() << endl;
+ tree = NULL;
+ }
+
+ if(tree != NULL) {
+ differential = deriv(tree);
+ delete tree;
+ delete differential;
+ }
return 0;
}