Extract out parse_propval_text

This commit is contained in:
Savanni D'Gerinel 2023-06-23 09:58:50 -04:00
parent 109d635d7a
commit 1f82558726
1 changed files with 15 additions and 5 deletions

View File

@ -379,17 +379,27 @@ fn parse_propval<'a, E: nom::error::ParseError<&'a str>>(
) -> IResult<&'a str, String, E> { ) -> IResult<&'a str, String, E> {
let (input, _) = multispace0(input)?; let (input, _) = multispace0(input)?;
println!("- {}", input); println!("- {}", input);
let (input, _) = tag("[")(input)?; let (input, _) = tag("[")(input)?;
println!("-- {}", input); println!("-- {}", input);
let (input, value) = parse_propval_text(input)?;
println!("--- {}", input);
let (input, _) = tag("]")(input)?;
Ok((input, value.unwrap_or(String::new())))
}
fn parse_propval_text<'a, E: nom::error::ParseError<&'a str>>(
input: &'a str,
) -> IResult<&'a str, Option<String>, E> {
let (input, value) = opt(escaped_transform( let (input, value) = opt(escaped_transform(
is_not(r"\]"), is_not(r"\]"),
'\\', '\\',
alt((value("]", tag("\\]")), value("", tag("\\\n")))), value("]", tag(r"\]")), // alt((value("]", tag(r"\]")), value("", tag("\\\n")))),
))(input)?; ))(input)?;
println!("--- {}", input); Ok((input, value.map(|v| v.to_owned())))
let (input, _) = tag("]")(input)?;
Ok((input, value.map(|v| v.to_owned()).unwrap_or(String::new())))
} }
fn parse_size<'a, E: nom::error::ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, Size, E> { fn parse_size<'a, E: nom::error::ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, Size, E> {