From 5a1ee058e1c0f4e6f2a37f0c302671d73b66b0b7 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 27 Sep 2014 18:35:16 +0200 Subject: Removed line breaks from `dot` export and fixed naming error * "doubleToString" converts a string to double, i.e. it should be named "stringToDouble"… --- src/tree.cc | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'src/tree.cc') diff --git a/src/tree.cc b/src/tree.cc index 900d891..ab227e4 100644 --- a/src/tree.cc +++ b/src/tree.cc @@ -50,12 +50,7 @@ std::string Tree::print() const { out << "digraph \"" << this->term_ - << "\"" - << std::endl - << "{" - << std::endl - << "node [shape = box];" - << std::endl; + << "\" { node [shape = box]; "; std::size_t nodeIndex{}; @@ -64,8 +59,7 @@ std::string Tree::print() const { << nodeIndex << " [ label = \"" << node->print() - << "\"];" - << std::endl; + << "\"]; "; if ( node->rightChild != nullptr && node->leftChild != nullptr ) { @@ -78,8 +72,7 @@ std::string Tree::print() const { << nodeIndex << "\" -> \"node" << childIndex - << "\";" - << std::endl; + << "\"; "; } ++childIndex; @@ -89,7 +82,7 @@ std::string Tree::print() const { ++nodeIndex; } - out << "}" << std::endl; + out << " }"; return out.str(); } @@ -119,9 +112,9 @@ Node* Tree::buildTree(const std::string& term) { const std::string& element = *elementIterator; const TokenType elementToken = determineToken(element.front()); - if ( elementToken != TokenType::VALUE_NUMBER && - elementToken != TokenType::VALUE_IDENTIFIER && - element.size() == 1 ) { + if ( elementToken != TokenType::VALUE_NUMBER && + elementToken != TokenType::VALUE_IDENTIFIER && + element.size() == 1 ) { if ( operators.empty() ) { operators.push( this->addNode(elementToken) @@ -155,7 +148,7 @@ Node* Tree::buildTree(const std::string& term) { case TokenType::VALUE_NUMBER: case TokenType::OPERATOR_MINUS: { operands.push(this->addNode( - doubleToString(subElements.front()) + stringToDouble(subElements.front()) )); break; -- cgit v1.2.3