aboutsummaryrefslogtreecommitdiff
path: root/tree.h
diff options
context:
space:
mode:
authorAdrian Kummerländer2013-01-05 22:04:23 +0100
committerAdrian Kummerländer2013-01-05 22:04:23 +0100
commite3081360c65eb4994e7e8042898cec72de0d560b (patch)
tree2cac723733c674381ccaf32df5a64fe23b026467 /tree.h
parent0ab1ad8c67ac5579e10104f53040d962a7f98f17 (diff)
downloadSimpleParser-e3081360c65eb4994e7e8042898cec72de0d560b.tar
SimpleParser-e3081360c65eb4994e7e8042898cec72de0d560b.tar.gz
SimpleParser-e3081360c65eb4994e7e8042898cec72de0d560b.tar.bz2
SimpleParser-e3081360c65eb4994e7e8042898cec72de0d560b.tar.lz
SimpleParser-e3081360c65eb4994e7e8042898cec72de0d560b.tar.xz
SimpleParser-e3081360c65eb4994e7e8042898cec72de0d560b.tar.zst
SimpleParser-e3081360c65eb4994e7e8042898cec72de0d560b.zip
Folder structure change; Further improvements of parser code
Diffstat (limited to 'tree.h')
-rw-r--r--tree.h78
1 files changed, 0 insertions, 78 deletions
diff --git a/tree.h b/tree.h
deleted file mode 100644
index 4527095..0000000
--- a/tree.h
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef PARSER_NODE_H_
-#define PARSER_NODE_H_
-
-#include <vector>
-#include <string>
-#include <sstream>
-#include <memory>
-#include <cmath>
-
-namespace SimpleParser {
-
-enum NodeType {
- OPERAND_NODE,
- OPERATOR_NODE,
-};
-
-class Node {
- public:
- virtual ~Node() {};
-
- virtual double solve() = 0;
- virtual NodeType getType() = 0;
- virtual std::string print() = 0;
-
- Node* leftChild;
- Node* rightChild;
-};
-
-class OperatorNode: public Node {
- public:
- explicit OperatorNode(char);
-
- virtual double solve();
- virtual NodeType getType();
- virtual std::string print();
-
- char getFunction();
-
- private:
- char function_;
-};
-
-
-class OperandNode: public Node {
- public:
- explicit OperandNode(double);
-
- virtual double solve();
- virtual NodeType getType();
- virtual std::string print();
-
- private:
- double value_;
-};
-
-class Tree {
- public:
- Node* root;
-
- Node* addOperand(Node**, double);
- Node* addOperator(Node**, char);
-
- std::string print(std::string);
-
- private:
- std::vector<std::unique_ptr<Node>> node_collection_;
-};
-
-class divide_exception: public std::exception {
- virtual const char* what() const throw()
- {
- return "A divison through zero had to be prevented by the parser - check your input term.";
- }
-};
-
-}
-
-#endif // PARSER_NODE_H_