-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parser.h
78 lines (70 loc) · 1.44 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <string>
#include <regex>
#include <map>
#include <stdexcept>
#include <iostream>
#ifndef PARSER
#define PARSER
namespace db {
class Table;
class Record;
namespace parser {
enum Equiv {EQ='=', NEQ='!',
LEQ='l', GEQ='g',
LT='<', GT='>',
LPAREN='(', RPAREN=')',
AND='&', OR='|', NOT = 'n',
VAL='v', IN = 'i', ALL = 'a',
ANY = 'y', EXISTS = 'e', ENDL=';'};
class Character {
/*
* The character goes through each character of the stream.
* The types of characters are checked to see which is the one needed.
*/
public:
Character()
{
};
Character(std::string str);
Equiv type;
std::string val;
};
class CharacterStream {
/*
* The input is handled, and the character is handled.
*
*/
public:
CharacterStream() {
};
CharacterStream(std::string str);
Character find_char();
void push(Character t);
std::vector<Character>getCharacters() const;
bool empty() const;
int size() const;
private:
bool full;
Character buffer;
std::vector<Character> Characters;
};
class Parser {
/*
* The parser returns the Record (of type string) that is used for the table
*/
public:
Parser(Table* t, std::string str)
: tab(t), stream(str), character_stream(str) {}
bool check_expr(Record* r);
private:
bool output_expr();
bool cond();
bool check(std::string attr_name, Character op, std::string val);
std::string stream;
CharacterStream character_stream;
Record *rec;
Table *tab;
};
}
}
#endif