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/tree.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/tree.cc') diff --git a/src/tree.cc b/src/tree.cc index 2dfb786..e63b7b3 100644 --- a/src/tree.cc +++ b/src/tree.cc @@ -41,7 +41,7 @@ std::string Tree::print() { << "\"];" << std::endl; - if ( (*it)->getType() == NodeType::OPERATOR_NODE ) { + if ( (*it)->getType() == NodeType::OPERATOR ) { for ( auto iter = this->node_collection_.begin(); iter != this->node_collection_.end(); ++iter ) { @@ -96,9 +96,9 @@ Node* Tree::addOperand(Node** place, std::string value) { return this->node_collection_.back().get(); } -Node* Tree::addOperator(Node** place, char oper) { +Node* Tree::addOperator(Node** place, TokenType token) { this->node_collection_.emplace_back( - new OperatorNode(oper) + new OperatorNode(token) ); if ( place != nullptr ) { @@ -137,9 +137,9 @@ Node* Tree::buildTree(std::string term) { static_cast(topNodeFrom(operatorStack)) ); - if ( token > getTokenType(lastNode->getFunction()) ) { + if ( token > lastNode->getToken() ) { operatorStack.push( - this->addOperator(nullptr, currTerm[0]) + this->addOperator(nullptr, token) ); } else { Node* currOperator = topNodeFrom(operatorStack); @@ -157,7 +157,7 @@ Node* Tree::buildTree(std::string term) { } } else { operatorStack.push( - this->addOperator(nullptr, currTerm[0]) + this->addOperator(nullptr, token) ); } } else { -- cgit v1.2.3