From ab3a0312247f1467cd1eee81f6b1d22b499a8715 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Thu, 2 Oct 2014 19:59:48 +0200 Subject: Moved exception based syntax check into buildTree * invalid expressions typically cause the operator and operand stacks to become unbalanced ** this in turn causes a operator_exception instance to be thrown as soon as the shunting yard implementation in "buildTree" tries to modify the stack _too far_ ** this is not directly visible from the tree construction implementation * the compilation unit local helper methods "pop" and "top" now return "boost::optional" instances ** this enables the operator placement errors to be handled where they occur * as a side effect children assignment is now more obvious through correctly named variables * added missing default initialization in lexer implementation --- src/utils.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/utils.cc') diff --git a/src/utils.cc b/src/utils.cc index 256cad8..46617d8 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -66,13 +66,13 @@ PrecedenceLevel precedence(const TokenType token) { } std::vector lexer(const std::string& term) { - std::vector resultBuffer; + std::vector resultBuffer{}; - std::string levelBuffer; - std::string numberBuffer; - std::string identifierBuffer; + std::string levelBuffer{}; + std::string numberBuffer{}; + std::string identifierBuffer{}; - TokenType previousToken; + TokenType previousToken{}; uint32_t level{0}; for ( auto&& termIter = term.begin(); -- cgit v1.2.3