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

Incorporate support for raw string literals #485

Merged
merged 5 commits into from
Dec 25, 2023

Conversation

ckganesan
Copy link
Contributor

The current parser lacks support for raw string literals

@ckganesan
Copy link
Contributor Author

Hello @antonmedv, I kindly request your review of this pull request when you have a moment. Your insights would be greatly appreciated. Thank you in advance for your time and assistance!

@antonmedv
Copy link
Member

Nice! But I'm thinking about adding byte strings later as well.

b'bytes string'

So maybe it is better to add raw strings was a prefix?

r'raw string\n'
r"any quotes"
r`and those too`

But allow back quotas to be multi line?

r`nice
multi
line`

@ckganesan
Copy link
Contributor Author

ckganesan commented Dec 12, 2023

I recommend that we reserve the r prefix exclusively for raw strings enclosed in single (' ') or double quotes (" "), aligning with your previous comment for a clear distinction between standard and raw strings. Additionally, for raw strings that do not require a prefix, using backticks (``) would be an effective approach.

@ckganesan
Copy link
Contributor Author

If you aim to implement raw strings with the r prefix for both single (' ') and double quotes (" "). I will take on this task and submit a pull request within the same PR.

@antonmedv
Copy link
Member

I recommend that we reserve the r prefix exclusively for raw strings enclosed in single (' ') or double quotes (" "), aligning with your previous comment for a clear distinction between standard and raw strings. Additionally, for raw strings that do not require a prefix, using backticks (``) would be an effective approach.

What is reason?

@ckganesan
Copy link
Contributor Author

I recommend that we reserve the r prefix exclusively for raw strings enclosed in single (' ') or double quotes (" "), aligning with your previous comment for a clear distinction between standard and raw strings. Additionally, for raw strings that do not require a prefix, using backticks (``) would be an effective approach.

What is reason?

Backticks are inherently interpreted as raw strings, which means there's no need to use escape sequences. However, when using quotes to implement raw strings, escape sequences become essential.

@ckganesan
Copy link
Contributor Author

That's why I believe there is no need for the r prefix when using backtick symbols alone.

@antonmedv
Copy link
Member

I see. This makes good point.

I was thinking about how raw string implemented in python.

@ckganesan
Copy link
Contributor Author

While Python uses the r prefix for raw strings, Go achieves this using backtick symbols.

// Go Using backticks for raw string
rawString := `This is a raw string in Go.
It can span multiple lines and include "quotes" without escaping them.`
# python Using the 'r' prefix for raw string
raw_string = r"This is a raw string in Python.\nIt can include escape characters like \n, \t, etc., without any special effect."

We can achieve raw strings in two ways: using the r prefix or with backticks

@antonmedv
Copy link
Member

Ok. Let me review pr more carefully.

@antonmedv antonmedv merged commit 529ee7a into expr-lang:master Dec 25, 2023
8 checks passed
@ckganesan ckganesan deleted the raw-string-support branch December 26, 2023 03:57
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.

2 participants