From fd4c6ff9352936183f53fa8699622e2ce96bbb70 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Fri, 23 Jun 2023 09:58:50 -0400 Subject: [PATCH] Extract out parse_propval_text --- go-sgf/src/lib.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/go-sgf/src/lib.rs b/go-sgf/src/lib.rs index 614126d..e40dd6e 100644 --- a/go-sgf/src/lib.rs +++ b/go-sgf/src/lib.rs @@ -379,17 +379,27 @@ fn parse_propval<'a, E: nom::error::ParseError<&'a str>>( ) -> IResult<&'a str, String, E> { let (input, _) = multispace0(input)?; println!("- {}", input); + let (input, _) = tag("[")(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, E> { let (input, value) = opt(escaped_transform( is_not(r"\]"), '\\', - alt((value("]", tag("\\]")), value("", tag("\\\n")))), + value("]", tag(r"\]")), // alt((value("]", tag(r"\]")), value("", tag("\\\n")))), ))(input)?; - println!("--- {}", input); - let (input, _) = tag("]")(input)?; - - Ok((input, value.map(|v| v.to_owned()).unwrap_or(String::new()))) + Ok((input, value.map(|v| v.to_owned()))) } fn parse_size<'a, E: nom::error::ParseError<&'a str>>(input: &'a str) -> IResult<&'a str, Size, E> {