Set up SGF reading and start on the game database #47

Merged
savanni merged 20 commits from kifu/sgf into main 2023-07-26 13:54:28 +00:00
1 changed files with 15 additions and 5 deletions
Showing only changes of commit fd4c6ff935 - Show all commits

View File

@ -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<String>, 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> {