Skip to content

fix: parse raw string prefixes and nested f-string braces - #68

Closed
HaoZeke wants to merge 1 commit into
fix/eb-parse-escaped-quotesfrom
fix/eb-parse-raw-and-nested-fstrings
Closed

HaoZeke wants to merge 1 commit into
fix/eb-parse-escaped-quotesfrom
fix/eb-parse-raw-and-nested-fstrings

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Parser::parse_atom in src/eb_parse.rs dispatched formatted strings
only on a leading f or F, so rf prefixes fell through to
identifier lookup even though starts_fstring intended to allow them.
Plain raw strings such as r'...' also failed as unknown identifiers,
and raw formatted strings passed through parse_string where backslash
escapes were interpreted instead of preserved verbatim. Inside
parse_fstring, scanning for the first closing brace with find
truncated any field containing an inline dict literal or a quoted
closing brace.

Replace starts_fstring with string_prefix to classify raw and
formatted prefixes consistently across expression and f-string parsing,
and add parse_raw_string so raw literals keep backslashes intact. Add
find_fstring_field_end to balance nested braces and skip quoted
strings when locating the closing brace of an f-string field.

`Parser::parse_atom` in `src/eb_parse.rs` dispatched formatted strings
only on a leading `f` or `F`, so `rf` prefixes fell through to
identifier lookup even though `starts_fstring` intended to allow them.
Plain raw strings such as `r'...'` also failed as unknown identifiers,
and raw formatted strings passed through `parse_string` where backslash
escapes were interpreted instead of preserved verbatim. Inside
`parse_fstring`, scanning for the first closing brace with `find`
truncated any field containing an inline dict literal or a quoted
closing brace.

Replace `starts_fstring` with `string_prefix` to classify raw and
formatted prefixes consistently across expression and f-string parsing,
and add `parse_raw_string` so raw literals keep backslashes intact. Add
`find_fstring_field_end` to balance nested braces and skip quoted
strings when locating the closing brace of an f-string field.
@HaoZeke

HaoZeke commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded: raw prefixes landed in 415703c, nested f-string braces in #75.

@HaoZeke HaoZeke closed this Nov 20, 2026
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.

1 participant