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

Performs syntax analysis on a stream of tokens to build a configuration tree. More...

#include <Parser.hpp>

Static Public Member Functions

static std::vector< ConfigNodeparse (TokenArray const &)

Private Member Functions

 Parser ()
 Parser (TokenArray const &)
size_t size () const
Token const & currentToken () const
Token const & peekToken () const
void consumeToken ()
void expectToken (TokenType type)
void expectToken (std::string const &literal)
bool isTokenAValue () const
void displayCurrentToken () const
void pushTokenTo (ParsedDirectiveArgs &args) const
void handleServerBlock ()
void handleStatement ()
void handleLocationBlock ()
ParsedDirectivePair handleDirective ()

Static Private Member Functions

static void addDirective (ConfigNode &node, ParsedDirectivePair const &pair)

Private Attributes

std::vector< ConfigNodenodes_
TokenArray const & tokens_
size_t pos_

Detailed Description

Performs syntax analysis on a stream of tokens to build a configuration tree.

The Parser consumes tokens from the Lexer and validates them against a defined grammar. Its primary role is to build a tree of ConfigNode objects (the IR) that represents the structure of the configuration file. It ensures syntactic correctness but does not validate the meaning of directives.

Note
This class is responsible for reporting syntax errors (e.g., missing ';'). Semantic errors (e.g., invalid port number) are handled by the ConfigBuilder.

Constructor & Destructor Documentation

◆ Parser() [1/2]

config::Parser::Parser ( )
private

◆ Parser() [2/2]

config::Parser::Parser ( TokenArray const & tokens)
explicitprivate

Member Function Documentation

◆ addDirective()

void config::Parser::addDirective ( ConfigNode & node,
ParsedDirectivePair const & pair )
staticprivate

◆ consumeToken()

void config::Parser::consumeToken ( )
private

◆ currentToken()

Token const & config::Parser::currentToken ( ) const
private

◆ displayCurrentToken()

void config::Parser::displayCurrentToken ( ) const
private

◆ expectToken() [1/2]

void config::Parser::expectToken ( std::string const & literal)
private

◆ expectToken() [2/2]

void config::Parser::expectToken ( TokenType type)
private

◆ handleDirective()

ParsedDirectivePair config::Parser::handleDirective ( )
private

◆ handleLocationBlock()

void config::Parser::handleLocationBlock ( )
private

◆ handleServerBlock()

void config::Parser::handleServerBlock ( )
private

◆ handleStatement()

void config::Parser::handleStatement ( )
private

◆ isTokenAValue()

bool config::Parser::isTokenAValue ( ) const
private

◆ parse()

std::vector< ConfigNode > config::Parser::parse ( TokenArray const & tokens)
static

◆ peekToken()

Token const & config::Parser::peekToken ( ) const
private

◆ pushTokenTo()

void config::Parser::pushTokenTo ( ParsedDirectiveArgs & args) const
private

◆ size()

size_t config::Parser::size ( ) const
private

Member Data Documentation

◆ nodes_

std::vector<ConfigNode> config::Parser::nodes_
private

◆ pos_

size_t config::Parser::pos_
private

◆ tokens_

TokenArray const& config::Parser::tokens_
private

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