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

Better scanner positioning #7

Merged
merged 9 commits into from
Jan 16, 2025
Merged

Better scanner positioning #7

merged 9 commits into from
Jan 16, 2025

Conversation

UnstoppableMango
Copy link
Contributor

No description provided.

Significant changes include:
- Introduced a new 'exports.go' file to handle token creation
- Refactored the Scanner struct in 'scanner.go' to include a file object and an offset
- Added a Pos() method to return the position of the current token in the file
- Created a newFile function for adding files to the FileSet
The token scanning logic has been improved to handle spaces as separate tokens. This change affects both the main scanner function and its associated tests. The handling of other special characters remains unchanged.
The scanner tests have been refactored to adjust the expected token positions. The changes include updating the position values in the "Starting token" and "Consume first token" test cases. Additionally, a new test case for 'identifier' has been added. The check for consuming only one token has also been removed from these tests.
Expanded the set of characters that are not allowed in identifiers to include whitespace. This change ensures that identifiers cannot contain spaces, improving parsing accuracy. Corresponding unit tests have also been updated to reflect this change.
A new function `skipWhitespace` has been added to the scanner which skips over any whitespace characters. This function is called before scanning for tokens, ensuring that leading whitespaces are ignored. Corresponding tests have also been updated to verify this behavior.
The constructors for the Parser and Scanner classes have been updated to include a file parameter. This change allows for more flexibility when creating instances of these classes, as they can now be associated with specific files right from their creation. The corresponding test cases have also been updated to reflect this change.
Significant changes include the removal of an unused file, exports.go, and a function from scanner.go. The scanner tests have been updated to reflect these changes. Additionally, new test cases have been added to track lines in the scanner_test.go file.
@UnstoppableMango UnstoppableMango merged commit bda6241 into main Jan 16, 2025
2 checks passed
@UnstoppableMango UnstoppableMango deleted the scan-pos branch January 16, 2025 19:02
Copy link

codecov bot commented Jan 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.76%. Comparing base (16c6a5f) to head (7c34da5).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #7      +/-   ##
==========================================
+ Coverage   95.59%   95.76%   +0.17%     
==========================================
  Files           6        6              
  Lines         363      378      +15     
==========================================
+ Hits          347      362      +15     
  Misses         12       12              
  Partials        4        4              

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

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