aboutsummaryrefslogtreecommitdiff
path: root/src/tree.h
diff options
context:
space:
mode:
authorAdrian Kummerländer2013-01-05 22:30:35 +0100
committerAdrian Kummerländer2013-01-05 22:30:35 +0100
commitcde848ce1eb995170723f6f070b9fcba0dfdb880 (patch)
treeb28b436619ade0f9b3ff7603cc987d7b5a621ff3 /src/tree.h
parente3081360c65eb4994e7e8042898cec72de0d560b (diff)
downloadSimpleParser-cde848ce1eb995170723f6f070b9fcba0dfdb880.tar
SimpleParser-cde848ce1eb995170723f6f070b9fcba0dfdb880.tar.gz
SimpleParser-cde848ce1eb995170723f6f070b9fcba0dfdb880.tar.bz2
SimpleParser-cde848ce1eb995170723f6f070b9fcba0dfdb880.tar.lz
SimpleParser-cde848ce1eb995170723f6f070b9fcba0dfdb880.tar.xz
SimpleParser-cde848ce1eb995170723f6f070b9fcba0dfdb880.tar.zst
SimpleParser-cde848ce1eb995170723f6f070b9fcba0dfdb880.zip
Moved node classes into separate compilation unit; File extension change
Diffstat (limited to 'src/tree.h')
-rw-r--r--src/tree.h61
1 files changed, 5 insertions, 56 deletions
diff --git a/src/tree.h b/src/tree.h
index 4177098..da611c7 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -1,57 +1,13 @@
-#ifndef PARSER_NODE_H_
-#define PARSER_NODE_H_
+#ifndef PARSER_SRC_NODE_H_
+#define PARSER_SRC_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);
+#include "nodes.h"
- 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_;
-};
+namespace SimpleParser {
class Tree {
public:
@@ -68,13 +24,6 @@ class Tree {
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_
+#endif // PARSER_SRC_NODE_H_