()
| 338 | } |
| 339 | |
| 340 | fn valid_prql_ident() -> &'static Regex { |
| 341 | static VALID_PRQL_IDENT: OnceLock<Regex> = OnceLock::new(); |
| 342 | VALID_PRQL_IDENT.get_or_init(|| { |
| 343 | // Pomsky expression (regex is to Pomsky what SQL is to PRQL): |
| 344 | // ^ ('*' | [ascii_alpha '_$'] [ascii_alpha ascii_digit '_$']* ) $ |
| 345 | Regex::new(r"^(?:\*|[a-zA-Z_$][a-zA-Z0-9_$]*)$").unwrap() |
| 346 | }) |
| 347 | } |
| 348 | |
| 349 | pub fn write_ident_part(s: &str) -> Cow<'_, str> { |
| 350 | if valid_prql_ident().is_match(s) && !keywords().contains(s) { |