From e3081360c65eb4994e7e8042898cec72de0d560b Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Sat, 5 Jan 2013 22:04:23 +0100 Subject: Folder structure change; Further improvements of parser code --- src/parser.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/parser.h (limited to 'src/parser.h') diff --git a/src/parser.h b/src/parser.h new file mode 100644 index 0000000..12d745a --- /dev/null +++ b/src/parser.h @@ -0,0 +1,36 @@ +#ifndef PARSER_PARSER_H_ +#define PARSER_PARSER_H_ + +#include +#include +#include + +#include "tree.h" + +namespace SimpleParser { + +class Parser { + public: + double calculate(std::string); + + private: + int8_t getPriority(char); + std::vector lexer(std::string); + Node* buildTree(Tree*, std::string); +}; + +class parenthese_exception: public std::exception { + virtual const char* what() const throw() { + return "Invalid parenthesized expression - check your input term."; + } +}; + +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