From 0ab1ad8c67ac5579e10104f53040d962a7f98f17 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Sat, 5 Jan 2013 17:46:21 +0100 Subject: Fixes for ugly style used in my early C++ days --- parser.h | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'parser.h') diff --git a/parser.h b/parser.h index e9cdde1..12d745a 100644 --- a/parser.h +++ b/parser.h @@ -1,37 +1,36 @@ -#include +#ifndef PARSER_PARSER_H_ +#define PARSER_PARSER_H_ + +#include #include #include + #include "tree.h" -struct ParserResult -{ - double result; - string tree; -}; +namespace SimpleParser { -class Parser -{ +class Parser { public: - ParserResult calculate(string, bool); + double calculate(std::string); private: - int getPriority(char); - vector lexer(string); - Node* buildTree(Tree*, string); + int8_t getPriority(char); + std::vector lexer(std::string); + Node* buildTree(Tree*, std::string); }; -class parenthese_exception: public exception -{ - virtual const char* what() const throw() - { +class parenthese_exception: public std::exception { + virtual const char* what() const throw() { return "Invalid parenthesized expression - check your input term."; } }; -class operator_exception: public exception -{ - virtual const char* what() const throw() - { +class operator_exception: public std::exception { + virtual const char* what() const throw() { return "Unexpected operator placement - check your input term."; } }; + +} + +#endif // PARSER_PARSER_H_ -- cgit v1.2.3