mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-28 21:07:59 +03:00
Merge branch 'roman'
This commit is contained in:
@@ -1,27 +1,5 @@
|
|||||||
#include "TOMLNode.hpp"
|
#include "TOMLNode.hpp"
|
||||||
|
|
||||||
/* toml_node::toml_node(void) */
|
|
||||||
/* { */
|
|
||||||
/* return; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* toml_node::toml_node(const toml_node &src) */
|
|
||||||
/* { */
|
|
||||||
/* *this = src; */
|
|
||||||
/* return; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* toml_node::~toml_node(void) */
|
|
||||||
/* { */
|
|
||||||
/* return; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* toml_node &toml_node::operator=(const toml_node &rhs) */
|
|
||||||
/* { */
|
|
||||||
/* //code */
|
|
||||||
/* return (*this); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
toml_node::e_type toml_node::get_type(void)
|
toml_node::e_type toml_node::get_type(void)
|
||||||
{
|
{
|
||||||
return (type);
|
return (type);
|
||||||
|
|||||||
@@ -1,27 +1,5 @@
|
|||||||
#include "TOMLParser.hpp"
|
#include "TOMLParser.hpp"
|
||||||
|
|
||||||
/* -Template::-Template(void) */
|
|
||||||
/* { */
|
|
||||||
/* return; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* -Template::-Template(const -Template &src) */
|
|
||||||
/* { */
|
|
||||||
/* *this = src; */
|
|
||||||
/* return; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* -Template::~-Template(void) */
|
|
||||||
/* { */
|
|
||||||
/* return; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* -Template &-Template::operator=(const -Template &rhs) */
|
|
||||||
/* { */
|
|
||||||
/* //code */
|
|
||||||
/* return (*this); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
namespace config
|
namespace config
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -32,7 +10,6 @@ namespace config
|
|||||||
|
|
||||||
void TOMLParser::processMap(void)
|
void TOMLParser::processMap(void)
|
||||||
{
|
{
|
||||||
/* std::cerr << "Processing map" << std::endl; */
|
|
||||||
toml_node *map_node;
|
toml_node *map_node;
|
||||||
s_token current;
|
s_token current;
|
||||||
|
|
||||||
@@ -51,8 +28,6 @@ namespace config
|
|||||||
else
|
else
|
||||||
throw UnexpectedToken("", "near " + current.value);
|
throw UnexpectedToken("", "near " + current.value);
|
||||||
|
|
||||||
/* std::cout << current.value << std::endl; */
|
|
||||||
|
|
||||||
std::vector<std::string> full_name;
|
std::vector<std::string> full_name;
|
||||||
|
|
||||||
full_name = split_name(current.value);
|
full_name = split_name(current.value);
|
||||||
@@ -72,7 +47,6 @@ namespace config
|
|||||||
|
|
||||||
toml_node *TOMLParser::parseMap(void)
|
toml_node *TOMLParser::parseMap(void)
|
||||||
{
|
{
|
||||||
/* std::cerr << "Parsing map" << std::endl; */
|
|
||||||
toml_node *node = new toml_node;
|
toml_node *node = new toml_node;
|
||||||
TOMLMap *mapObject = new TOMLMap;
|
TOMLMap *mapObject = new TOMLMap;
|
||||||
bool completed = false;
|
bool completed = false;
|
||||||
@@ -105,7 +79,6 @@ namespace config
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string key = nextToken.value;
|
std::string key = nextToken.value;
|
||||||
/* std::cerr << key << std::endl; */
|
|
||||||
if (tokenizer.getToken().type != ASSIGN)
|
if (tokenizer.getToken().type != ASSIGN)
|
||||||
throw ExpectedToken("assign", "after " + key);
|
throw ExpectedToken("assign", "after " + key);
|
||||||
|
|
||||||
@@ -137,7 +110,6 @@ namespace config
|
|||||||
}
|
}
|
||||||
case MAPARRAY_DECL:
|
case MAPARRAY_DECL:
|
||||||
{
|
{
|
||||||
/* std::cerr << "reached MAPARRAY_DECL in parseMap" << std::endl; */
|
|
||||||
completed = true;
|
completed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -170,7 +142,6 @@ namespace config
|
|||||||
void TOMLParser::processMapArray(void)
|
void TOMLParser::processMapArray(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* std::cerr << "Parsing MapArray" << std::endl; */
|
|
||||||
toml_node *map_node;
|
toml_node *map_node;
|
||||||
s_token current;
|
s_token current;
|
||||||
|
|
||||||
@@ -189,8 +160,6 @@ namespace config
|
|||||||
else
|
else
|
||||||
throw UnexpectedToken(current.value, "when expected array of map declaration");
|
throw UnexpectedToken(current.value, "when expected array of map declaration");
|
||||||
|
|
||||||
/* std::cout << current.value << std::endl; */
|
|
||||||
|
|
||||||
std::vector<std::string> full_name;
|
std::vector<std::string> full_name;
|
||||||
|
|
||||||
full_name = split_name(current.value);
|
full_name = split_name(current.value);
|
||||||
@@ -211,7 +180,6 @@ namespace config
|
|||||||
{
|
{
|
||||||
std::string *string;
|
std::string *string;
|
||||||
|
|
||||||
/* std::cerr << "Parsing string" << std::endl; */
|
|
||||||
s_token token = tokenizer.getToken();
|
s_token token = tokenizer.getToken();
|
||||||
string = new std::string(token.value);
|
string = new std::string(token.value);
|
||||||
|
|
||||||
@@ -225,7 +193,6 @@ namespace config
|
|||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
/* std::cerr << "Parsing number" << std::endl; */
|
|
||||||
s_token token = tokenizer.getToken();
|
s_token token = tokenizer.getToken();
|
||||||
value = std::atoi(token.value.c_str());
|
value = std::atoi(token.value.c_str());
|
||||||
|
|
||||||
@@ -237,7 +204,6 @@ namespace config
|
|||||||
|
|
||||||
toml_node *TOMLParser::parseArray(void)
|
toml_node *TOMLParser::parseArray(void)
|
||||||
{
|
{
|
||||||
/* std::cerr << "Parsing array" << std::endl; */
|
|
||||||
toml_node *result = new toml_node;
|
toml_node *result = new toml_node;
|
||||||
TOMLArray *array = new TOMLArray;
|
TOMLArray *array = new TOMLArray;
|
||||||
toml_node *node;
|
toml_node *node;
|
||||||
@@ -305,7 +271,6 @@ namespace config
|
|||||||
{
|
{
|
||||||
bool value;
|
bool value;
|
||||||
|
|
||||||
/* std::cerr << "Parsing bool" << std::endl; */
|
|
||||||
s_token token = tokenizer.getToken();
|
s_token token = tokenizer.getToken();
|
||||||
if (token.value == "true")
|
if (token.value == "true")
|
||||||
value = true;
|
value = true;
|
||||||
@@ -321,7 +286,6 @@ namespace config
|
|||||||
toml_node *TOMLParser::parseNil(void)
|
toml_node *TOMLParser::parseNil(void)
|
||||||
{
|
{
|
||||||
toml_node *node = new toml_node;
|
toml_node *node = new toml_node;
|
||||||
/* std::cerr << "Parsing NIL" << std::endl; */
|
|
||||||
node->setNil();
|
node->setNil();
|
||||||
return (node);
|
return (node);
|
||||||
}
|
}
|
||||||
@@ -329,7 +293,6 @@ namespace config
|
|||||||
/* parse tha root ! */
|
/* parse tha root ! */
|
||||||
void TOMLParser::parse(void)
|
void TOMLParser::parse(void)
|
||||||
{
|
{
|
||||||
/* std::cerr << "Parsing ROOT" << std::endl; */
|
|
||||||
bool completed = false;
|
bool completed = false;
|
||||||
while (!completed)
|
while (!completed)
|
||||||
{
|
{
|
||||||
@@ -350,7 +313,6 @@ namespace config
|
|||||||
}
|
}
|
||||||
else if (current.type == MAP_DECL)
|
else if (current.type == MAP_DECL)
|
||||||
{
|
{
|
||||||
/* std::cerr << "MAP_DECL value: " << current.value << std::endl; */
|
|
||||||
tokenizer.set_last(NEWLINE);
|
tokenizer.set_last(NEWLINE);
|
||||||
tokenizer.rollBackToken();
|
tokenizer.rollBackToken();
|
||||||
processMap();
|
processMap();
|
||||||
|
|||||||
@@ -1,26 +1,5 @@
|
|||||||
#include "Tokenizer.hpp"
|
#include "Tokenizer.hpp"
|
||||||
|
|
||||||
/* -Template::-Template(void) */
|
|
||||||
/* { */
|
|
||||||
/* return; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* -Template::-Template(const -Template &src) */
|
|
||||||
/* { */
|
|
||||||
/* *this = src; */
|
|
||||||
/* return; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* -Template::~-Template(void) */
|
|
||||||
/* { */
|
|
||||||
/* return; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* -Template &-Template::operator=(const -Template &rhs) */
|
|
||||||
/* { */
|
|
||||||
/* //code */
|
|
||||||
/* return (*this); */
|
|
||||||
/* } */
|
|
||||||
namespace config
|
namespace config
|
||||||
{
|
{
|
||||||
bool isspace(char c)
|
bool isspace(char c)
|
||||||
@@ -71,7 +50,6 @@ namespace config
|
|||||||
|
|
||||||
if (file.eof())
|
if (file.eof())
|
||||||
{
|
{
|
||||||
DBOUT << RED << "Tokens exhausted" << ENDL;
|
|
||||||
throw NoMoreTokens();
|
throw NoMoreTokens();
|
||||||
}
|
}
|
||||||
prev_pos = file.tellg();
|
prev_pos = file.tellg();
|
||||||
@@ -222,19 +200,12 @@ namespace config
|
|||||||
do
|
do
|
||||||
file.get(c);
|
file.get(c);
|
||||||
while (c != '\n' || file.eof());
|
while (c != '\n' || file.eof());
|
||||||
DBOUT << "getting comment token" << ENDL;
|
|
||||||
if (last_token == NO_TOK || last_token == NEWLINE)
|
if (last_token == NO_TOK || last_token == NEWLINE)
|
||||||
{
|
{
|
||||||
DBOUT << "getting first token instead of comment" << ENDL;
|
|
||||||
struct s_token actual;
|
struct s_token actual;
|
||||||
actual.type = NEWLINE;
|
actual.type = NEWLINE;
|
||||||
while (actual.type == NEWLINE)
|
while (actual.type == NEWLINE)
|
||||||
actual = getToken();
|
actual = getToken();
|
||||||
DBOUT
|
|
||||||
<< "actual token: '"
|
|
||||||
<< actual.value << "', type: "
|
|
||||||
<< actual.type
|
|
||||||
<< ENDL;
|
|
||||||
token = actual;
|
token = actual;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -245,7 +216,6 @@ namespace config
|
|||||||
{
|
{
|
||||||
while (!config::isspace(c) && (c != '\n'))
|
while (!config::isspace(c) && (c != '\n'))
|
||||||
{
|
{
|
||||||
DBOUT << RED << "[" << c << "]" <<ENDL;
|
|
||||||
token.value += c;
|
token.value += c;
|
||||||
file.get(c);
|
file.get(c);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,17 +117,6 @@ namespace config
|
|||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* struct s_token Tokenizer::getKey(void) */
|
|
||||||
/* { */
|
|
||||||
/* char c; */
|
|
||||||
/* struct s_token token; */
|
|
||||||
/* if (file.eof()) */
|
|
||||||
/* { */
|
|
||||||
/* std::cout << "Tokens exhausted" << std::endl; */
|
|
||||||
/* } */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user