diff options
author | Adrian Kummerländer | 2013-01-05 17:46:21 +0100 |
---|---|---|
committer | Adrian Kummerländer | 2013-01-05 17:46:21 +0100 |
commit | 0ab1ad8c67ac5579e10104f53040d962a7f98f17 (patch) | |
tree | 257428157cbf53b941ce19147ec59bf79cf4675b /parser.h | |
parent | 16e2509100611447887f6050a5eb1c21ac9170c4 (diff) | |
download | SimpleParser-0ab1ad8c67ac5579e10104f53040d962a7f98f17.tar SimpleParser-0ab1ad8c67ac5579e10104f53040d962a7f98f17.tar.gz SimpleParser-0ab1ad8c67ac5579e10104f53040d962a7f98f17.tar.bz2 SimpleParser-0ab1ad8c67ac5579e10104f53040d962a7f98f17.tar.lz SimpleParser-0ab1ad8c67ac5579e10104f53040d962a7f98f17.tar.xz SimpleParser-0ab1ad8c67ac5579e10104f53040d962a7f98f17.tar.zst SimpleParser-0ab1ad8c67ac5579e10104f53040d962a7f98f17.zip |
Fixes for ugly style used in my early C++ days
Diffstat (limited to 'parser.h')
-rw-r--r-- | parser.h | 39 |
1 files changed, 19 insertions, 20 deletions
@@ -1,37 +1,36 @@ -#include <stdlib.h> +#ifndef PARSER_PARSER_H_ +#define PARSER_PARSER_H_ + +#include <vector> #include <stack> #include <exception> + #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<string> lexer(string); - Node* buildTree(Tree*, string); + int8_t getPriority(char); + std::vector<std::string> 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_ |