Better comment token handling for the parser translator#3393
Merged
Better comment token handling for the parser translator#3393
Conversation
Collaborator
Author
|
I disabled sorbet typechecking for the lexer file. sorbet is not good enough to properly analyse the code without |
There appear to be a bunch of rules, changing behaviour for inline comments, multiple comments after another, etc. This seems to line up with reality pretty closely, token differences for RuboCop tests go from 1129 to 619 which seems pretty impressive
The whole while switch/case construct makes typechecking difficult because sorbet does not recognize that outside variables may change their value in individual switches.
88d7305 to
2bcc494
Compare
kddnewton
approved these changes
Jan 11, 2025
Earlopain
added a commit
to Earlopain/prism
that referenced
this pull request
Jan 12, 2025
In ruby#3393 I made a mistake. When there is no previous token, it wraps around to -1. Oops
Earlopain
added a commit
to Earlopain/prism
that referenced
this pull request
Jan 12, 2025
In ruby#3393 I made a mistake. When there is no previous token, it wraps around to -1. Oops Additionally, if a comment has no newline then the offset should be kept as is
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Jan 12, 2025
In ruby/prism#3393 I made a mistake. When there is no previous token, it wraps around to -1. Oops Additionally, if a comment has no newline then the offset should be kept as is ruby/prism@3c266f1de4
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.
There appear to be a bunch of rules, changing behaviour for inline comments, multiple comments after another, etc.
This seems to line up with reality pretty closely, token differences for RuboCop tests go from 1129 to 619 which seems pretty impressive.
Arguably most of this behaviour is a bug (whitequark/parser#1025) but I don't think it'll be changed now.