-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.h
40 lines (33 loc) · 1.02 KB
/
parser.h
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
#ifndef PARSER_H
#define PARSER_H
#include <cstdlib>
#include <string>
#include <sstream>
#include <stack>
#include <queue>
#include <vector>
#include "streamutilities.h"
#include "parseexception.h"
#include "mixednumber.h"
class parser
{
public:
enum ERRORS {TRANSLATE_ERROR};
// Takes in algebraic expression, returns RPN expression
// Throws parseexpression when invalid
static std::vector<std::string> parseToRPN(const std::string &input);
private:
//takes in expression and returns RPN
static std::vector<std::string> toRPN(std::vector<std::string>);
//used by RPN during equality comparisons
static int getPrecedence(std::string);
//product is sent to toRPN
static std::vector<std::string> strToVector(std::string);
// Determines if algebraic expression is valid
// Throws parseexception if input not valid
static void ensureInputValid(const std::string &input);
// Translates algebraic expression to RPN expression
static std::string toRPN(const std::string &input);
parser() {}
};
#endif // PARSER_H