Parser - #8
Parser#8
Conversation
pulling main
…emoved unnecessary overload assigment operator from Location and Limit access classes
Amjad exper
There was a problem hiding this comment.
Pull Request Overview
This PR implements a comprehensive configuration file parser for a web server project (pginx). The main purpose is to enable the server to read and parse NGINX-style configuration files, tokenizing the content and building structured configuration objects.
- Implements lexer for tokenizing configuration file content into symbols, keywords, and values
- Adds parser to build hierarchical configuration structures from tokens
- Creates configuration classes (Container, Server, LocationConfig) to store parsed data
Reviewed Changes
Copilot reviewed 33 out of 38 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/models/srcs/parser.cpp | Core parser implementation with functions to parse HTTP, server, and location blocks |
| src/models/srcs/lexer.cpp | Lexical analyzer that tokenizes configuration file content |
| src/models/srcs/readFile.cpp | Utility function to read file contents into string |
| src/models/srcs/LocationConfig.cpp | Location configuration class implementation |
| src/models/srcs/Container.cpp | Container class to hold multiple server configurations |
| src/models/headers/parser.hpp | Parser module header with token definitions and function declarations |
| src/main.cpp | Updated main function to use new parser and display parsed configuration |
| config/ | Various test configuration files for parser validation |
| Tests/ | Comprehensive test suite for parser functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if (tokens[i].value == ";") | ||
| i++; | ||
| else | ||
| i++; |
There was a problem hiding this comment.
This is a duplicate of the same pattern found in parseLocationDirective. Both branches increment i, so this can be simplified to just i++.
| if (tokens[i].value == ";") | |
| i++; | |
| else | |
| i++; | |
| i++; |
|
|
||
| std::string readFile(const std::string& filename) { | ||
|
|
||
| std::ifstream file(filename.c_str()); |
There was a problem hiding this comment.
[nitpick] In C++98, using filename.c_str() is necessary, but the code should use filename directly as modern C++ constructors accept std::string. However, since this project uses C++98 standard, this is acceptable.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Great! |
No description provided.