-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Adding more f-string
features
#4827
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
base: main
Are you sure you want to change the base?
Adding more f-string
features
#4827
Conversation
@hediet Would love to see this issue resolved. |
Raymond can you please reach out internally to find someone to approve this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for the PR. I am not the owner of the area, so I have a few questions I wanted to ask you to gain a better understanding of the PR. Thank you.
[/"/, 'string.escape', '@dblStringBody'] | ||
], | ||
fStringBody: [ | ||
fStringBody3: [ | ||
[/[^\\'\{\}]+/, 'string'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have several questions about the PR which I would like to ask to better understand this PR.
How come here on line 262 it's written
[/[^\\'\{\}]+/, 'string']
But on line 273 we have:
[/[^\\'\{\}]+$/, 'string', '@popall'],
[/[^\\'\{\}]+/, 'string'],
For the other case? It seems like this code is not the exact duplicate of the other code, as it does not contain the third value '@popall'.
Also would you know what popall here refers to? I am trying to understand.
[/\{f"{1}/, 'string', '@fDblStringBody1'], // for nested f-strings | ||
[/\{[^\}'":!=]+/, 'identifier', '@fStringDetail'], | ||
[/\\./, 'string'], | ||
[/'''/, 'string.escape', '@popall'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this added? The equivalent of this does not seem to be present in the fStringBody1 array. What use case does it fix?
[/\{[^\}'":!=]+/, 'identifier', '@fStringDetail'], | ||
[/\\./, 'string'], | ||
[/"""/, 'string.escape', '@popall'], | ||
[/"/, 'string.escape'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we escape on the "
and on the """
. What use case does it fix? And why does line 298 not have @popall
as third value in the array?
[/[!][ars]/, 'string'], // only !a, !r, !s are supported by f-strings: https://docs.python.org/3/tutorial/inputoutput.html#formatted-string-literals | ||
[/=/, 'string'], | ||
[/=/, 'identifier'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this changed from string to identifier?
[/=/, 'string'], | ||
[/=/, 'identifier'], | ||
[/'[^\']+'/, 'string'], | ||
[/"[^\""]+"/, 'string'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be instead
/"[^\"]+"/
?
@@ -287,9 +317,13 @@ export const language = <languages.IMonarchLanguage>{ | |||
[/\\$/, 'string'] | |||
], | |||
fStringDetail: [ | |||
[/[:][^}]+/, 'string'], | |||
[/:=[^}]+/, 'identifier'], // walrus operator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give me examples of where these would activate? Why are they followed by 'identifier' and not string?
Looking forward to this fix! |
Would love to see this PR merged! |
Hi everyone thanks for the comments. I left some questions regarding the PR which I'd like to enquire on before merging the PR. If there is no response, I may close the PR in the future to clean the PR stack. |
f-string
features
Fixed issue #4601 and add more f-string features with tests: