MCPcopy Create free account
hub / github.com/PRQL/prql / interpolation

Function interpolation

prqlc/prqlc-parser/src/lexer/mod.rs:225–238  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

223}
224
225fn 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
240fn whitespace<'a>() -> impl Parser<'a, ParserInput<'a>, (), ParserError<'a>> {
241 text::inline_whitespace().at_least(1)

Callers 1

tokenFunction · 0.70

Calls 2

quoted_stringFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected