mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-29 05:17:59 +03:00
75 lines
1.0 KiB
C++
75 lines
1.0 KiB
C++
#ifndef TOKENIZER_HPP
|
|
#define TOKENIZER_HPP
|
|
|
|
#include "webserv.hpp"
|
|
#include "tomlstuff.hpp"
|
|
|
|
#include <map>
|
|
#include <vector>
|
|
#include <fstream>
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
#include <exception>
|
|
|
|
|
|
namespace config
|
|
{
|
|
enum e_token
|
|
{
|
|
KEY,
|
|
NEWLINE,
|
|
ASSIGN,
|
|
STRING,
|
|
NUMBER,
|
|
COMMA,
|
|
BOOL,
|
|
NIL,
|
|
OPEN_BRACKET,
|
|
CLOSE_BRACKET,
|
|
MAP_DECL,
|
|
MAPARRAY_DECL
|
|
};
|
|
|
|
struct s_token
|
|
{
|
|
std::string value;
|
|
e_token type;
|
|
/* std::string to_string(void); */
|
|
};
|
|
|
|
bool isspace(char c);
|
|
|
|
bool istomlkey(char c);
|
|
|
|
class Tokenizer
|
|
{
|
|
private:
|
|
std::fstream file;
|
|
size_t prev_pos;
|
|
e_token last_token;
|
|
|
|
public:
|
|
Tokenizer(std::string filename);
|
|
char getWithoutWhiteSpace();
|
|
struct s_token getToken();
|
|
bool hasMoreTokens();
|
|
bool firstToken();
|
|
void rollBackToken();
|
|
void set_last(e_token type);
|
|
|
|
};
|
|
|
|
/* struct s_token Tokenizer::getKey(void) */
|
|
/* { */
|
|
/* char c; */
|
|
/* struct s_token token; */
|
|
/* if (file.eof()) */
|
|
/* { */
|
|
/* std::cout << "Tokens exhausted" << std::endl; */
|
|
/* } */
|
|
/* } */
|
|
|
|
}
|
|
|
|
#endif
|