diff options
author | Adrian Kummerländer | 2011-11-18 21:29:51 +0100 |
---|---|---|
committer | Adrian Kummerländer | 2011-11-18 21:29:51 +0100 |
commit | 64c34a42ce96c8368b8dc0636e8a452def6f8ea5 (patch) | |
tree | f51db27bc1ef84eb81d22336180662f8d748da16 /parser.h | |
download | SimpleParser-64c34a42ce96c8368b8dc0636e8a452def6f8ea5.tar SimpleParser-64c34a42ce96c8368b8dc0636e8a452def6f8ea5.tar.gz SimpleParser-64c34a42ce96c8368b8dc0636e8a452def6f8ea5.tar.bz2 SimpleParser-64c34a42ce96c8368b8dc0636e8a452def6f8ea5.tar.lz SimpleParser-64c34a42ce96c8368b8dc0636e8a452def6f8ea5.tar.xz SimpleParser-64c34a42ce96c8368b8dc0636e8a452def6f8ea5.tar.zst SimpleParser-64c34a42ce96c8368b8dc0636e8a452def6f8ea5.zip |
Inital commit
Diffstat (limited to 'parser.h')
-rw-r--r-- | parser.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/parser.h b/parser.h new file mode 100644 index 0000000..e4299dc --- /dev/null +++ b/parser.h @@ -0,0 +1,40 @@ +#include <stack> +#include <string> +#include <sstream> +#include <exception> +#include <boost/lexical_cast.hpp> + +#include "tree.h" + +struct ParserResult +{ + double result; + string tree; +}; + +class Parser +{ + public: + ParserResult calculate(string, bool); + + private: + int getPriority(char); + vector<string>* lexer(string); + Node* buildTree(Tree**, string); +}; + +class parenthese_exception: public 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() + { + return "Unexpected operator placement - check your input term."; + } +}; |