Function parse_with_options

Source
pub fn parse_with_options(
    text: &str,
    options: &ParseOptions,
) -> Result<Vec<GameTree>, SgfParseError>
Expand description

Returns the GameTree values parsed from the provided text.

§Errors

If the text can’t be parsed as an SGF FF[4] collection, then an error is returned.

§Examples

use sgf_parse::{parse_with_options, ParseOptions, GameType, SgfParseError};

// Default options
let sgf = "(;SZ[9]C[Some comment];B[de];W[fe])(;B[de];W[ff])";
let gametrees = parse_with_options(sgf, &ParseOptions::default()).unwrap();
assert!(gametrees.len() == 2);
assert!(gametrees.iter().all(|gametree| gametree.gametype() == GameType::Go));

// Strict FF[4] identifiers
let sgf = "(;SZ[9]CoPyright[Julian Andrews 2025];B[de];W[fe])(;B[de];W[ff])";
let parse_options = ParseOptions {
    convert_mixed_case_identifiers: false,
    ..ParseOptions::default()
};
let result = parse_with_options(sgf, &parse_options);
assert_eq!(result, Err(SgfParseError::InvalidFF4Property));