()
| 223 | } |
| 224 | |
| 225 | fn interpolation<'a>() -> impl Parser<'a, ParserInput<'a>, TokenKind, ParserError<'a>> { |
| 226 | // For s-strings and f-strings, use the same multi-quote string parser |
| 227 | // Enable escaping so that `\"` in the source becomes a literal `"` in the string |
| 228 | // |
| 229 | // NOTE: Known limitation in error reporting for unclosed interpolated strings: |
| 230 | // When an f-string or s-string is unclosed (e.g., `f"{}`), the error is reported at the |
| 231 | // opening quote position (e.g., position 17) rather than at the end of input where the |
| 232 | // closing quote should be (e.g., position 20). This is because the `.then()` combinator |
| 233 | // modifies error spans during error recovery, and there's no way to prevent this from |
| 234 | // custom parsers. |
| 235 | one_of("sf") |
| 236 | .then(quoted_string(true)) |
| 237 | .map(|(c, s)| TokenKind::Interpolation(c, s)) |
| 238 | } |
| 239 | |
| 240 | fn whitespace<'a>() -> impl Parser<'a, ParserInput<'a>, (), ParserError<'a>> { |
| 241 | text::inline_whitespace().at_least(1) |
no test coverage detected