py/lexer: Support concatenation of adjacent f-strings.

This is quite a simple and small change to support concatenation of
adjacent f-strings, and improve compatibility with CPython.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2024-06-06 11:14:28 +10:00
parent d7aa2fe9d7
commit a066f2308f
3 changed files with 18 additions and 5 deletions

View File

@@ -65,3 +65,13 @@ print(f"{a!s:8s}")
# Still allow ! in expressions.
print(f"{'1' if a != '456' else '0'!r:8s}")
print(f"{'1' if a != '456' else '0'!s:8s}")
# Concatenation of adjacent f-strings.
print(f"" f"")
print(f"a" f"b")
print(f"{x}" f"{y}")
print(
f"a{x}b---------------------------------"
f"cd---------------------------------"
f"e{y}f---------------------------------"
)