-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathParser.hpp
86 lines (72 loc) · 1.96 KB
/
Parser.hpp
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
79
80
81
82
83
84
85
86
#pragma once
#include "Lexer.hpp"
#include <utility>
typedef struct s_route {
s_route();
std::string path;
std::string redir;
std::list<std::string> httpMethods;
std::list<std::string> index;
std::string rroot;
int dirListing;
} t_route;
typedef struct s_server {
s_server();
std::string host;
int port;
std::string serverName;
std::string root;
std::string redir;
std::list<std::string> httpMethods;
std::list<std::string> index;
std::list<std::pair<int, std::string> > errorPages;
std::list<std::pair<std::string, std::string> > cgi;
long long maxCBSize;
int maxConn;
int dirListing;
std::list<t_route> route;
} t_server;
class Parser
{
private:
std::list<token>::iterator it;
std::list<token>::iterator end;
std::list<token> tokens;
std::list<t_server> serverNodes;
std::map<int, bool> nodeCheck;
std::list<token>::iterator getLastTokenIt(std::list<token> tokens);
void resetParam(int type, int identLevel);
std::string getParam(token token);
std::string getRoute(token token);
bool checkIndent(token token);
long long convertToByte(std::string str);
void pushBackMultipleParams(std::list<std::string>& list, std::string str);
/* Start of BNF syntax validator and 'serverNodes'
composer based on syntax.txt. */
bool configuration();
bool configurationCase1();
bool configurationCase2();
bool serverBlock();
bool serverBlockCase1();
bool directives();
bool directivesCase1();
bool directivesCase2();
bool directivesCase3();
bool directivesCase4();
bool directivesCase5();
bool directivesCase6();
bool blockDirs(int flag);
bool blockDirsCase1(int flag);
bool blockDirsCase2(int flag);
template <typename T>
bool parameterLst(T& container);
template <typename T>
bool parameterLstCase1(T& container);
public:
Parser();
~Parser();
void parse(std::list<token> tokens);
std::list<t_server>::iterator getServerNodesIt(void);
std::list<t_server> getServerNodes(void);
void printServerNodes(std::list<t_server>::iterator it);
};