aboutsummaryrefslogtreecommitdiff
path: root/parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'parser.h')
-rw-r--r--parser.h40
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.";
+ }
+};