aboutsummaryrefslogtreecommitdiff
path: root/src/nodes.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/nodes.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/nodes.h')
-rw-r--r--src/nodes.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/nodes.h b/src/nodes.h
new file mode 100644
index 0000000..3a99474
--- /dev/null
+++ b/src/nodes.h
@@ -0,0 +1,53 @@
+#ifndef PARSER_SRC_NODES_H_
+#define PARSER_SRC_NODES_H_
+
+#include <string>
+
+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_;
+};
+
+}
+
+#endif // PARSER_SRC_NODES_H_