You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PEP 701 formalizes the grammar for f-strings. This will require updates to both the lexer and parser while keeping the AST representation the same.
Update the lexer to emit the new tokens (FSTRING_START, FSTRING_MIDDLE, FSTRING_END). This means that f"foo {bar}" wouldn't be emitted as a single String token but rather something like:
Update the parser to account for any grammar changes required to recognize these tokens and parse it into an equivalent AST nodes. There are few things to note here:
We can remove the f-string parsing done in the string parser (string.rs)
Debug expressions (f"foo {bar = }") preserves whitespaces using the debug_text field. Newlines needs to be preserved as well.
Implicit string concatenation
SimpleTokenizer changes
The goal is to complete this in the current iteration (August) before the official release of Python 3.12.
dhruvmanila
changed the title
Add support for PEP 701: Syntactic formalization of f-strings
Support PEP 701: Syntactic formalization of f-strings
Sep 1, 2023
PEP 701 formalizes the grammar for f-strings. This will require updates to both the lexer and parser while keeping the AST representation the same.
Update the lexer to emit the new tokens (
FSTRING_START
,FSTRING_MIDDLE
,FSTRING_END
). This means thatf"foo {bar}"
wouldn't be emitted as a singleString
token but rather something like:Update the parser to account for any grammar changes required to recognize these tokens and parse it into an equivalent AST nodes. There are few things to note here:
string.rs
)f"foo {bar = }"
) preserves whitespaces using thedebug_text
field. Newlines needs to be preserved as well.SimpleTokenizer
changesThe goal is to complete this
in the current iteration (August)before the official release of Python 3.12.Tasks
FormatStringContinuation
to use the new f-string tokens #7517Reference implementation:
The text was updated successfully, but these errors were encountered: