From 0e3cfcde619fb60e6e43bf0ffe715df6d5c22218 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 16 Sep 2014 19:57:28 +0200 Subject: Improved lexer readabilty and replaced raw new in tree construction * "new" in Tree::addNode member method was replaced with C++14 std::make_unique * renamed and constified lexer local variables to increase readabilty ** replaced chunky if-clauses with switch-clauses where appropriate * updated README.md to mention C++14 requirement --- src/nodes.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/nodes.cc') diff --git a/src/nodes.cc b/src/nodes.cc index e75c02b..f15a8c9 100644 --- a/src/nodes.cc +++ b/src/nodes.cc @@ -49,12 +49,11 @@ double OperatorNode::solve() { ); } case TokenType::OPERATOR_DIVIDE: { - double rightChild = this->rightChild->solve(); + const double rightChild{ this->rightChild->solve() }; if ( rightChild != 0 ) { return this->leftChild->solve() / rightChild; - } - else { + } else { throw divide_exception(); } } -- cgit v1.2.3