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 escaping handling for all strings in the parser translator #3344

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Earlopain
Copy link
Contributor

Builds on top of #3343, which builds on top of #3341. I'll stop here for now until these are all handled, could get very messy otherwise.

This implements more of the escaping rules for all kinds of strings that can appear in:

  • %i/%I
  • %w/%W
  • %q/%Q (and %)

It takes into account that for %downcase notation and single-quoted strings, the delimiter is allowed to be escaped.
It also implements the special rule about symetric delimiters like (, where ) is also allowed.

Leave regexp as is for now, they have their own special rules.

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.
This implements more of the escaping rules for all kinds of strings that can appear in:
* %i/%I
* %w/%W
* %q/%Q (and %)

It takes into account that for %downcase notation and single-quoted strings, the delimiter is allowed to be escaped.
It also implements the special rule about symetric delimiters like `(`, where `)` is also allowed.

Leave regexp as is for now, they have their own special rules.
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