aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-09-27 18:35:16 +0200
committerAdrian Kummerlaender2014-09-27 18:35:16 +0200
commit5a1ee058e1c0f4e6f2a37f0c302671d73b66b0b7 (patch)
treeffe4063af7bd6689a9efa3569f33d2b785c71410
parent1479b2ab1ae2e5a82ab6ac79663939ae651000fd (diff)
downloadSimpleParser-5a1ee058e1c0f4e6f2a37f0c302671d73b66b0b7.tar
SimpleParser-5a1ee058e1c0f4e6f2a37f0c302671d73b66b0b7.tar.gz
SimpleParser-5a1ee058e1c0f4e6f2a37f0c302671d73b66b0b7.tar.bz2
SimpleParser-5a1ee058e1c0f4e6f2a37f0c302671d73b66b0b7.tar.lz
SimpleParser-5a1ee058e1c0f4e6f2a37f0c302671d73b66b0b7.tar.xz
SimpleParser-5a1ee058e1c0f4e6f2a37f0c302671d73b66b0b7.tar.zst
SimpleParser-5a1ee058e1c0f4e6f2a37f0c302671d73b66b0b7.zip
Removed line breaks from `dot` export and fixed naming error
* "doubleToString" converts a string to double, i.e. it should be named "stringToDouble"…
-rw-r--r--src/tree.cc23
-rw-r--r--src/utils.cc2
-rw-r--r--src/utils.h2
3 files changed, 10 insertions, 17 deletions
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<OperatorNode>(elementToken)
@@ -155,7 +148,7 @@ Node* Tree::buildTree(const std::string& term) {
case TokenType::VALUE_NUMBER:
case TokenType::OPERATOR_MINUS: {
operands.push(this->addNode<OperandNode>(
- doubleToString(subElements.front())
+ stringToDouble(subElements.front())
));
break;
diff --git a/src/utils.cc b/src/utils.cc
index 832b701..256cad8 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -195,7 +195,7 @@ std::vector<std::string> lexer(const std::string& term) {
return resultBuffer;
}
-double doubleToString(const std::string& str) {
+double stringToDouble(const std::string& str) {
double value;
std::istringstream convertStream(str);
convertStream >> value;
diff --git a/src/utils.h b/src/utils.h
index 63ccf55..5c6e80e 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -33,7 +33,7 @@ TokenType determineToken(const std::string&);
PrecedenceLevel precedence(TokenType);
std::vector<std::string> lexer(const std::string&);
-double doubleToString(const std::string&);
+double stringToDouble(const std::string&);
}