Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the parsing pipeline by splitting raw grouping from identifier-based AST construction, renames parse_group to parse, updates reader position tracking, enriches error contexts, and adjusts all dependent tests and interfaces accordingly.
- Renamed
parse_grouptoparseand split out a two-phase parse+identify workflow. - Enhanced
readerwithget_position/jump_to_positionand filename tracking. - Overhauled AST node interfaces (
get,first,get_start,squeeze,pop_back) and placeholder logic. - Updated CMake and all tests to use the new
parseAPI and expanded identifier tests.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/identify_tests.cpp | Added new identifier tests for control structures and calls. |
| tests/grouper_tests.cpp | Updated tests to call parse() instead of parse_group(). |
| tests/ast_tests.cpp | Split AST dump tests into partial and full dumps with limits. |
| src/reader.cpp | Added token::dump, filename member, get_position, and resets. |
| src/main.cpp | Changed main to use g.parse() and removed unused include. |
| src/grouper.cpp | Major refactor: private parse_group, public parse + identify. |
| src/ast.cpp | Extended AST node interfaces and placeholder/squeeze logic. |
| include/token.hpp | Adjusted dump signature formatting. |
| include/reader.hpp | Introduced position, token_kind, and updated method signatures. |
| include/grouper.hpp | Renamed method to parse, declared identify/peek. |
| include/ast.hpp | Expanded AST node classes with new methods and removed duplicates. |
| CMakeLists.txt | Linked OpenMP conditionally and reordered test sources. |
Comments suppressed due to low confidence (4)
tests/identify_tests.cpp:41
- [nitpick] The variable name 'halt' is ambiguous; consider renaming it to 'rootGroup' or 'fileGroup' to improve readability.
auto* halt = dynamic_cast<group_node*>(res->nodes[0].get());
tests/identify_tests.cpp:53
- [nitpick] The variable name 'els' is not descriptive; consider renaming it to 'elseNode' or 'controlNode'.
auto* els = dynamic_cast<control_node*>(halt->nodes.back().get());
include/grouper.hpp:39
- [nitpick] The member variable
currentis ambiguous; renaming it tocurrentTokenwould make its purpose clearer.
token current;
include/grouper.hpp:34
- [nitpick] Renaming
parse_grouptoparsecould break existing integrations. Consider providing a deprecatedparse_groupalias or forwarding to maintain backward compatibility.
group_ptr parse(group_kind kind = group_kind::file);
| return current; | ||
| } | ||
|
|
||
| void grouper::identify(const group_ptr& group, const group_ptr& result) const { |
There was a problem hiding this comment.
[nitpick] The identify method is very large and complex. Consider breaking it into smaller helper functions (e.g., identifyControlKeywords, identifySecondaryKeywords) to improve readability and testability.
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.
No description provided.