Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a rudimentary parser #5

Merged
merged 11 commits into from
Jan 15, 2025
Merged

Add a rudimentary parser #5

merged 11 commits into from
Jan 15, 2025

Conversation

UnstoppableMango
Copy link
Contributor

No description provided.

The update introduces a 'clean' command in the Makefile. This new command removes the '.make' directory and 'cover.profile' file, helping to maintain a cleaner workspace by deleting unnecessary files generated during build or test processes.
The Abstract Syntax Tree (AST) has been significantly expanded. New structures like File, TargetList, PreReqList, LiteralFileName, and Ident have been introduced to better represent the syntax of a Makefile. Each structure now includes Pos() and End() methods for determining their position within the file. The token package has also been replaced with a custom implementation to provide more flexibility in handling tokens.
Significant enhancements have been made to the parser.go file. The Parser struct now includes additional fields for error handling and token tracking. New methods have also been introduced to parse files, handle errors, and manage tokens. A new test file, parser_test.go, has been created to ensure the correct functioning of the updated Parser.
A new constant, NoPos, has been added to the token package. This will be used to represent a non-existent or undefined position in the code.
The parser has been refactored to improve its readability and efficiency. The scanner is now initialized within the NewParser function, removing the need for an external fmt import. Error messages have also been made more descriptive, providing better feedback when a token does not match expectations. Additionally, unnecessary print statements have been removed to clean up the console output.

In terms of functionality, rules parsing has been enhanced to handle cases where identifiers are expected but not found. This includes situations where a rule starts with a colon instead of an identifier.

Corresponding tests have also been updated and expanded to cover these new scenarios, ensuring that errors are handled correctly and informative messages are returned.
Copy link

codecov bot commented Jan 14, 2025

Codecov Report

Attention: Patch coverage is 92.00000% with 10 lines in your changes missing coverage. Please review.

Project coverage is 95.59%. Comparing base (5024fb9) to head (b0c718e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
parser.go 90.10% 6 Missing and 3 partials ⚠️
ast/ast.go 96.96% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #5      +/-   ##
==========================================
+ Coverage   90.79%   95.59%   +4.79%     
==========================================
  Files           4        6       +2     
  Lines         239      363     +124     
==========================================
+ Hits          217      347     +130     
+ Misses         13       12       -1     
+ Partials        9        4       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Significant changes include:
- Reorganized import statements in ast_test.go
- Updated the expected end position of targets and prerequisites to account for name length
- Added new tests for LiteralFileName, Recipe, and Ident classes in ast_test.go
- Modified the description of a test case in parser_test.go for better clarity
@UnstoppableMango UnstoppableMango merged commit 16c6a5f into main Jan 15, 2025
4 checks passed
@UnstoppableMango UnstoppableMango deleted the parser branch January 15, 2025 04:13
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.

1 participant