From 3c8089d1b10683ee31ddbaeebd0b18c47bf6d09d Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 6 Jun 2024 17:31:19 +1000 Subject: py/lexer: Support raw f-strings. Support for raw str/bytes already exists, and extending that to raw f-strings is easy. It also reduces code size because it eliminates an error message. Signed-off-by: Damien George --- py/lexer.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'py/lexer.c') diff --git a/py/lexer.c b/py/lexer.c index 2774759a15..48497663c5 100644 --- a/py/lexer.c +++ b/py/lexer.c @@ -661,21 +661,19 @@ void mp_lexer_to_next(mp_lexer_t *lex) { } #if MICROPY_PY_FSTRINGS if (is_char_following(lex, 'f')) { - // raw-f-strings unsupported, immediately return (invalid) token. - lex->tok_kind = MP_TOKEN_FSTRING_RAW; - break; + is_fstring = true; + n_char = 2; } #endif } #if MICROPY_PY_FSTRINGS else if (is_char(lex, 'f')) { + is_fstring = true; + n_char = 1; if (is_char_following(lex, 'r')) { - // raw-f-strings unsupported, immediately return (invalid) token. - lex->tok_kind = MP_TOKEN_FSTRING_RAW; - break; + is_raw = true; + n_char = 2; } - n_char = 1; - is_fstring = true; } #endif -- cgit v1.2.3