Function parse_text

Source
pub fn parse_text(input: &str) -> IResult<&str, String>
Expand description

Parse a text literal from a string.

This function parses text literals in the AIM expression language, supporting both single-quoted and double-quoted strings with escape sequence processing. It can handle common escape sequences like \n, \t, \", \', etc.

§Supported Quote Types

  • Double-quoted: "text" - supports all escape sequences
  • Single-quoted: 'text' - supports all escape sequences

§Supported Escape Sequences

  • \n - newline
  • \r - carriage return
  • \t - tab
  • \\ - backslash
  • \" - double quote
  • \' - single quote
  • \b - backspace
  • \f - form feed
  • \/ - forward slash

§Arguments

  • input - A string slice containing the text literal to parse

§Returns

  • IResult<&str, String> - A nom result with remaining input and parsed text content

§Examples

use aimx::literals::text::parse_text;
 
assert_eq!(parse_text("\"hello\""), Ok(("", "hello".to_string())));
assert_eq!(parse_text("'world'"), Ok(("", "world".to_string())));
assert_eq!(parse_text("\"line1\\nline2\""), Ok(("", "line1\nline2".to_string())));