Webserv
Loading...
Searching...
No Matches
config::Lexer Class Reference

A static utility class that performs lexical analysis on a config string. More...

#include <Lexer.hpp>

Static Public Member Functions

static void tokenize (std::string const &content, TokenArray &res)
static TokenArray tokenize (std::string const &content)
static void printTokens (TokenArray const &tokens)

Private Member Functions

 Lexer (std::string const &content, std::vector< Token > &res)
void run ()
void pushToken (TokenType type, std::string const &literal)
void pushToken (TokenType type, char)
void readChar ()
void eatWhitespaces ()
void identifyLastToken ()
bool isPunctuation ()
bool handleValue ()
void handleComment ()
void handleUnknown ()
void handlePunctuation ()

Private Attributes

std::string const & content_
TokenArraytokens_
size_t pos_
char ch_

Detailed Description

A static utility class that performs lexical analysis on a config string.

The Lexer breaks down a raw string into a sequence of Tokens, which can then be consumed by the Parser. It handles basic elements like keywords, strings, numbers, and punctuation, ignoring whitespace and comments.

Constructor & Destructor Documentation

◆ Lexer()

config::Lexer::Lexer ( std::string const & content,
std::vector< Token > & res )
private

Member Function Documentation

◆ eatWhitespaces()

void config::Lexer::eatWhitespaces ( )
private

◆ handleComment()

void config::Lexer::handleComment ( )
private

◆ handlePunctuation()

void config::Lexer::handlePunctuation ( )
private

◆ handleUnknown()

void config::Lexer::handleUnknown ( )
private

◆ handleValue()

bool config::Lexer::handleValue ( )
private

◆ identifyLastToken()

void config::Lexer::identifyLastToken ( )
private

◆ isPunctuation()

bool config::Lexer::isPunctuation ( )
private

◆ printTokens()

void config::Lexer::printTokens ( TokenArray const & tokens)
static

◆ pushToken() [1/2]

void config::Lexer::pushToken ( TokenType type,
char c )
private

◆ pushToken() [2/2]

void config::Lexer::pushToken ( TokenType type,
std::string const & literal )
private

◆ readChar()

void config::Lexer::readChar ( )
private

◆ run()

void config::Lexer::run ( )
private

◆ tokenize() [1/2]

TokenArray config::Lexer::tokenize ( std::string const & content)
static

◆ tokenize() [2/2]

void config::Lexer::tokenize ( std::string const & content,
TokenArray & res )
static

Member Data Documentation

◆ ch_

char config::Lexer::ch_
private

◆ content_

std::string const& config::Lexer::content_
private

◆ pos_

size_t config::Lexer::pos_
private

◆ tokens_

TokenArray& config::Lexer::tokens_
private

The documentation for this class was generated from the following files: