Skip to main content

wpl/parser/
string.rs

1//! String parsing helpers for WPL: quoted string, raw string, simple quoted and escapes.
2
3use wp_primitives::WResult;
4
5use crate::parser::utils::{self, quot_r_str, window_path};
6
7/// Parse a quoted string content with common escapes: \" \\ \n \t \r \xHH.
8pub fn parse_quoted_string<'a>(input: &mut &'a str) -> WResult<&'a str> {
9    utils::duble_quot_str_impl(input)
10}
11
12/// Parse a raw string r#"..."# or r"..." (compat) without processing escapes.
13pub fn parse_raw_string<'a>(input: &mut &'a str) -> WResult<&'a str> {
14    quot_r_str(input)
15}
16
17/// Parse a simple quoted string without escapes (read until next ").
18pub fn parse_simple_quoted<'a>(input: &mut &'a str) -> WResult<&'a str> {
19    window_path(input)
20}
21
22/// Decode common escapes in a string (\" \\ \n \t \r \xHH) into UTF-8 string.
23pub use utils::decode_escapes;