Skip to content

Parser - #8

Merged
Basil-Ismail merged 36 commits into
buildfrom
parser
Sep 27, 2025
Merged

Basil-Ismail merged 36 commits into
buildfrom
parser

Conversation

@Basil-Ismail

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/models/srcs/lexer.cpp Outdated
Comment thread src/models/srcs/parser.cpp Outdated
Comment on lines +210 to +213
if (tokens[i].value == ";")
i++;
else
i++;

Copilot AI Sep 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a duplicate of the same pattern found in parseLocationDirective. Both branches increment i, so this can be simplified to just i++.

Suggested change
if (tokens[i].value == ";")
i++;
else
i++;
i++;

Copilot uses AI. Check for mistakes.

std::string readFile(const std::string& filename) {

std::ifstream file(filename.c_str());

Copilot AI Sep 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copilot uses AI. Check for mistakes.
Comment thread src/models/srcs/parser.cpp Outdated
Basil-Ismail and others added 3 commits September 23, 2025 22:45
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>

@maemran maemran left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is good

@ramasham

Copy link
Copy Markdown
Contributor

Great!

@Basil-Ismail
Basil-Ismail merged commit 2fd9534 into build Sep 27, 2025
2 checks passed
@Basil-Ismail
Basil-Ismail deleted the parser branch September 27, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants