From 69ce370c9ebf92caea64ef1ba28a502affdad3d5 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Sat, 19 Oct 2013 21:41:19 +0200 Subject: Switched OperatorNode to TokenType * OperatorNode class now uses TokenType for internal operator storage and logic selection * print-Method resolves the TokenType back into its character representation --- src/nodes.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/nodes.h') diff --git a/src/nodes.h b/src/nodes.h index a59f4a5..e90669c 100644 --- a/src/nodes.h +++ b/src/nodes.h @@ -3,11 +3,13 @@ #include +#include "utils.h" + namespace SimpleParser { -enum NodeType { - OPERAND_NODE, - OPERATOR_NODE, +enum class NodeType { + OPERAND, + OPERATOR, }; class Node { @@ -24,22 +26,21 @@ class Node { class OperatorNode: public Node { public: - explicit OperatorNode(char); + explicit OperatorNode(TokenType); virtual double solve(); virtual NodeType getType(); virtual std::string print(); - char getFunction(); + TokenType getToken(); private: - char function_; + TokenType operator_; }; class OperandNode: public Node { public: explicit OperandNode(double); - explicit OperandNode(std::string); virtual double solve(); virtual NodeType getType(); -- cgit v1.2.3