Allow newlines and whitespace in more sequence locations
This commit is contained in:
parent
ba814fd899
commit
e3957a5dbe
|
@ -131,7 +131,9 @@ fn parse_sequence<'a, E: nom::error::ParseError<&'a str>>(
|
|||
println!("::: parse_sequence: {}", input);
|
||||
let (input, _) = multispace0(input)?;
|
||||
let (input, nodes) = many1(parse_node)(input)?;
|
||||
let (input, _) = multispace0(input)?;
|
||||
let (input, sub_sequences) = many0(parse_tree)(input)?;
|
||||
let (input, _) = multispace0(input)?;
|
||||
|
||||
Ok((
|
||||
input,
|
||||
|
@ -157,6 +159,7 @@ fn parse_property<'a, E: nom::error::ParseError<&'a str>>(
|
|||
let (input, _) = multispace0(input)?;
|
||||
let (input, ident) = alpha1(input)?;
|
||||
let (input, values) = many1(parse_propval)(input)?;
|
||||
let (input, _) = multispace0(input)?;
|
||||
|
||||
let values = values
|
||||
.into_iter()
|
||||
|
@ -477,4 +480,22 @@ k<. Hard line breaks are all other linebreaks.",
|
|||
.to_owned()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_parses_sgf_with_newline_in_sequence() {
|
||||
let data = String::from(
|
||||
"(;FF[4]C[root](;C[a];C[b](;C[c])(;C[d];C[e]
|
||||
))(;C[f](;C[g];C[h];C[i])(;C[j])))",
|
||||
);
|
||||
parse_tree::<nom::error::VerboseError<&str>>(&data).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_parses_sgf_with_newline_between_two_sequence_closings() {
|
||||
let data = String::from(
|
||||
"(;FF[4]C[root](;C[a];C[b](;C[c])(;C[d];C[e])
|
||||
)(;C[f](;C[g];C[h];C[i])(;C[j])))",
|
||||
);
|
||||
parse_tree::<nom::error::VerboseError<&str>>(&data).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue