From c04051c034a5de33ba25e3182191d854edbbb516 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Fri, 27 Sep 2013 18:02:33 +0200 Subject: Modified Makefile to generate shared library * library is called libSimpleParser.so * parser was renamed to clc * test and clc are using the shared library --- src/tree.cc | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/tree.cc') diff --git a/src/tree.cc b/src/tree.cc index 868183d..45484c6 100644 --- a/src/tree.cc +++ b/src/tree.cc @@ -18,30 +18,6 @@ double Tree::solve() { return this->root_node_->solve(); } -Node* Tree::addOperand(Node** place, double value) { - this->node_collection_.emplace_back( - new OperandNode(value) - ); - - if ( place != nullptr ) { - *place = this->node_collection_.back().get(); - } - - return this->node_collection_.back().get(); -} - -Node* Tree::addOperator(Node** place, char oper) { - this->node_collection_.emplace_back( - new OperatorNode(oper) - ); - - if ( place != nullptr ) { - *place = this->node_collection_.back().get(); - } - - return this->node_collection_.back().get(); -} - std::string Tree::print() { std::stringstream out; out.precision(std::numeric_limits::digits10); @@ -65,7 +41,7 @@ std::string Tree::print() { << "\"];" << std::endl; - if ( (*it)->getType() == OPERATOR_NODE ) { + if ( (*it)->getType() == NodeType::OPERATOR_NODE ) { for ( auto iter = this->node_collection_.begin(); iter != this->node_collection_.end(); ++iter ) { @@ -96,6 +72,30 @@ std::string Tree::print() { return out.str(); } +Node* Tree::addOperand(Node** place, double value) { + this->node_collection_.emplace_back( + new OperandNode(value) + ); + + if ( place != nullptr ) { + *place = this->node_collection_.back().get(); + } + + return this->node_collection_.back().get(); +} + +Node* Tree::addOperator(Node** place, char oper) { + this->node_collection_.emplace_back( + new OperatorNode(oper) + ); + + if ( place != nullptr ) { + *place = this->node_collection_.back().get(); + } + + return this->node_collection_.back().get(); +} + Node* Tree::buildTree(std::string term) { std::stack operandStack; std::stack operatorStack; -- cgit v1.2.3