Better handle heredoc escaping in the parser translator#3343
Merged
Better handle heredoc escaping in the parser translator#3343
Conversation
b751c75 to
79ea4e6
Compare
In parser, the string content is dedented. This implements these rules as far as I was able to understand them. It's all a bit confusing with spaces/tabs, always learning more funny things about them. I refered to the prism implementation, parser seems to adhere to it very closely.
This does a few things: * After a line continuation in a heredoc, emit only a single token * Dedent ` heredocs * Properly handle escapes in single and doublequoted heredocs Some of the heredoc escaping logic should be applied to strings as well, but I'll leave that for a different PR.
79ea4e6 to
a5dc98b
Compare
kddnewton
approved these changes
Jan 3, 2025
Collaborator
kddnewton
left a comment
There was a problem hiding this comment.
Makes sense. I think we will need to share this escaping logic with the parser translation as well, but that can be done later.
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.
Builds on top of #3341,
will fix rubocop/rubocop#12878This does a few things:
Some of the heredoc escaping logic should be applied to strings as well,
but I'll leave that for a different PR.
Also, if the heredoc consists only of literal string content, this new escaping branch is not yet taken. It only works if interpolation is used.