feat(config): complete config file parser (tokenizer + parser)#19
Merged
Conversation
d183676 to
49f97b3
Compare
- Tokenizer: full lexer (words, numbers, symbols, comments, line tracking) - ConfigParser: file reading + navigation helpers (current/advance/expect) + parseServer skeleton (recognizes server block structure) - tests: standalone harnesses for tokenizer and parser WIP: directive and location parsing still to come. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
49f97b3 to
6c3dd7e
Compare
- parseLocation + parseLocationDirective (root, index, autoindex, methods, upload_store, cgi_extensions) - parseSize: client_max_body_size with k/m/g suffix + overflow guard - advance() guard against reading past END_OF_FILE (no crash on truncated files) - verbose test harness printing the full parsed Config default.conf now parses fully; malformed/truncated configs throw cleanly without crashing.
6c3dd7e to
50744e4
Compare
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objectif
Module config parsing complet : transforme un fichier
.conf(façon NGINX) en une structureConfigvalidée, prête à être consommée par le reste du serveur. Respecte l'interface du mock (Config/ServerConfig/LocationConfig) — il remplit les mêmes structures quecreateMockConfig().Architecture (recursive descent, 2 étages)
Étage 1 — Tokenizer (
Tokenizer.hpp/.cpp){ } ;), commentaires#makeSymbol,readWordOrNumber)Étage 2 — Parser (
ConfigParser.hpp/.cpp)throwsi introuvable)current(),advance(),expect()parse()→parseServer()→parseServerDirective()/parseLocation()→parseLocationDirective()listen,host,server_name,client_max_body_size,error_pageroot,index,autoindex,methods,upload_store,cgi_extensionsparseSize(): suffixek/m/gpourclient_max_body_size+ garde-fou anti-débordementRobustesse
advance()ne lit jamais au-delà deEND_OF_FILE→ pas de crash sur fichier tronquéUnexpected token at line N), rattrapée proprement — aucun segfaultTests
tests/config/test_tokenizer.cpp— vérifie le découpage en tokenstests/config/test_parser.cpp— parsedefault.confet affiche le Config complet (servers, locations, methods, cgi…)-Wall -Wextra -Werror -std=c++98Reste à faire (hors PR)
main(remplacer le mock par le parser)