blob: e4299dc18e0a044cddcc612d3b3396948a550d59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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.";
}
};
|